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;
}
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);
}
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);
}
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);
}
Aggregations