Search in sources :

Example 41 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class AdminHolidayBean method getUserRequests.

// Getters to list possible values of related entities
/**
 * Get the list of all userRequests
 * @return the list of all userRequests
 */
public List<SelectItem> getUserRequests() {
    List<User> refs = UserManager.getDefault().getAllEntities(null, new SortCriteria("name"));
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    for (User ref : refs) {
        ret.add(new SelectItem(ref, ref.getName()));
    }
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) User(com.autentia.tnt.businessobject.User) SelectItem(javax.faces.model.SelectItem) ArrayList(java.util.ArrayList)

Example 42 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class RequestHolidayBean method validateHasEnoughAvailableFreeHoliday.

private boolean validateHasEnoughAvailableFreeHoliday() {
    User user = AuthenticationManager.getDefault().getCurrentPrincipal().getUser();
    int requestedDays = UserHolidaysStateManager.getDefault().getWorkingDays(this.getBeginDate(), this.getFinalDate());
    int freeDays = UserHolidaysStateManager.getDefault().getFreeDays(user, this.getChargeYear());
    if (log.isDebugEnabled()) {
        log.debug("Solicito " + requestedDays + " dias. Le quedan libres " + freeDays + " dias");
    }
    return (requestedDays <= freeDays);
}
Also used : User(com.autentia.tnt.businessobject.User)

Example 43 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class AvailabilityBean method getAll.

public List<Availability> getAll() {
    List<Availability> ret = new ArrayList<Availability>();
    UserSearch searchUser = new UserSearch();
    searchUser.setActive(true);
    SortCriteria sCriteria = new SortCriteria("name");
    List<User> users = userMgr.getAllEntities(searchUser, sCriteria);
    for (User user : users) {
        OcupationModelImpl model = new OcupationModelImpl();
        Availability availability = new Availability();
        availability.setUser(user);
        availability.setModel(model);
        fillModelHolidays(user, model);
        fillAvailability(user, model);
        ret.add(availability);
    }
    return ret;
}
Also used : SortCriteria(com.autentia.tnt.dao.SortCriteria) User(com.autentia.tnt.businessobject.User) ArrayList(java.util.ArrayList) UserSearch(com.autentia.tnt.dao.search.UserSearch)

Example 44 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class LdapCustomAuthenticationProviderTest method shouldNotSetExpiredPasswordWhenPwdGraceUseTimeIsActive.

@Test
public void shouldNotSetExpiredPasswordWhenPwdGraceUseTimeIsActive() {
    Attribute noPwdGrace = new BasicAttribute("noPwdGrace");
    Attributes attributes = new BasicAttributes();
    attributes.put(noPwdGrace);
    when(ldapUserDetails.getAttributes()).thenReturn(attributes);
    User userForTest = getUserForTest();
    Boolean passExpired = sut.checkExpiredPassword(ldapUserDetails.getAttributes());
    userForTest.setPasswordExpired(passExpired);
    assertThat(passExpired, is(false));
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) User(com.autentia.tnt.businessobject.User) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) Test(org.junit.Test)

Example 45 with User

use of com.autentia.tnt.businessobject.User in project TNTConcept by autentia.

the class LdapCustomAuthenticationProviderTest method shouldMergeDbUserWithLdapCredentialsWhenMigrationTest.

@Test
public void shouldMergeDbUserWithLdapCredentialsWhenMigrationTest() {
    Attribute pwdGraceUseTime = new BasicAttribute("pwdGraceUseTime");
    pwdGraceUseTime.add(new Date());
    Attributes attributes = new BasicAttributes();
    attributes.put(pwdGraceUseTime);
    when(ldapUserDetails.getAttributes()).thenReturn(attributes);
    User user = getUserForTest();
    Principal principal = new Principal(user, new GrantedAuthority[] {});
    principal.dto = null;
    final String ldapPassword = "ldapPassword";
    final Principal ldapPrincipal = sut.mergeUsers(ldapUserDetails, principal, ldapPassword);
    assertThat(ldapPrincipal.getId(), is(999));
    assertThat(ldapPrincipal.getPassword(), is(ldapPassword));
}
Also used : BasicAttribute(javax.naming.directory.BasicAttribute) BasicAttributes(javax.naming.directory.BasicAttributes) User(com.autentia.tnt.businessobject.User) BasicAttribute(javax.naming.directory.BasicAttribute) Attribute(javax.naming.directory.Attribute) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) Date(java.util.Date) Test(org.junit.Test)

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