try
{
if ( request.getRequest().getUserPrincipal() != null )
{
Subject subject = request.getSubject();
UserCredential userCredential = SubjectHelper.getUserCredential(subject);
Integer passwordDaysValid = null;
// check for an existing password credential
if ( userCredential != null )
{
if ( userCredential.isUpdateRequired() )
{
passwordDaysValid = new Integer(0); // required change
}
if ( request.getSessionAttribute(CHECKED_KEY) == null )
{
request.setSessionAttribute(CHECKED_KEY,Boolean.TRUE);
if ( userCredential.getPreviousAuthenticationDate() != null &&
userCredential.getLastAuthenticationDate() != null &&
userCredential.getExpirationDate() != null )
{
long expirationTime = userCredential.getExpirationDate().getTime();
long lastAuthTime = userCredential.getLastAuthenticationDate().getTime();
int lastAuthDaysBeforeExpiration = (int)((expirationTime-lastAuthTime)/(24*60*60*1000));
if ( lastAuthDaysBeforeExpiration < 1 )
{
passwordDaysValid = new Integer(1);
}
else if (expirationWarningDays.length > 0)
{
long prevAuthTime = Long.MIN_VALUE;
if (userCredential.getPreviousAuthenticationDate() != null )
{
prevAuthTime = userCredential.getPreviousAuthenticationDate().getTime();
}
int prevAuthDaysBeforeExpiration = (int)((expirationTime-prevAuthTime)/(24*60*60*1000));
if ( prevAuthDaysBeforeExpiration > lastAuthDaysBeforeExpiration )
{
for ( int i = 0; i < expirationWarningDays.length; i++ )