use of com.github.zhenwei.core.asn1.ASN1Enumerated in project ldapsdk by pingidentity.
the class UniquenessRequestControlTestCase method testDecodeControlValueSequenceUnrecognizedElementType.
/**
* Tests the behavior when trying to decode a control whose value sequence has
* an element with an unrecognized BER type.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeControlValueSequenceUnrecognizedElementType() throws Exception {
final ASN1Sequence valueSequence = new ASN1Sequence(new ASN1OctetString((byte) 0x80, "uniqueness-id"), new ASN1Set((byte) 0xA1, new ASN1OctetString("uid")), new ASN1Enumerated((byte) 0x8F, 12345));
new UniquenessRequestControl(new Control("1.3.6.1.4.1.30221.2.5.52", true, new ASN1OctetString(valueSequence.encode())));
}
use of com.github.zhenwei.core.asn1.ASN1Enumerated in project ldapsdk by pingidentity.
the class ContentSyncStateControl method encodeValue.
/**
* Encodes the provided information into a form suitable for use as the value
* of this control.
*
* @param state The sync state for the associated entry or reference.
* It must not be {@code null}.
* @param entryUUID The entryUUID for the associated entry or reference. It
* must not be {@code null}.
* @param cookie A cookie with an updated synchronization state. It may
* be {@code null} if no updated state is available.
*
* @return An ASN.1 octet string containing the encoded control value.
*/
@NotNull()
private static ASN1OctetString encodeValue(@NotNull final ContentSyncState state, @NotNull final UUID entryUUID, @Nullable final ASN1OctetString cookie) {
Validator.ensureNotNull(state, entryUUID);
final ArrayList<ASN1Element> elements = new ArrayList<>(3);
elements.add(new ASN1Enumerated(state.intValue()));
elements.add(new ASN1OctetString(StaticUtils.encodeUUID(entryUUID)));
if (cookie != null) {
elements.add(cookie);
}
return new ASN1OctetString(new ASN1Sequence(elements).encode());
}
use of com.github.zhenwei.core.asn1.ASN1Enumerated in project ldapsdk by pingidentity.
the class PasswordPolicyResponseControlTestCase method testDecodeControlOnlyError.
/**
* Tests the {@code decodeControl} method with a valid set of information
* with only an error element.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test()
public void testDecodeControlOnlyError() throws Exception {
ASN1Element[] valueElements = { new ASN1Enumerated((byte) 0x81, 1) };
ASN1OctetString value = new ASN1OctetString(new ASN1Sequence(valueElements).encode());
PasswordPolicyResponseControl c = new PasswordPolicyResponseControl().decodeControl("1.3.6.1.4.1.42.2.27.8.5.1", false, value);
assertNull(c.getWarningType());
assertEquals(c.getWarningValue(), -1);
assertNotNull(c.getErrorType());
assertEquals(c.getErrorType(), PasswordPolicyErrorType.ACCOUNT_LOCKED);
assertNotNull(c.getControlName());
assertNotNull(c.toString());
}
use of com.github.zhenwei.core.asn1.ASN1Enumerated in project ldapsdk by pingidentity.
the class PasswordPolicyResponseControlTestCase method testDecodeControlValueSequenceMultipleValueElements.
/**
* Tests the {@code decodeControl} method with a value sequence multiple value
* elements.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeControlValueSequenceMultipleValueElements() throws Exception {
ASN1Element[] valueElements = { new ASN1Enumerated((byte) 0x81, 0), new ASN1Enumerated((byte) 0x81, 1) };
ASN1OctetString value = new ASN1OctetString(new ASN1Sequence(valueElements).encode());
new PasswordPolicyResponseControl().decodeControl("1.3.6.1.4.1.42.2.27.8.5.1", false, value);
}
use of com.github.zhenwei.core.asn1.ASN1Enumerated in project ldapsdk by pingidentity.
the class PasswordPolicyResponseControlTestCase method testDecodeControlValueSequenceInvalidErrorType.
/**
* Tests the {@code decodeControl} method with a value sequence with an
* invalid error type.
*
* @throws Exception If an unexpected problem occurs.
*/
@Test(expectedExceptions = { LDAPException.class })
public void testDecodeControlValueSequenceInvalidErrorType() throws Exception {
ASN1Element[] valueElements = { new ASN1Enumerated((byte) 0x81, 999) };
ASN1OctetString value = new ASN1OctetString(new ASN1Sequence(valueElements).encode());
new PasswordPolicyResponseControl().decodeControl("1.3.6.1.4.1.42.2.27.8.5.1", false, value);
}
Aggregations