| | |
| | | boolean debug) |
| | | throws DirectoryException |
| | | { |
| | | |
| | | |
| | | this.userEntry = userEntry; |
| | | this.updateEntry = updateEntry; |
| | | this.debug = debug; |
| | |
| | | private PasswordPolicy getPasswordPolicyInternal() |
| | | throws DirectoryException |
| | | { |
| | | |
| | | |
| | | // See if the user entry contains the ds-pwp-password-policy-dn attribute to |
| | | // select a custom objectclass (whether real or virtual). |
| | | AttributeType type = |
| | |
| | | */ |
| | | private String getValue(AttributeType attributeType) |
| | | { |
| | | |
| | | List<Attribute> attrList = userEntry.getAttribute(attributeType); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | { |
| | |
| | | private long getGeneralizedTime(AttributeType attributeType) |
| | | throws DirectoryException |
| | | { |
| | | |
| | | List<Attribute> attrList = userEntry.getAttribute(attributeType); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | { |
| | |
| | | private List<Long> getGeneralizedTimes(AttributeType attributeType) |
| | | throws DirectoryException |
| | | { |
| | | |
| | | |
| | | ArrayList<Long> timeValues = new ArrayList<Long>(); |
| | | |
| | | List<Attribute> attrList = userEntry.getAttribute(attributeType); |
| | |
| | | private boolean getBoolean(AttributeType attributeType, boolean defaultValue) |
| | | throws DirectoryException |
| | | { |
| | | |
| | | List<Attribute> attrList = userEntry.getAttribute(attributeType); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | | { |
| | |
| | | */ |
| | | public PasswordPolicy getPolicy() |
| | | { |
| | | |
| | | return passwordPolicy; |
| | | } |
| | | |
| | |
| | | */ |
| | | public LinkedList<Modification> getModifications() |
| | | { |
| | | |
| | | return modifications; |
| | | } |
| | | |
| | |
| | | */ |
| | | public LinkedHashSet<AttributeValue> getPasswordValues() |
| | | { |
| | | |
| | | List<Attribute> attrList = |
| | | userEntry.getAttribute(passwordPolicy.getPasswordAttribute()); |
| | | for (Attribute a : attrList) |
| | |
| | | */ |
| | | public boolean requireSecureAuthentication() |
| | | { |
| | | |
| | | return passwordPolicy.requireSecureAuthentication(); |
| | | } |
| | | |
| | |
| | | */ |
| | | public long getCurrentTime() |
| | | { |
| | | |
| | | return currentTime; |
| | | } |
| | | |
| | |
| | | */ |
| | | public String getCurrentGeneralizedTime() |
| | | { |
| | | |
| | | return currentGeneralizedTime; |
| | | } |
| | | |
| | |
| | | */ |
| | | public void setPasswordChangedTime() |
| | | { |
| | | |
| | | if (debug) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | */ |
| | | public boolean isDisabled() |
| | | { |
| | | |
| | | if ((isDisabled == null) || (isDisabled == ConditionResult.UNDEFINED)) |
| | | { |
| | | AttributeType type = |
| | |
| | | */ |
| | | public void setDisabled(boolean isDisabled) |
| | | { |
| | | |
| | | if (debug) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | */ |
| | | public boolean isAccountExpired() |
| | | { |
| | | |
| | | if ((isAccountExpired == null) || |
| | | (isAccountExpired == ConditionResult.UNDEFINED)) |
| | | { |
| | |
| | | */ |
| | | public List<Long> getAuthFailureTimes() |
| | | { |
| | | |
| | | if (authFailureTimes == null) |
| | | { |
| | | AttributeType type = |
| | |
| | | */ |
| | | public void updateAuthFailureTimes() |
| | | { |
| | | |
| | | if (debug) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | */ |
| | | public void clearAuthFailureTimes() |
| | | { |
| | | |
| | | if (debug) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | */ |
| | | public boolean lockedDueToFailures() |
| | | { |
| | | |
| | | |
| | | int maxFailures = passwordPolicy.getLockoutFailureCount(); |
| | | if (maxFailures <= 0) |
| | | { |
| | |
| | | */ |
| | | public int getSecondsUntilUnlock() |
| | | { |
| | | |
| | | if (secondsUntilUnlock < 0) |
| | | { |
| | | return -1; |
| | |
| | | */ |
| | | public void lockDueToFailures() |
| | | { |
| | | |
| | | if (debug) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | */ |
| | | public void clearFailureLockout() |
| | | { |
| | | |
| | | if (debug) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | */ |
| | | public long getLastLoginTime() |
| | | { |
| | | |
| | | if (lastLoginTime == Long.MIN_VALUE) |
| | | { |
| | | AttributeType type = passwordPolicy.getLastLoginTimeAttribute(); |
| | |
| | | */ |
| | | public void setLastLoginTime() |
| | | { |
| | | |
| | | AttributeType type = passwordPolicy.getLastLoginTimeAttribute(); |
| | | String format = passwordPolicy.getLastLoginTimeFormat(); |
| | | |
| | |
| | | */ |
| | | public boolean lockedDueToIdleInterval() |
| | | { |
| | | |
| | | if ((isIdleLocked == null) || (isIdleLocked == ConditionResult.UNDEFINED)) |
| | | { |
| | | if (passwordPolicy.getIdleLockoutInterval() <= 0) |
| | |
| | | */ |
| | | public boolean mustChangePassword() |
| | | { |
| | | |
| | | // If the password policy doesn't use force change on add or force change on |
| | | // reset, or if it forbits the user from changing their password, then this |
| | | // must return false. |
| | |
| | | */ |
| | | public void setMustChangePassword(boolean mustChangePassword) |
| | | { |
| | | |
| | | if (debug) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | */ |
| | | public boolean lockedDueToMaximumResetAge() |
| | | { |
| | | |
| | | if (passwordPolicy.getMaximumPasswordResetAge() <= 0) |
| | | { |
| | | if (debug) |
| | |
| | | */ |
| | | public long getPasswordExpirationTime() |
| | | { |
| | | |
| | | if (expirationTime == Long.MIN_VALUE) |
| | | { |
| | | expirationTime = Long.MAX_VALUE; |
| | |
| | | */ |
| | | public boolean isPasswordExpired() |
| | | { |
| | | |
| | | if ((isPasswordExpired == null) || |
| | | (isPasswordExpired == ConditionResult.UNDEFINED)) |
| | | { |
| | |
| | | */ |
| | | public boolean isWithinMinimumAge() |
| | | { |
| | | |
| | | int minAge = passwordPolicy.getMinimumPasswordAge(); |
| | | if (minAge <= 0) |
| | | { |
| | |
| | | */ |
| | | public boolean mayUseGraceLogin() |
| | | { |
| | | |
| | | if ((mayUseGraceLogin == null) || |
| | | (mayUseGraceLogin == ConditionResult.UNDEFINED)) |
| | | { |
| | |
| | | */ |
| | | public boolean shouldWarn() |
| | | { |
| | | |
| | | if ((shouldWarn == null) || (shouldWarn == ConditionResult.UNDEFINED)) |
| | | { |
| | | getPasswordExpirationTime(); |
| | |
| | | */ |
| | | public boolean isFirstWarning() |
| | | { |
| | | |
| | | if ((isFirstWarning == null) || |
| | | (isFirstWarning == ConditionResult.UNDEFINED)) |
| | | { |
| | |
| | | */ |
| | | public int getSecondsUntilExpiration() |
| | | { |
| | | |
| | | long expirationTime = getPasswordExpirationTime(); |
| | | if (expirationTime < 0) |
| | | { |
| | |
| | | */ |
| | | public long getRequiredChangeTime() |
| | | { |
| | | |
| | | if (requiredChangeTime == Long.MIN_VALUE) |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | |
| | | */ |
| | | public void setRequiredChangeTime() |
| | | { |
| | | |
| | | if (debug) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | */ |
| | | public long getWarnedTime() |
| | | { |
| | | |
| | | |
| | | if (warnedTime == Long.MIN_VALUE) |
| | | { |
| | | AttributeType type = |
| | |
| | | */ |
| | | public void setWarnedTime() |
| | | { |
| | | |
| | | long warnTime = getWarnedTime(); |
| | | if (warnTime == currentTime) |
| | | { |
| | |
| | | */ |
| | | public void clearWarnedTime() |
| | | { |
| | | |
| | | AttributeType type = |
| | | DirectoryServer.getAttributeType(OP_ATTR_PWPOLICY_WARNED_TIME, true); |
| | | if (updateEntry) |
| | |
| | | */ |
| | | public List<Long> getGraceLoginTimes() |
| | | { |
| | | |
| | | |
| | | if (graceLoginTimes == null) |
| | | { |
| | | AttributeType type = DirectoryServer.getAttributeType( |
| | |
| | | */ |
| | | public int getGraceLoginsRemaining() |
| | | { |
| | | |
| | | int maxGraceLogins = passwordPolicy.getGraceLoginCount(); |
| | | if (maxGraceLogins <= 0) |
| | | { |
| | |
| | | */ |
| | | public void updateGraceLoginTimes() |
| | | { |
| | | |
| | | if (debug) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | */ |
| | | public void clearGraceLoginTimes() |
| | | { |
| | | |
| | | if (debug) |
| | | { |
| | | if (debugEnabled()) |
| | |
| | | */ |
| | | public boolean passwordMatches(ByteString password) |
| | | { |
| | | |
| | | |
| | | List<Attribute> attrList = |
| | | userEntry.getAttribute(passwordPolicy.getPasswordAttribute()); |
| | | if ((attrList == null) || attrList.isEmpty()) |
| | |
| | | */ |
| | | public boolean passwordIsPreEncoded(ByteString passwordValue) |
| | | { |
| | | |
| | | if (passwordPolicy.usesAuthPasswordSyntax()) |
| | | { |
| | | return AuthPasswordSyntax.isEncoded(passwordValue); |
| | |
| | | public List<ByteString> encodePassword(ByteString password) |
| | | throws DirectoryException |
| | | { |
| | | |
| | | List<PasswordStorageScheme> schemes = |
| | | passwordPolicy.getDefaultStorageSchemes(); |
| | | List<ByteString> encodedPasswords = |
| | |
| | | Set<ByteString> currentPasswords, |
| | | StringBuilder invalidReason) |
| | | { |
| | | |
| | | for (DN validatorDN : passwordPolicy.getPasswordValidators().keySet()) |
| | | { |
| | | PasswordValidator validator = |
| | |
| | | */ |
| | | public void handleDeprecatedStorageSchemes(ByteString password) |
| | | { |
| | | |
| | | if (passwordPolicy.getDefaultStorageSchemes().isEmpty()) |
| | | { |
| | | if (debug) |
| | |
| | | public ByteString generatePassword() |
| | | throws DirectoryException |
| | | { |
| | | |
| | | PasswordGenerator generator = passwordPolicy.getPasswordGenerator(); |
| | | if (generator == null) |
| | | { |
| | |
| | | AccountStatusNotificationType notificationType, |
| | | DN userDN, int messageID, String message) |
| | | { |
| | | |
| | | |
| | | Collection<AccountStatusNotificationHandler> handlers = |
| | | passwordPolicy.getAccountStatusNotificationHandlers().values(); |
| | | if ((handlers == null) || handlers.isEmpty()) |
| | |
| | | public void generateAccountStatusNotification( |
| | | AccountStatusNotification notification) |
| | | { |
| | | |
| | | |
| | | Collection<AccountStatusNotificationHandler> handlers = |
| | | passwordPolicy.getAccountStatusNotificationHandlers().values(); |
| | | if ((handlers == null) || handlers.isEmpty()) |
| | |
| | | public void updateUserEntry() |
| | | throws DirectoryException |
| | | { |
| | | |
| | | |
| | | // If there are no modifications, then there's nothing to do. |
| | | if (modifications.isEmpty()) |
| | | { |