Package org.jbehave.example.spring.security.domain

Examples of org.jbehave.example.spring.security.domain.User


  private OrganizationDao organizationDao;

  @Given("a user for $orgName with username $username and password $password")
  public void createUserWithUsernameAndPassword(String orgName, String username, String password) {
    Organization org = organizationDao.findByName(orgName);
    User user = new User();
    user.setOrganization(org);
    user.setUsername(username);
    user.setPasswordCleartext(password);
    userDao.persist(user);
  }
View Full Code Here


  }

  @Given("user for $orgName $username is disabled")
  public void setUserDisabled(String orgName, String username) {
    Organization org = organizationDao.findByName(orgName);
    User user = userDao.findUserByOrganizationAndUsername(org.getId(), username);
    user.setEnabled(false);
    userDao.persist(user);
  }
View Full Code Here

  }

  @Given("user for $orgName $username is enabled")
  public void setUserEnabled(String orgName, String username) {
    Organization org = organizationDao.findByName(orgName);
    User user = userDao.findUserByOrganizationAndUsername(org.getId(), username);
    user.setEnabled(true);
    userDao.persist(user);
  }
View Full Code Here

  }

  @Given("user for $orgName $username is expired")
  public void setUserExpired(String orgName, String username) {
    Organization org = organizationDao.findByName(orgName);
    User user = userDao.findUserByOrganizationAndUsername(org.getId(), username);
    user.setExpired(true);
    userDao.persist(user);
  }
View Full Code Here

    // on success - principal is a UserDetails
    UserDetails details = (UserDetails) event.getAuthentication().getPrincipal();
    String username = details.getUsername();
    if (!StringUtils.isBlank(username)) {
      Long orgId = organizationManager.getOrganization().getId();
      User user = userDao.findUserByOrganizationAndUsername(orgId, username);
      if (user != null) {
        user.setLoginFailureCount(0);
        userDao.persist(user);
      }
    }
  }
View Full Code Here

  protected void onAuthenticationFailure(AbstractAuthenticationFailureEvent event) {
    // on failure - principal is a username
    String username = (String) event.getAuthentication().getPrincipal();
    if (!StringUtils.isBlank(username)) {
      Long orgId = organizationManager.getOrganization().getId();
      User user = userDao.findUserByOrganizationAndUsername(orgId, username);
      if (user != null) {
        int loginFailureCount = user.getLoginFailureCount();
        user.setLoginFailureCount(++loginFailureCount);
        userDao.persist(user);
      }
    }
  }
View Full Code Here

  @Autowired
  private OrganizationManager organizationManager;

  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
    Organization org = organizationManager.getOrganization();
    User user = userDao.findUserByOrganizationAndUsername(org.getId(), username);
    if (user == null) {
      throw new UsernameNotFoundException(username);
    }
    return new UserDetailsImpl(user, org.getAuthenticationPolicy());
  }
View Full Code Here

TOP

Related Classes of org.jbehave.example.spring.security.domain.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.