Package org.springframework.security.core.authority

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


    }

    private List<GrantedAuthority> getGrantedAuthorities(Set<UserRole> roles) {
        List<GrantedAuthority> result = new ArrayList<GrantedAuthority>();
        for (UserRole r : roles) {
            result.add(new GrantedAuthorityImpl(r.name()));
        }
        return result;
    }
View Full Code Here


     * @param sc {@code SecurityContext}
     * @return an {@code OAuthAuthenticationToken} that is used as the {@code Authentication} object by the Spring Security
     */
    public static Authentication createAuthentication(SecurityContext sc) {
        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        authorities.add(new GrantedAuthorityImpl(sc.getRole()));
        OAuthAuthenticationToken newAuthToken =
            new OAuthAuthenticationToken(new ForceUserPrincipal(sc.getUserName(), sc.getSessionId()), null,
            authorities);
        newAuthToken.setDetails(sc.getForceSecurityContext());
        return newAuthToken;
View Full Code Here

        return true;
    }
   
    private static Authentication createAuthentication(SecurityContext sc) {
        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        authorities.add(new GrantedAuthorityImpl("ROLE_USER"));
        OAuthAuthenticationToken newAuthToken =
            new OAuthAuthenticationToken(new ForceUserPrincipal(sc.getUserName(), sc.getSessionId()), null, authorities);
        newAuthToken.setDetails(sc);
        return newAuthToken;
    }
View Full Code Here

    Collection<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
    /*
     * for (UserRoles role : user.getUserRoleses()) { authorities.add(new GrantedAuthorityImpl(role.getRoles().getRoleName())); }
     */
    // authorities.add(new GrantedAuthorityImpl("ROLE_GOD"));
    authorities.add(new GrantedAuthorityImpl(user.getRole()));
    UserDetails userS = new UserDetails(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
    userS.setName(user.getName());
    userS.setLastname(user.getLastName());
    userS.setLanguage(user.getLanguage());
    userS.setAccount(user.getAccount().getId());
View Full Code Here

        SecurityContextService securityContextService = new TestSecurityContextServiceReturnSession();
        ForceRememberMeServices rememberMeServices = new ForceRememberMeServices();
        rememberMeServices.setSecurityContextService(securityContextService);
       
        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        authorities.add(new GrantedAuthorityImpl(ROLE));
        OAuthAuthenticationToken newAuthToken = new OAuthAuthenticationToken(null, null, authorities);
        newAuthToken.setDetails(securityContext);

        HttpServletRequest request = new MockHttpServletRequest();
        HttpServletResponse response = new MockHttpServletResponse();
View Full Code Here

        sc.setSessionId(SESSION_ID);
        sc.setEndPoint(ENDPOINT);
        sc.setRole("ROLE_USER");
        sc.setUserName("username");
        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        authorities.add(new GrantedAuthorityImpl(sc.getRole()));
        OAuthAuthenticationToken newAuthToken = new OAuthAuthenticationToken(new ForceUserPrincipal(sc.getUserName(),
                sc.getSessionId()), null, authorities);
        newAuthToken.setDetails(sc.getForceSecurityContext());

        org.springframework.security.core.context.SecurityContext springSecurityContext = new SecurityContextImpl();
View Full Code Here

  }
 
  public Collection<GrantedAuthority> getAuthorities(Integer access) {
    List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
    log.debug("Grant ROLE_USER to this user");
    authList.add(new GrantedAuthorityImpl(ROLE_USER));
    if (access.compareTo(1) == 0) {
      log.debug("Grant ROLE_ADMIN to this user");
      authList.add(new GrantedAuthorityImpl(ROLE_ADMIN));
    }
    return authList;
  }
View Full Code Here

      _log.error(e,e);
    }
        if (debug) {
            // in debug mode, we provide temporary Acegi user
            Collection<GrantedAuthority> auths = new ArrayList<GrantedAuthority>();
            auths.add(new GrantedAuthorityImpl("SUPER_USER"));
            SessionUser user = new SessionUser("debug","debug",true, auths);
            user.setId(999999l);
            user.setFirstName("Superuser");
            user.setLastName("Debugger");
            return user;
View Full Code Here

        Assert.hasText(groupName);

        List<GrantedAuthority> authorities = getJdbcTemplate().query(groupAuthoritiesSql, new String[] {groupName}, new RowMapper() {
            public Object mapRow(ResultSet rs, int rowNum) throws SQLException {
                 String roleName = getRolePrefix() + rs.getString(3);
                 GrantedAuthorityImpl authority = new GrantedAuthorityImpl(roleName);

                 return authority;
            }
        });
View Full Code Here

        Matcher roleHierarchyMatcher = pattern.matcher(roleHierarchyStringRepresentation);
        rolesReachableInOneStepMap = new HashMap<GrantedAuthority, Set<GrantedAuthority>>();

        while (roleHierarchyMatcher.find()) {
            GrantedAuthority higherRole = new GrantedAuthorityImpl(roleHierarchyMatcher.group(2));
            GrantedAuthority lowerRole = new GrantedAuthorityImpl(roleHierarchyMatcher.group(3));
            Set<GrantedAuthority> rolesReachableInOneStepSet = null;

            if (!rolesReachableInOneStepMap.containsKey(higherRole)) {
                rolesReachableInOneStepSet = new HashSet<GrantedAuthority>();
                rolesReachableInOneStepMap.put(higherRole, rolesReachableInOneStepSet);
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.