@Override public void handle(final DERParser parser, final ByteBuffer encoded) { rdns.add(new RDN(AttributeValueAssertion.decode(encoded.slice()))); encoded.position(encoded.limit()); } });
@Override public byte[] encode() { return types.encode(); } });
/** * Returns the attribute values for the supplied oid. * * @param oid to match * * @return attribute values */ public AttributeValueAssertion.Value[] getAttributeValues(final String oid) { final List<AttributeValueAssertion.Value> values = new ArrayList<>(); for (AttributeValueAssertion type : attributeValueAssertions) { if (type.getOid().equals(oid)) { values.add(type.getValue()); } } return values.toArray(new AttributeValueAssertion.Value[values.size()]); }
/** * 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 */ public static AttributeValueAssertion[] decode(final ByteBuffer encoded) { final List<AttributeValueAssertion> assertions = new ArrayList<>(); final DERParser parser = new DERParser(); parser.registerHandler( "/SEQ", (parser1, encoded1) -> { if (UniversalDERTag.OID.getTagNo() != parser1.readTag(encoded1).getTagNo()) { throw new IllegalArgumentException("Expected OID tag"); } final int seqLimit = encoded1.limit(); final int oidLength = parser1.readLength(encoded1); encoded1.limit(encoded1.position() + oidLength); final String oid = OidType.decode(encoded1); encoded1.limit(seqLimit); final DERTag tag = parser1.readTag(encoded1); parser1.readLength(encoded1); assertions.add(new AttributeValueAssertion(oid, new Value(tag, readBuffer(encoded1)))); }); parser.parse(encoded); return assertions.toArray(new AttributeValueAssertion[assertions.size()]); }
@Override public void handle(final DERParser parser, final ByteBuffer encoded) { if (UniversalDERTag.OID.getTagNo() != parser.readTag(encoded).getTagNo()) { throw new IllegalArgumentException("Expected OID tag"); } final int seqLimit = encoded.limit(); final int oidLength = parser.readLength(encoded); encoded.limit(encoded.position() + oidLength); final String oid = OidType.decode(encoded); encoded.limit(seqLimit); final DERTag tag = parser.readTag(encoded); parser.readLength(encoded); assertions.add(new AttributeValueAssertion(oid, new Value(tag, readBuffer(encoded)))); } });
@Override public String toString() { return String.format( "[%s@%d::attributeOid=%s, attributeValue=%s]", getClass().getName(), hashCode(), attributeOid, attributeValue); }
/** * 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 */ public static AttributeValueAssertion[] decode(final ByteBuffer encoded) { final List<AttributeValueAssertion> assertions = new ArrayList<>(); final DERParser parser = new DERParser(); parser.registerHandler( "/SEQ", (parser1, encoded1) -> { if (UniversalDERTag.OID.getTagNo() != parser1.readTag(encoded1).getTagNo()) { throw new IllegalArgumentException("Expected OID tag"); } final int seqLimit = encoded1.limit(); final int oidLength = parser1.readLength(encoded1); encoded1.limit(encoded1.position() + oidLength); final String oid = OidType.decode(encoded1); encoded1.limit(seqLimit); final DERTag tag = parser1.readTag(encoded1); parser1.readLength(encoded1); assertions.add(new AttributeValueAssertion(oid, new Value(tag, readBuffer(encoded1)))); }); parser.parse(encoded); return assertions.toArray(new AttributeValueAssertion[assertions.size()]); }
new DN( new RDN( new AttributeValueAssertion( "2.5.4.3", new AttributeValueAssertion.Value(UniversalDERTag.PRINTSTR, "www.ldaptive.org".getBytes("UTF-8")))), new RDN( new AttributeValueAssertion( "0.9.2342.19200300.100.1.25", new AttributeValueAssertion.Value(UniversalDERTag.IA5STR, "ldaptive".getBytes("UTF-8")))), new RDN( new AttributeValueAssertion( "0.9.2342.19200300.100.1.25", new AttributeValueAssertion.Value(UniversalDERTag.IA5STR, "org".getBytes("UTF-8"))))), new DN( new RDN( new AttributeValueAssertion( "0.9.2342.19200300.100.1.1", new AttributeValueAssertion.Value(UniversalDERTag.PRINTSTR, "7".getBytes("UTF-8"))), new AttributeValueAssertion( "2.5.4.3", new AttributeValueAssertion.Value(UniversalDERTag.PRINTSTR, "www.ldaptive.org".getBytes("UTF-8")))), new RDN( new AttributeValueAssertion( "0.9.2342.19200300.100.1.25", new AttributeValueAssertion.Value(UniversalDERTag.IA5STR, "ldaptive".getBytes("UTF-8")))), new RDN( new AttributeValueAssertion( "0.9.2342.19200300.100.1.25",
@Override public String toString() { return String.format( "[%s@%d::attributeOid=%s, attributeValue=%s]", getClass().getName(), hashCode(), attributeOid, attributeValue); }
/** * Returns the attribute values for the supplied oid. * * @param oid to match * * @return attribute values */ public AttributeValueAssertion.Value[] getAttributeValues(final String oid) { final List<AttributeValueAssertion.Value> values = new ArrayList<>(); for (AttributeValueAssertion type : attributeValueAssertions) { if (type.getOid().equals(oid)) { values.add(type.getValue()); } } return values.toArray(new AttributeValueAssertion.Value[values.size()]); }
@Override public byte[] encode() { return AttributeValueAssertion.this.encode(attributeValue.getBytes()); } });
@Override public String toString() { return String.format( "[%s@%d::attributeOid=%s, attributeValue=%s]", getClass().getName(), hashCode(), attributeOid, attributeValue); }
/** * Converts bytes in the buffer to RDNs 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 RDN and the * limit is set beyond the last byte of the RDN. * * @return decoded bytes as RDNs */ public static RDN[] decode(final ByteBuffer encoded) { final List<RDN> rdns = new ArrayList<>(); final DERParser parser = new DERParser(); parser.registerHandler( "/SEQ/SET", (parser1, encoded1) -> { rdns.add(new RDN(AttributeValueAssertion.decode(encoded1.slice()))); encoded1.position(encoded1.limit()); }); parser.parse(encoded); return rdns.toArray(new RDN[rdns.size()]); }
/** * Returns the attribute values for the supplied oid. * * @param oid to match * * @return attribute values */ public AttributeValueAssertion.Value[] getAttributeValues(final String oid) { final List<AttributeValueAssertion.Value> values = new ArrayList<>(); for (AttributeValueAssertion type : attributeValueAssertions) { if (type.getOid().equals(oid)) { values.add(type.getValue()); } } return values.toArray(new AttributeValueAssertion.Value[values.size()]); }
@Override public byte[] encode() { final ConstructedDEREncoder se = new ConstructedDEREncoder( UniversalDERTag.SEQ, () -> { final OidType type = new OidType(attributeOid); return type.encode(); }, () -> AttributeValueAssertion.this.encode(attributeValue.getBytes())); return se.encode(); }
/** * Converts bytes in the buffer to RDNs 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 RDN and the * limit is set beyond the last byte of the RDN. * * @return decoded bytes as RDNs */ public static RDN[] decode(final ByteBuffer encoded) { final List<RDN> rdns = new ArrayList<>(); final DERParser parser = new DERParser(); parser.registerHandler( "/SEQ/SET", (parser1, encoded1) -> { rdns.add(new RDN(AttributeValueAssertion.decode(encoded1.slice()))); encoded1.position(encoded1.limit()); }); parser.parse(encoded); return rdns.toArray(new RDN[rdns.size()]); }
/** * Returns the attribute values decoded by the supplied transcoder. * * @param <T> type of value * @param oid to match * @param transcoder to decode the binary value * * @return decoded attribute values */ @SuppressWarnings("unchecked") public <T> T[] getAttributeValues(final String oid, final ValueTranscoder<T> transcoder) { final List<T> values = new ArrayList<>(); for (AttributeValueAssertion type : attributeValueAssertions) { if (type.getOid().equals(oid)) { values.add(transcoder.decodeBinaryValue(type.getValue().getBytes())); } } return (T[]) values.toArray(); }
@Override public byte[] encode() { final ConstructedDEREncoder se = new ConstructedDEREncoder( UniversalDERTag.SEQ, () -> { final OidType type = new OidType(attributeOid); return type.encode(); }, () -> AttributeValueAssertion.this.encode(attributeValue.getBytes())); return se.encode(); }
/** * Returns the attribute values decoded by the supplied transcoder. * * @param <T> type of value * @param oid to match * @param transcoder to decode the binary value * * @return decoded attribute values */ @SuppressWarnings("unchecked") public <T> T[] getAttributeValues(final String oid, final ValueTranscoder<T> transcoder) { final List<T> values = new ArrayList<>(); for (AttributeValueAssertion type : attributeValueAssertions) { if (type.getOid().equals(oid)) { values.add(transcoder.decodeBinaryValue(type.getValue().getBytes())); } } return (T[]) values.toArray(); }
/** * Returns the attribute values decoded by the supplied transcoder. * * @param <T> type of value * @param oid to match * @param transcoder to decode the binary value * * @return decoded attribute values */ @SuppressWarnings("unchecked") public <T> T[] getAttributeValues(final String oid, final ValueTranscoder<T> transcoder) { final List<T> values = new ArrayList<>(); for (AttributeValueAssertion type : attributeValueAssertions) { if (type.getOid().equals(oid)) { values.add(transcoder.decodeBinaryValue(type.getValue().getBytes())); } } return (T[]) values.toArray(); }