use of org.apache.directory.api.ldap.model.message.controls.ProxiedAuthz in project directory-ldap-api by apache.
the class ProxiedAuthzControlTest method testEncodeProxiedDnAuthzControl.
/**
* Test encoding of a ProxiedAuthzControl.
*/
@Test
public void testEncodeProxiedDnAuthzControl() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x14);
bb.put(new byte[] { // ProxiedAuthzNotification ::= dn:dc=example,dc=com
'd', 'n', ':', 'd', 'c', '=', 'e', 'x', 'a', 'm', 'p', 'l', 'e', ',', 'd', 'c', '=', 'c', 'o', 'm' });
String expected = Strings.dumpBytes(bb.array());
bb.flip();
ProxiedAuthzDecorator decorator = new ProxiedAuthzDecorator(codec);
ProxiedAuthz proxiedAuthz = (ProxiedAuthz) decorator.getDecorated();
proxiedAuthz.setAuthzId("dn:dc=example,dc=com");
bb = decorator.encode(ByteBuffer.allocate(decorator.computeLength()));
String decoded = Strings.dumpBytes(bb.array());
assertEquals(expected, decoded);
}
use of org.apache.directory.api.ldap.model.message.controls.ProxiedAuthz in project directory-ldap-api by apache.
the class ProxiedAuthzControlTest method testEncodeProxiedUserAuthzControl.
/**
* Test encoding of a ProxiedAuthzControl.
*/
@Test
public void testEncodeProxiedUserAuthzControl() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x0C);
bb.put(new byte[] { // ProxiedAuthzNotification ::= u:elecharny
'u', ':', 'e', 'l', (byte) 0xc3, (byte) 0xa9, 'c', 'h', 'a', 'r', 'n', 'y' });
String expected = Strings.dumpBytes(bb.array());
bb.flip();
ProxiedAuthzDecorator decorator = new ProxiedAuthzDecorator(codec);
ProxiedAuthz proxiedAuthz = (ProxiedAuthz) decorator.getDecorated();
proxiedAuthz.setAuthzId("u:el\u00e9charny");
bb = decorator.encode(ByteBuffer.allocate(decorator.computeLength()));
String decoded = Strings.dumpBytes(bb.array());
assertEquals(expected, decoded);
}
use of org.apache.directory.api.ldap.model.message.controls.ProxiedAuthz in project directory-ldap-api by apache.
the class ProxiedAuthzControlTest method testDecodeProxiedAuthzControlUSuccess.
/**
* Test the decoding of a ProxiedAuthzControl with a normal user
*/
@Test
public void testDecodeProxiedAuthzControlUSuccess() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x0C);
bb.put(new byte[] { // ProxiedAuthzNotification ::= u:elecharny
'u', ':', 'e', 'l', (byte) 0xc3, (byte) 0xa9, 'c', 'h', 'a', 'r', 'n', 'y' });
bb.flip();
ProxiedAuthzDecorator decorator = new ProxiedAuthzDecorator(codec);
ProxiedAuthz proxiedAuthz = (ProxiedAuthz) decorator.decode(bb.array());
assertEquals("u:el\u00e9charny", proxiedAuthz.getAuthzId());
}
use of org.apache.directory.api.ldap.model.message.controls.ProxiedAuthz in project directory-ldap-api by apache.
the class ProxiedAuthzControlTest method testEncodeProxiedAnonymousAuthzControl.
/**
* Test encoding of a ProxiedAuthzControl.
*/
@Test
public void testEncodeProxiedAnonymousAuthzControl() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x00);
bb.put(new byte[] {// ProxiedAuthzNotification ::= anonymous
});
String expected = Strings.dumpBytes(bb.array());
bb.flip();
ProxiedAuthzDecorator decorator = new ProxiedAuthzDecorator(codec);
ProxiedAuthz proxiedAuthz = (ProxiedAuthz) decorator.getDecorated();
proxiedAuthz.setAuthzId("");
bb = decorator.encode(ByteBuffer.allocate(decorator.computeLength()));
String decoded = Strings.dumpBytes(bb.array());
assertEquals(expected, decoded);
}
use of org.apache.directory.api.ldap.model.message.controls.ProxiedAuthz in project directory-ldap-api by apache.
the class ProxiedAuthzControlTest method testDecodeProxiedAuthzControlAnonymousSuccess.
/**
* Test the decoding of a ProxiedAuthzControl with a anonymous user
*/
@Test
public void testDecodeProxiedAuthzControlAnonymousSuccess() throws Exception {
ByteBuffer bb = ByteBuffer.allocate(0x00);
bb.put(new byte[] {// ProxiedAuthzNotification ::= anonymous
});
bb.flip();
ProxiedAuthzDecorator decorator = new ProxiedAuthzDecorator(codec);
ProxiedAuthz proxiedAuthz = (ProxiedAuthz) decorator.decode(bb.array());
assertEquals("", proxiedAuthz.getAuthzId());
}
Aggregations