Example usage for org.bouncycastle.asn1.x509 X509Extensions PolicyMappings

List of usage examples for org.bouncycastle.asn1.x509 X509Extensions PolicyMappings

Introduction

In this page you can find the example usage for org.bouncycastle.asn1.x509 X509Extensions PolicyMappings.

Prototype

ASN1ObjectIdentifier PolicyMappings

To view the source code for org.bouncycastle.asn1.x509 X509Extensions PolicyMappings.

Click Source Link

Document

Policy Mappings

Usage

From source file:org.qipki.crypto.x509.X509ExtensionsReaderImpl.java

License:Open Source License

@Override
public Set<PolicyMapping> getPolicyMappings(X509Certificate cert) {
    try {/*ww w  .  j a v a2  s. c o  m*/
        byte[] value = cert.getExtensionValue(X509Extensions.PolicyMappings.getId());
        if (value == null) {
            return Collections.emptySet();
        }
        ASN1Sequence mappingsSequence = (ASN1Sequence) ASN1Object.fromByteArray(value);
        Set<PolicyMapping> mappings = new LinkedHashSet<PolicyMapping>();
        for (int idx = 0; idx < mappingsSequence.size(); idx++) {
            ASN1Sequence seq = (ASN1Sequence) mappingsSequence.getObjectAt(idx);
            PolicyMapping mapping = new PolicyMapping();
            if (seq.size() > 0) {
                mapping.setIssuerDomainPolicyOID(((DERObjectIdentifier) seq.getObjectAt(0)).getId());
            }
            if (seq.size() > 1) {
                mapping.setIssuerDomainPolicyOID(((DERObjectIdentifier) seq.getObjectAt(1)).getId());
            }
            mappings.add(mapping);
        }
        return mappings;
    } catch (IOException ex) {
        throw new CryptoFailure("Unable to extract PolicyMappings from X509Certificate extensions", ex);
    }
}