Package com.isode.dsapi.config
Class PasswordPolicyConfig
java.lang.Object
com.isode.dsapi.config.PasswordPolicyConfig
This class encapsulates a set of settings relating to the password policy
as retrieved from the DSA.
Callers are assumed to be using an IsodeDirectorySession which has operator access rights to the DSA. To check the password policy status of a user, fetch an Entry object for the user, making sure to include all attributes that are needed by this class. For example
IsodeDirectorySession ids; . . PasswordPolicyConfig ppc = new PasswordPolicyConfig(ids); Selection mySel = new Selection(SelectionType.NO_ATTRIBUTES); ListNote that a user may be excluded from password policy. Useattrs = ppc.getPasswordPolicyAttributes(); for (AttributeType at:attrs) { mySel.selectAttributeType(at); } // now add any other attributes of interest... . . // now read the entry from the directory Entry = ids.readEntry(entryDN, mySel, null); . // and find out what might be wrong with it Set<PasswordPolicy.AccountIssue> issues = ppc.getAccountIssues(e); . .
isExcludedFromPwdPolicy(Entry)
to check whether a user is
subject to password policy. For such users, methods
which return password-policy related information (such as getPwdMaxIdle()
will still work. However, getAccountIssues(Entry)
will not return
any problems that are caused by password policy for such users.- Since:
- R16.6
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
An AccountIssue represents a problem that means an account will be locked, and contains a LOCK_REASON as well as an Object which gives more information about the LOCK_REASON.static enum
Enum representing possible problems with a particular account. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
static AttributeType
-
Constructor Summary
ConstructorsConstructorDescriptionConstruct a new object and read password policy confirmation from the directory -
Method Summary
Modifier and TypeMethodDescriptionGet a set of reasons why password policy would lock this user.Determine the createTimestamp for this entrystatic List<AttributeType>
Returns a list of attributes that should be requested when performing a search or read of user entries.Determine the pwdAttribute defined by the password policyDetermine the last time the password was changed for this entryDetermine the "password end time" for this entryDetermine the last time the password was successfully used for this entrylong
Determine what the "pwdMaxAge" value is for this configuration.long
Determine what the "pwdMaxIdle" value is for this configuration.Determine the "password start time" for this entryDetermine whether the password for this user has expired, based on the last pwdChangedTime being more than pwdMaxAge seconds ago.Determine whether an account has been administratively locked (i.e.boolean
Determine whether this user is excluded from password policyDetermine whether the password for this user has been unused for more than the configured value for password policy's "pwdMaxIdle".Determines whether the user represented by the specified entry has a passwordStartTime that is before the current time, and a passwordEndTime that is later than the current time.boolean
Determine whether password policy is enabled.boolean
Determine whether an account has a password attribute (where the attribute name comes from password policy, or, if password policy is not enabled or does not specify an attribute, then "userPassword").boolean
Determine whether an account requires a password reset before it can be used.
-
Field Details
-
at_pwdAttribute
-
at_pwdCheckQuality
-
at_pwdExpireWarning
-
at_pwdLockout
-
at_pwdGraceAuthNLimit
-
at_pwdFailureCountInterval
-
at_pwdInHistory
-
at_pwdLockoutDuration
-
at_pwdMaxAge
-
at_pwdMaxFailure
-
at_pwdMaxIdle
-
at_pwdMaxDelay
-
at_pwdMinDelay
-
at_pwdGraceExpiry
-
at_pwdMinAge
-
at_pwdMinLength
-
at_pwdMaxLength
-
at_pwdMustChange
-
at_pwdAllowUserChange
-
at_pwdSafeModify
-
at_pwdCheckEntropy
-
at_pwdHistoryDuration
-
at_pwdAutoMigrate
-
at_pwdConfiguredSchemeComparators
-
at_pwdConfiguredSchemeGenerators
-
at_pwdStartTime
-
at_pwdEndTime
-
at_pwdLastSuccess
-
at_pwdChangedTime
-
at_createTimeStamp
-
at_accountLock
-
at_accountLockReason
-
at_pwdExclude
-
at_pwdReset
-
-
Constructor Details
-
PasswordPolicyConfig
public PasswordPolicyConfig(IsodeDirectorySession ids) throws NoSuchAttributeException, NotBoundException Construct a new object and read password policy confirmation from the directory- Parameters:
ids
- a directory session, must not be null- Throws:
NoSuchAttributeException
- if the schema does not have password policy attributes defined or if the config entry could not be readNotBoundException
- if the session is not bound
-
-
Method Details
-
getPasswordPolicyAttributes
Returns a list of attributes that should be requested when performing a search or read of user entries. This list contains password policy related attributes that are used by this class when it is determining whether a user has violated password policy constraints.- Returns:
- a List of AttributeType values which should be added to any Selection that the caller uses when reading user entry information.
- Throws:
NoSuchAttributeException
- if the schema does not have password policy attributes defined.
-
getPwdStartTime
Determine the "password start time" for this entry- Parameters:
e
- a user entry. Must not be null;- Returns:
- the password start time for the entry, or null if none is present
- Throws:
BadValueException
- if the password start time is present but cannot be interpreted as a date.
-
getPwdEndTime
Determine the "password end time" for this entry- Parameters:
e
- an Entry representing a user- Returns:
- the password end time for the entry, or null if none is present
- Throws:
BadValueException
- if the password start time is present but cannot be interpreted as a date.
-
isExcludedFromPwdPolicy
Determine whether this user is excluded from password policy- Parameters:
e
- an Entry representing a user- Returns:
- true if the user is excluded from password policy, false otherwise.
-
isPasswordInValidityPeriod
Determines whether the user represented by the specified entry has a passwordStartTime that is before the current time, and a passwordEndTime that is later than the current time. If no passwordStartTime or passwordEndTime is specified, then the method returns null- Parameters:
e
- a user entry. Must not be null;- Returns:
- the passwordStartTime if the password is not yet valid, or passwordEndTime if the password is no longer valid, or null if the password is within its validity period (or there is no validity period restriction, or if password policy is not enabled).
- Throws:
BadValueException
- if either time value does not represent an actual time.
-
getPwdLastSuccess
Determine the last time the password was successfully used for this entry- Parameters:
e
- a user entry. Must not be null;- Returns:
- the pwdLastSuccess for the entry, or null if none is present
- Throws:
BadValueException
- if the time value is present but cannot be interpreted as a date.
-
getPwdChangedTime
Determine the last time the password was changed for this entry- Parameters:
e
- a user entry. Must not be null;- Returns:
- the pwdChangedTime for the entry, or the createtimestamp if no valid pwdChangedTime is present, or null if there's no createtimestamp either
- Throws:
BadValueException
- if createTimeStamp contains an illegal value
-
getCreateTimestamp
Determine the createTimestamp for this entry- Parameters:
e
- a user entry. Must not be null;- Returns:
- the createTimestamp for the entry, should not be null assuming the directory isn't broken.
- Throws:
BadValueException
- if the time value is present but cannot be interpreted as a date.
-
getPwdAttribute
Determine the pwdAttribute defined by the password policy- Returns:
- the pwdAttribute (e.g. "userPassword") which is the attribute on an entry which is used to store the password, or "userPassword" if password policy is not enabled (or the field "pwdAttribute" is not set for some reason).
- Throws:
BadAttributeTypeException
- if the password policy specifies an illegal value for pwdAttribute
-
getPwdMaxIdle
Determine what the "pwdMaxIdle" value is for this configuration. This is the time that can elapse after a successful password authentication before the account is locked.- Returns:
- the pwdMaxIdle time in milliseconds, or -1 if none is configured, or if password policy is not enabled.
- Throws:
BadValueException
- if the pwdMaxIdle time is configured to an illegal value.
-
getPwdMaxAge
Determine what the "pwdMaxAge" value is for this configuration. This is the time that can elapse after a password has been changed before it expires- Returns:
- the pwdMaxAge time in milliseconds, or -1 if none is configured, or if password policy is not enabled.
- Throws:
BadValueException
- if the pwdMaxIdle time is configured to an illegal value.
-
isPasswordIdle
Determine whether the password for this user has been unused for more than the configured value for password policy's "pwdMaxIdle". If no password policy is configured, then this method always null.- Parameters:
e
- a user entry. Must not be null;- Returns:
- an Instant representing the time that this password could last have been used before it became idle, or null if the password is not considered to be idle (which will also be the case if password policy is not enabled).
- Throws:
BadValueException
- if the pwdMaxIdle or pwdLastSuccess values cannot be interpreted as a date, or there is no createTimestamp on the entry
-
hasPasswordExpired
Determine whether the password for this user has expired, based on the last pwdChangedTime being more than pwdMaxAge seconds ago.- Parameters:
e
- a user entry. Must not be null;- Returns:
- null if the password has not expired (which will also be the case if password policy is not enabled), or the date when the password expired.
- Throws:
BadValueException
- if the pwdMaxIdle or pwdLastSuccess values cannot be interpreted as a date.
-
getAccountIssues
Get a set of reasons why password policy would lock this user.- Parameters:
e
- an entry representing a user- Returns:
- a set (which may be empty) containing password policy issues for this user.
-
isAccountLocked
Determine whether an account has been administratively locked (i.e. it has the "accountLock" attribute set).- Parameters:
e
- the entry representing the account to test- Returns:
- a String containing the accountLockReason (if any). This String may be empty ("") if the account is locked but no reason has been specified. A value of null is returned if the account is not administratively locked.
-
isPasswordResetRequired
Determine whether an account requires a password reset before it can be used.- Parameters:
e
- the entry representing the account to test- Returns:
- true if the user's entry has the pwdReset attribute set to true and password policy is enabled, false otherwise.
-
isPasswordPresent
Determine whether an account has a password attribute (where the attribute name comes from password policy, or, if password policy is not enabled or does not specify an attribute, then "userPassword").- Parameters:
e
- the entry representing the account to test- Returns:
- true if the user's entry has a password, false otherwise.
-
isPasswordPolicyEnabled
public boolean isPasswordPolicyEnabled()Determine whether password policy is enabled.- Returns:
- true if password policy is enabled for this DSA, false otherwise.
-