Search in sources :

Example 1 with ASN1BufferSet

use of com.unboundid.asn1.ASN1BufferSet in project ldapsdk by pingidentity.

the class Attribute method writeTo.

/**
 * Writes an ASN.1-encoded representation of this attribute to the provided
 * ASN.1 buffer.
 *
 * @param  buffer  The ASN.1 buffer to which the encoded representation should
 *                 be written.
 */
public void writeTo(@NotNull final ASN1Buffer buffer) {
    final ASN1BufferSequence attrSequence = buffer.beginSequence();
    buffer.addOctetString(name);
    final ASN1BufferSet valueSet = buffer.beginSet();
    for (final ASN1OctetString value : values) {
        buffer.addElement(value);
    }
    valueSet.end();
    attrSequence.end();
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ASN1BufferSet(com.unboundid.asn1.ASN1BufferSet)

Example 2 with ASN1BufferSet

use of com.unboundid.asn1.ASN1BufferSet in project ldapsdk by pingidentity.

the class Filter method writeTo.

/**
 * Writes an ASN.1-encoded representation of this filter to the provided ASN.1
 * buffer.
 *
 * @param  buffer  The ASN.1 buffer to which the encoded representation should
 *                 be written.
 */
public void writeTo(@NotNull final ASN1Buffer buffer) {
    switch(filterType) {
        case FILTER_TYPE_AND:
        case FILTER_TYPE_OR:
            final ASN1BufferSet compSet = buffer.beginSet(filterType);
            for (final Filter f : filterComps) {
                f.writeTo(buffer);
            }
            compSet.end();
            break;
        case FILTER_TYPE_NOT:
            buffer.addElement(new ASN1Element(filterType, notComp.encode().encode()));
            break;
        case FILTER_TYPE_EQUALITY:
        case FILTER_TYPE_GREATER_OR_EQUAL:
        case FILTER_TYPE_LESS_OR_EQUAL:
        case FILTER_TYPE_APPROXIMATE_MATCH:
            final ASN1BufferSequence avaSequence = buffer.beginSequence(filterType);
            buffer.addOctetString(attrName);
            buffer.addElement(assertionValue);
            avaSequence.end();
            break;
        case FILTER_TYPE_SUBSTRING:
            final ASN1BufferSequence subFilterSequence = buffer.beginSequence(filterType);
            buffer.addOctetString(attrName);
            final ASN1BufferSequence valueSequence = buffer.beginSequence();
            if (subInitial != null) {
                buffer.addOctetString(SUBSTRING_TYPE_SUBINITIAL, subInitial.getValue());
            }
            for (final ASN1OctetString s : subAny) {
                buffer.addOctetString(SUBSTRING_TYPE_SUBANY, s.getValue());
            }
            if (subFinal != null) {
                buffer.addOctetString(SUBSTRING_TYPE_SUBFINAL, subFinal.getValue());
            }
            valueSequence.end();
            subFilterSequence.end();
            break;
        case FILTER_TYPE_PRESENCE:
            buffer.addOctetString(filterType, attrName);
            break;
        case FILTER_TYPE_EXTENSIBLE_MATCH:
            final ASN1BufferSequence mrSequence = buffer.beginSequence(filterType);
            if (matchingRuleID != null) {
                buffer.addOctetString(EXTENSIBLE_TYPE_MATCHING_RULE_ID, matchingRuleID);
            }
            if (attrName != null) {
                buffer.addOctetString(EXTENSIBLE_TYPE_ATTRIBUTE_NAME, attrName);
            }
            buffer.addOctetString(EXTENSIBLE_TYPE_MATCH_VALUE, assertionValue.getValue());
            if (dnAttributes) {
                buffer.addBoolean(EXTENSIBLE_TYPE_DN_ATTRIBUTES, true);
            }
            mrSequence.end();
            break;
    }
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) JSONObjectFilter(com.unboundid.ldap.sdk.unboundidds.jsonfilter.JSONObjectFilter) ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ASN1Element(com.unboundid.asn1.ASN1Element) ASN1BufferSet(com.unboundid.asn1.ASN1BufferSet)

Example 3 with ASN1BufferSet

use of com.unboundid.asn1.ASN1BufferSet in project ldapsdk by pingidentity.

the class Modification method writeTo.

/**
 * Writes an ASN.1-encoded representation of this modification to the provided
 * ASN.1 buffer.
 *
 * @param  buffer  The ASN.1 buffer to which the encoded representation should
 *                 be written.
 */
public void writeTo(@NotNull final ASN1Buffer buffer) {
    final ASN1BufferSequence modSequence = buffer.beginSequence();
    buffer.addEnumerated(modificationType.intValue());
    final ASN1BufferSequence attrSequence = buffer.beginSequence();
    buffer.addOctetString(attributeName);
    final ASN1BufferSet valueSet = buffer.beginSet();
    for (final ASN1OctetString v : values) {
        buffer.addElement(v);
    }
    valueSet.end();
    attrSequence.end();
    modSequence.end();
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1BufferSequence(com.unboundid.asn1.ASN1BufferSequence) ASN1BufferSet(com.unboundid.asn1.ASN1BufferSet)

Aggregations

ASN1BufferSequence (com.unboundid.asn1.ASN1BufferSequence)3 ASN1BufferSet (com.unboundid.asn1.ASN1BufferSet)3 ASN1OctetString (com.unboundid.asn1.ASN1OctetString)3 ASN1Element (com.unboundid.asn1.ASN1Element)1 JSONObjectFilter (com.unboundid.ldap.sdk.unboundidds.jsonfilter.JSONObjectFilter)1