Search in sources :

Example 16 with User

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

the class LdapCustomAuthenticationProviderTest method shouldMergeDbUserWithLdapCredentialsTest.

@Test
public void shouldMergeDbUserWithLdapCredentialsTest() {
    Attribute pwdGraceUseTime = new BasicAttribute("pwdGraceUseTime");
    pwdGraceUseTime.add(new Date());
    Attributes attributes = new BasicAttributes();
    attributes.put(pwdGraceUseTime);
    when(ldapUserDetails.getAttributes()).thenReturn(attributes);
    User user = getUserForTest();
    final Principal principal = new Principal(user, new GrantedAuthority[] {});
    final String ldapPassword = "ldapPassword";
    final Principal ldapPrincipal = sut.mergeUsers(ldapUserDetails, principal, ldapPassword);
    assertThat(ldapPrincipal.getPassword(), is(ldapPassword));
    assertThat(ldapPrincipal.getUser().getLdapPassword(), is(ldapPassword));
    assertThat(ldapPrincipal.getUser().getPassword(), is(nullValue()));
    assertThat(ldapPrincipal.getUser().isActive(), 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) Date(java.util.Date) Test(org.junit.Test)

Example 17 with User

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

the class SpringUtilsForTesting method createUserInContextWithRoleAndDepartment.

public static User createUserInContextWithRoleAndDepartment() {
    setUserForTestingInContext();
    final User user = new User();
    user.setLogin("admin");
    user.setRole(createRoleInContext());
    user.setDepartment(createDepartmentInContext());
    user.setCategory(createUserCategoryInContext());
    user.setAgreement(createAgreementInContext());
    final UserDAO userDao = (UserDAO) appCtx.getBean("daoUser");
    userDao.insert(user);
    user.setActive(true);
    return user;
}
Also used : User(com.autentia.tnt.businessobject.User) UserDAO(com.autentia.tnt.dao.hibernate.UserDAO)

Example 18 with User

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

the class AuthenticationManagerLdapImplTest method resetPassword.

@Test
public void resetPassword() throws Exception {
    User userAdmin = getUserAdmin();
    Principal principal = mock(Principal.class);
    when(principal.getUser()).thenReturn(userAdmin);
    when(authenticationManager.getCurrentPrincipal()).thenReturn(principal);
    final String randomPassword = sut.generateRandomPassword(RANDOM, RANDOM, RANDOM, RANDOM, RANDOM);
    doNothing().when(authManagerLdapTemplate).modifyAttributes(any(DirContext.class), eq(user), any(ModificationItem[].class));
    sut.resetPassword(user, RANDOM, RANDOM, RANDOM, RANDOM, RANDOM);
    verify(authManagerLdapTemplate).changePassword(user, randomPassword, userAdmin);
    verify(authManagerLdapTemplate, times(2)).getTemplate(userAdmin);
    verify(authManagerLdapTemplate).getCallback(user, randomPassword);
    verify(authManagerLdapTemplate).getCallback(user);
    verify(authManagerLdapTemplate).changeLdapUserPassword(any(DirContext.class), eq(randomPassword), eq(user));
    verify(authManagerLdapTemplate).setLdapUserPasswordResetFlag(any(DirContext.class), eq(user));
}
Also used : User(com.autentia.tnt.businessobject.User) DirContext(javax.naming.directory.DirContext) Test(org.junit.Test)

Example 19 with User

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

the class AuthenticationManagerLdapImplTest method getUser.

private User getUser() {
    User user = new User();
    user.setLdapPassword(PASSWORD);
    user.setPasswordExpired(Boolean.TRUE);
    user.setDn("dc=autentia,dc=com");
    user.setLdapName("uid=user");
    user.setLogin("user");
    return user;
}
Also used : User(com.autentia.tnt.businessobject.User)

Example 20 with User

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

the class AuthenticationManagerLdapImplTest method changeAsAdminPassword.

@Test
public void changeAsAdminPassword() throws Exception {
    User userAdmin = getUserAdmin();
    doNothing().when(authManagerLdapTemplate).modifyAttributes(any(DirContext.class), eq(user), any(ModificationItem[].class));
    sut.changePassword(user, NEW_PASSWORD, userAdmin);
    verify(authManagerLdapTemplate).changePassword(user, NEW_PASSWORD, userAdmin);
    verify(authManagerLdapTemplate).getTemplate(userAdmin);
    verify(authManagerLdapTemplate).getCallback(user, NEW_PASSWORD);
    verify(authManagerLdapTemplate).changeLdapUserPassword(any(DirContext.class), eq(NEW_PASSWORD), eq(user));
}
Also used : User(com.autentia.tnt.businessobject.User) DirContext(javax.naming.directory.DirContext) 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