summaryrefslogtreecommitdiffstats
path: root/pki/base/console/src/com/netscape/admin/certsrv/UIMapperRegistry.java
blob: 531a0b5fc7c4a24623f8edd501220d5593ce9e60 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (C) 2007 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
package com.netscape.admin.certsrv;

import com.netscape.management.client.util.*;
import java.security.cert.CertificateException;
import netscape.security.x509.*;
import java.util.*;

/**
 * UIMapper Registry
 *
 * This Registry keeps track of the mappings between the certificate
 * attribute class and the UI Mapper.
 *
 * @author Jack Pan-Chen
 * @version $Revision$, $Date$
 * @see com.netscape.admin.certsrv.IUIMapper
 */
public class UIMapperRegistry {

    /*==========================================================
     * variables
     *==========================================================*/
    private static UIMapperRegistry mSelf = null;
    private static Hashtable mAttrContent = new Hashtable();

	/*==========================================================
	 * public methods
     *==========================================================*/

    /**
     * register new certificate attribute.
     *
     * @param className fully qualified class name implementing CertAttrSet
     * @param oid the string representation of the object identifier
     * @param extentionName the name of the attribute.
     * @param mapperClassName fully qualified class name implementing UI
     */
    /* XXX WE DON'T NEED THIS
    public static void registerCertAttrUI(String className, String oid, 
                                    String attrName, String mapperClassName) 
        throws ClassNotFoundException, CertificateException
    {                                    
        Class extClass, mapClass;
        extClass = Class.forName(className);
        mapClass = Class.forName(mapperClassName);
        OIDMap.addAttribute(className,oid,attrName);
        registerCertAttrUI(attrName,mapperClassName);
    }
    */
    
    /**
     * internal register new cert attr
     *
     * @param className fully qualified class name implementing CertAttrSet
     * @param extentionName the name of the attribute.
     * @param mapperClassName fully qualified class name implementing UI
     */
    public static void registerCertAttrUI(String attrName, String mapperClassName) {
        mAttrContent.put(attrName, mapperClassName);
    }    
    
    /**
     * Retrieve all certificate attribute name
     */
    public static Enumeration getCertAttrNames() {
        return mAttrContent.keys();
    }    

    /**
     * Retrieve all extension UI Mappers
     */
    public static Enumeration getCertAttrUIs() {
        return mAttrContent.elements();
    }

    /**
     * Get instance of UI Mapper by certificate attribute name
     *
     * @param certAttrClassName certificate attribute name
     */
    public static IUIMapper getCertAttrUI(String certAttrClassName) 
        throws InstantiationException, IllegalAccessException, ClassNotFoundException
    {
        String mapperClassName = (String) mAttrContent.get(certAttrClassName);
        Class mapClass = Class.forName(mapperClassName);
        IUIMapper instance = (IUIMapper) mapClass.newInstance();
        return instance;
    }

    //load the static stuff here
    static {
        loadUIMappings();
    }

    //loads the standard UI components
    private static void loadUIMappings() {
        /*
        UIMapperRegistry registry = UIMapperRegistry.getUIMapperRegistry();
        registry.addExtensionMapping
        */
    }
    
}