use of com.github.zhenwei.core.asn1.ASN1Sequence 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());
}
use of com.github.zhenwei.core.asn1.ASN1Sequence 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());
}
use of com.github.zhenwei.core.asn1.ASN1Sequence 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());
}
use of com.github.zhenwei.core.asn1.ASN1Sequence 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());
}
use of com.github.zhenwei.core.asn1.ASN1Sequence 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());
}
Aggregations