@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class PasswordExpiredControl extends Control implements DecodeableControl
// Send a simple bind request to the directory server.
BindRequest bindRequest =
new SimpleBindRequest("uid=test.user,ou=People,dc=example,dc=com",
"password");
BindResult bindResult;
boolean bindSuccessful;
boolean passwordExpired;
boolean passwordAboutToExpire;
try
{
bindResult = connection.bind(bindRequest);
// If we got here, the bind was successful and we know the password was
// not expired. However, we shouldn't ignore the result because the
// password might be about to expire. To determine whether that is the
// case, we should see if the bind result included a password expiring
// control.
bindSuccessful = true;
passwordExpired = false;
PasswordExpiringControl expiringControl =
PasswordExpiringControl.get(bindResult);
if (expiringControl != null)
{
passwordAboutToExpire = true;
int secondsToExpiration = expiringControl.getSecondsUntilExpiration();
}
else
{
passwordAboutToExpire = false;
}
}
catch (LDAPException le)
{
// If we got here, then the bind failed. The failure may or may not have
// been due to an expired password. To determine that, we should see if
// the bind result included a password expired control.
bindSuccessful = false;
passwordAboutToExpire = false;
bindResult = new BindResult(le.toLDAPResult());
ResultCode resultCode = le.getResultCode();
String errorMessageFromServer = le.getDiagnosticMessage();
PasswordExpiredControl expiredControl =
PasswordExpiredControl.get(le);
if (expiredControl != null)
{
passwordExpired = true;
}
else
{
passwordExpired = false;
}
}
| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
PASSWORD_EXPIRED_OID
The OID (2.16.840.1.113730.3.4.4) for the password expired response
control.
|
| Constructor and Description |
|---|
PasswordExpiredControl()
Creates a new password expired control.
|
PasswordExpiredControl(java.lang.String oid,
boolean isCritical,
ASN1OctetString value)
Creates a new password expired control with the provided information.
|
| Modifier and Type | Method and Description |
|---|---|
PasswordExpiredControl |
decodeControl(java.lang.String oid,
boolean isCritical,
ASN1OctetString value)
Creates a new instance of this decodeable control from the provided
information.
|
static PasswordExpiredControl |
get(LDAPException exception)
Extracts a password expired control from the provided exception.
|
static PasswordExpiredControl |
get(LDAPResult result)
Extracts a password expired control from the provided result.
|
java.lang.String |
getControlName()
Retrieves the user-friendly name for this control, if available.
|
void |
toString(java.lang.StringBuilder buffer)
Appends a string representation of this LDAP control to the provided
buffer.
|
decode, decode, decodeControls, deregisterDecodeableControl, encode, encodeControls, equals, getOID, getValue, hashCode, hasValue, isCritical, readFrom, registerDecodeableControl, toString, writeTopublic static final java.lang.String PASSWORD_EXPIRED_OID
public PasswordExpiredControl()
public PasswordExpiredControl(java.lang.String oid, boolean isCritical, ASN1OctetString value) throws LDAPException
oid - The OID for the control.isCritical - Indicates whether the control should be marked
critical.value - The encoded value for the control. This may be
null if no value was provided.LDAPException - If the provided control cannot be decoded as a
password expired response control.public PasswordExpiredControl decodeControl(java.lang.String oid, boolean isCritical, ASN1OctetString value) throws LDAPException
decodeControl in interface DecodeableControloid - The OID for the control.isCritical - Indicates whether the control should be marked
critical.value - The encoded value for the control. This may be
null if no value was provided.LDAPException - If the provided information cannot be decoded as a
valid instance of this decodeable control.public static PasswordExpiredControl get(LDAPResult result) throws LDAPException
result - The result from which to retrieve the password expired
control.null if the result did not contain a password expired
control.LDAPException - If a problem is encountered while attempting to
decode the password expired control contained in
the provided result.public static PasswordExpiredControl get(LDAPException exception) throws LDAPException
exception - The exception from which to retrieve the password
expired control.null if the exception did not contain a password
expired control.LDAPException - If a problem is encountered while attempting to
decode the password expired control contained in
the provided exception.public java.lang.String getControlName()
getControlName in class Control