KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > jmeter > util > keystore > JmeterKeyStore


1 // $Header: /home/cvs/jakarta-jmeter/src/core/org/apache/jmeter/util/keystore/JmeterKeyStore.java,v 1.5 2004/02/13 02:21:38 sebb Exp $
2
/*
3  * Copyright 2001-2004 The Apache Software Foundation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17 */

18
19 package org.apache.jmeter.util.keystore;
20
21 import java.io.InputStream JavaDoc;
22 import java.lang.reflect.Constructor JavaDoc;
23 import java.security.PrivateKey JavaDoc;
24 import java.security.cert.X509Certificate JavaDoc;
25
26 /**
27  * Use this Keystore for JMeter specific KeyStores.
28  *
29  * @author <a HREF="bloritsch@apache.org">Berin Loritsch</a>
30  * @version CVS $Revision: 1.5 $ $Date: 2004/02/13 02:21:38 $
31  */

32 public abstract class JmeterKeyStore
33 {
34
35     /**
36      * Process the input stream
37      */

38     public abstract void load(InputStream JavaDoc is, String JavaDoc password) throws Exception JavaDoc;
39
40     /**
41      * Get the ordered certificate chain.
42      */

43     public abstract X509Certificate JavaDoc[] getCertificateChain();
44
45     public abstract String JavaDoc getAlias();
46
47     /**
48      * Return the private Key
49      */

50     public abstract PrivateKey JavaDoc getPrivateKey();
51
52     public static final JmeterKeyStore getInstance(String JavaDoc type) throws Exception JavaDoc
53     {
54         if ("PKCS12".equalsIgnoreCase(type))
55         {
56             try
57             {
58                 Class JavaDoc PKCS12 =
59                     Class.forName(
60                         "org.apache.jmeter.util.keystore.PKCS12KeyStore");
61                 Constructor JavaDoc con =
62                     PKCS12.getConstructor(new Class JavaDoc[] { String JavaDoc.class });
63                 return (JmeterKeyStore) con.newInstance(new Object JavaDoc[] { type });
64             }
65             catch (Exception JavaDoc e)
66             {}
67         }
68
69         Class JavaDoc keyStore =
70             Class.forName("org.apache.jmeter.util.keystore.DefaultKeyStore");
71         Constructor JavaDoc con = keyStore.getConstructor(new Class JavaDoc[] { String JavaDoc.class });
72         return (JmeterKeyStore) con.newInstance(new Object JavaDoc[] { type });
73     }
74 }
Popular Tags