Class PasswordPolicyResponseControl

java.lang.Object
org.forgerock.opendj.ldap.controls.PasswordPolicyResponseControl
All Implemented Interfaces:
Control

public final class PasswordPolicyResponseControl extends Object implements Control
The password policy response control as defined in draft-behera-ldap-password-policy.
 
 Connection connection = ...;
 String DN = ...;
 char[] password = ...;

 try {
     BindRequest request = Requests.newSimpleBindRequest(DN, password)
             .addControl(PasswordPolicyRequestControl.newControl(true));

     BindResult result = connection.bind(request);

     PasswordPolicyResponseControl control =
             result.getControl(PasswordPolicyResponseControl.DECODER,
                     new DecodeOptions());
     if (!(control == null) && !(control.getWarningType() == null)) {
         // Password policy warning, use control.getWarningType(),
         // and control.getWarningValue().
     }
 } catch (LdapException e) {
     Result result = e.getResult();
     try {
         PasswordPolicyResponseControl control =
                 result.getControl(PasswordPolicyResponseControl.DECODER,
                         new DecodeOptions());
         if (!(control == null)) {
             // Password policy error, use control.getErrorType().
         }
     } catch (DecodeException de) {
         // Failed to decode the response control.
     }
 } catch (DecodeException e) {
     // Failed to decode the response control.
 }
 
 
If the client has sent a passwordPolicyRequest control, the server (when solicited by the inclusion of the request control) sends this control with the following operation responses: bindResponse, modifyResponse, addResponse, compareResponse and possibly extendedResponse, to inform of various conditions, and MAY be sent with other operations (in the case of the changeAfterReset error).
See Also:
  • Field Details

  • Method Details

    • newControl

      public static PasswordPolicyResponseControl newControl()
      Creates a new password policy response control with no error nor warning.
      Returns:
      The new control.
    • newControl

      public static PasswordPolicyResponseControl newControl(PasswordPolicyErrorType errorType)
      Creates a new password policy response control with the provided error.
      Parameters:
      errorType - The password policy error type.
      Returns:
      The new control.
      Throws:
      NullPointerException - If errorType was null.
    • newControl

      public static PasswordPolicyResponseControl newControl(PasswordPolicyWarningType warningType, int warningValue)
      Creates a new password policy response control with the provided warning.
      Parameters:
      warningType - The password policy warning type.
      warningValue - The password policy warning value.
      Returns:
      The new control.
      Throws:
      IllegalArgumentException - If warningValue was negative.
      NullPointerException - If warningType was null.
    • newControl

      public static PasswordPolicyResponseControl newControl(PasswordPolicyWarningType warningType, int warningValue, PasswordPolicyErrorType errorType)
      Creates a new password policy response control with the provided warning and error.
      Parameters:
      warningType - The password policy warning type.
      warningValue - The password policy warning value.
      errorType - The password policy error type.
      Returns:
      The new control.
      Throws:
      IllegalArgumentException - If warningValue was negative.
      NullPointerException - If warningType or errorType was null.
    • getErrorType

      public PasswordPolicyErrorType getErrorType()
      Returns the password policy error type, if available.
      Returns:
      The password policy error type, or null if this control does not contain an error.
    • getOid

      public String getOid()
      Description copied from interface: Control
      Returns the numeric OID associated with this control.
      Specified by:
      getOid in interface Control
      Returns:
      The numeric OID associated with this control.
    • getValue

      public ByteString getValue()
      Description copied from interface: Control
      Returns the value, if any, associated with this control. Its format is defined by the specification of this control.
      Specified by:
      getValue in interface Control
      Returns:
      The value associated with this control, or null if there is no value.
    • getWarningType

      public PasswordPolicyWarningType getWarningType()
      Returns the password policy warning type, if available.
      Returns:
      The password policy warning type, or null if this control does not contain a warning.
    • getWarningValue

      public int getWarningValue()
      Returns the password policy warning value, if available. The value is undefined if this control does not contain a warning.
      Returns:
      The password policy warning value, or -1 if this control does not contain a warning.
    • hasValue

      public boolean hasValue()
      Description copied from interface: Control
      Returns true if this control has a value. In some circumstances it may be useful to determine if a control has a value, without actually calculating the value and incurring any performance costs.
      Specified by:
      hasValue in interface Control
      Returns:
      true if this control has a value, or false if there is no value.
    • isCritical

      public boolean isCritical()
      Description copied from interface: Control
      Returns true if it is unacceptable to perform the operation without applying the semantics of this control.

      The criticality field only has meaning in controls attached to request messages (except UnbindRequest). For controls attached to response messages and the UnbindRequest, the criticality field SHOULD be false, and MUST be ignored by the receiving protocol peer. A value of true indicates that it is unacceptable to perform the operation without applying the semantics of the control.

      Specified by:
      isCritical in interface Control
      Returns:
      true if this control must be processed by the Directory Server, or false if it can be ignored.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getAlias

      public String getAlias()
      Description copied from interface: Control
      Returns the control "friendly name" alias for the control.
      Specified by:
      getAlias in interface Control
      Returns:
      "Friendly name" alias for the control.