Search in sources :

Example 11 with User

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

the class ReportBean method getUsers.

public ArrayList<SelectItem> getUsers() {
    ArrayList<SelectItem> ret = new ArrayList<SelectItem>();
    List<User> refs = userDAO.search(new SortCriteria("name"));
    for (User ref : refs) {
        ret.add(new SelectItem(ref.getId().toString(), 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 12 with User

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

the class SpringUtilsForTesting method createUser.

public static User createUser(String login) {
    final User user = new User();
    user.setLogin(login);
    user.setPassword(login);
    user.setName(login);
    user.setRole(createRoleInContext());
    user.setDepartment(createDepartmentInContext());
    user.setCategory(createUserCategoryInContext());
    user.setAgreement(createAgreementInContext());
    user.setActive(true);
    user.setStartDate(new java.util.Date());
    return user;
}
Also used : User(com.autentia.tnt.businessobject.User)

Example 13 with User

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

the class LdapCustomAuthenticationProviderTest method shouldCallLoadUserFromServiceWhenCreateUserDetailsIsCalled.

@Test
public void shouldCallLoadUserFromServiceWhenCreateUserDetailsIsCalled() {
    User user = getUserForTest();
    Principal principal = mock(Principal.class);
    when(userDetailsService.loadUserByUsername(USERNAME)).thenReturn(principal);
    when(principal.getUser()).thenReturn(user);
    when(principal.getAuthorities()).thenReturn(new GrantedAuthority[1]);
    when(ldapUserDetails.getAttributes()).thenReturn(mock(Attributes.class));
    sut.createUserDetails(ldapUserDetails, USERNAME, PASSWORD);
    verify(userDetailsService).loadUserByUsername(USERNAME);
    verify(ldapUserDetails).isEnabled();
}
Also used : User(com.autentia.tnt.businessobject.User) BasicAttributes(javax.naming.directory.BasicAttributes) Attributes(javax.naming.directory.Attributes) Test(org.junit.Test)

Example 14 with User

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

the class LdapCustomAuthenticationProviderTest method shouldSetExpiredPasswordWhenPwdGraceUseTimeIsActive.

@Test
public void shouldSetExpiredPasswordWhenPwdGraceUseTimeIsActive() {
    Attribute pwdGraceUseTime = new BasicAttribute("pwdGraceUseTime");
    Attributes attributes = new BasicAttributes();
    attributes.put(pwdGraceUseTime);
    when(ldapUserDetails.getAttributes()).thenReturn(attributes);
    User userForTest = getUserForTest();
    Boolean passExpired = sut.checkExpiredPassword(ldapUserDetails.getAttributes());
    userForTest.setPasswordExpired(passExpired);
    assertThat(passExpired, is(true));
}
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 15 with User

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

the class LdapCustomAuthenticationProviderTest method getUserForTest.

private User getUserForTest() {
    Role role = mock(Role.class);
    when(role.getId()).thenReturn(1);
    User user = mock(User.class);
    when(user.getId()).thenReturn(1);
    when(user.getDepartmentId()).thenReturn(1);
    when(user.getLogin()).thenReturn("login");
    when(user.getLdapPassword()).thenReturn("ldapPassword");
    when(user.isActive()).thenReturn(true);
    when(user.getName()).thenReturn("name");
    when(user.getRole()).thenReturn(role);
    return user;
}
Also used : Role(com.autentia.tnt.businessobject.Role) 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