Search in sources :

Example 21 with DerValue

use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.

the class CertificateExtensions method decodeEx.

/**
 * Decode the extensions from the InputStream.
 *
 * @param in the InputStream to unmarshal the contents from.
 * @exception IOException on decoding or validity errors.
 */
public void decodeEx(InputStream in) throws IOException {
    DerValue val = new DerValue(in);
    DerInputStream str = null;
    if (val.isConstructed() && val.isContextSpecific((byte) 3)) {
        str = val.data;
    } else {
        str = val.toDerInputStream();
    }
    map = new LinkedHashMap<>();
    DerValue[] exts = str.getSequence(5);
    for (int i = 0; i < exts.length; i++) {
        Extension ext = new Extension(exts[i]);
        parseExtension(ext);
    }
}
Also used : DerValue(org.mozilla.jss.netscape.security.util.DerValue) DerInputStream(org.mozilla.jss.netscape.security.util.DerInputStream)

Example 22 with DerValue

use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.

the class CertificateExtensions method decode.

/**
 * Decode the extensions from the InputStream.
 *
 * @param in the InputStream to unmarshal the contents from.
 * @exception IOException on decoding or validity errors.
 */
@Override
public void decode(InputStream in) throws IOException {
    DerValue val = new DerValue(in);
    DerInputStream str = val.toDerInputStream();
    map = new LinkedHashMap<>();
    DerValue[] exts = str.getSequence(5);
    for (int i = 0; i < exts.length; i++) {
        Extension ext = new Extension(exts[i]);
        parseExtension(ext);
    }
}
Also used : DerValue(org.mozilla.jss.netscape.security.util.DerValue) DerInputStream(org.mozilla.jss.netscape.security.util.DerInputStream)

Example 23 with DerValue

use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.

the class CertificateIssuerName method decode.

/**
 * Decode the name in DER form from the stream.
 *
 * @param in the InputStream to marshal the contents from.
 * @exception IOException on errors.
 */
@Override
public void decode(InputStream in) throws IOException {
    DerValue derVal = new DerValue(in);
    dnName = new X500Name(derVal);
}
Also used : DerValue(org.mozilla.jss.netscape.security.util.DerValue)

Example 24 with DerValue

use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.

the class GenericValueConverter method getValue.

@Override
public DerValue getValue(String valueString, byte[] tags) throws IOException {
    if (tags == null || tags.length == 0)
        tags = DefEncodingTags;
    for (int i = 0; i < tags.length; i++) {
        try {
            CharsetEncoder encoder = ASN1CharStrConvMap.getDefault().getEncoder(tags[i]);
            if (encoder == null)
                continue;
            CharBuffer charBuffer = CharBuffer.wrap(valueString.toCharArray());
            ByteBuffer byteBuffer = encoder.encode(charBuffer);
            return new DerValue(tags[i], byteBuffer.array(), byteBuffer.arrayOffset(), byteBuffer.limit());
        } catch (CharacterCodingException e) {
            continue;
        }
    }
    throw new IOException("Cannot convert the string value to a ASN.1 type");
}
Also used : DerValue(org.mozilla.jss.netscape.security.util.DerValue) CharBuffer(java.nio.CharBuffer) CharacterCodingException(java.nio.charset.CharacterCodingException) IOException(java.io.IOException) CharsetEncoder(java.nio.charset.CharsetEncoder) ByteBuffer(java.nio.ByteBuffer)

Example 25 with DerValue

use of org.mozilla.jss.netscape.security.util.DerValue in project jss by dogtagpki.

the class ExtensionsRequested method decode.

@Override
public void decode(InputStream in) throws CertificateException, IOException {
    DerValue derVal = new DerValue(in);
    construct(derVal);
}
Also used : DerValue(org.mozilla.jss.netscape.security.util.DerValue)

Aggregations

DerValue (org.mozilla.jss.netscape.security.util.DerValue)70 IOException (java.io.IOException)31 DerInputStream (org.mozilla.jss.netscape.security.util.DerInputStream)20 DerOutputStream (org.mozilla.jss.netscape.security.util.DerOutputStream)8 ObjectIdentifier (org.mozilla.jss.netscape.security.util.ObjectIdentifier)8 NoSuchAlgorithmException (java.security.NoSuchAlgorithmException)5 ByteBuffer (java.nio.ByteBuffer)4 CharBuffer (java.nio.CharBuffer)4 CharacterCodingException (java.nio.charset.CharacterCodingException)4 CharsetEncoder (java.nio.charset.CharsetEncoder)4 MessageDigest (java.security.MessageDigest)4 CRLException (java.security.cert.CRLException)4 BitArray (org.mozilla.jss.netscape.security.util.BitArray)4 AuthorityKeyIdentifierExtension (org.mozilla.jss.netscape.security.x509.AuthorityKeyIdentifierExtension)4 KeyIdentifier (org.mozilla.jss.netscape.security.x509.KeyIdentifier)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 InvalidKeyException (java.security.InvalidKeyException)3 BigInt (org.mozilla.jss.netscape.security.util.BigInt)3 GeneralName (org.mozilla.jss.netscape.security.x509.GeneralName)3 CertificateException (java.security.cert.CertificateException)2