Search in sources :

Example 1 with DERParser

use of org.ldaptive.asn1.DERParser in project ldaptive by vt-middleware.

the class DirSyncControl method decode.

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

Example 2 with DERParser

use of org.ldaptive.asn1.DERParser in project ldaptive by vt-middleware.

the class SyncStateControl method decode.

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

Example 3 with DERParser

use of org.ldaptive.asn1.DERParser in project ldaptive by vt-middleware.

the class DefaultDnParser method parse.

/**
 * Parses the supplied DN into a list of RDNs.
 *
 * @param  dn  to parse
 *
 * @return  unmodifiable list of RDNs
 */
public List<RDn> parse(final String dn) {
    if (dn.trim().isEmpty()) {
        return Collections.emptyList();
    }
    final List<RDn> rdns = new ArrayList<>();
    final List<NameValue> nameValues = new ArrayList<>();
    int pos = 0;
    while (pos < dn.length()) {
        final int[] endAttrNamePos = readToChar(dn, new char[] { '=' }, pos);
        final String attrName = dn.substring(pos, endAttrNamePos[0]).trim();
        if (attrName.isEmpty()) {
            throw new IllegalArgumentException("Invalid RDN: no attribute name found for " + dn);
        } else if (attrName.contains("+") || attrName.contains(",")) {
            throw new IllegalArgumentException("Invalid RDN: unexpected '" + attrName.charAt(0) + "' for " + dn);
        }
        pos = endAttrNamePos[0];
        // error if char isn't an '='
        if (pos >= dn.length() || dn.charAt(pos++) != '=') {
            throw new IllegalArgumentException("Invalid RDN: no equals found for " + dn);
        }
        final int[] endAttrValuePos = readToChar(dn, new char[] { '+', ',' }, pos);
        final String attrValue = dn.substring(pos, endAttrValuePos[0]).trim();
        if (attrValue.isEmpty()) {
            nameValues.add(new NameValue(attrName, ""));
        } else if (attrValue.startsWith("#")) {
            final DERParser parser = new DERParser();
            final OctetStringHandler handler = new OctetStringHandler();
            parser.registerHandler(HEX_PATH, handler);
            final String hexData = attrValue.substring(1);
            parser.parse(new DefaultDERBuffer(decodeHexValue(hexData.toCharArray())));
            nameValues.add(new NameValue(attrName, handler.getDecodedValue()));
        } else {
            nameValues.add(new NameValue(attrName, decodeStringValue(attrValue)));
        }
        if (endAttrValuePos[1] == -1 || endAttrValuePos[1] == ',') {
            rdns.add(new RDn(nameValues));
            nameValues.clear();
        }
        pos = endAttrValuePos[0] + 1;
        if (pos == dn.length() && endAttrValuePos[1] != -1) {
            // dangling match character
            throw new IllegalArgumentException("Invalid RDN: attribute value ends with '" + endAttrValuePos[1] + "' for " + dn);
        }
    }
    return Collections.unmodifiableList(rdns);
}
Also used : DefaultDERBuffer(org.ldaptive.asn1.DefaultDERBuffer) ArrayList(java.util.ArrayList) DERParser(org.ldaptive.asn1.DERParser)

Example 4 with DERParser

use of org.ldaptive.asn1.DERParser in project ldaptive by vt-middleware.

the class SessionTrackingControl method decode.

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

Example 5 with DERParser

use of org.ldaptive.asn1.DERParser in project ldaptive by vt-middleware.

the class SortResponseControl method decode.

@Override
public void decode(final DERBuffer encoded) {
    final DERParser parser = new DERParser();
    parser.registerHandler(SortResultHandler.PATH, new SortResultHandler(this));
    parser.registerHandler(AttributeTypeHandler.PATH, new AttributeTypeHandler(this));
    parser.parse(encoded);
}
Also used : 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