1414 * License along with this library; if not, write to the Free Software
1515 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1616 *
17- * $Id$
1817 */
1918
2019package org .kopi .ebics .certificate ;
2120
22- import java .io .ByteArrayInputStream ;
2321import java .io .IOException ;
24- import java .io .InputStream ;
2522import java .math .BigInteger ;
2623import java .security .GeneralSecurityException ;
2724import java .security .KeyPair ;
3128import java .util .Date ;
3229import java .util .TimeZone ;
3330
34- import org .bouncycastle .asn1 .ASN1EncodableVector ;
35- import org .bouncycastle .asn1 .ASN1InputStream ;
36- import org .bouncycastle .asn1 .ASN1Sequence ;
37- import org .bouncycastle .asn1 .DERSequence ;
3831import org .bouncycastle .asn1 .x500 .X500Name ;
3932import org .bouncycastle .asn1 .x509 .AuthorityKeyIdentifier ;
4033import org .bouncycastle .asn1 .x509 .BasicConstraints ;
4639import org .bouncycastle .asn1 .x509 .SubjectKeyIdentifier ;
4740import org .bouncycastle .asn1 .x509 .SubjectPublicKeyInfo ;
4841import org .bouncycastle .asn1 .x509 .X509Extensions ;
49- import org .bouncycastle .asn1 .x509 .X509Name ;
5042import org .bouncycastle .jce .X509Principal ;
5143import org .bouncycastle .x509 .X509V3CertificateGenerator ;
44+ import org .kopi .ebics .certificate .X509Constants .CertificateKeyUsage ;
5245import org .kopi .ebics .utils .Utils ;
5346
5447/**
5548 * An X509 certificate generator for EBICS protocol.
5649 * Generated certificates are self signed certificates.
5750 *
58- * @author hachani
5951 *
6052 */
6153@ SuppressWarnings ("deprecation" )
@@ -81,7 +73,7 @@ public X509Certificate generateA005Certificate(KeyPair keypair,
8173 issuer ,
8274 notBefore ,
8375 notAfter ,
84- X509Constants .SIGNATURE_KEY_USAGE );
76+ CertificateKeyUsage .SIGNATURE_KEY_USAGE );
8577 }
8678
8779 /**
@@ -104,7 +96,7 @@ public X509Certificate generateX002Certificate(KeyPair keypair,
10496 issuer ,
10597 notBefore ,
10698 notAfter ,
107- X509Constants .AUTHENTICATION_KEY_USAGE );
99+ CertificateKeyUsage .AUTHENTICATION_KEY_USAGE );
108100 }
109101
110102 /**
@@ -127,7 +119,7 @@ public X509Certificate generateE002Certificate(KeyPair keypair,
127119 issuer ,
128120 notBefore ,
129121 notAfter ,
130- X509Constants .ENCRYPTION_KEY_USAGE );
122+ CertificateKeyUsage .ENCRYPTION_KEY_USAGE );
131123 }
132124
133125 /**
@@ -146,14 +138,15 @@ public X509Certificate generate(KeyPair keypair,
146138 String issuer ,
147139 Date notBefore ,
148140 Date notAfter ,
149- int keyusage )
141+ CertificateKeyUsage keyusage )
150142 throws GeneralSecurityException , IOException
151143 {
152144 X509V3CertificateGenerator generator ;
153145 BigInteger serial ;
154146 X509Certificate certificate ;
155147
156148 serial = BigInteger .valueOf (generateSerial ());
149+
157150 generator = new X509V3CertificateGenerator ();
158151 generator .setSerialNumber (serial );
159152 generator .setIssuerDN (new X509Principal (issuer ));
@@ -180,13 +173,13 @@ public X509Certificate generate(KeyPair keypair,
180173 generator .addExtension (X509Extensions .ExtendedKeyUsage , false , new ExtendedKeyUsage (purposeIds ));
181174
182175 switch (keyusage ) {
183- case X509Constants . SIGNATURE_KEY_USAGE :
176+ case SIGNATURE_KEY_USAGE :
184177 generator .addExtension (X509Extensions .KeyUsage , false , new KeyUsage (KeyUsage .nonRepudiation ));
185178 break ;
186- case X509Constants . AUTHENTICATION_KEY_USAGE :
179+ case AUTHENTICATION_KEY_USAGE :
187180 generator .addExtension (X509Extensions .KeyUsage , false , new KeyUsage (KeyUsage .digitalSignature ));
188181 break ;
189- case X509Constants . ENCRYPTION_KEY_USAGE :
182+ case ENCRYPTION_KEY_USAGE :
190183 generator .addExtension (X509Extensions .KeyUsage , false , new KeyUsage (KeyUsage .keyAgreement ));
191184 break ;
192185 default :
0 commit comments