Example usage for javax.naming.ldap Control getEncodedValue

List of usage examples for javax.naming.ldap Control getEncodedValue

Introduction

In this page you can find the example usage for javax.naming.ldap Control getEncodedValue.

Prototype

public byte[] getEncodedValue();

Source Link

Document

Retrieves the ASN.1 BER encoded value of the LDAP control.

Usage

From source file:org.atricore.idbus.idojos.ldapidentitystore.LDAPBindIdentityStore.java

protected PasswordPolicyResponseControl decodePasswordPolicyControl(Control[] ldapControls)
        throws DecoderException {

    if (ldapControls == null)
        return null;

    for (Control ldapControl : ldapControls) {

        if (ldapControl.getID().equals(PasswordPolicyResponseControl.CONTROL_OID)) {

            PasswordPolicyControlContainer container = new PasswordPolicyControlContainer();
            container.setPasswordPolicyResponseControl(new PasswordPolicyResponseControl());
            ControlDecoder decoder = container.getPasswordPolicyControl().getDecoder();
            decoder.decode(ldapControl.getEncodedValue(), container.getPasswordPolicyControl());

            PasswordPolicyResponseControl ctrl = container.getPasswordPolicyControl();

            if (logger.isDebugEnabled())
                logger.debug("Password Policy Control : " + ctrl.toString());

            return ctrl;
        }//from  w ww. ja v  a 2 s.  c om
    }

    logger.warn("No LDAP Control found for " + PasswordPolicyResponseControl.CONTROL_OID);

    return null;
}

From source file:org.springframework.ldap.core.RequestControlMatcher.java

private boolean controlMatches(Control expected, Control actual) {

    // Compare SortControl
    return StringUtils.equals(expected.getID(), actual.getID()) && expected.isCritical() == actual.isCritical()
            && ArrayUtils.isEquals(expected.getEncodedValue(), actual.getEncodedValue());
}