Search in sources :

Example 1 with Tag

use of org.mozilla.jss.asn1.Tag in project jss by dogtagpki.

the class JSSUtil method decode.

public static String decode(byte tag, byte[] bytes) throws Exception {
    ASN1Template template;
    switch(tag) {
        case DerValue.tag_BMPString:
            template = new BMPString.Template();
            break;
        case DerValue.tag_IA5String:
            template = new IA5String.Template();
            break;
        case DerValue.tag_PrintableString:
            template = new PrintableString.Template();
            break;
        case DerValue.tag_T61String:
            template = new TeletexString.Template();
            break;
        case DerValue.tag_UniversalString:
            template = new UniversalString.Template();
            break;
        case DerValue.tag_UTF8String:
            template = new UTF8String.Template();
            break;
        default:
            throw new Exception("Unsupported tag: " + tag);
    }
    ASN1Value asnValue = ASN1Util.decode(new Tag(Tag.UNIVERSAL, tag), template, bytes);
    if (asnValue == null) {
        throw new Exception("Cannot decode the given bytes.");
    }
    return asnValue.toString();
}
Also used : ASN1Template(org.mozilla.jss.asn1.ASN1Template) UTF8String(org.mozilla.jss.asn1.UTF8String) PrintableString(org.mozilla.jss.asn1.PrintableString) TeletexString(org.mozilla.jss.asn1.TeletexString) ASN1Value(org.mozilla.jss.asn1.ASN1Value) IA5String(org.mozilla.jss.asn1.IA5String) Tag(org.mozilla.jss.asn1.Tag) UniversalString(org.mozilla.jss.asn1.UniversalString) BMPString(org.mozilla.jss.asn1.BMPString)

Example 2 with Tag

use of org.mozilla.jss.asn1.Tag in project jss by dogtagpki.

the class CertReqMsg method encode.

/**
 * Encodes this <i>CertReqMsg</i> to the given OutputStream using
 * DER encoding, with the given implicit tag.
 */
@Override
public void encode(Tag implicit, OutputStream ostream) throws IOException {
    // Assert.notYetImplemented("CertReqMsg encoding");
    SEQUENCE sequence = new SEQUENCE();
    sequence.addElement(certReq);
    if (pop != null)
        sequence.addElement(pop);
    if (regInfo != null)
        sequence.addElement(regInfo);
    sequence.encode(implicit, ostream);
}
Also used : SEQUENCE(org.mozilla.jss.asn1.SEQUENCE)

Example 3 with Tag

use of org.mozilla.jss.asn1.Tag in project jss by dogtagpki.

the class CertTemplate method encode.

@Override
public void encode(Tag t, OutputStream ostream) throws IOException {
    SEQUENCE seq = new SEQUENCE();
    seq.addElement(Tag.get(0), version);
    seq.addElement(Tag.get(1), serialNumber);
    seq.addElement(Tag.get(2), signingAlg);
    if (issuer != null) {
        // issuer is a CHOICE, so it must be EXPLICITly tagged
        seq.addElement(new EXPLICIT(Tag.get(3), issuer));
    }
    if (notBefore != null || notAfter != null) {
        SEQUENCE optionalVal = new SEQUENCE();
        // notBefore & notAfter are CHOICES, so must be EXPLICITly tagged
        if (notBefore != null) {
            optionalVal.addElement(new EXPLICIT(Tag.get(0), dateToASN1(notBefore)));
        }
        if (notAfter != null) {
            optionalVal.addElement(new EXPLICIT(Tag.get(1), dateToASN1(notAfter)));
        }
        seq.addElement(Tag.get(4), optionalVal);
    }
    if (subject != null) {
        // subject is a CHOICE, so it must be EXPLICITly tagged
        seq.addElement(new EXPLICIT(Tag.get(5), subject));
    }
    seq.addElement(Tag.get(6), publicKey);
    seq.addElement(Tag.get(7), issuerUID);
    seq.addElement(Tag.get(8), subjectUID);
    seq.addElement(Tag.get(9), extensions);
    seq.encode(t, ostream);
}
Also used : SEQUENCE(org.mozilla.jss.asn1.SEQUENCE) EXPLICIT(org.mozilla.jss.asn1.EXPLICIT)

Example 4 with Tag

use of org.mozilla.jss.asn1.Tag in project jss by dogtagpki.

the class AVA method encode.

@Override
public void encode(Tag implicit, OutputStream ostream) throws IOException {
    SEQUENCE seq = new SEQUENCE();
    seq.addElement(oid);
    seq.addElement(value);
    seq.encode(implicit, ostream);
}
Also used : SEQUENCE(org.mozilla.jss.asn1.SEQUENCE)

Example 5 with Tag

use of org.mozilla.jss.asn1.Tag in project jss by dogtagpki.

the class Attribute method encode.

@Override
public void encode(Tag implicit, OutputStream ostream) throws IOException {
    SEQUENCE seq = new SEQUENCE();
    seq.addElement(type);
    seq.addElement(values);
    seq.encode(implicit, ostream);
}
Also used : SEQUENCE(org.mozilla.jss.asn1.SEQUENCE)

Aggregations

Tag (org.openstreetmap.osmosis.core.domain.v0_6.Tag)66 SEQUENCE (org.mozilla.jss.asn1.SEQUENCE)23 CommonEntityData (org.openstreetmap.osmosis.core.domain.v0_6.CommonEntityData)23 WayNode (org.openstreetmap.osmosis.core.domain.v0_6.WayNode)17 IOException (java.io.IOException)16 Test (org.junit.Test)16 Node (org.openstreetmap.osmosis.core.domain.v0_6.Node)16 OsmUser (org.openstreetmap.osmosis.core.domain.v0_6.OsmUser)16 Way (org.openstreetmap.osmosis.core.domain.v0_6.Way)12 Date (java.util.Date)10 RelationMember (org.openstreetmap.osmosis.core.domain.v0_6.RelationMember)10 OsmosisRuntimeException (org.openstreetmap.osmosis.core.OsmosisRuntimeException)9 Relation (org.openstreetmap.osmosis.core.domain.v0_6.Relation)9 Tag (org.mozilla.jss.asn1.Tag)7 SQLException (java.sql.SQLException)6 ArrayList (java.util.ArrayList)6 EXPLICIT (org.mozilla.jss.asn1.EXPLICIT)6 Osmformat (crosby.binary.Osmformat)5 NodeContainer (org.openstreetmap.osmosis.core.container.v0_6.NodeContainer)5 Point (com.vividsolutions.jts.geom.Point)4