Package org.springframework.security.core.authority

Examples of org.springframework.security.core.authority.GrantedAuthorityImpl


          @Override
          public Collection<? extends GrantedAuthority> getAuthorities() {
            // this is to test differences between implementations of GrantedAuthority,
            // see the containsAll method in ifRole
            Collection<GrantedAuthorityImpl> auth = new ArrayList<GrantedAuthorityImpl>();
            auth.add(new GrantedAuthorityImpl("GROUP1"));
            return  auth;
          }
        };
      }
    });
View Full Code Here


    public void testAuthorizeExtendsGrantedAuthorityImpl() throws JspException {
        authorizeTag.setIfAnyGranted(null);
        authorizeTag.setIfNotGranted(null);
        authorizeTag.setIfAllGranted("ROLE_TEST");
        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        authorities.add(new GrantedAuthorityImpl("ROLE_TEST") {});
        SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("abc", "123", authorities));
        assertEquals("Expected to be authorized", Tag.EVAL_BODY_INCLUDE, authorizeTag.doStartTag());
    }
View Full Code Here

    public void testAuthorizeUsingGrantedAuthorityImpl() throws JspException {
        authorizeTag.setIfAnyGranted(null);
        authorizeTag.setIfNotGranted(null);
        authorizeTag.setIfAllGranted("ROLE_TEST");
        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        authorities.add(new GrantedAuthorityImpl("ROLE_TEST"));
        SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("abc", "123", authorities));
        assertEquals("Expected to be authorized", Tag.EVAL_BODY_INCLUDE, authorizeTag.doStartTag());
    }
View Full Code Here

    public void testNotAuthorizeUsingGrantedAuthorityImpl() throws JspException {
        authorizeTag.setIfAnyGranted(null);
        authorizeTag.setIfNotGranted(null);
        authorizeTag.setIfAllGranted("ROLE_ADMIN");
        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        authorities.add(new GrantedAuthorityImpl("ROLE_TEST"));
        SecurityContextHolder.getContext().setAuthentication(new TestingAuthenticationToken("abc", "123", authorities));
        assertEquals("Expected to not be authorized", Tag.SKIP_BODY, authorizeTag.doStartTag());
    }
View Full Code Here

    private Authentication createAuthenticationToken(String username, String password, String... roles) {
        Authentication authToken;
        if (roles != null && roles.length > 0) {
            List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>(roles.length);
            for (int i = 0; i < roles.length; i++) {
                authorities.add(new GrantedAuthorityImpl(roles[i]));
            }
            authToken = new UsernamePasswordAuthenticationToken(username, password, authorities);
        } else {
            authToken = new UsernamePasswordAuthenticationToken(username, password);
        }
View Full Code Here

        cz.muni.fi.pa165.library.backend.User user = userDAO.findUserByEmail(email);
        List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>(2);
        String pass;
        if (user != null){
            pass = user.getPassword();
            authList.add(new GrantedAuthorityImpl("ROLE_LIBRARIAN"));
            authList.add(new GrantedAuthorityImpl("ROLE_READER"));
        }else{
            Reader reader = readerDAO.findReaderByEmail(email);
            if (reader == null){throw new UsernameNotFoundException("Username Not Found");}
            pass = reader.getPassword();
            authList.add(new GrantedAuthorityImpl("ROLE_READER"));   
        }
         return new User(email, pass, true, true, true, true, authList);


       
View Full Code Here

 
    protected List<GrantedAuthority> loadUserAuthorities(String username) {
      List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
     
     
      GrantedAuthority authority = new GrantedAuthorityImpl("ROLE_USER");
     
      authorities.add(authority);
     
      return authorities;
//        return getJdbcTemplate().query(authoritiesByUsernameQuery, new String[] {username}, new RowMapper<GrantedAuthority>() {
View Full Code Here

        final Collection<GrantedAuthority> requiredAuthorities = new ArrayList<GrantedAuthority>();
        final String[] roles = authorizationsString.split(",");

        for (int i = 0; i < roles.length; i++) {
            String role = roles[i].trim();
            requiredAuthorities.add(new GrantedAuthorityImpl(role));
        }

        return requiredAuthorities;
    }
View Full Code Here

     */
    protected List<GrantedAuthority> loadUserAuthorities(String username) {
        return getJdbcTemplate().query(authoritiesByUsernameQuery, new String[] {username, systemCode}, new RowMapper<GrantedAuthority>() {
            public GrantedAuthority mapRow(ResultSet rs, int rowNum) throws SQLException {
                String roleName = getRolePrefix() + rs.getString(2);
                GrantedAuthorityImpl authority = new GrantedAuthorityImpl(roleName);

                return authority;
            }
        });
    }
View Full Code Here

        user2.setEntityId(VALID_USER_ID2);
        user2.setUsername(VALID_USERNAME2);

        mockAuthentication = createMock(Authentication.class);
        grantedAuthoritiesList = new ArrayList<GrantedAuthority>();
        grantedAuthoritiesList.add(new GrantedAuthorityImpl("ROLE_USER"));

    }
View Full Code Here

TOP

Related Classes of org.springframework.security.core.authority.GrantedAuthorityImpl

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.