use of com.unboundid.asn1.ASN1Null in project ldapsdk by pingidentity.
the class DebugTestCase method testDebugASN1Write2DisabledAll.
/**
* Tests the second {@code debugASN1Write} method with the debugger disabled
* and a debug type set of all types.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDebugASN1Write2DisabledAll() throws Exception {
Debug.setEnabled(false);
testLogHandler.resetMessageCount();
assertFalse(Debug.debugEnabled(DebugType.ASN1));
Debug.debugASN1Write(Level.FINEST, new ASN1Null());
assertTrue(testLogHandler.getMessageCount() >= 0);
}
use of com.unboundid.asn1.ASN1Null in project ldapsdk by pingidentity.
the class DebugTestCase method testDebugASN1Write1EnabledIncludeASN1.
/**
* Tests the first {@code debugASN1Write} method with the debugger enabled
* and a debug type set that includes the ASN.1 type among others.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDebugASN1Write1EnabledIncludeASN1() throws Exception {
Debug.setEnabled(true, EnumSet.of(DebugType.ASN1, DebugType.OTHER));
testLogHandler.resetMessageCount();
assertTrue(Debug.debugEnabled(DebugType.ASN1));
Debug.debugASN1Write(new ASN1Null());
assertTrue(testLogHandler.getMessageCount() >= 1);
}
use of com.unboundid.asn1.ASN1Null in project ldapsdk by pingidentity.
the class DebugTestCase method testDebugASN1Read1EnabledIncludeASN1.
/**
* Tests the first {@code debugASN1Read} method with the debugger enabled
* and a debug type set that includes the ASN.1 type among others.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDebugASN1Read1EnabledIncludeASN1() throws Exception {
Debug.setEnabled(true, EnumSet.of(DebugType.ASN1, DebugType.OTHER));
testLogHandler.resetMessageCount();
assertTrue(Debug.debugEnabled(DebugType.ASN1));
Debug.debugASN1Read(new ASN1Null());
assertTrue(testLogHandler.getMessageCount() >= 1);
}
use of com.unboundid.asn1.ASN1Null in project ldapsdk by pingidentity.
the class DebugTestCase method testDebugASN1Read1EnabledWithoutASN1.
/**
* Tests the first {@code debugASN1Read} method with the debugger enabled
* and a debug type set that does not include the ASN.1 type.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDebugASN1Read1EnabledWithoutASN1() throws Exception {
Debug.setEnabled(true, EnumSet.of(DebugType.OTHER));
testLogHandler.resetMessageCount();
assertFalse(Debug.debugEnabled(DebugType.ASN1));
Debug.debugASN1Read(new ASN1Null());
assertTrue(testLogHandler.getMessageCount() >= 0);
}
use of com.unboundid.asn1.ASN1Null in project ldapsdk by pingidentity.
the class GeneratePasswordExtendedRequest method encodeValue.
/**
* Uses the provided information to generate an ASN.1 octet string that may be
* used as the value of a generate password extended request.
*
* @param passwordPolicySelectionType
* The password policy selection type to use. It must not be
* {@code null}.
* @param passwordPolicyDN
* The password policy DN to use in conjunction with the
* {@link GeneratePasswordPolicySelectionType#PASSWORD_POLICY_DN}
* password policy selection type. It must be non-{@code null}
* when used in conjunction with that policy selection type, and
* it must be {@code null} for all other selection types.
* @param targetEntryDN
* The target entry DN to use in conjunction with the
* {@link GeneratePasswordPolicySelectionType#TARGET_ENTRY_DN}
* password policy selection type. It must be non-{@code null}
* when used in conjunction with that policy selection type, and
* it must be {@code null} for all other selection types.
* @param numberOfPasswords
* The number of passwords to generate. The value must be
* greater than or equal to one.
* @param numberOfValidationAttempts
* The number of attempts that should be made to generate each
* password in an attempt to obtain a password that satisfies the
* associated set of password validators. The value must be
* greater than or equal to zero.
*
* @return An ASN.1 octet string that may be used as the value of a generate
* password extended request with the provided information, or
* {@code null} if the request uses all the default settings and no
* value is needed.
*/
@Nullable()
private static ASN1OctetString encodeValue(@NotNull final GeneratePasswordPolicySelectionType passwordPolicySelectionType, @Nullable final String passwordPolicyDN, @Nullable final String targetEntryDN, final int numberOfPasswords, final int numberOfValidationAttempts) {
Validator.ensureNotNullWithMessage(passwordPolicySelectionType, "GeneratePasswordExtendedRequest.passwordPolicySelectionType must " + "not be null.");
final List<ASN1Element> elements = new ArrayList<>(3);
switch(passwordPolicySelectionType) {
case DEFAULT_POLICY:
Validator.ensureTrue((passwordPolicyDN == null), "GeneratePasswordExtendedRequest.passwordPolicyDN must be null " + "when using a password policy selection type of " + passwordPolicySelectionType + '.');
Validator.ensureTrue((targetEntryDN == null), "GeneratePasswordExtendedRequest.targetEntryDN must be null " + "when using a password policy selection type of " + passwordPolicySelectionType + '.');
if ((numberOfPasswords == DEFAULT_NUMBER_OF_PASSWORDS) && (numberOfValidationAttempts == DEFAULT_VALIDATION_ATTEMPTS)) {
return null;
}
elements.add(new ASN1Null(passwordPolicySelectionType.getBERType()));
break;
case PASSWORD_POLICY_DN:
Validator.ensureNotNullWithMessage(passwordPolicyDN, "GeneratePasswordExtendedRequest.passwordPolicyDN must not be " + "null when using a password policy selection type of " + passwordPolicySelectionType + '.');
Validator.ensureTrue((targetEntryDN == null), "GeneratePasswordExtendedRequest.targetEntryDN must be null " + "when using a password policy selection type of " + passwordPolicySelectionType + '.');
elements.add(new ASN1OctetString(passwordPolicySelectionType.getBERType(), passwordPolicyDN));
break;
case TARGET_ENTRY_DN:
Validator.ensureTrue((passwordPolicyDN == null), "GeneratePasswordExtendedRequest.passwordPolicyDN must be null " + "when using a password policy selection type of " + passwordPolicySelectionType + '.');
Validator.ensureNotNullWithMessage(targetEntryDN, "GeneratePasswordExtendedRequest.targetEntryDN must not be null " + "when using a password policy selection type of " + passwordPolicySelectionType + '.');
elements.add(new ASN1OctetString(passwordPolicySelectionType.getBERType(), targetEntryDN));
break;
}
if (numberOfPasswords != DEFAULT_NUMBER_OF_PASSWORDS) {
Validator.ensureTrue((numberOfPasswords >= 1), "GeneratePasswordExtendedRequest.numberOfPasswords must be " + "greater than or equal to one.");
elements.add(new ASN1Integer(TYPE_NUMBER_OF_PASSWORDS, numberOfPasswords));
}
if (numberOfValidationAttempts != DEFAULT_VALIDATION_ATTEMPTS) {
Validator.ensureTrue((numberOfValidationAttempts >= 0), "GeneratePasswordExtendedRequest.validationAttempts must be " + "greater than or equal to zero.");
elements.add(new ASN1Integer(TYPE_VALIDATION_ATTEMPTS, numberOfValidationAttempts));
}
return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
Aggregations