public final class PasswordPolicyResponseControl extends Object implements Control
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).Modifier and Type | Field and Description |
---|---|
static ControlDecoder<PasswordPolicyResponseControl> |
DECODER
A decoder which can be used for decoding the password policy response control.
|
static String |
OID
The OID for the password policy control from draft-behera-ldap-password-policy.
|
Modifier and Type | Method and Description |
---|---|
PasswordPolicyErrorType |
getErrorType()
Returns the password policy error type, if available.
|
String |
getOid()
Returns the numeric OID associated with this control.
|
ByteString |
getValue()
Returns the value, if any, associated with this control.
|
PasswordPolicyWarningType |
getWarningType()
Returns the password policy warning type, if available.
|
int |
getWarningValue()
Returns the password policy warning value, if available.
|
boolean |
hasValue()
Returns
true if this control has a value. |
boolean |
isCritical()
Returns
true if it is unacceptable to perform the operation
without applying the semantics of this control. |
static PasswordPolicyResponseControl |
newControl()
Creates a new password policy response control with no error nor warning.
|
static PasswordPolicyResponseControl |
newControl(PasswordPolicyErrorType errorType)
Creates a new password policy response control with the provided error.
|
static PasswordPolicyResponseControl |
newControl(PasswordPolicyWarningType warningType,
int warningValue)
Creates a new password policy response control with the provided warning.
|
static PasswordPolicyResponseControl |
newControl(PasswordPolicyWarningType warningType,
int warningValue,
PasswordPolicyErrorType errorType)
Creates a new password policy response control with the provided warning
and error.
|
String |
toString() |
public static final String OID
public static final ControlDecoder<PasswordPolicyResponseControl> DECODER
public static PasswordPolicyResponseControl newControl()
public static PasswordPolicyResponseControl newControl(PasswordPolicyErrorType errorType)
errorType
- The password policy error type.NullPointerException
- If errorType
was null
.public static PasswordPolicyResponseControl newControl(PasswordPolicyWarningType warningType, int warningValue)
warningType
- The password policy warning type.warningValue
- The password policy warning value.IllegalArgumentException
- If warningValue
was negative.NullPointerException
- If warningType
was null
.public static PasswordPolicyResponseControl newControl(PasswordPolicyWarningType warningType, int warningValue, PasswordPolicyErrorType errorType)
warningType
- The password policy warning type.warningValue
- The password policy warning value.errorType
- The password policy error type.IllegalArgumentException
- If warningValue
was negative.NullPointerException
- If warningType
or errorType
was null
.public PasswordPolicyErrorType getErrorType()
null
if this control
does not contain a error.public String getOid()
Control
public ByteString getValue()
Control
public PasswordPolicyWarningType getWarningType()
null
if this control
does not contain a warning.public int getWarningValue()
-1
if this control
does not contain a warning.public boolean hasValue()
Control
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.public boolean isCritical()
Control
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.
isCritical
in interface Control
true
if this control must be processed by the Directory
Server, or false
if it can be ignored.Copyright 2010-2022 ForgeRock AS.