Example usage for org.bouncycastle.cert X509AttributeCertificateHolder getHolder

List of usage examples for org.bouncycastle.cert X509AttributeCertificateHolder getHolder

Introduction

In this page you can find the example usage for org.bouncycastle.cert X509AttributeCertificateHolder getHolder.

Prototype

public AttributeCertificateHolder getHolder() 

Source Link

Document

Return the holder details for this attribute certificate.

Usage

From source file:AAModulePackage.ACHelper.java

/**
 * Checks to see if the X.509 ID Certificate "Owns" the AC.
 * @param ac - X.509 Attribute Certificate
 * @param associatedCert - "Owner's" ID Certificate.
 * @return - True if the ID Cert "owns" the AC, False otherwise.
 *//*from   ww  w.java  2 s  . co m*/
public static boolean checkAssociatedCertificate(X509AttributeCertificateHolder ac,
        X509CertificateHolder associatedCert) {
    BigInteger acSerial = ac.getHolder().getSerialNumber();

    if (acSerial.equals(associatedCert.getSerialNumber())) {
        return true;
    }
    return false;
}

From source file:org.italiangrid.voms.asn1.VOMSACUtils.java

License:Apache License

/**
 * Deserializes the information in a VOMS attribute certificate.
 * //from  w w  w. j  av  a  2s. c  om
 * @param ac
 *          a VOMS {@link AttributeCertificate}
 * @return a {@link VOMSAttribute} object which provides more convenient
 *         access to the VOMS authorization information
 */
public static VOMSAttribute deserializeVOMSAttributes(AttributeCertificate ac) {

    VOMSAttributesImpl attrs = new VOMSAttributesImpl();

    X509AttributeCertificateHolder acHolder = new X509AttributeCertificateHolder(ac);
    Attribute[] asn1Attrs = acHolder.getAttributes(VOMS_FQANS_OID);

    for (Attribute a : asn1Attrs) {
        DERObject theVOMSDerObject = a.getAttributeValues()[0].getDERObject();
        IetfAttrSyntax attrSyntax = new IetfAttrSyntax(ASN1Sequence.getInstance(theVOMSDerObject));

        String policyAuthority = policyAuthoritySanityChecks(attrSyntax);

        // The policy authority string has the following format:
        // <vo name>://<hostname>:<port>

        attrs.setVO(policyAuthority.substring(0, policyAuthority.indexOf(POLICY_AUTHORITY_SEP)));
        attrs.setHost(policyAuthority.substring(policyAuthority.indexOf(POLICY_AUTHORITY_SEP) + 3,
                policyAuthority.lastIndexOf(":")));
        attrs.setPort(Integer.parseInt(policyAuthority.substring(policyAuthority.lastIndexOf(":") + 1)));

        attrs.setFQANs(deserializeFQANs(attrSyntax));

        attrs.setNotBefore(acHolder.getNotBefore());
        attrs.setNotAfter(acHolder.getNotAfter());
        attrs.setSignature(acHolder.getSignature());
        attrs.setGenericAttributes(deserializeGAs(acHolder));
        attrs.setAACertificates(deserializeACCerts(acHolder));
        attrs.setTargets(deserializeACTargets(acHolder));

        attrs.setVOMSAC(acHolder);

        try {

            attrs.setIssuer(new X500Principal(acHolder.getIssuer().getNames()[0].getEncoded()));
            attrs.setHolder(new X500Principal(acHolder.getHolder().getIssuer()[0].getEncoded()));
            attrs.setHolderSerialNumber(acHolder.getHolder().getSerialNumber());

        } catch (IOException e) {
            throw new VOMSError("Error parsing attribute certificate issuer  or holder name: " + e.getMessage(),
                    e);
        }
    }

    return attrs;
}