Package com.agiletec.aps.system.services.user

Examples of com.agiletec.aps.system.services.user.User


  }
 
  public void testDeactivateUser() throws ApsSystemException {
    String username = "username_test";
    try {
      User user = new User();
      user.setDisabled(false);
      user.setUsername(username);
      user.setPassword("password");
      _userManager.addUser(user);
      user = (User) _userManager.getUser(username);
      assertNotNull(user);
      assertFalse(user.isDisabled());
      _userRegManager.deactivateUser(user);
      user = (User) _userManager.getUser(username);
      assertNotNull(user);
      assertTrue(user.isDisabled());
    } finally {
      //    clean
      _userManager.removeUser(username);
    }
  }
View Full Code Here


 
  public void testGetUsernameFromToken() throws Exception {
    String username = "username_test";
    String token = "token_test";
    try {
      User user = new User();
      user.setDisabled(true);
      user.setUsername(username);
      user.setPassword("password");
      _userManager.addUser(user);
      _userRegDAO.addActivationToken(username, token, new Date(), IUserRegDAO.REACTIVATION_RECOVER_TOKEN_TYPE);
      String checkUsername = _userRegManager.getUsernameFromToken(token);
      assertNotNull(checkUsername);
      assertEquals(user.getUsername(), checkUsername);
    } finally {
      //    clean
      _userManager.removeUser(username);
      _userRegDAO.clearTokenByUsername(username);
    }
View Full Code Here

  public void testAddActivationToken_ClearOldAccountRequests_GetUsernameFromToken() throws Exception {
    Calendar calendar = Calendar.getInstance();
    calendar.set(2000, 01, 01);
    String token = "test_token";
    String username = "test_username";
    User user = new User();
    user.setDisabled(true);
    user.setUsername(username);
    user.setPassword("password");
    _userManager.addUser(user);
    _userRegDAO.addActivationToken(username, token, calendar.getTime(), IUserRegDAO.ACTIVATION_TOKEN_TYPE);
    username = _userRegDAO.getUsernameFromToken(token);
    assertNotNull(username);
    _userRegManager.clearOldAccountRequests();
View Full Code Here

  }
 
  @Override
  public void regAccount(IUserProfile userProfile) throws ApsSystemException {
    try {
      User user = new User();
      user.setDisabled(true);
      user.setUsername(userProfile.getUsername());
      user.setProfile(userProfile);
      user.setPassword("");
      String token = this.createToken(userProfile.getUsername());
      this.sendAlertRegProfile((IUserProfile) user.getProfile(), token);
      this.getUserManager().addUser(user);
      this.getUserRegDAO().addActivationToken(userProfile.getUsername(), token, new Date(), IUserRegDAO.ACTIVATION_TOKEN_TYPE);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "regAccount");
      throw new ApsSystemException("Error in Account registration", t);
View Full Code Here

  @Override
  public void activateUser(String username, String password, String token) throws ApsSystemException {
    try {
      IUserManager userManager = this.getUserManager();
      this.clearOldAccountRequests();
      User user = (User) userManager.getUser(username);
      user.setLastPasswordChange(new Date());
      user.setPassword(password);
      user.setDisabled(false);
      this.loadUserDefaultRoles(user);
      this.loadUserDefaultGroups(user);
      userManager.updateUser(user);
      userManager.changePassword(username, password);// Per salvare password non in chiaro
      this.getUserRegDAO().removeConsumedToken(token);
View Full Code Here

  @Override
  public void reactivateUser(String username, String password, String token) throws ApsSystemException {
    try {
      IUserManager userManager = this.getUserManager();
      this.clearOldAccountRequests();
      User user = (User) userManager.getUser(username);
      user.setLastPasswordChange(new Date());
      user.setPassword(password);
      user.setDisabled(false);
      userManager.updateUser(user);
      userManager.changePassword(username, password);// Per salvare password non in chiaro
      this.getUserRegDAO().removeConsumedToken(token);
    } catch (Throwable t) {
      ApsSystemUtils.logThrowable(t, this, "reactivateUser");
View Full Code Here

  public void testReactivate() throws Throwable {
    String username = "username_test";
    String token = "token_test";
    try {
      //    prepare
      User user = new User();
      user.setDisabled(true);
      user.setUsername(username);
      user.setPassword("password");
      _userManager.addUser(user);
      _userRegDAO.addActivationToken(username, token, new Date(), IUserRegDAO.REACTIVATION_RECOVER_TOKEN_TYPE);
           
      this.initAction("/do/jpuserreg/UserReg", "reactivate");
      this.addParameter("token", token);
      this.addParameter("password", "password");
      this.addParameter("passwordConfirm", "wrongPasswordConfirm");
      String result = this.executeAction();
      assertEquals("input", result);
         
      this.initAction("/do/jpuserreg/UserReg", "reactivate");
      this.addParameter("token", token);
      this.addParameter("password", "new_password");
      this.addParameter("passwordConfirm", "new_password");
      result = this.executeAction();
      assertEquals("success", result);
      user = (User) _userManager.getUser(username,"new_password");
      assertNotNull(user);
      assertFalse(user.isDisabled());
    } finally {
      //    clean
      _userManager.removeUser(username);
    }
  }
View Full Code Here

  }
 
  public void testSuspend_NoRequiredPassword() throws Throwable {
    String username = "username_test";
    try {
      User user = new User();
      user.setDisabled(false);
      user.setUsername(username);
      user.setPassword(username);
      _userManager.addUser(user);
      this.setUserOnSession(username);
     
      this.initAction("/do/jpuserreg/UserReg", "suspend");
      String result = this.executeAction();
View Full Code Here

  }
 
  public void testSuspend_WrongPassword() throws Throwable {
    String username = "username_test";
    try {
      User user = new User();
      user.setDisabled(false);
      user.setUsername(username);
      user.setPassword(username);
      _userManager.addUser(user);
      this.setUserOnSession(username);
     
      this.initAction("/do/jpuserreg/UserReg", "suspend");
      this.addParameter("password", "wrongpassword");
View Full Code Here

 
  public void testSuspend() throws Throwable {
    String username = "username_test";
    try {
      this.setUserOnSession("editorCoach");
      User user = new User();
      user.setDisabled(false);
      user.setUsername(username);
      user.setPassword(username);
      _userManager.addUser(user);
      this.setUserOnSession(username);
      this.initAction("/do/jpuserreg/UserReg", "suspend");
      this.addParameter("password", username);
      String result = this.executeAction();
      assertEquals(Action.SUCCESS, result);
      user = (User) _userManager.getUser(username);
      assertNotNull(user);
      assertTrue(user.isDisabled());
    } finally {
      //    clean
      _userManager.removeUser(username);
    }
  }
View Full Code Here

TOP

Related Classes of com.agiletec.aps.system.services.user.User

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.