use of org.apache.directory.api.ldap.model.message.controls.OpaqueControl in project directory-ldap-api by apache.
the class BindRequestPerfTest method testEncodeBindRequestPerf.
/**
* Test the decoding of a BindRequest with Simple authentication and no
* controls
*/
@Test
@Ignore
public void testEncodeBindRequestPerf() throws Exception {
Dn dn = new Dn("uid=akarasulu,dc=example,dc=com");
int nbLoops = 1000000;
long t0 = System.currentTimeMillis();
for (int i = 0; i < nbLoops; i++) {
// Check the decoded BindRequest
BindRequest bindRequest = new BindRequestImpl();
bindRequest.setMessageId(1);
bindRequest.setSimple(true);
bindRequest.setDn(dn);
bindRequest.setCredentials(Strings.getBytesUtf8("password"));
Control control = new OpaqueControl("2.16.840.1.113730.3.4.2");
bindRequest.addControl(control);
// Check the encoding
try {
encoder.encodeMessage(bindRequest);
} catch (EncoderException ee) {
ee.printStackTrace();
fail(ee.getMessage());
}
}
long t1 = System.currentTimeMillis();
System.out.println("BindRequest testEncodeBindRequestPerf, " + nbLoops + " loops, Delta = " + (t1 - t0));
}
use of org.apache.directory.api.ldap.model.message.controls.OpaqueControl in project directory-ldap-api by apache.
the class DefaultLdapCodecService method fromJndiControl.
/**
* {@inheritDoc}
*/
@Override
public Control fromJndiControl(javax.naming.ldap.Control control) throws DecoderException {
@SuppressWarnings("rawtypes") ControlFactory factory = controlFactories.get(control.getID());
if (factory == null) {
OpaqueControl ourControl = new OpaqueControl(control.getID());
ourControl.setCritical(control.isCritical());
BasicControlDecorator decorator = new BasicControlDecorator(this, ourControl);
decorator.setValue(control.getEncodedValue());
return decorator;
}
@SuppressWarnings("unchecked") CodecControl<? extends Control> ourControl = factory.newCodecControl();
ourControl.setCritical(control.isCritical());
ourControl.setValue(control.getEncodedValue());
ourControl.decode(control.getEncodedValue());
return ourControl;
}
Aggregations