Search in sources :

Example 6 with User

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;
}
Also used : User(com.autentia.tnt.businessobject.User)

Example 7 with User

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";
}
Also used : User(com.autentia.tnt.businessobject.User) DocumentBean(com.autentia.tnt.bean.document.DocumentBean) ArrayList(java.util.ArrayList) DocumentCategory(com.autentia.tnt.businessobject.DocumentCategory)

Example 8 with User

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;
}
Also used : LdapDataAccessException(org.acegisecurity.ldap.LdapDataAccessException) User(com.autentia.tnt.businessobject.User) BadCredentialsException(org.acegisecurity.BadCredentialsException) Date(java.util.Date) BadCredentialsException(org.acegisecurity.BadCredentialsException) LdapDataAccessException(org.acegisecurity.ldap.LdapDataAccessException)

Example 9 with User

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;
}
Also used : User(com.autentia.tnt.businessobject.User)

Example 10 with User

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;
}
Also used : User(com.autentia.tnt.businessobject.User)

Aggregations

User (com.autentia.tnt.businessobject.User)70 Test (org.junit.Test)24 ArrayList (java.util.ArrayList)17 SortCriteria (com.autentia.tnt.dao.SortCriteria)15 SelectItem (javax.faces.model.SelectItem)11 UserDAO (com.autentia.tnt.dao.hibernate.UserDAO)10 Date (java.util.Date)9 Link (com.autentia.tnt.businessobject.Link)6 UserSearch (com.autentia.tnt.dao.search.UserSearch)5 Attributes (javax.naming.directory.Attributes)5 BasicAttributes (javax.naming.directory.BasicAttributes)5 Activity (com.autentia.tnt.businessobject.Activity)4 Attribute (javax.naming.directory.Attribute)4 BasicAttribute (javax.naming.directory.BasicAttribute)4 GlobalHourReport (com.autentia.tnt.businessobject.GlobalHourReport)3 GlobalHoursReportBean (com.autentia.tnt.bean.activity.GlobalHoursReportBean)2 Commissioning (com.autentia.tnt.businessobject.Commissioning)2 Objective (com.autentia.tnt.businessobject.Objective)2 Occupation (com.autentia.tnt.businessobject.Occupation)2 DataIntegrityException (com.autentia.tnt.dao.DataIntegrityException)2