Search in sources :

Example 6 with User

use of com.agiletec.aps.system.services.user.User in project entando-core by entando.

the class UserControllerUnitTest method mockUserDetails.

private UserDetails mockUserDetails() {
    User user1 = new User();
    user1.setUsername("user");
    user1.setDisabled(false);
    user1.setLastAccess(new Date());
    user1.setLastPasswordChange(new Date());
    user1.setMaxMonthsSinceLastAccess(2);
    user1.setMaxMonthsSinceLastPasswordChange(1);
    String password;
    try {
        password = this.getEncrypter().encrypt("password");
    } catch (ApsSystemException ex) {
        password = "plain_password";
    }
    user1.setPassword(password);
    return user1;
}
Also used : User(com.agiletec.aps.system.services.user.User) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Date(java.util.Date)

Example 7 with User

use of com.agiletec.aps.system.services.user.User in project entando-core by entando.

the class UserControllerUnitTest method mockUser.

private UserDto mockUser() {
    User user1 = new User();
    user1.setUsername("user");
    user1.setDisabled(false);
    user1.setLastAccess(new Date());
    user1.setLastPasswordChange(new Date());
    user1.setMaxMonthsSinceLastAccess(2);
    user1.setMaxMonthsSinceLastPasswordChange(1);
    String password;
    try {
        password = this.getEncrypter().encrypt("password");
    } catch (ApsSystemException ex) {
        password = "plain_password";
    }
    user1.setPassword(password);
    return new UserDto(user1);
}
Also used : User(com.agiletec.aps.system.services.user.User) UserDto(org.entando.entando.aps.system.services.user.model.UserDto) ApsSystemException(com.agiletec.aps.system.exception.ApsSystemException) Date(java.util.Date)

Example 8 with User

use of com.agiletec.aps.system.services.user.User in project entando-core by entando.

the class TestCurrentUserProfileAction method init.

private void init() throws Exception {
    try {
        this._userManager = (IUserManager) this.getService(SystemConstants.USER_MANAGER);
        this._authorizationManager = (IAuthorizationManager) this.getService(SystemConstants.AUTHORIZATION_SERVICE);
        User user = this.createUserForTest(USERNAME_FOR_TEST);
        this._userManager.addUser(user);
        this._authorizationManager.addUserAuthorization(USERNAME_FOR_TEST, Group.FREE_GROUP_NAME, "editor");
    } catch (Throwable t) {
        throw new Exception(t);
    }
}
Also used : User(com.agiletec.aps.system.services.user.User)

Example 9 with User

use of com.agiletec.aps.system.services.user.User in project entando-core by entando.

the class TestCurrentUserProfileAction method createUserForTest.

protected User createUserForTest(String username) {
    User user = new User();
    user.setUsername(username);
    user.setPassword(username);
    return user;
}
Also used : User(com.agiletec.aps.system.services.user.User)

Example 10 with User

use of com.agiletec.aps.system.services.user.User in project entando-core by entando.

the class TestUserAction method testResetUser.

public void testResetUser() throws Throwable {
    String username = "username";
    String password = "password";
    String datePattern = "ddMMyyyy";
    String today = DateConverter.getFormattedDate(new Date(), datePattern);
    try {
        this.addUser(username, password);
        User extracted = (User) this._userManager.getUser(username, password);
        assertEquals(today, DateConverter.getFormattedDate(extracted.getCreationDate(), datePattern));
        assertNull(extracted.getLastAccess());
        assertNull(extracted.getLastPasswordChange());
        this.setUserOnSession("admin");
        this.initAction("/do/User", "save");
        this.addParameter("strutsAction", String.valueOf(ApsAdminSystemConstants.EDIT));
        this.addParameter("username", username);
        this.addParameter("reset", "true");
        String result = this.executeAction();
        assertEquals(Action.SUCCESS, result);
        extracted = (User) this._userManager.getUser(username, password);
        assertNotNull(extracted);
        assertEquals(today, DateConverter.getFormattedDate(extracted.getCreationDate(), datePattern));
        assertEquals(today, DateConverter.getFormattedDate(extracted.getLastAccess(), datePattern));
        assertEquals(today, DateConverter.getFormattedDate(extracted.getLastPasswordChange(), datePattern));
    } catch (Throwable t) {
        throw t;
    } finally {
        this._userManager.removeUser(username);
    }
}
Also used : User(com.agiletec.aps.system.services.user.User) Date(java.util.Date)

Aggregations

User (com.agiletec.aps.system.services.user.User)15 Date (java.util.Date)6 ApsSystemException (com.agiletec.aps.system.exception.ApsSystemException)2 UserDto (org.entando.entando.aps.system.services.user.model.UserDto)2 SearcherDaoPaginatedResult (com.agiletec.aps.system.common.model.dao.SearcherDaoPaginatedResult)1 Group (com.agiletec.aps.system.services.group.Group)1 Role (com.agiletec.aps.system.services.role.Role)1 UserDetails (com.agiletec.aps.system.services.user.UserDetails)1 ArrayList (java.util.ArrayList)1 UserDtoBuilder (org.entando.entando.aps.system.services.user.model.UserDtoBuilder)1 PagedMetadata (org.entando.entando.web.common.model.PagedMetadata)1 RestListRequest (org.entando.entando.web.common.model.RestListRequest)1