Search in sources :

Example 1 with BcX509ExtensionUtils

use of org.bouncycastle.cert.bc.BcX509ExtensionUtils in project signer by demoiselle.

the class CertificateHelper method createSubjectKeyIdentifier.

private static SubjectKeyIdentifier createSubjectKeyIdentifier(Key key) throws IOException {
    ByteArrayInputStream bIn = new ByteArrayInputStream(key.getEncoded());
    ASN1InputStream is = null;
    try {
        is = new ASN1InputStream(bIn);
        ASN1Sequence seq = (ASN1Sequence) is.readObject();
        SubjectPublicKeyInfo info = new SubjectPublicKeyInfo(seq);
        return new BcX509ExtensionUtils().createSubjectKeyIdentifier(info);
    } finally {
        IOUtils.closeQuietly(is);
    }
}
Also used : ASN1InputStream(org.bouncycastle.asn1.ASN1InputStream) ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) ByteArrayInputStream(java.io.ByteArrayInputStream) BcX509ExtensionUtils(org.bouncycastle.cert.bc.BcX509ExtensionUtils) SubjectPublicKeyInfo(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo)

Example 2 with BcX509ExtensionUtils

use of org.bouncycastle.cert.bc.BcX509ExtensionUtils in project runwar by cfmlprojects.

the class SelfSignedCertificate method createSubjectKeyIdentifier.

private static SubjectKeyIdentifier createSubjectKeyIdentifier(Key publicKey) throws IOException {
    try (ASN1InputStream is = new ASN1InputStream(new ByteArrayInputStream(publicKey.getEncoded()))) {
        ASN1Sequence seq = (ASN1Sequence) is.readObject();
        SubjectPublicKeyInfo info = SubjectPublicKeyInfo.getInstance(seq);
        return new BcX509ExtensionUtils().createSubjectKeyIdentifier(info);
    }
}
Also used : ASN1InputStream(org.bouncycastle.asn1.ASN1InputStream) ASN1Sequence(org.bouncycastle.asn1.ASN1Sequence) ByteArrayInputStream(java.io.ByteArrayInputStream) BcX509ExtensionUtils(org.bouncycastle.cert.bc.BcX509ExtensionUtils) SubjectPublicKeyInfo(org.bouncycastle.asn1.x509.SubjectPublicKeyInfo)

Aggregations

ByteArrayInputStream (java.io.ByteArrayInputStream)2 ASN1InputStream (org.bouncycastle.asn1.ASN1InputStream)2 ASN1Sequence (org.bouncycastle.asn1.ASN1Sequence)2 SubjectPublicKeyInfo (org.bouncycastle.asn1.x509.SubjectPublicKeyInfo)2 BcX509ExtensionUtils (org.bouncycastle.cert.bc.BcX509ExtensionUtils)2