| | |
| | | private static final LocalizedLogger logger = LocalizedLogger.getLoggerForThisClass(); |
| | | |
| | | |
| | | |
| | | /** The string representation of the user's DN. */ |
| | | private final String userDNString; |
| | | |
| | |
| | | |
| | | /** Indicates whether the user's account is expired. */ |
| | | private ConditionResult isAccountExpired = ConditionResult.UNDEFINED; |
| | | |
| | | /** Indicates whether the user's password is expired. */ |
| | | private ConditionResult isPasswordExpired = ConditionResult.UNDEFINED; |
| | | |
| | | /** Indicates whether the warning to send to the client would be the first warning for the user. */ |
| | | private ConditionResult isFirstWarning = ConditionResult.UNDEFINED; |
| | | |
| | | /** Indicates whether the user's account is locked by the idle lockout. */ |
| | | private ConditionResult isIdleLocked = ConditionResult.UNDEFINED; |
| | | |
| | | /** |
| | | * Indicates whether the user may use a grace login if the password is expired and there are one |
| | | * or more grace logins remaining. |
| | | */ |
| | | private ConditionResult mayUseGraceLogin = ConditionResult.UNDEFINED; |
| | | |
| | | /** Indicates whether the user's password must be changed. */ |
| | | private ConditionResult mustChangePassword = ConditionResult.UNDEFINED; |
| | | |
| | | /** Indicates whether the user should be warned of an upcoming expiration. */ |
| | | private ConditionResult shouldWarn = ConditionResult.UNDEFINED; |
| | | |
| | |
| | | |
| | | /** The set of authentication failure times for this user. */ |
| | | private List<Long> authFailureTimes; |
| | | |
| | | /** The set of grace login times for this user. */ |
| | | private List<Long> graceLoginTimes; |
| | | |
| | | /** The time that the user's account should expire (or did expire). */ |
| | | private long accountExpirationTime = Long.MIN_VALUE; |
| | | |
| | | /** The time that the user's entry was locked due to too many authentication failures. */ |
| | | private long failureLockedTime = Long.MIN_VALUE; |
| | | |
| | | /** The time that the user last authenticated to the Directory Server. */ |
| | | private long lastLoginTime = Long.MIN_VALUE; |
| | | |
| | | /** The time that the user's password should expire (or did expire). */ |
| | | private long passwordExpirationTime = Long.MIN_VALUE; |
| | | |
| | | /** The last required change time with which the user complied. */ |
| | | private long requiredChangeTime = Long.MIN_VALUE; |
| | | |
| | | /** The time that the user was first warned about an upcoming expiration. */ |
| | | private long warnedTime = Long.MIN_VALUE; |
| | | |
| | |
| | | } |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public PasswordPolicy getAuthenticationPolicy() |
| | | { |
| | |
| | | |
| | | if (valuesToRemove != null) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(type); |
| | | builder.addAll(valuesToRemove); |
| | | Attribute a = builder.toAttribute(); |
| | | Attribute a = newAttribute(type, valuesToRemove); |
| | | modifications.add(new Modification(ModificationType.DELETE, a, true)); |
| | | } |
| | | } |
| | |
| | | |
| | | |
| | | List<Long> failureTimes = getAuthFailureTimes(); |
| | | // Note: failureTimes == this.authFailureTimes |
| | | long highestFailureTime = -1; |
| | | for (Long l : failureTimes) |
| | | { |
| | | highestFailureTime = Math.max(l, highestFailureTime); |
| | | } |
| | | |
| | | if (highestFailureTime >= currentTime) |
| | | { |
| | | highestFailureTime++; |
| | | } |
| | | else |
| | | { |
| | | highestFailureTime = currentTime; |
| | | } |
| | | long highestFailureTime = computeHighestTime(failureTimes); |
| | | // Update the current policy state |
| | | failureTimes.add(highestFailureTime); |
| | | |
| | |
| | | AttributeBuilder builder = new AttributeBuilder(type); |
| | | long highestFailureTime = -1; |
| | | |
| | | for (Long l : authFailureTimes) |
| | | for (long l : authFailureTimes) |
| | | { |
| | | highestFailureTime = Math.max(l, highestFailureTime); |
| | | builder.add(GeneralizedTimeSyntax.format(l)); |
| | |
| | | return locked; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * Returns whether the account was locked for any reason. |
| | | * |
| | | * @return true if the account is locked, false otherwise |
| | | */ |
| | | public boolean isLocked() |
| | | { |
| | | return lockedDueToIdleInterval() || lockedDueToMaximumResetAge() || lockedDueToFailures(); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the time that the user's password should expire (if the expiration is in the future) or |
| | |
| | | } |
| | | |
| | | List<Long> graceTimes = getGraceLoginTimes(); |
| | | long highestGraceTime = -1; |
| | | for (Long l : graceTimes) |
| | | { |
| | | highestGraceTime = Math.max(l, highestGraceTime); |
| | | } |
| | | |
| | | if (highestGraceTime >= currentTime) |
| | | { |
| | | highestGraceTime++; |
| | | } |
| | | else |
| | | { |
| | | highestGraceTime = currentTime; |
| | | } |
| | | long highestGraceTime = computeHighestTime(graceTimes); |
| | | graceTimes.add(highestGraceTime); // graceTimes == this.graceLoginTimes |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault( |
| | |
| | | modifications.add(new Modification(ModificationType.ADD, addAttr, true)); |
| | | } |
| | | |
| | | private long computeHighestTime(List<Long> graceTimes) |
| | | { |
| | | long highestTime = -1; |
| | | for (long l : graceTimes) |
| | | { |
| | | highestTime = Math.max(l, highestTime); |
| | | } |
| | | |
| | | if (highestTime >= currentTime) |
| | | { |
| | | highestTime++; |
| | | } |
| | | else |
| | | { |
| | | highestTime = currentTime; |
| | | } |
| | | return highestTime; |
| | | } |
| | | |
| | | |
| | | |
| | | /** |
| | |
| | | |
| | | AttributeType type = DirectoryServer.getAttributeTypeOrDefault(OP_ATTR_PWPOLICY_GRACE_LOGIN_TIME_LC); |
| | | AttributeBuilder builder = new AttributeBuilder(type); |
| | | for (Long l : graceLoginTimes) |
| | | for (long l : graceLoginTimes) |
| | | { |
| | | builder.add(GeneralizedTimeSyntax.format(l)); |
| | | } |
| | |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public boolean passwordMatches(ByteString password) |
| | | { |
| | |
| | | return; |
| | | } |
| | | |
| | | AttributeBuilder builder = new AttributeBuilder(type); |
| | | builder.addAll(removedValues); |
| | | Attribute a = builder.toAttribute(); |
| | | Attribute a = newAttribute(type, removedValues); |
| | | modifications.add(new Modification(ModificationType.DELETE, a, true)); |
| | | |
| | | if (! addedValues.isEmpty()) |
| | | { |
| | | builder = new AttributeBuilder(type); |
| | | builder.addAll(addedValues); |
| | | Attribute a2 = builder.toAttribute(); |
| | | Attribute a2 = newAttribute(type, addedValues); |
| | | modifications.add(new Modification(ModificationType.ADD, a2, true)); |
| | | } |
| | | |
| | |
| | | while (iterator.hasNext()) |
| | | { |
| | | long historyDate = iterator.next(); |
| | | if (historyDate < retainDate) |
| | | { |
| | | iterator.remove(); |
| | | } |
| | | else |
| | | if (historyDate >= retainDate) |
| | | { |
| | | break; |
| | | } |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | |
| | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | logger.trace("Could not decode the timestamp in history value " + histStr + " -- " + e + |
| | | ". Marking it for removal."); |
| | | } |
| | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.traceException(e); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Returning false because of an exception: " + stackTraceToSingleLineString(e)); |
| | | } |
| | | logger.trace("Returning false because of an exception: " + stackTraceToSingleLineString(e)); |
| | | } |
| | | |
| | | return false; |
| | |
| | | |
| | | if (! removeValues.isEmpty()) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(historyType); |
| | | builder.addAll(removeValues); |
| | | removeAttrs.add(builder.toAttribute()); |
| | | removeAttrs.add(newAttribute(historyType, removeValues)); |
| | | } |
| | | } |
| | | |
| | |
| | | while (iterator.hasNext()) |
| | | { |
| | | long timestamp = iterator.next(); |
| | | if (timestamp < minAgeToKeep) |
| | | { |
| | | ByteString v = historyMap.get(timestamp); |
| | | removeValues.add(v); |
| | | iterator.remove(); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Removing history value %s to preserve the history duration.", v); |
| | | } |
| | | } |
| | | else |
| | | if (timestamp >= minAgeToKeep) |
| | | { |
| | | break; |
| | | } |
| | | |
| | | ByteString v = historyMap.get(timestamp); |
| | | removeValues.add(v); |
| | | iterator.remove(); |
| | | |
| | | if (logger.isTraceEnabled()) |
| | | { |
| | | logger.trace("Removing history value %s to preserve the history duration.", v); |
| | | } |
| | | } |
| | | |
| | | if (! removeValues.isEmpty()) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(historyType); |
| | | builder.addAll(removeValues); |
| | | removeAttrs.add(builder.toAttribute()); |
| | | removeAttrs.add(newAttribute(historyType, removeValues)); |
| | | } |
| | | } |
| | | |
| | |
| | | modifications.add(new Modification(ModificationType.ADD, newHistAttr, true)); |
| | | } |
| | | |
| | | |
| | | private Attribute newAttribute(AttributeType type, LinkedHashSet<ByteString> values) |
| | | { |
| | | AttributeBuilder builder = new AttributeBuilder(type); |
| | | builder.addAll(values); |
| | | return builder.toAttribute(); |
| | | } |
| | | |
| | | /** |
| | | * Retrieves the password history state values for the user. This is only intended for testing purposes. |
| | |
| | | |
| | | |
| | | |
| | | /** {@inheritDoc} */ |
| | | @Override |
| | | public void finalizeStateAfterBind() |
| | | throws DirectoryException |