Search in sources :

Example 1 with SpringSecurityAuthorisationManager

use of org.ff4j.security.SpringSecurityAuthorisationManager in project ff4j by ff4j.

the class FlipSecurityTests method setUp.

@Before
public void setUp() throws Exception {
    securityCtx = SecurityContextHolder.getContext();
    // Init SpringSecurity Context
    SecurityContext context = new SecurityContextImpl();
    List<GrantedAuthority> listOfRoles = new ArrayList<GrantedAuthority>();
    listOfRoles.add(new SimpleGrantedAuthority("ROLE_USER"));
    User u1 = new User("user1", "user1", true, true, true, true, listOfRoles);
    UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(u1.getUsername(), u1.getPassword(), u1.getAuthorities());
    token.setDetails(u1);
    context.setAuthentication(token);
    SecurityContextHolder.setContext(context);
    // <--
    ff4j = new FF4j("test-ff4j-security-spring.xml");
    ff4j.setAuthorizationsManager(new SpringSecurityAuthorisationManager());
}
Also used : SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) User(org.springframework.security.core.userdetails.User) FF4j(org.ff4j.FF4j) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority) SecurityContext(org.springframework.security.core.context.SecurityContext) ArrayList(java.util.ArrayList) SpringSecurityAuthorisationManager(org.ff4j.security.SpringSecurityAuthorisationManager) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) Before(org.junit.Before)

Example 2 with SpringSecurityAuthorisationManager

use of org.ff4j.security.SpringSecurityAuthorisationManager in project ff4j by ff4j.

the class FlipSecurityTests2 method setUp.

@Before
public void setUp() throws Exception {
    securityCtx = SecurityContextHolder.getContext();
    // Init SpringSecurity Context
    SecurityContext context = new SecurityContextImpl();
    List<GrantedAuthority> listOfRoles = new ArrayList<GrantedAuthority>();
    listOfRoles.add(new SimpleGrantedAuthority("ROLE_USER"));
    User u1 = new User("user1", "user1", true, true, true, true, listOfRoles);
    UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(u1.getUsername(), u1.getPassword(), u1.getAuthorities());
    token.setDetails(u1);
    context.setAuthentication(token);
    SecurityContextHolder.setContext(context);
    // <--
    ff4j = new FF4j("test-ff4j-security-spring.xml");
    ff4j.setAuthorizationsManager(new SpringSecurityAuthorisationManager());
}
Also used : SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) SecurityContextImpl(org.springframework.security.core.context.SecurityContextImpl) User(org.springframework.security.core.userdetails.User) FF4j(org.ff4j.FF4j) SimpleGrantedAuthority(org.springframework.security.core.authority.SimpleGrantedAuthority) GrantedAuthority(org.springframework.security.core.GrantedAuthority) SecurityContext(org.springframework.security.core.context.SecurityContext) ArrayList(java.util.ArrayList) SpringSecurityAuthorisationManager(org.ff4j.security.SpringSecurityAuthorisationManager) UsernamePasswordAuthenticationToken(org.springframework.security.authentication.UsernamePasswordAuthenticationToken) Before(org.junit.Before)

Aggregations

ArrayList (java.util.ArrayList)2 FF4j (org.ff4j.FF4j)2 SpringSecurityAuthorisationManager (org.ff4j.security.SpringSecurityAuthorisationManager)2 Before (org.junit.Before)2 UsernamePasswordAuthenticationToken (org.springframework.security.authentication.UsernamePasswordAuthenticationToken)2 GrantedAuthority (org.springframework.security.core.GrantedAuthority)2 SimpleGrantedAuthority (org.springframework.security.core.authority.SimpleGrantedAuthority)2 SecurityContext (org.springframework.security.core.context.SecurityContext)2 SecurityContextImpl (org.springframework.security.core.context.SecurityContextImpl)2 User (org.springframework.security.core.userdetails.User)2