com.sun.jndi.ldap.ctl
Class PasswordExpiringResponseControl

java.lang.Object
  extended by com.sun.jndi.ldap.BasicControl
      extended by com.sun.jndi.ldap.ctl.PasswordExpiringResponseControl
All Implemented Interfaces:
java.io.Serializable, javax.naming.ldap.Control

public class PasswordExpiringResponseControl
extends com.sun.jndi.ldap.BasicControl

This class implements the LDAP response control notifying password expiration. The Password Expiring control is a notification to the client when password is about to expiring according to the server's password policy. This control should be checked whenever a LDAP bind operation is performed as a result of operations on the context such as when a new initial context is created or when InitialLdapContext.reconnect is called.

The Password Expiring control is defined in draft-vchu-ldap-pwd-policy-00.txt

The object identifier for Password Expiry is 2.16.840.1.113730.3.4.5 and the value returned indicates the time left until the password expires. The control's value has the following ASN.1 definition:


     PasswordExpiring ::= OCTET STRING  ; time in seconds until the 
                                        ; password expires

 

The following code sample shows how the control may be used:


     // create an initial context using the supplied environment properties
     LdapContext ctx = new InitialLdapContext(env, null);
     Control[] respControls;

     // retrieve response controls
     if ((respControls = ctx.getResponseControls()) != null) {
         for (int i = 0; i < respControls.length; i++) {

             // locate the password expiring control
             if (respControls[i] instanceof PasswordExpiringResponseControl) {
                 System.out.println("Password expires in " +
                     ((PasswordExpiringResponseControl) respControls[i])
                         .timeRemaining() + " seconds");
             }
         }
     }

 

Author:
Vincent Ryan
See Also:
PasswordExpiredResponseControl, Serialized Form

Field Summary
static java.lang.String OID
          The password expiring control's assigned object identifier is 2.16.840.1.113730.3.4.5.
private static long serialVersionUID
           
private  long timeLeft
          The time remaining until the password expires
 
Fields inherited from class com.sun.jndi.ldap.BasicControl
criticality, id, value
 
Fields inherited from interface javax.naming.ldap.Control
CRITICAL, NONCRITICAL
 
Constructor Summary
PasswordExpiringResponseControl(java.lang.String id, boolean criticality, byte[] value)
          Constructs a control to notify of password expiration.
 
Method Summary
 byte[] getEncodedValue()
          Retrieves the PasswordExpiring control response's ASN.1 BER encoded value.
 long timeRemaining()
          The time remaining until the password expires.
 
Methods inherited from class com.sun.jndi.ldap.BasicControl
getID, isCritical
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

OID

public static final java.lang.String OID
The password expiring control's assigned object identifier is 2.16.840.1.113730.3.4.5.

See Also:
Constant Field Values

timeLeft

private long timeLeft
The time remaining until the password expires


serialVersionUID

private static final long serialVersionUID
See Also:
Constant Field Values
Constructor Detail

PasswordExpiringResponseControl

PasswordExpiringResponseControl(java.lang.String id,
                                boolean criticality,
                                byte[] value)
                          throws java.io.IOException
Constructs a control to notify of password expiration.

Parameters:
id - The control's object identifier string.
criticality - The control's criticality.
value - The control's ASN.1 BER encoded value. May be null.
Throws:
java.io.IOException - if an error is encountered while decoding the control's value.
Method Detail

timeRemaining

public long timeRemaining()
The time remaining until the password expires.

Returns:
The number of seconds until the password expires.

getEncodedValue

public byte[] getEncodedValue()
Retrieves the PasswordExpiring control response's ASN.1 BER encoded value.

Specified by:
getEncodedValue in interface javax.naming.ldap.Control
Overrides:
getEncodedValue in class com.sun.jndi.ldap.BasicControl
Returns:
The ASN.1 BER encoded value of the LDAP control.