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.jboss.as.test.integration.security.common.negotiation.KerberosTestUtils.java

License:Open Source License

/**
 * Generates SPNEGO init token with given initial ticket and supported mechanisms.
 *
 * @param ticket initial ticket for the preferred (the first) mechanism.
 * @param supMechOids object identifiers (OIDs) of supported mechanisms for the SPNEGO.
 * @return ASN.1 encoded SPNEGO init token
 *//* ww  w.jav a2 s .c o  m*/
public static byte[] generateSpnegoTokenInit(byte[] ticket, String... supMechOids) throws IOException {
    DEROctetString ticketForPreferredMech = new DEROctetString(ticket);

    ASN1EncodableVector mechSeq = new ASN1EncodableVector();
    for (String mech : supMechOids) {
        mechSeq.add(new ASN1ObjectIdentifier(mech));
    }
    DERTaggedObject taggedMechTypes = new DERTaggedObject(0, new DERSequence(mechSeq));
    DERTaggedObject taggedMechToken = new DERTaggedObject(2, ticketForPreferredMech);
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(taggedMechTypes);
    v.add(taggedMechToken);
    DERSequence seqNegTokenInit = new DERSequence(v);
    DERTaggedObject taggedSpnego = new DERTaggedObject(0, seqNegTokenInit);

    ASN1EncodableVector appVec = new ASN1EncodableVector();
    appVec.add(new ASN1ObjectIdentifier(OID_SPNEGO));
    appVec.add(taggedSpnego);
    DERApplicationSpecific app = new DERApplicationSpecific(0, appVec);
    return app.getEncoded();
}

From source file:org.jboss.as.test.integration.security.common.negotiation.KerberosTestUtils.java

License:Open Source License

/**
 * Generates SPNEGO response (to a "select mechanism challenge") with given bytes as the ticket for selected mechanism.
 *
 * @param ticket/*w  ww  .ja va  2  s. c  o  m*/
 * @return ASN.1 encoded SPNEGO response
 */
public static byte[] generateSpnegoTokenResp(byte[] ticket) throws IOException {
    DEROctetString ourKerberosTicket = new DEROctetString(ticket);

    DERTaggedObject taggedNegState = new DERTaggedObject(0, new ASN1Enumerated(1)); // accept-incomplete
    DERTaggedObject taggedResponseToken = new DERTaggedObject(2, ourKerberosTicket);
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(taggedNegState);
    v.add(taggedResponseToken);
    DERSequence seqNegTokenResp = new DERSequence(v);
    DERTaggedObject taggedSpnego = new DERTaggedObject(1, seqNegTokenResp);
    return taggedSpnego.getEncoded();
}

From source file:org.jmrtd.lds.ActiveAuthenticationInfo.java

License:Open Source License

@Deprecated
public ASN1Primitive getDERObject() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(new ASN1ObjectIdentifier(oid));
    v.add(new ASN1Integer(version));
    if (signatureAlgorithmOID != null) {
        v.add(new ASN1ObjectIdentifier(signatureAlgorithmOID));
    }//  www  . j av  a  2  s.c  om
    return new DLSequence(v);
}

From source file:org.jmrtd.lds.CardAccessFile.java

License:Open Source License

protected void writeContent(OutputStream outputStream) throws IOException {
    ASN1EncodableVector vector = new ASN1EncodableVector();
    for (SecurityInfo si : securityInfos) {
        vector.add(si.getDERObject());//from  w ww.  jav  a  2s .  c  om
    }
    ASN1Set derSet = new DLSet(vector);
    outputStream.write(derSet.getEncoded(ASN1Encoding.DER));
}

From source file:org.jmrtd.lds.CardSecurityFile.java

License:Open Source License

private static ContentInfo toContentInfo(String contentTypeOID, Collection<SecurityInfo> securityInfos) {
    try {/* w ww  . j  av a 2s  . c o m*/
        ASN1EncodableVector vector = new ASN1EncodableVector();
        for (SecurityInfo si : securityInfos) {
            vector.add(si.getDERObject());
        }
        ASN1Set derSet = new DLSet(vector);

        return new ContentInfo(new ASN1ObjectIdentifier(contentTypeOID), new DEROctetString(derSet));
    } catch (IOException ioe) {
        LOGGER.log(Level.SEVERE, "Error creating signedData: " + ioe.getMessage());
        throw new IllegalArgumentException("Error DER encoding the security infos");
    }
}

From source file:org.jmrtd.lds.ChipAuthenticationInfo.java

License:Open Source License

@Deprecated
public ASN1Primitive getDERObject() {
    ASN1EncodableVector v = new ASN1EncodableVector();
    v.add(new ASN1ObjectIdentifier(oid));
    v.add(new ASN1Integer(version));
    if (keyId.compareTo(BigInteger.ZERO) >= 0) {
        v.add(new ASN1Integer(keyId));
    }/*w  w  w.  jav  a 2s. c  o m*/
    return new DLSequence(v);
}

From source file:org.jmrtd.lds.ChipAuthenticationPublicKeyInfo.java

License:Open Source License

@Deprecated
public ASN1Primitive getDERObject() {
    ASN1EncodableVector vector = new ASN1EncodableVector();
    vector.add(new ASN1ObjectIdentifier(oid));
    vector.add((ASN1Sequence) subjectPublicKeyInfo.toASN1Primitive());
    if (keyId.compareTo(BigInteger.ZERO) >= 0) {
        vector.add(new ASN1Integer(keyId));
    }/*from  w w  w. j  a va2  s  . co  m*/
    return new DLSequence(vector);
}

From source file:org.jmrtd.lds.DG14File.java

License:Open Source License

protected void writeContent(OutputStream outputStream) throws IOException {
    ASN1EncodableVector vector = new ASN1EncodableVector();
    for (SecurityInfo securityInfo : securityInfos) {
        ASN1Primitive derObject = securityInfo.getDERObject();
        vector.add(derObject);/*  w ww  .  j  a  v  a  2 s. c  o  m*/
    }
    ASN1Set derSet = new DLSet(vector);
    outputStream.write(derSet.getEncoded(ASN1Encoding.DER));
}

From source file:org.jmrtd.lds.PACEDomainParameterInfo.java

License:Open Source License

@Deprecated
@Override//from  w  w w .j av  a2  s  .  co  m
public ASN1Primitive getDERObject() {
    ASN1EncodableVector vector = new ASN1EncodableVector();

    /* Protocol */
    vector.add(new ASN1ObjectIdentifier(protocolOID));

    /* Required data */
    vector.add(domainParameter);

    /* Optional data */
    if (parameterId >= 0) {
        vector.add(new ASN1Integer(parameterId));
    }
    return new DLSequence(vector);
}

From source file:org.jmrtd.lds.PACEInfo.java

License:Open Source License

@Deprecated
@Override/* www . j  a  v a 2  s  . c  o m*/
public ASN1Primitive getDERObject() {
    ASN1EncodableVector vector = new ASN1EncodableVector();

    /* Protocol */
    vector.add(new ASN1ObjectIdentifier(protocolOID));

    /* Required data */
    vector.add(new ASN1Integer(version));

    /* Optional data */
    if (parameterId >= 0) {
        vector.add(new ASN1Integer(parameterId));
    }
    return new DLSequence(vector);
}