Search in sources :

Example 11 with TBSCertificateStructure

use of org.bouncycastle.asn1.x509.TBSCertificateStructure in project nhin-d by DirectProject.

the class SubjectPublicKeyAlgorithmField method injectReferenceValue.

/**
	 * {@inheritDoc}
	 */
@Override
public void injectReferenceValue(X509Certificate value) throws PolicyProcessException {
    this.certificate = value;
    DERObject tbsValue = null;
    try {
        tbsValue = this.getDERObject(certificate.getTBSCertificate());
    }///CLOVER:OFF
     catch (Exception e) {
        throw new PolicyProcessException("Exception parsing TBS certificate fields.", e);
    }
    ///CLOVER:ON
    final TBSCertificateStructure tbsStruct = TBSCertificateStructure.getInstance(tbsValue);
    this.policyValue = PolicyValueFactory.getInstance(tbsStruct.getSubjectPublicKeyInfo().getAlgorithmId().getObjectId().toString());
}
Also used : DERObject(org.bouncycastle.asn1.DERObject) TBSCertificateStructure(org.bouncycastle.asn1.x509.TBSCertificateStructure) PolicyProcessException(org.nhindirect.policy.PolicyProcessException) PolicyProcessException(org.nhindirect.policy.PolicyProcessException)

Example 12 with TBSCertificateStructure

use of org.bouncycastle.asn1.x509.TBSCertificateStructure in project BiglyBT by BiglySoftware.

the class PrincipalUtil method getIssuerX509Principal.

/**
 * return the issuer of the given cert as an X509PrincipalObject.
 */
public static X509Principal getIssuerX509Principal(X509Certificate cert) throws CertificateEncodingException {
    try {
        ByteArrayInputStream bIn = new ByteArrayInputStream(cert.getTBSCertificate());
        ASN1InputStream aIn = new ASN1InputStream(bIn);
        TBSCertificateStructure tbsCert = new TBSCertificateStructure((ASN1Sequence) aIn.readObject());
        return new X509Principal(tbsCert.getIssuer());
    } catch (IOException e) {
        throw new CertificateEncodingException(e.toString());
    }
}
Also used : ASN1InputStream(org.gudy.bouncycastle.asn1.ASN1InputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) TBSCertificateStructure(org.gudy.bouncycastle.asn1.x509.TBSCertificateStructure) CertificateEncodingException(java.security.cert.CertificateEncodingException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)6 TBSCertificateStructure (org.bouncycastle.asn1.x509.TBSCertificateStructure)6 ASN1EncodableVector (org.bouncycastle.asn1.ASN1EncodableVector)4 DERSequence (org.bouncycastle.asn1.DERSequence)4 CertificateParsingException (java.security.cert.CertificateParsingException)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 CertificateEncodingException (java.security.cert.CertificateEncodingException)2 DERBitString (org.bouncycastle.asn1.DERBitString)2 DERObject (org.bouncycastle.asn1.DERObject)2 X509CertificateStructure (org.bouncycastle.asn1.x509.X509CertificateStructure)2 X509CertificateObject (org.bouncycastle.jce.provider.X509CertificateObject)2 ASN1InputStream (org.gudy.bouncycastle.asn1.ASN1InputStream)2 TBSCertificateStructure (org.gudy.bouncycastle.asn1.x509.TBSCertificateStructure)2 PolicyProcessException (org.nhindirect.policy.PolicyProcessException)2 DERObjectIdentifier (org.bouncycastle.asn1.DERObjectIdentifier)1 DERTaggedObject (org.bouncycastle.asn1.DERTaggedObject)1 X509Name (org.bouncycastle.asn1.x509.X509Name)1 PolicyRequiredException (org.nhindirect.policy.PolicyRequiredException)1