use of org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator in project directory-ldap-api by apache.
the class ApiLdapExtrasCodecOsgiTest method useBundleClasses.
@Override
protected void useBundleClasses() throws Exception {
CodecControl<? extends Control> control = ldapApiService.newControl(PasswordPolicy.OID);
assertNotNull(control);
assertTrue(control instanceof PasswordPolicyDecorator);
ExtendedRequest extendedRequest = ldapApiService.newExtendedRequest(StartTlsRequest.EXTENSION_OID, null);
assertNotNull(extendedRequest);
assertTrue(extendedRequest instanceof StartTlsRequestDecorator);
}
use of org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator in project directory-ldap-api by apache.
the class PasswordPolicyTest method testDecodeRespWithTimeBeforeExpiryWarningOnly.
@Test
public void testDecodeRespWithTimeBeforeExpiryWarningOnly() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(7);
bb.put(new byte[] { 0x30, 0x05, (byte) 0xA0, 0x03, // timeBeforeExpiration
(byte) 0x80, // timeBeforeExpiration
0x01, // timeBeforeExpiration
0x01 });
bb.flip();
PasswordPolicyDecorator control = new PasswordPolicyDecorator(codec, true);
PasswordPolicy passwordPolicy = (PasswordPolicy) control.decode(bb.array());
assertTrue(passwordPolicy.hasResponse());
assertEquals(1, passwordPolicy.getResponse().getTimeBeforeExpiration());
ByteBuffer encoded = ((PasswordPolicyDecorator) passwordPolicy).encode(ByteBuffer.allocate(((PasswordPolicyDecorator) passwordPolicy).computeLength()));
assertEquals(Strings.dumpBytes(bb.array()), Strings.dumpBytes(encoded.array()));
}
use of org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator in project directory-ldap-api by apache.
the class PasswordPolicyTest method testDecodeRespWithGraceAuthWarningAndError.
@Test
public void testDecodeRespWithGraceAuthWarningAndError() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0xA);
bb.put(new byte[] { 0x30, 0x08, // warning
(byte) 0xA0, // warning
0x03, (byte) 0x81, 0x01, // graceAuthNsRemaining
0x01, (byte) 0x81, 0x01, // error
0x01 });
bb.flip();
PasswordPolicyDecorator control = new PasswordPolicyDecorator(codec, true);
PasswordPolicy passwordPolicy = (PasswordPolicy) control.decode(bb.array());
assertTrue(passwordPolicy.hasResponse());
assertEquals(1, passwordPolicy.getResponse().getGraceAuthNRemaining());
assertEquals(1, passwordPolicy.getResponse().getPasswordPolicyError().getValue());
ByteBuffer encoded = ((PasswordPolicyDecorator) passwordPolicy).encode(ByteBuffer.allocate(((PasswordPolicyDecorator) passwordPolicy).computeLength()));
assertEquals(Strings.dumpBytes(bb.array()), Strings.dumpBytes(encoded.array()));
}
use of org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator in project directory-ldap-api by apache.
the class PasswordPolicyTest method testDecodeRespWithErrorOnly.
@Test
public void testDecodeRespWithErrorOnly() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(5);
bb.put(new byte[] { 0x30, 0x03, // error
(byte) 0x81, // error
0x01, // error
0x01 });
bb.flip();
PasswordPolicyDecorator control = new PasswordPolicyDecorator(codec, true);
PasswordPolicy passwordPolicy = (PasswordPolicy) control.decode(bb.array());
assertTrue(passwordPolicy.hasResponse());
assertEquals(1, passwordPolicy.getResponse().getPasswordPolicyError().getValue());
ByteBuffer encoded = ((PasswordPolicyDecorator) passwordPolicy).encode(ByteBuffer.allocate(((PasswordPolicyDecorator) passwordPolicy).computeLength()));
assertEquals(Strings.dumpBytes(bb.array()), Strings.dumpBytes(encoded.array()));
}
use of org.apache.directory.api.ldap.extras.controls.ppolicy_impl.PasswordPolicyDecorator in project directory-ldap-api by apache.
the class PasswordPolicyTest method testDecodeRespWithExpiryWarningAndError.
@Test
public void testDecodeRespWithExpiryWarningAndError() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0xA);
bb.put(new byte[] { 0x30, 0x08, // timeBeforeExpiration
(byte) 0xA0, // timeBeforeExpiration
0x03, (byte) 0x80, 0x01, 0x01, (byte) 0x81, 0x01, // ppolicyError
0x01 });
bb.flip();
PasswordPolicyDecorator control = new PasswordPolicyDecorator(codec, true);
PasswordPolicy passwordPolicy = (PasswordPolicy) control.decode(bb.array());
assertTrue(passwordPolicy.hasResponse());
assertEquals(1, passwordPolicy.getResponse().getTimeBeforeExpiration());
assertEquals(1, passwordPolicy.getResponse().getPasswordPolicyError().getValue());
ByteBuffer encoded = ((PasswordPolicyDecorator) passwordPolicy).encode(ByteBuffer.allocate(((PasswordPolicyDecorator) passwordPolicy).computeLength()));
assertEquals(Strings.dumpBytes(bb.array()), Strings.dumpBytes(encoded.array()));
}
Aggregations