Example usage for org.bouncycastle.asn1 ASN1EncodableVector ASN1EncodableVector

List of usage examples for org.bouncycastle.asn1 ASN1EncodableVector ASN1EncodableVector

Introduction

In this page you can find the example usage for org.bouncycastle.asn1 ASN1EncodableVector ASN1EncodableVector.

Prototype

public ASN1EncodableVector() 

Source Link

Usage

From source file:org.globus.gsi.bc.X509NameHelper.java

License:Apache License

/**
 * Appends the specified OID and value pair name component to the end of the
 * current name./*from   w  w  w .  j  a v a2s. c  o  m*/
 *
 * @param oid   the name component oid, e.g. {@link org.bouncycastle.asn1.x500.style.BCStyle#CN
 *              BCStyle.CN}
 * @param value the value (e.g. "proxy")
 */
public void add(ASN1ObjectIdentifier oid, String value) {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(oid);
    v.add(new DERPrintableString(value));
    add(new DERSet(new DERSequence(v)));
}

From source file:org.globus.gsi.proxy.ext.ProxyCertInfo.java

License:Apache License

/**
 * Returns the DER-encoded ASN.1 representation of the extension.
 *
 * @return <code>DERObject</code> the encoded representation of the extension.
 *///from  w w  w . ja  va2s  .co  m
public ASN1Primitive toASN1Primitive() {
    ASN1EncodableVector vec = new ASN1EncodableVector();

    if (this.pathLenConstraint != null) {
        vec.add(this.pathLenConstraint);
    }

    vec.add(this.proxyPolicy.toASN1Primitive());

    return new DERSequence(vec);
}

From source file:org.globus.gsi.proxy.ext.ProxyPolicy.java

License:Apache License

/**
 * Returns the DER-encoded ASN.1 representation of proxy policy.
 *
 * @return <code>DERObject</code> the encoded representation of the proxy
 *         policy./* w  w w .j ava2 s .c om*/
 */
public ASN1Primitive toASN1Primitive() {

    ASN1EncodableVector vec = new ASN1EncodableVector();

    vec.add(this.policyLanguage);

    if (this.policy != null) {
        vec.add(this.policy);
    }

    return new DERSequence(vec);
}

From source file:org.globus.security.proxyExtension.ProxyPolicy.java

License:Apache License

/**
 * Returns the DER-encoded ASN.1 representation of proxy policy.
 *
 * @return <code>DERObject</code> the encoded representation of the proxy
 *         policy.// www .  j  a  va 2 s. c o  m
 */
public DERObject getDERObject() {

    ASN1EncodableVector vec = new ASN1EncodableVector();

    vec.add(this.policyLanguage);

    if (this.policy != null) {
        vec.add(this.policy);
    }

    return new DERSequence(vec);
}

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

License:Apache License

private ASN1Encodable buildACCertsExtensionContent(EnumSet<ACGenerationProperties> properties) {

    ASN1EncodableVector issuerCertsContainer = new ASN1EncodableVector();

    if (properties.contains(ACGenerationProperties.INCLUDE_EMPTY_AC_CERTS_EXTENSION))
        issuerCertsContainer.add(new DERSequence());
    else//from ww w  . j  ava  2s  .c  om
        issuerCertsContainer.add(new DERSequence(getCertAsDEREncodable(aaCredential.getCertificate())));

    return new DERSequence(issuerCertsContainer);
}

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

License:Apache License

private ASN1Encodable buildFQANsAttributeContent(List<String> fqans, GeneralName policyAuthorityInfo) {

    ASN1EncodableVector container = new ASN1EncodableVector();
    ASN1EncodableVector encodedFQANs = new ASN1EncodableVector();

    // Policy authority info
    DERTaggedObject pai = new DERTaggedObject(0, policyAuthorityInfo);
    container.add(pai);/*from   w  ww .  j  a va 2 s .  c  o m*/

    for (String s : fqans)
        encodedFQANs.add(new DEROctetString(s.getBytes()));

    container.add(new DERSequence(encodedFQANs));

    return new DERSequence(container);
}

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

License:Apache License

private ASN1Encodable buildGAExtensionContent(EnumSet<ACGenerationProperties> properties,
        List<VOMSGenericAttribute> gas, GeneralName policyAuthorityInfo) {

    ASN1EncodableVector tagContainer = new ASN1EncodableVector();
    ASN1EncodableVector tagSequences = new ASN1EncodableVector();

    for (VOMSGenericAttribute a : gas)
        tagSequences.add(buildTagSequence(a));

    tagContainer.add(new GeneralNames(policyAuthorityInfo));
    tagContainer.add(new DERSequence(tagSequences));

    DERSequence finalSequence;//from   ww w  .  j a  v a  2  s  .  c  o  m

    // We wrap this three times as VOMS core does, even if I think this
    // is a bug
    finalSequence = new DERSequence(new DERSequence(new DERSequence(tagContainer)));

    return finalSequence;
}

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

License:Apache License

private DERSequence buildTagSequence(VOMSGenericAttribute ga) {

    ASN1EncodableVector tagSequence = new ASN1EncodableVector();

    tagSequence.add(getDEROctetString(ga.getName()));
    tagSequence.add(getDEROctetString(ga.getValue()));
    tagSequence.add(getDEROctetString(ga.getContext()));

    return new DERSequence(tagSequence);

}

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

License:Apache License

private ASN1Encodable buildTargetsExtensionContent(EnumSet<ACGenerationProperties> properties,
        List<String> targets) {

    ASN1EncodableVector targetSeq = new ASN1EncodableVector();

    for (String s : targets) {

        DERTaggedObject encodedTarget = new DERTaggedObject(0,
                new GeneralName(GeneralName.uniformResourceIdentifier, s));

        // We wrap the target in another sequence as the old VOMS does
        targetSeq.add(new DERSequence(encodedTarget));
    }/*  w w  w . jav  a 2  s  .c o m*/

    DERSequence targetExtensionContent = new DERSequence(new DERSequence(targetSeq));
    return targetExtensionContent;
}

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

License:Apache License

public CertificateExtension generateVOMSExtension(List<X509AttributeCertificateHolder> acs) {

    ASN1EncodableVector vomsACs = new ASN1EncodableVector();

    for (X509AttributeCertificateHolder ac : acs)
        vomsACs.add(ac.toASN1Structure());

    DERSequence acSeq = new DERSequence(vomsACs);

    CertificateExtension ext = new CertificateExtension(VOMS_EXTENSION_OID.getId(), acSeq.toASN1Object(),
            false);/*from w  ww.  j  a v a 2  s  .  c  o  m*/

    return ext;
}