if (udb.supportsPasswordChange()) {
/* Check that the password matches the current policy, if not then
request a new one */
Pattern p = null;
try {
String pattern = Property.getProperty(new RealmKey("security.password.pattern", scheme.getUser().getRealm()
.getResourceId()));
p = ReplacementEngine.getPatternPool().getPattern(pattern, false, false);
if (!p.matcher(new String(credentials.getPassword())).matches()) {
scheme.getServletSession().setAttribute(Constants.PASSWORD_CHANGE_REASON_MESSAGE, new ActionMessage("passwordChange.noLongerMatchesPattern"));
}
} catch (Exception e) {
throw new SecurityErrorException(SecurityErrorException.INTERNAL_ERROR, e, "Could not check password against current policy.");
} finally {
if (p != null) {
ReplacementEngine.getPatternPool().releasePattern(p);
}
}
// Check if the password has expired (or is
try {
if (scheme.getUser().getLastPasswordChange() != null) {
GregorianCalendar lastChange = new GregorianCalendar();
lastChange.setTimeInMillis(scheme.getUser().getLastPasswordChange().getTime());
GregorianCalendar warningOn = new GregorianCalendar();
int warningInDays = Property.getPropertyInt(new RealmKey("security.password.daysBeforeExpiryWarning", scheme.getUser().getRealm()
.getResourceId()));
warningOn.setTimeInMillis(scheme.getUser().getLastPasswordChange().getTime());
warningOn.add(Calendar.DATE, warningInDays);
GregorianCalendar expiresOn = new GregorianCalendar();
expiresOn.setTimeInMillis(scheme.getUser().getLastPasswordChange().getTime());
int expiryInDays = Property.getPropertyInt(new RealmKey("security.password.daysBeforeExpiry", scheme.getUser().getRealm()
.getResourceId()));
expiresOn.add(Calendar.DATE, expiryInDays);
GregorianCalendar now = new GregorianCalendar();