KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ejbca > core > protocol > xkms > Constants


1 /*************************************************************************
2  * *
3  * EJBCA: The OpenSource Certificate Authority *
4  * *
5  * This software is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU Lesser General Public *
7  * License as published by the Free Software Foundation; either *
8  * version 2.1 of the License, or any later version. *
9  * *
10  * See terms of license at gnu.org. *
11  * *
12  *************************************************************************/

13 package org.ejbca.core.protocol.xkms;
14
15 import java.io.ByteArrayInputStream JavaDoc;
16 import java.security.KeyFactory JavaDoc;
17 import java.security.KeyStore JavaDoc;
18 import java.security.NoSuchProviderException JavaDoc;
19 import java.security.PrivateKey JavaDoc;
20 import java.security.cert.CertificateException JavaDoc;
21 import java.security.cert.CertificateFactory JavaDoc;
22 import java.security.cert.X509Certificate JavaDoc;
23 import java.security.spec.PKCS8EncodedKeySpec JavaDoc;
24 import java.util.ArrayList JavaDoc;
25
26 import org.ejbca.util.Base64;
27 import org.ejbca.util.KeyTools;
28
29 /**
30  * Class containing constans common for unit tests.
31  *
32  * @author Philip Vendil
33  * $Id: Constants.java,v 1.1 2006/12/22 09:29:14 herrvendil Exp $
34  */

35 public class Constants {
36     
37     private static byte[] certroottest = Base64.decode((
38              "MIIDCzCCAfOgAwIBAgIIK5kLeM4VChowDQYJKoZIhvcNAQEFBQAwEzERMA8GA1UE"
39             +"AxMIY2VydHRlc3QwHhcNMDYwMTMxMTAxNTE1WhcNMjYwMjE1MTAyNTE1WjATMREw"
40             +"DwYDVQQDEwhjZXJ0dGVzdDCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEB"
41             +"ALInKM0KfuSpFawo9wvEx2kb+UZ6KQ4L4UPLL6Vo/h/Wu+fPrKZo6UKApGqL68Wz"
42             +"5RSoDrhCV3DPKzCCbvtIjUHQ2kmqdEdq3LeUopYV4D4dy6ENin4g7fJk3+ChWgSM"
43             +"bq5WGwng45DZAQ9U4FS5z6vGf5062gdCeOfvGShj/hFYgNPDJvipB+c+vchFcqBv"
44             +"XwrOXFZa5tKgXcx3zNn7dPefM02Z4fBwvS3yhvq62WLQ1R2RuqNeI4rm9dlbtBEk"
45             +"Zb/VU25fkv+ZnGp3ekD0TgNi5bowsZiEClzWODvIpXS/TBhcXgp63/e/jwd/KNc4"
46             +"m0XovQzgb5wWRSorS5lFiT0CAwEAAaNjMGEwDwYDVR0TAQH/BAUwAwEB/zAOBgNV"
47             +"HQ8BAf8EBAMCAYYwHQYDVR0OBBYEFFJgR2sUAaXmkBfpgNjBqGgycUxBMB8GA1Ud"
48             +"IwQYMBaAFFJgR2sUAaXmkBfpgNjBqGgycUxBMA0GCSqGSIb3DQEBBQUAA4IBAQCf"
49             +"2q0hWIXSOwbO5az2TMI4pwzmL+gz7GsAeCZ46TFSn8qIDQ4I8sMOB4vaIsAxUCUO"
50             +"UCSkakgQTlrCORL45H8GZ7Z0Clu60tjJtIuoRRi8lsaZWtmKXw3P2cBSyFakSq64"
51             +"vDJCGHadGzeHqYRiAHFs98MbLWd4X3fxLvsWEtEjaMiL3ocd4FRAv9UMGL6KUzIJ"
52             +"wpl+xgBtp/lyzIMokRdgYNTLsFkrtR0DgG+nVXg+PJRJXz7UWJfZ0WFUz4+o+DgZ"
53             +"BYk5MNpAssbi6z4F6eVtqN3RcLZ3KhN6HR4t3+NDNdCRyW2GJk8swEnsbYUOeOGe"
54             +"RafwgiudJEFS+OLJ9fWf").getBytes());
55     
56     private static byte[] certintertest = Base64.decode((
57             "MIIDDzCCAfegAwIBAgIISqSAWg1vgP4wDQYJKoZIhvcNAQEFBQAwEzERMA8GA1UE"
58             +"AxMIY2VydHRlc3QwHhcNMDYwMTMxMTAyMzIwWhcNMjUxMDE4MTAzMzIwWjAXMRUw"
59             +"EwYDVQQDEwxjZXJ0dGVzdHN1YjIwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEK"
60             +"AoIBAQCZKBvVMID5uukn6bZ8JD4cXug3hb+UlmEVLJj7Sm6wcF3TYFhDlwPIeCXj"
61             +"qn9ZIULxpmNNda1E4ZcqpHYcxbBu8bhYmffeEtzIWOXd1MQ8WWlGbB1i8bNpZHOq"
62             +"2ZhbV8qtGRg8JRVdi8MGKsDq74KjjcduV9jb8gK1R5iah2YrNU+7JNDutN3sLTHR"
63             +"NDnW2wTIJfd+S+mh5hcgroNXbLT50CEdmjNBucSGzHHwWIgiL/7PZlchDLVkdiza"
64             +"A5suAjuSIr4tSKnxXDWrrkcBu9R5pOUPYS00eaMXDW3p+OesRYwMkmG74JS6aw8/"
65             +"JY8r52AmvXJgc5Gjkma6LkXn1NuxAgMBAAGjYzBhMA8GA1UdEwEB/wQFMAMBAf8w"
66             +"DgYDVR0PAQH/BAQDAgGGMB0GA1UdDgQWBBT7WnnEHd6xvC8/Dhvo/pIhVkMiIDAf"
67             +"BgNVHSMEGDAWgBRSYEdrFAGl5pAX6YDYwahoMnFMQTANBgkqhkiG9w0BAQUFAAOC"
68             +"AQEAULha8ZiRIUx8FdayL/fsPwicGwZko3DuGhnY97aUSvcSx2JTdAFM0wWXdEL5"
69             +"gWq4451wBqhnV62yma1QR8v/O8ypmsNt7nKBGgZ7jRzq/GGFUCJvvTZmAQa/iz9L"
70             +"KNiKOouUOaDkA8d00qroJMBkiDE4rt1OCMFPjfjxh4ozEXilx1Bg15IFW3B7TQRw"
71             +"vv3cpYx0HDFDLYloDEVOWmmBb5gVm1JS3zqVxJU9dwGWi8+5yrsnnY7Cd6m6GKui"
72             +"a17PcoX3yiBwHQQQNh8kmXVqhSMrVUNBZuauR8AjwVnW0yR8f2buaGnx6Bzg66Y7"
73             +"7jZRFYdRZw7zQ3ki6BzVrdI2qg==").getBytes());
74             
75                     
76     
77     private static byte[] certtestuser = Base64.decode((
78              "MIICjDCCAXSgAwIBAgIIO9I75BAR2iQwDQYJKoZIhvcNAQEFBQAwFzEVMBMGA1UE"
79             +"AxMMY2VydHRlc3RzdWIyMB4XDTA2MDEzMTEwMjQwNloXDTI2MDEyNjEwMzQwNlow"
80             +"FzEVMBMGA1UEAxMMY2VydHRlc3R1c2VyMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCB"
81             +"iQKBgQCsXEslTgDUcYYLVvg7ip+ED0ahi1575XJdukhA89Vhmdr2dr3anANAhQ3P"
82             +"HmumX023fxc/FPeFm0YsmWAFdgVvo4OgNqn8uHnUZtDyBz2x1BcSZPl4BemiegWR"
83             +"AH49b7DY9ov0WrCn+f2G4/bi/+B47Bg/2xTCB4db82/uljAJBwIDAQABo2AwXjAM"
84             +"BgNVHRMBAf8EAjAAMA4GA1UdDwEB/wQEAwIFoDAdBgNVHQ4EFgQU+QezAWJBLplL"
85             +"X48jAQvthJAc580wHwYDVR0jBBgwFoAU+1p5xB3esbwvPw4b6P6SIVZDIiAwDQYJ"
86             +"KoZIhvcNAQEFBQADggEBAEQ0buiAhEARQrYWu2W0Z8K+NdP3H8CbgZqnrgVwPGHa"
87             +"jlcczpEEqM2B8jWbACGqZs9098DwW3NaNK+vRscdClTWcFLjvL/c8egFSbsVuTR2"
88             +"jeUXpOgalwa5lL/NICaHBFvCeXZam1frND6NQzIZeoJyIS3Dz3wKPj8JwP0wa/I9"
89             +"MqkwZfrYkOlAfBVE5AxYK3PHCrGn5DE8PoPYu4nqqmjrql6RkpLyXa2gP0R8nM/M"
90             +"nwGu3CfmzCHelPimFoR/hgyI/WShzUJ8I294RtLCJGHyKBYp4putP2x8vVA3rKLx"
91             +"tk0aFncO0UPPFCcuufxAkDEDYXYELl6oS45ho8ANOZc=").getBytes());
92     
93     
94     private static byte[] userkey = Base64.decode((
95              "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAKxcSyVOANRxhgtW"
96             +"+DuKn4QPRqGLXnvlcl26SEDz1WGZ2vZ2vdqcA0CFDc8ea6ZfTbd/Fz8U94WbRiyZ"
97             +"YAV2BW+jg6A2qfy4edRm0PIHPbHUFxJk+XgF6aJ6BZEAfj1vsNj2i/RasKf5/Ybj"
98             +"9uL/4HjsGD/bFMIHh1vzb+6WMAkHAgMBAAECgYEAgO/h/xwlHsd14RHETLZcsivD"
99             +"SKG7oq94KIlr97rwSz0PQgR97gV7oU5nkCNPoHv25WgbecMzjy0jB8YMwMkTMr0r"
100             +"acXbi4GeCLL3iyVcfElCx5D+D09VoHnW1otCTxMTLFvNnbewnNUecTf3DJNgd43S"
101             +"8Clxw66R3Y4w1mzwjnECQQDxYtLhQ3OmfIduvUni1XqJ+68LsktIg3bPGPNV5REa"
102             +"90585NTf/KvO+sJDVHTsKrEe9+FSp4UTwNRbQCEb1t69AkEAtsupiYxVY9ujymKu"
103             +"hLfpZKi5qjohG+hGoqrHSHJKXpevrhmTOkFALVVCT+fC2scHNloZxXVjd0VtXucE"
104             +"5FgVEwJBAMyqHOEwfstnhLFJP29b0AVUZ8vEBX7bMI5RumhWy5UQoPTWVQQBSW86"
105             +"QCI0ZtqjLAB07hBVx0jDU4p3KltfaQUCQFTwfB4rNH6LUCe6BSgsoWohsOx1yG7E"
106             +"VxY9Tw7N9NrRl1PKFIysR1sJVB/3LKcmdqZ95Z3Id2izvSetJ6vHdjsCQDDXaW1R"
107             +"q6Y2mFTmc2afDFzxkHvHOoMf9tnj7KwjZEuqGckUCbKqvk1MX/9cB3KLo9t+wqCW"
108             +"jk+w4V4pCK643qQ=").getBytes());
109     
110     public static String JavaDoc pkcs10_1 =
111              "MIIBkzCB/QIBADBUMQswCQYDVQQGEwJTRTETMBEGA1UECBMKU29tZS1TdGF0ZTEh"
112             +"MB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQ0wCwYDVQQDEwRUZXN0"
113             +"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDczgi13kcTGTMmOdMU/QzvH6JV"
114             +"QxL23dqdYpsV//XHO2bjKlgqqc3MpGH4QQkz/80rzFi4EwuqBpOnXo0P09I2jztk"
115             +"IG4TSM+RwOfvaAMDJ1B6eeih6JX+v0A5PaWJlx1nshUuikcYJK3iNVepy39li0m3"
116             +"OBwub9NnnVWXuClUGwIDAQABoAAwDQYJKoZIhvcNAQEEBQADgYEAz4NpjNraufWg"
117             +"ZDv5J1muOHwZvOO9Is1L8WvMLG+jgH8Q2rPpDq8buIIWDy6VK8ghr7xhZzEZznTX"
118             +"5HLSLB1a6KvktiVSKB0nmAmDU28xXLWWwkA7/68J6DvAipk00bHdxuEJ4+Mg8UJ0"
119             +"Mr+aXDlmZUfghzlB70dDUy/Np/YJVb8=";
120     
121     public static String JavaDoc pkcs10_2 =
122         "-----BEGIN CERTIFICATE REQUEST-----\n"
123         +"MIIBkzCB/QIBADBUMQswCQYDVQQGEwJzZTETMBEGA1UECBMKU29tZS1TdGF0ZTEh\n"
124         +"MB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQ0wCwYDVQQDEwRURVNU\n"
125         +"MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQC6zGAfzcf8+ECqvI6r2z22fI9h\n"
126         +"pVTPWkY+vpw6w6ilzhqeMJslAQG5WogOc+NpWrGLAd8UCN2AicQE1p5dFKN8URF0\n"
127         +"3eyNIXTTveQqzcAYaFHAuD2Ua1a3W9vbnPAm2NSiD3keeFMgXZqqFtnEqU/4XvA6\n"
128         +"ClrEMu5/W20N3fKyVwIDAQABoAAwDQYJKoZIhvcNAQEEBQADgYEASbGs+s5PjTYW\n"
129         +"vYQ0OOLYuNZcV2uj56FVP4jjaxed6SNC3XNrsJcqoBIUT14OTGvo+kt/Du3X5src\n"
130         +"sLtaUfVr74y1FhDq55fqAY5+k0IpJVYGlOVsAAcx5O2jUKbxZHBSQnyVBLKczITY\n"
131         +"PfoNI8s9NXa/fIfqp56llOPzDy3OcHc=\n"
132         +"-----END CERTIFICATE REQUEST-----";
133
134     public static X509Certificate JavaDoc getUserCert() throws CertificateException JavaDoc, NoSuchProviderException JavaDoc{
135         CertificateFactory JavaDoc cf = CertificateFactory.getInstance("X.509", "BC");
136         return (X509Certificate JavaDoc)cf.generateCertificate(new ByteArrayInputStream JavaDoc(certtestuser));
137     }
138     
139     public static X509Certificate JavaDoc getIntermediateCert() throws CertificateException JavaDoc, NoSuchProviderException JavaDoc{
140         CertificateFactory JavaDoc cf = CertificateFactory.getInstance("X.509", "BC");
141         return (X509Certificate JavaDoc)cf.generateCertificate(new ByteArrayInputStream JavaDoc(certintertest));
142     }
143     
144     public static X509Certificate JavaDoc getRootCert() throws CertificateException JavaDoc, NoSuchProviderException JavaDoc{
145         CertificateFactory JavaDoc cf = CertificateFactory.getInstance("X.509", "BC");
146         return (X509Certificate JavaDoc)cf.generateCertificate(new ByteArrayInputStream JavaDoc(certroottest));
147     }
148     
149     public static PrivateKey JavaDoc getUserKey() throws Exception JavaDoc{
150         PKCS8EncodedKeySpec JavaDoc pkKeySpec = new PKCS8EncodedKeySpec JavaDoc(userkey);
151         KeyFactory JavaDoc keyFactory = KeyFactory.getInstance("RSA");
152         return keyFactory.generatePrivate(pkKeySpec);
153     }
154
155     public static KeyStore JavaDoc getUserKeyStore() throws Exception JavaDoc {
156         ArrayList JavaDoc list = new ArrayList JavaDoc();
157         list.add(Constants.getRootCert());
158         list.add(Constants.getIntermediateCert());
159
160         return KeyTools.createP12("TEST",Constants.getUserKey(),Constants.getUserCert(),list);
161     }
162
163
164     
165 }
166
Popular Tags