|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.unboundid.ldap.sdk.Control
com.unboundid.ldap.sdk.controls.PasswordExpiredControl
@NotMutable @ThreadSafety(level=COMPLETELY_THREADSAFE) public final class PasswordExpiredControl
This class provides an implementation of the password expired control as
described in draft-vchu-ldap-pwd-policy. It may be included in the response
for an unsuccessful bind operation to indicate that the reason for the
failure is that the target user's password has expired and must be reset
before the user will be allowed to authenticate. Some servers may also
include this control in a successful bind response to indicate that the
authenticated user must change his or her password before being allowed to
perform any other operation.
No request control is required to trigger the server to send the password
expired response control. If the server supports the use of this control and
the corresponding bind operation meets the criteria for this control to be
included in the response, then it will be returned to the client.
// 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; } }
Field Summary | |
---|---|
static java.lang.String |
PASSWORD_EXPIRED_OID
The OID (2.16.840.1.113730.3.4.4) for the password expired response control. |
Constructor Summary | |
---|---|
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. |
Method Summary | |
---|---|
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. |
Methods inherited from class com.unboundid.ldap.sdk.Control |
---|
decode, decode, decodeControls, deregisterDecodeableControl, encode, encodeControls, equals, getOID, getValue, hashCode, hasValue, isCritical, readFrom, registerDecodeableControl, toString, writeTo |
Methods inherited from class java.lang.Object |
---|
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final java.lang.String PASSWORD_EXPIRED_OID
Constructor Detail |
---|
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.Method Detail |
---|
public PasswordExpiredControl decodeControl(java.lang.String oid, boolean isCritical, ASN1OctetString value) throws LDAPException
decodeControl
in interface DecodeableControl
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 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
public void toString(java.lang.StringBuilder buffer)
toString
in class Control
buffer
- The buffer to which to append the string representation of
this buffer.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |