Search in sources :

Example 26 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class ListNotificationSubscriptionsExtendedRequest method encodeValue.

/**
 * Encodes the provided information into an ASN.1 octet string suitable for
 * use as the value of this extended request.
 *
 * @param  managerID          The notification manager ID.  It must not be
 *                            {@code null}.
 * @param  destinationIDs     The set of notification destination IDs for
 *                            which to retrieve the subscription information.
 *                            It may be {@code null} or empty if subscription
 *                            information for all destinations should be
 *                            returned.
 *
 * @return  The ASN.1 octet string containing the encoded value.
 */
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final String managerID, @Nullable final Collection<String> destinationIDs) {
    Validator.ensureNotNull(managerID);
    final ArrayList<ASN1Element> elements = new ArrayList<>(2);
    elements.add(new ASN1OctetString(managerID));
    if ((destinationIDs != null) && (!destinationIDs.isEmpty())) {
        final LinkedHashSet<ASN1Element> destIDElements = new LinkedHashSet<>(StaticUtils.computeMapCapacity(destinationIDs.size()));
        for (final String destinationID : destinationIDs) {
            destIDElements.add(new ASN1OctetString(destinationID));
        }
        elements.add(new ASN1Set(destIDElements));
    }
    return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) LinkedHashSet(java.util.LinkedHashSet) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Set(com.unboundid.asn1.ASN1Set) ASN1Element(com.unboundid.asn1.ASN1Element) ArrayList(java.util.ArrayList) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) NotNull(com.unboundid.util.NotNull)

Example 27 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class ReplaceCertificateExtendedResult method encodeValue.

/**
 * Encodes a value for this extended result, if appropriate.
 *
 * @param  oid         The OID to use for the extended result.  It may be
 *                     {@code null} if no OID should be used.
 * @param  toolOutput  The output obtained from running the
 *                     {@code replace-certificate} tool.  It may be
 *                     {@code null} if request processing failed before
 *                     running the tool.
 *
 * @return  The encoded value for this extended result, or {@code null} if
 *          no value should be included.
 */
@Nullable()
public static ASN1OctetString encodeValue(@Nullable final String oid, @Nullable final String toolOutput) {
    if ((oid == null) && (toolOutput == null)) {
        return null;
    }
    final List<ASN1Element> valueElements = new ArrayList<>(1);
    if (toolOutput != null) {
        valueElements.add(new ASN1OctetString(TYPE_TOOL_OUTPUT, toolOutput));
    }
    final ASN1Sequence valueSequence = new ASN1Sequence(valueElements);
    return new ASN1OctetString(valueSequence.encode());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Element(com.unboundid.asn1.ASN1Element) ArrayList(java.util.ArrayList) Nullable(com.unboundid.util.Nullable)

Example 28 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class ReplaceInterServerCertificateExtendedRequest method encodeValue.

/**
 * Encodes the provided information into an ASN.1 octet string suitable for
 * use as the encoded value for a replace inter-server certificate extended
 * request.
 *
 * @param  keyStoreContent
 *              An object with information about how the server should obtain
 *              the new inter-server certificate data.  It must not be
 *              {@code null}.
 * @param  skipCertificateValidation
 *              Indicates whether to skip validation for the new certificate
 *              chain.
 *
 * @return  An ASN.1 octet string containing the encoded request value.
 */
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final ReplaceCertificateKeyStoreContent keyStoreContent, final boolean skipCertificateValidation) {
    Validator.ensureNotNullWithMessage(keyStoreContent, "ReplaceInterServerCertificateExtendedRequest.keyStoreContent must " + "not be null.");
    final List<ASN1Element> elements = new ArrayList<>();
    elements.add(keyStoreContent.encode());
    if (skipCertificateValidation) {
        elements.add(new ASN1Boolean(TYPE_SKIP_CERT_VALIDATION, true));
    }
    return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Element(com.unboundid.asn1.ASN1Element) ArrayList(java.util.ArrayList) ASN1Boolean(com.unboundid.asn1.ASN1Boolean) NotNull(com.unboundid.util.NotNull)

Example 29 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class SetNotificationDestinationExtendedRequest method encodeValue.

/**
 * Encodes the provided information into an ASN.1 octet string suitable for
 * use as the value of this extended request.
 *
 * @param  managerID           The notification manager ID.  It must not be
 *                             {@code null}.
 * @param  destinationID       The notification destination ID.  It must not
 *                             be {@code null}.
 * @param  destinationDetails  The implementation-specific details for the
 *                             notification destination.  At least one detail
 *                             value must be provided.
 * @param  changeType          The change type for the destination details.
 *
 * @return  The ASN.1 octet string containing the encoded value.
 */
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final String managerID, @NotNull final String destinationID, @NotNull final Collection<ASN1OctetString> destinationDetails, @Nullable final SetNotificationDestinationChangeType changeType) {
    Validator.ensureNotNull(managerID);
    Validator.ensureNotNull(destinationID);
    Validator.ensureNotNull(destinationDetails);
    Validator.ensureFalse(destinationDetails.isEmpty());
    final ArrayList<ASN1Element> elements = new ArrayList<>(4);
    elements.add(new ASN1OctetString(managerID));
    elements.add(new ASN1OctetString(destinationID));
    elements.add(new ASN1Sequence(new ArrayList<ASN1Element>(destinationDetails)));
    if ((changeType != null) && (changeType != SetNotificationDestinationChangeType.REPLACE)) {
        elements.add(new ASN1Enumerated(BER_TYPE_CHANGE_TYPE, changeType.intValue()));
    }
    return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ASN1Element(com.unboundid.asn1.ASN1Element) ArrayList(java.util.ArrayList) NotNull(com.unboundid.util.NotNull)

Example 30 with ASN1OctetString

use of com.mindbright.asn1.ASN1OctetString in project ldapsdk by pingidentity.

the class SetSubtreeAccessibilityExtendedRequest method encodeValue.

/**
 * Encodes the provided information for use as the extended request value.
 *
 * @param  subtreeBaseDNs      The set of base DNs for the target subtrees.
 *                             It must not be {@code null} or empty.
 * @param  accessibilityState  The accessibility state to use for the target
 *                             subtrees.
 * @param  bypassUserDN        The DN of a user that will be allowed to bypass
 *                             restrictions on the target subtrees.
 *
 * @return  An ASN.1 octet string containing the encoded value.
 */
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final Collection<String> subtreeBaseDNs, @NotNull final SubtreeAccessibilityState accessibilityState, @Nullable final String bypassUserDN) {
    final Iterator<String> dnIterator = subtreeBaseDNs.iterator();
    final String subtreeBaseDN = dnIterator.next();
    Validator.ensureNotNull(subtreeBaseDN);
    final ArrayList<ASN1Element> elements = new ArrayList<>(4);
    elements.add(new ASN1OctetString(subtreeBaseDN));
    elements.add(new ASN1Enumerated(accessibilityState.intValue()));
    if (bypassUserDN != null) {
        elements.add(new ASN1OctetString(TYPE_BYPASS_USER_DN, bypassUserDN));
    }
    if (dnIterator.hasNext()) {
        final ArrayList<ASN1Element> additionalDNElements = new ArrayList<>(subtreeBaseDNs.size() - 1);
        while (dnIterator.hasNext()) {
            final String additionalDN = dnIterator.next();
            Validator.ensureNotNull(additionalDN);
            additionalDNElements.add(new ASN1OctetString(additionalDN));
        }
        elements.add(new ASN1Sequence(TYPE_ADDITIONAL_SUBTREE_BASE_DNS, additionalDNElements));
    }
    return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
Also used : ASN1OctetString(com.unboundid.asn1.ASN1OctetString) ASN1Sequence(com.unboundid.asn1.ASN1Sequence) ASN1Enumerated(com.unboundid.asn1.ASN1Enumerated) ASN1Element(com.unboundid.asn1.ASN1Element) ArrayList(java.util.ArrayList) ASN1OctetString(com.unboundid.asn1.ASN1OctetString) NotNull(com.unboundid.util.NotNull)

Aggregations

ASN1OctetString (com.unboundid.asn1.ASN1OctetString)1173 Test (org.testng.annotations.Test)852 ASN1Sequence (com.unboundid.asn1.ASN1Sequence)382 Control (com.unboundid.ldap.sdk.Control)310 ASN1Element (com.unboundid.asn1.ASN1Element)237 ArrayList (java.util.ArrayList)204 NotNull (com.unboundid.util.NotNull)191 LDAPException (com.unboundid.ldap.sdk.LDAPException)142 ASN1OctetString (org.bouncycastle.asn1.ASN1OctetString)133 ExtendedResult (com.unboundid.ldap.sdk.ExtendedResult)99 ASN1Enumerated (com.unboundid.asn1.ASN1Enumerated)92 IOException (java.io.IOException)88 ASN1Integer (com.unboundid.asn1.ASN1Integer)80 ExtendedRequest (com.unboundid.ldap.sdk.ExtendedRequest)69 DN (com.unboundid.ldap.sdk.DN)65 LDAPConnection (com.unboundid.ldap.sdk.LDAPConnection)64 ByteArrayInputStream (java.io.ByteArrayInputStream)56 AuthorizationIdentityRequestControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityRequestControl)53 ASN1Boolean (com.unboundid.asn1.ASN1Boolean)52 AuthorizationIdentityResponseControl (com.unboundid.ldap.sdk.controls.AuthorizationIdentityResponseControl)49