KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sslexplorer > keystore > wizards > KeyStoreImportTypeManager


1 /*
2  * SSL-Explorer
3  *
4  * Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2 of
9  * the License, or (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public
16  * License along with this program; if not, write to the Free Software
17  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18  */

19             
20 package com.sslexplorer.keystore.wizards;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collections JavaDoc;
24 import java.util.HashMap JavaDoc;
25 import java.util.List JavaDoc;
26 import java.util.Map JavaDoc;
27
28 /**
29  * Allows <i>Key Store Import</i> types to be registered and integrated with
30  * the import wizard.
31  *
32  * @author Brett Smith <a HREF="mailto: brett@3sp.com">&lt;brett@3sp.com&gt;</a>
33  */

34 public class KeyStoreImportTypeManager {
35
36     // Private instance variables
37
private Map JavaDoc<String JavaDoc,AbstractKeyStoreImportType> types;
38
39     // Private statics
40
private static KeyStoreImportTypeManager instance;
41
42     /*
43      * Private constructor to prevent instantiation
44      */

45     private KeyStoreImportTypeManager() {
46         super();
47         types = new HashMap JavaDoc<String JavaDoc,AbstractKeyStoreImportType>();
48     }
49
50     /**
51      * Register a new key store import type to be made available in the key
52      * store import wizard
53      *
54      * @param type key store import type
55      */

56     public void registerType(AbstractKeyStoreImportType type) {
57         types.put(type.getName(), type);
58     }
59
60     /**
61      * Deregister a key store import type from those available in the key store
62      * import wizard
63      *
64      * @param typeName key store import type name
65      */

66     public void deregisterType(String JavaDoc typeName) {
67         types.remove(typeName);
68     }
69
70     /**
71      * Get a sorted list of {@link AbstractKeyStoreImportType} implementations to
72      * display in the wizard
73      *
74      * @return list of types
75      */

76     public List JavaDoc getTypes() {
77         List JavaDoc<AbstractKeyStoreImportType> listOfAbstractKeyStoreImportType = new ArrayList JavaDoc<AbstractKeyStoreImportType>(types.values());
78         Collections.sort(listOfAbstractKeyStoreImportType);
79         return listOfAbstractKeyStoreImportType;
80     }
81
82     /**
83      * Get an import type given its name, or <code>null</code> if no such
84      * type exists.
85      *
86      * @param name name
87      * @return import type
88      */

89     public AbstractKeyStoreImportType getType(String JavaDoc name) {
90         return types.get(name);
91     }
92
93     /**
94      * Get an instance of the key store import type manager.
95      *
96      * @return key store import type manager
97      */

98     public static KeyStoreImportTypeManager getInstance() {
99         if (instance == null) {
100             instance = new KeyStoreImportTypeManager();
101         }
102         return instance;
103     }
104
105 }
106
Popular Tags