Search in sources :

Example 6 with Organization

use of org.jbehave.example.spring.security.domain.Organization in project jbehave-core by jbehave.

the class OrganizationSteps method updateOrganizationWithDefaultAuthPolicy.

@Given("authentication policy for $orgName: $authPolicyTable")
public void updateOrganizationWithDefaultAuthPolicy(String orgName, ExamplesTable table) {
    Organization org = organizationDao.findByName(orgName);
    Map<String, String> row = table.getRow(0);
    org.setAuthenticationPolicy(new AuthenticationPolicyBuilder(row).build());
    organizationDao.persist(org);
}
Also used : AuthenticationPolicyBuilder(org.jbehave.example.spring.security.domain.AuthenticationPolicyBuilder) Organization(org.jbehave.example.spring.security.domain.Organization) Given(org.jbehave.core.annotations.Given)

Example 7 with Organization

use of org.jbehave.example.spring.security.domain.Organization in project jbehave-core by jbehave.

the class UserSteps method setUserEnabled.

@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);
}
Also used : Organization(org.jbehave.example.spring.security.domain.Organization) User(org.jbehave.example.spring.security.domain.User) Given(org.jbehave.core.annotations.Given)

Example 8 with Organization

use of org.jbehave.example.spring.security.domain.Organization in project jbehave-core by jbehave.

the class UserSteps method setUserDisabled.

@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);
}
Also used : Organization(org.jbehave.example.spring.security.domain.Organization) User(org.jbehave.example.spring.security.domain.User) Given(org.jbehave.core.annotations.Given)

Example 9 with Organization

use of org.jbehave.example.spring.security.domain.Organization in project jbehave-core by jbehave.

the class UserSteps method createUserWithUsernameAndPassword.

@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);
}
Also used : Organization(org.jbehave.example.spring.security.domain.Organization) User(org.jbehave.example.spring.security.domain.User) Given(org.jbehave.core.annotations.Given)

Example 10 with Organization

use of org.jbehave.example.spring.security.domain.Organization in project jbehave-core by jbehave.

the class UserDetailsServiceImpl method loadUserByUsername.

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());
}
Also used : UsernameNotFoundException(org.springframework.security.core.userdetails.UsernameNotFoundException) Organization(org.jbehave.example.spring.security.domain.Organization) User(org.jbehave.example.spring.security.domain.User)

Aggregations

Organization (org.jbehave.example.spring.security.domain.Organization)10 Given (org.jbehave.core.annotations.Given)8 User (org.jbehave.example.spring.security.domain.User)5 AuthenticationPolicy (org.jbehave.example.spring.security.domain.AuthenticationPolicy)2 Alias (org.jbehave.core.annotations.Alias)1 When (org.jbehave.core.annotations.When)1 Parameters (org.jbehave.core.steps.Parameters)1 AuthenticationPolicyBuilder (org.jbehave.example.spring.security.domain.AuthenticationPolicyBuilder)1 UserBuilder (org.jbehave.example.spring.security.domain.UserBuilder)1 UsernameNotFoundException (org.springframework.security.core.userdetails.UsernameNotFoundException)1