Search in sources :

Example 1 with BasicControlDecorator

use of org.apache.directory.api.ldap.codec.BasicControlDecorator 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;
}
Also used : BasicControlDecorator(org.apache.directory.api.ldap.codec.BasicControlDecorator) ControlFactory(org.apache.directory.api.ldap.codec.api.ControlFactory) OpaqueControl(org.apache.directory.api.ldap.model.message.controls.OpaqueControl)

Aggregations

BasicControlDecorator (org.apache.directory.api.ldap.codec.BasicControlDecorator)1 ControlFactory (org.apache.directory.api.ldap.codec.api.ControlFactory)1 OpaqueControl (org.apache.directory.api.ldap.model.message.controls.OpaqueControl)1