Package org.opends.server.api
Class AuthenticationPolicyState
java.lang.Object
org.opends.server.api.AuthenticationPolicyState
- Direct Known Subclasses:
PasswordPolicyState
The authentication policy context associated with a user's entry, which is responsible for managing the user's
account, their password, as well as authenticating the user.
-
Field Summary
Modifier and TypeFieldDescriptionprotected ConditionResult
A boolean indicating whether the account associated with this authentication state has been administratively disabled.protected final Entry
The user entry associated with this authentication policy state. -
Constructor Summary
ModifierConstructorDescriptionprotected
AuthenticationPolicyState
(Entry userEntry) Creates a new abstract authentication policy context. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Performs any finalization required after a bind operation has completed.static AuthenticationPolicyState
forUser
(Entry userEntry, Consumer<LocalizableMessage> onMultiplePasswordPolicies, ServerContext serverContext) Returns the authentication policy state for the user provided user.static AuthenticationPolicyState
forUser
(Entry userEntry, ServerContext serverContext) Returns the authentication policy state for the user provided user.abstract AuthenticationPolicy
Returns the authentication policy associated with this state.protected static ConditionResult
getBoolean
(Entry entry, String attributeName) A utility method which may be used by implementations in order to obtain the value of the specified attribute from the provided entry as a boolean.protected static long
getGeneralizedTime
(Entry entry, AttributeDescription attrDesc) A utility method which may be used by implementations in order to obtain the value of the specified attribute from the provided entry as a time in generalized time format.boolean
Returnstrue
if this authentication policy state is associated with a user whose account has been administratively disabled.boolean
passwordMatches
(ByteString password) Returnstrue
if the provided password value matches any of the user's passwords.abstract boolean
passwordMatches
(ByteString password, AtomicReference<ByteString> matchedEncodedPassword) Returnstrue
if the provided password value matches any of the user's passwords.
-
Field Details
-
isDisabled
A boolean indicating whether the account associated with this authentication state has been administratively disabled. -
userEntry
The user entry associated with this authentication policy state.
-
-
Constructor Details
-
AuthenticationPolicyState
Creates a new abstract authentication policy context.- Parameters:
userEntry
- The user's entry.
-
-
Method Details
-
forUser
public static AuthenticationPolicyState forUser(Entry userEntry, ServerContext serverContext) throws LdapException Returns the authentication policy state for the user provided user. This method is equivalent to the following:AuthenticationPolicy policy = AuthenticationPolicy.forUser(userEntry, useDefaultOnError); AuthenticationPolicyState state = policy.createAuthenticationPolicyState(userEntry);
See the documentation ofAuthenticationPolicy.forUser(org.forgerock.opendj.ldap.Entry, org.opends.server.core.ServerContext)
for a description of the algorithm used to find a user's authentication policy.- Parameters:
userEntry
- The user entry.serverContext
- The server context- Returns:
- The password policy for the user.
- Throws:
LdapException
- If a problem occurs while attempting to determine the password policy for the user.- See Also:
-
forUser
public static AuthenticationPolicyState forUser(Entry userEntry, Consumer<LocalizableMessage> onMultiplePasswordPolicies, ServerContext serverContext) throws LdapException Returns the authentication policy state for the user provided user. This method is equivalent to the following:AuthenticationPolicy policy = AuthenticationPolicy.forUser(userEntry, useDefaultOnError, onMultiplePasswordPolicies); AuthenticationPolicyState state = policy.createAuthenticationPolicyState(userEntry);
See the documentation ofAuthenticationPolicy.forUser(org.forgerock.opendj.ldap.Entry, org.opends.server.core.ServerContext)
for a description of the algorithm used to find a user's authentication policy.- Parameters:
userEntry
- The user entry.onMultiplePasswordPolicies
- Invoked when multiple password policy subentries are detected to the entry.serverContext
- The server context- Returns:
- The password policy for the user.
- Throws:
LdapException
- If a problem occurs while attempting to determine the password policy for the user.- See Also:
-
getBoolean
A utility method which may be used by implementations in order to obtain the value of the specified attribute from the provided entry as a boolean.- Parameters:
entry
- The entry whose attribute is to be parsed as a boolean.attributeName
- The attribute name whose value should be parsed as a boolean.- Returns:
- The attribute's value represented as a ConditionResult value, or ConditionResult.UNDEFINED if the specified attribute does not exist in the entry.
- Throws:
LdapException
- If the value cannot be decoded as a boolean.
-
getGeneralizedTime
protected static long getGeneralizedTime(Entry entry, AttributeDescription attrDesc) throws LdapException A utility method which may be used by implementations in order to obtain the value of the specified attribute from the provided entry as a time in generalized time format.- Parameters:
entry
- The entry whose attribute is to be parsed as a boolean.attrDesc
- The attribute description whose value should be parsed as a generalized time value.- Returns:
- The requested time, or -1 if it could not be determined.
- Throws:
LdapException
- If a problem occurs while attempting to decode the value as a generalized time.
-
finalizeStateAfterBind
Performs any finalization required after a bind operation has completed. Implementations may perform internal operations in order to persist internal state to the user's entry if needed.- Throws:
LdapException
- If a problem occurs during finalization.
-
getAuthenticationPolicy
Returns the authentication policy associated with this state.- Returns:
- The authentication policy associated with this state.
-
isDisabled
public boolean isDisabled()Returnstrue
if this authentication policy state is associated with a user whose account has been administratively disabled.The default implementation is use the value of the "ds-pwp-account-disable" attribute in the user's entry.
- Returns:
true
if this authentication policy state is associated with a user whose account has been administratively disabled.
-
passwordMatches
public abstract boolean passwordMatches(ByteString password, AtomicReference<ByteString> matchedEncodedPassword) throws LdapException Returnstrue
if the provided password value matches any of the user's passwords.- Parameters:
password
- The user-provided password to verify.matchedEncodedPassword
- Iftrue
is returned, the matching stored password may be returned.- Returns:
true
if the provided password value matches any of the user's passwords.- Throws:
LdapException
- If verification unexpectedly failed.
-
passwordMatches
Returnstrue
if the provided password value matches any of the user's passwords.- Parameters:
password
- The user-provided password to verify.- Returns:
true
if the provided password value matches any of the user's passwords.- Throws:
LdapException
- If verification unexpectedly failed.
-