Search in sources :

Example 6 with DerParser

use of io.churchkey.asn1.DerParser in project ldaptive by vt-middleware.

the class SyncDoneControl method decode.

@Override
public void decode(final DERBuffer encoded) {
    final DERParser parser = new DERParser();
    parser.registerHandler(CookieHandler.PATH, new CookieHandler(this));
    parser.registerHandler(RefreshDeletesHandler.PATH, new RefreshDeletesHandler(this));
    parser.parse(encoded);
}
Also used : DERParser(org.ldaptive.asn1.DERParser)

Example 7 with DerParser

use of io.churchkey.asn1.DerParser in project ldaptive by vt-middleware.

the class EntryChangeNotificationControl method decode.

@Override
public void decode(final DERBuffer encoded) {
    final DERParser parser = new DERParser();
    parser.registerHandler(ChangeTypeHandler.PATH, new ChangeTypeHandler(this));
    parser.registerHandler(PreviousDnHandler.PATH, new PreviousDnHandler(this));
    parser.registerHandler(ChangeNumberHandler.PATH, new ChangeNumberHandler(this));
    parser.parse(encoded);
}
Also used : DERParser(org.ldaptive.asn1.DERParser)

Example 8 with DerParser

use of io.churchkey.asn1.DerParser in project ldaptive by vt-middleware.

the class PasswordModifyResponseParser method parse.

/**
 * Parse the supplied extended operation response.
 *
 * @param  response  from a password modify extended operation
 *
 * @return  generated password
 */
public static String parse(final ExtendedResponse response) {
    final StringBuilder sb = new StringBuilder();
    final DERParser p = new DERParser();
    p.registerHandler(GenPasswdHandler.PATH, new GenPasswdHandler(sb));
    p.parse(new DefaultDERBuffer(response.getResponseValue()));
    return sb.toString();
}
Also used : DefaultDERBuffer(org.ldaptive.asn1.DefaultDERBuffer) DERParser(org.ldaptive.asn1.DERParser)

Example 9 with DerParser

use of io.churchkey.asn1.DerParser in project ldaptive by vt-middleware.

the class X509DnDecoder method decode.

/**
 * Converts bytes in the buffer to attribute value assertions by reading from the current position to the limit.
 *
 * @param  encoded  buffer containing DER-encoded data where the buffer is positioned at the tag of the oid and the
 *                  limit is set beyond the last byte of attribute value data.
 *
 * @return  decoded bytes as attribute value assertions
 */
private static List<NameValue> decode(final DERBuffer encoded) {
    final List<NameValue> nameValues = new ArrayList<>();
    final DERParser parser = new DERParser();
    parser.registerHandler(ASSERTION_PATH, (p, e) -> {
        if (UniversalDERTag.OID.getTagNo() != p.readTag(e).getTagNo()) {
            throw new IllegalArgumentException("Expected OID tag");
        }
        final int seqLimit = e.limit();
        final int oidLength = p.readLength(e);
        e.limit(e.position() + oidLength);
        final String oid = OidType.decode(e);
        e.limit(seqLimit);
        p.readTag(e);
        p.readLength(e);
        nameValues.add(new NameValue(oid, e.getRemainingBytes()));
    });
    parser.parse(encoded);
    return nameValues;
}
Also used : NameValue(org.ldaptive.dn.NameValue) ArrayList(java.util.ArrayList) DERParser(org.ldaptive.asn1.DERParser)

Example 10 with DerParser

use of io.churchkey.asn1.DerParser in project ldaptive by vt-middleware.

the class X509DnDecoder method apply.

@Override
public Dn apply(final DERBuffer encoded) {
    final List<RDn> rdns = new ArrayList<>();
    final DERParser parser = new DERParser();
    parser.registerHandler(RDN_PATH, (p, e) -> {
        rdns.add(new RDn(decode(e)));
        e.position(e.limit());
    });
    parser.parse(encoded);
    return new Dn(rdns);
}
Also used : ArrayList(java.util.ArrayList) RDn(org.ldaptive.dn.RDn) Dn(org.ldaptive.dn.Dn) RDn(org.ldaptive.dn.RDn) DERParser(org.ldaptive.asn1.DERParser)

Aggregations

DERParser (org.ldaptive.asn1.DERParser)16 DerParser (io.churchkey.asn1.DerParser)13 Asn1Object (io.churchkey.asn1.Asn1Object)12 Key (io.churchkey.Key)8 RSAPrivateCrtKey (java.security.interfaces.RSAPrivateCrtKey)5 RSAPublicKey (java.security.interfaces.RSAPublicKey)5 IOException (java.io.IOException)4 UncheckedIOException (java.io.UncheckedIOException)4 BigInteger (java.math.BigInteger)4 DSAPrivateKey (java.security.interfaces.DSAPrivateKey)4 DSAPublicKey (java.security.interfaces.DSAPublicKey)4 ECPrivateKey (java.security.interfaces.ECPrivateKey)4 ECPublicKey (java.security.interfaces.ECPublicKey)4 ArrayList (java.util.ArrayList)4 Oid (io.churchkey.asn1.Oid)3 ECPoint (java.security.spec.ECPoint)3 DefaultDERBuffer (org.ldaptive.asn1.DefaultDERBuffer)3 Dsa (io.churchkey.dsa.Dsa)2 Curve (io.churchkey.ec.Curve)2 Pem (io.churchkey.util.Pem)2