Search in sources :

Example 26 with DerParser

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

the class MessageFrameDecoder method readMessageLength.

/**
 * Inspects the supplied buffer for a {@link UniversalDERTag#SEQ} tag and confirms the buffer contains enough bytes
 * for the length specified for the tag.
 *
 * @param  buffer  to read
 *
 * @return  DER message length
 *
 * @throws  IllegalArgumentException  if the buffer doesn't contain a SEQ tag
 */
private int readMessageLength(final DERBuffer buffer) {
    final DERParser messageParser = new DERParser();
    final int tag = messageParser.readTag(buffer).getTagNo();
    if (UniversalDERTag.SEQ.getTagNo() != tag) {
        throw new IllegalArgumentException("Invalid message tag: " + tag);
    }
    try {
        final int len = messageParser.readLength(buffer);
        if (buffer.position() + len <= buffer.capacity()) {
            logger.trace("read entire message of length {} with buffer {}", len, buffer);
            return buffer.position() + len;
        }
        logger.trace("could not read entire message of length {} with buffer {}", len, buffer);
    } catch (IndexOutOfBoundsException e) {
        // it's possible to receive a multi-byte length without all the bytes
        // don't log that outcome as a warning
        logger.trace("error reading message length with buffer {}", buffer, e);
    } catch (Exception e) {
        logger.warn("Error reading message length with buffer {}", buffer, e);
    }
    return -1;
}
Also used : DERParser(org.ldaptive.asn1.DERParser)

Example 27 with DerParser

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

the class VirtualListViewResponseControl method decode.

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

Example 28 with DerParser

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

the class PagedResultsControl method decode.

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

Example 29 with DerParser

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

the class PasswordPolicyControl method decode.

@Override
public void decode(final DERBuffer encoded) {
    final DERParser parser = new DERParser();
    parser.registerHandler(TimeBeforeExpirationHandler.PATH, new TimeBeforeExpirationHandler(this));
    parser.registerHandler(GraceAuthnsRemainingHandler.PATH, new GraceAuthnsRemainingHandler(this));
    parser.registerHandler(ErrorHandler.PATH, new ErrorHandler(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