{
try
{
boolean passwordSet = false;
UserManager manager = (UserManager) getManager();
PasswordCredential credential = manager
.getPasswordCredential((User) getPrincipal());
if (getCredentialValue() != null
&& getCredentialValue().trim().length() > 0)
{
credential.setPassword(null, getCredentialValue());
getServiceLocator()
.getAuditActivity()
.logAdminCredentialActivity(
getPortletRequest()
.getUserPrincipal()
.getName(),
getIPAddress(),
getPrincipal().getName(),
AuditActivity.PASSWORD_RESET,
AdminPortletWebPage.USER_ADMINISTRATION);
passwordSet = true;
}
if (getCredentialUpdateRequired() != credential
.isUpdateRequired())
{
credential
.setUpdateRequired(getCredentialUpdateRequired());
getServiceLocator()
.getAuditActivity()
.logAdminCredentialActivity(
getPortletRequest()
.getUserPrincipal()
.getName(),
getIPAddress(),
getPrincipal().getName(),
AuditActivity.PASSWORD_UPDATE_REQUIRED,
AdminPortletWebPage.USER_ADMINISTRATION);
}
if (getCredentialEnabled() != credential.isEnabled())
{
credential.setEnabled(getCredentialEnabled());
String activity = (getCredentialEnabled() ? AuditActivity.PASSWORD_ENABLED
: AuditActivity.PASSWORD_DISABLED);
getServiceLocator()
.getAuditActivity()
.logAdminCredentialActivity(
getPortletRequest()
.getUserPrincipal()
.getName(),
getIPAddress(),
getPrincipal().getName(),
activity,
AdminPortletWebPage.USER_ADMINISTRATION);
}
String expiredFlagStr = getUserExpiredFlag();
if (expiredFlagStr != null)
{
if (!passwordSet
&& expiredFlagStr.equals("expired"))
{
java.sql.Date today = new java.sql.Date(
new Date().getTime());
credential.setExpirationDate(today);
getServiceLocator()
.getAuditActivity()
.logAdminCredentialActivity(
getPortletRequest()
.getUserPrincipal()
.getName(),
getIPAddress(),
getPrincipal().getName(),
AuditActivity.PASSWORD_EXPIRE,
AdminPortletWebPage.USER_ADMINISTRATION);
} else if (expiredFlagStr.equals("extend"))
{
// getUserManager().setPasswordExpiration(getUserName(),
// null);
// TODO confirm with Ate/David
credential.setExpirationDate(MAX_DATE);
getServiceLocator()
.getAuditActivity()
.logAdminCredentialActivity(
getPortletRequest()
.getUserPrincipal()
.getName(),
getIPAddress(),
getPrincipal().getName(),
AuditActivity.PASSWORD_EXTEND,
AdminPortletWebPage.USER_ADMINISTRATION);
} else if (expiredFlagStr.equals("unlimited"))
{
credential.setExpirationDate(MAX_DATE);
getServiceLocator()
.getAuditActivity()
.logAdminCredentialActivity(
getPortletRequest()
.getUserPrincipal()