use of io.churchkey.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);
}
use of io.churchkey.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);
}
use of io.churchkey.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);
}
use of io.churchkey.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);
}
use of io.churchkey.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);
}
Aggregations