| | |
| | | * CDDL HEADER END |
| | | * |
| | | * |
| | | * Portions Copyright 2006 Sun Microsystems, Inc. |
| | | * Portions Copyright 2006-2007 Sun Microsystems, Inc. |
| | | */ |
| | | package org.opends.server.controls; |
| | | |
| | |
| | | import org.opends.server.protocols.ldap.LDAPException; |
| | | import org.opends.server.protocols.ldap.LDAPResultCode; |
| | | import org.opends.server.types.Control; |
| | | import org.opends.server.types.DebugLogLevel; |
| | | |
| | | import static org.opends.server.loggers.Debug.*; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugCought; |
| | | import static org.opends.server.loggers.debug.DebugLogger.debugEnabled; |
| | | import static org.opends.server.messages.MessageHandler.*; |
| | | import static org.opends.server.messages.ProtocolMessages.*; |
| | | import static org.opends.server.util.ServerConstants.*; |
| | |
| | | public class AccountUsableResponseControl |
| | | extends Control |
| | | { |
| | | /** |
| | | * The fully-qualified name of this class for debugging purposes. |
| | | */ |
| | | private static final String CLASS_NAME = |
| | | "org.opends.server.controls.AccountUsableResponseControl"; |
| | | |
| | | |
| | | |
| | |
| | | super(OID_ACCOUNT_USABLE_CONTROL, false, |
| | | encodeValue(secondsBeforeExpiration)); |
| | | |
| | | assert debugConstructor(CLASS_NAME, |
| | | String.valueOf(secondsBeforeExpiration)); |
| | | |
| | | this.secondsBeforeExpiration = secondsBeforeExpiration; |
| | | |
| | |
| | | { |
| | | super(oid, isCritical, encodeValue(secondsBeforeExpiration)); |
| | | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(oid), |
| | | String.valueOf(isCritical), |
| | | String.valueOf(secondsBeforeExpiration)); |
| | | |
| | | this.secondsBeforeExpiration = secondsBeforeExpiration; |
| | | |
| | |
| | | encodeValue(isInactive, isReset, isExpired, remainingGraceLogins, |
| | | isLocked, secondsBeforeUnlock)); |
| | | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(isInactive), |
| | | String.valueOf(isReset), String.valueOf(isExpired), |
| | | String.valueOf(remainingGraceLogins), |
| | | String.valueOf(isLocked), |
| | | String.valueOf(secondsBeforeUnlock)); |
| | | |
| | | this.isInactive = isInactive; |
| | | this.isReset = isReset; |
| | |
| | | encodeValue(isInactive, isReset, isExpired, remainingGraceLogins, |
| | | isLocked, secondsBeforeUnlock)); |
| | | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(oid), |
| | | String.valueOf(isCritical), |
| | | String.valueOf(isInactive), String.valueOf(isReset), |
| | | String.valueOf(isExpired), |
| | | String.valueOf(remainingGraceLogins), |
| | | String.valueOf(isLocked), |
| | | String.valueOf(secondsBeforeUnlock)); |
| | | |
| | | this.isInactive = isInactive; |
| | | this.isReset = isReset; |
| | |
| | | { |
| | | super(oid, isCritical, encodedValue); |
| | | |
| | | assert debugConstructor(CLASS_NAME, String.valueOf(oid), |
| | | String.valueOf(isCritical), |
| | | String.valueOf(isAvailable), |
| | | String.valueOf(secondsBeforeExpiration), |
| | | String.valueOf(isInactive), |
| | | String.valueOf(isReset), |
| | | String.valueOf(isExpired), |
| | | String.valueOf(remainingGraceLogins), |
| | | String.valueOf(isLocked), |
| | | String.valueOf(secondsBeforeUnlock)); |
| | | |
| | | this.isUsable = isAvailable; |
| | | this.secondsBeforeExpiration = secondsBeforeExpiration; |
| | |
| | | */ |
| | | private static ASN1OctetString encodeValue(int secondsBeforeExpiration) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "encodeValue", |
| | | String.valueOf(secondsBeforeExpiration)); |
| | | |
| | | |
| | | ASN1Integer sbeInteger = new ASN1Integer(TYPE_SECONDS_BEFORE_EXPIRATION, |
| | |
| | | boolean isLocked, |
| | | int secondsBeforeUnlock) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "encodeValue", String.valueOf(isInactive), |
| | | String.valueOf(isReset), String.valueOf(isExpired), |
| | | String.valueOf(remainingGraceLogins), |
| | | String.valueOf(isLocked), |
| | | String.valueOf(secondsBeforeUnlock)); |
| | | |
| | | |
| | | ArrayList<ASN1Element> elements = new ArrayList<ASN1Element>(5); |
| | |
| | | public static AccountUsableResponseControl decodeControl(Control control) |
| | | throws LDAPException |
| | | { |
| | | assert debugEnter(CLASS_NAME, "decodeControl", String.valueOf(control)); |
| | | |
| | | |
| | | ASN1OctetString controlValue = control.getValue(); |
| | |
| | | } |
| | | catch (ASN1Exception ae) |
| | | { |
| | | assert debugException(CLASS_NAME, "decodeControl", ae); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, ae); |
| | | } |
| | | |
| | | int msgID = MSGID_ACCTUSABLERES_DECODE_ERROR; |
| | | int msgID = MSGID_ACCTUSABLERES_DECODE_ERROR; |
| | | String message = getMessage(msgID, ae.getMessage()); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | } |
| | | catch (Exception e) |
| | | { |
| | | assert debugException(CLASS_NAME, "decodeControl", e); |
| | | if (debugEnabled()) |
| | | { |
| | | debugCought(DebugLogLevel.ERROR, e); |
| | | } |
| | | |
| | | int msgID = MSGID_ACCTUSABLERES_DECODE_ERROR; |
| | | int msgID = MSGID_ACCTUSABLERES_DECODE_ERROR; |
| | | String message = getMessage(msgID, stackTraceToSingleLineString(e)); |
| | | throw new LDAPException(LDAPResultCode.PROTOCOL_ERROR, msgID, message); |
| | | } |
| | |
| | | */ |
| | | public boolean isUsable() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isAvailable"); |
| | | |
| | | return isUsable; |
| | | } |
| | |
| | | */ |
| | | public int getSecondsBeforeExpiration() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSecondsBeforeExpiration"); |
| | | |
| | | return secondsBeforeExpiration; |
| | | } |
| | |
| | | */ |
| | | public boolean isInactive() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isInactive"); |
| | | |
| | | return isInactive; |
| | | } |
| | |
| | | */ |
| | | public boolean isReset() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isReset"); |
| | | |
| | | return isReset; |
| | | } |
| | |
| | | */ |
| | | public boolean isExpired() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isExpired"); |
| | | |
| | | return isExpired; |
| | | } |
| | |
| | | */ |
| | | public int getRemainingGraceLogins() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getRemainingGraceLogins"); |
| | | |
| | | return remainingGraceLogins; |
| | | } |
| | |
| | | */ |
| | | public boolean isLocked() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "isLocked"); |
| | | |
| | | return isLocked; |
| | | } |
| | |
| | | */ |
| | | public int getSecondsBeforeUnlock() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "getSecondsBeforeUnlock"); |
| | | |
| | | return secondsBeforeUnlock; |
| | | } |
| | |
| | | */ |
| | | public String toString() |
| | | { |
| | | assert debugEnter(CLASS_NAME, "toString"); |
| | | |
| | | StringBuilder buffer = new StringBuilder(); |
| | | toString(buffer); |
| | |
| | | */ |
| | | public void toString(StringBuilder buffer) |
| | | { |
| | | assert debugEnter(CLASS_NAME, "toString", "java.lang.StringBuilder"); |
| | | |
| | | buffer.append("AccountUsableResponseControl(isUsable="); |
| | | buffer.append(isUsable); |