use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class UserBean method create.
/**
* Go to create page
*
* @return forward to CREATE page
*/
public String create() {
user = new User();
// Set default password to "password"
user.setPassword("5baa61e4c9b93f3f0682250b6cf8331b7ee68fd8");
// Set default hours to 8*60
user.setDayDuration(480);
return NavigationResults.CREATE;
}
use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class UserBean method goDocuments.
/**
* Saves and goes to user's document category
*/
public String goDocuments() {
User currentUser = user;
final Integer userId = user.getId();
// Save user's data
save();
// Prepares the category bean filter
final DocumentBean documentBean = (DocumentBean) FacesUtils.getBean("documentBean");
final List<DocumentCategory> categories = new ArrayList<DocumentCategory>();
categories.add(currentUser.getDocumentCategory());
documentBean.setSearchCategoriesValid(true);
documentBean.setSearchCategories(categories);
documentBean.getSearch().setOwnerId(userId);
return "goDocuments";
}
use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class AbstractPasswordBean method changePassword.
/**
* Cambia la password
*/
public String changePassword() {
String result = null;
try {
// Recuperamos el usuario actual
User user = authMgr.getCurrentPrincipal().getUser();
Boolean isReset = user.isResetPassword();
// Comprobamos que la password antigua introducida es correcta
if (!authMgr.checkPassword(user, passwordOld)) {
// Avisamos que la password introducida no es correcta
addErrorMessage("error.invalidPassword");
} else {
if (!this.password.equals(passwordRepe)) {
// Avisamos que las password introducidas no son iguales
addErrorMessage("error.newPasswordsNotEquals");
} else {
if (authMgr.checkPassword(user, password)) {
// Las contraseñas no coinciden
addErrorMessage("error.newPasswordEqualsOldPassword");
} else {
authMgr.changePassword(user, password);
if (!user.isLdapAuthentication()) {
Date expireDate = calcNextExpireDate();
// Establecemos la nueva fecha de expiración
user.setPasswordExpireDate(expireDate);
manager.updateEntity(user, false);
}
if ((isReset != null) && isReset) {
result = NavigationResults.RESET_PASSWORD_OK;
} else {
result = NavigationResults.CHANGE_PASSWORD_OK;
}
}
}
}
} catch (LdapDataAccessException ex) {
String message = ex.getMessage();
if (ex.getCause() != null) {
message = ex.getCause().getMessage();
}
addErrorMessage("error.ppolicy", message);
} catch (BadCredentialsException ex) {
addErrorMessage("error.administrator.needed");
} catch (Exception ex) {
result = returnError(ex);
}
return result;
}
use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class AuthenticationManagerLdapImpl method resetPassword.
public String resetPassword(User user, String[] rnd0, String[] rnd1, String[] rnd2, String[] rnd3, String[] rnd4) {
String changedPassword = generateRandomPassword(rnd0, rnd1, rnd2, rnd3, rnd4);
final User userAdmin = AuthenticationManager.getDefault().getCurrentPrincipal().getUser();
changePassword(user, changedPassword, userAdmin);
activateLdapUserPasswordResetFlag(user, userAdmin);
return changedPassword;
}
use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.
the class LdapCustomAuthenticationProvider method mergeUsers.
protected Principal mergeUsers(LdapUserDetails ldapUser, Principal principalFromDB, String password) {
User user;
Boolean console = false;
if (principalFromDB.getUser() == null) {
user = new User();
console = true;
} else {
user = principalFromDB.getUser();
}
user.setDn(ldapUser.getDn());
user.setLdapName(ldapUser.getDn().replace(",dc=autentia,dc=com", ""));
user.setLdapPassword(password);
user.setActive(ldapUser.isEnabled());
user.setPasswordExpired(checkExpiredPassword(ldapUser.getAttributes()));
user.setResetPassword(checkResetPassword(ldapUser.getAttributes()));
Principal ret;
if (console) {
ret = new Principal(999, 999, user.getLdapName(), user.getLdapPassword(), user.isActive(), user.getName(), 999, principalFromDB.getAuthorities());
} else {
ret = new Principal(user, user.getLdapPassword(), principalFromDB.getAuthorities());
}
return ret;
}
Aggregations