Package org.springframework.security.core.authority

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


        auth.setAuthenticated(true);
        SecurityContextHolder.getContext().setAuthentication(auth);

        ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, 100);
        AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
                new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_AUDITING"),
                new SimpleGrantedAuthority("ROLE_GENERAL"));

        Acl acl = new AclImpl(identity, 1, aclAuthorizationStrategy, new ConsoleAuditLogger(), null, null,
                false, new PrincipalSid(auth));
        try {
            aclAuthorizationStrategy.securityCheck(acl, AclAuthorizationStrategy.CHANGE_GENERAL);
View Full Code Here


    public void cacheOperationsAclWithoutParent() throws Exception {
        Cache cache = getCache();
        Map realCache = (Map) cache.getNativeCache();
        ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(100));
        AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
                new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_AUDITING"),
                new SimpleGrantedAuthority("ROLE_GENERAL"));
        AuditLogger auditLogger = new ConsoleAuditLogger();

        PermissionGrantingStrategy permissionGrantingStrategy = new DefaultPermissionGrantingStrategy(auditLogger);
        SpringCacheBasedAclCache myCache = new SpringCacheBasedAclCache(cache, permissionGrantingStrategy, aclAuthorizationStrategy);
        MutableAcl acl = new AclImpl(identity, Long.valueOf(1), aclAuthorizationStrategy, auditLogger);
View Full Code Here

        SecurityContextHolder.getContext().setAuthentication(auth);

        ObjectIdentity identity = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(1));
        ObjectIdentity identityParent = new ObjectIdentityImpl(TARGET_CLASS, Long.valueOf(2));
        AclAuthorizationStrategy aclAuthorizationStrategy = new AclAuthorizationStrategyImpl(
                new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_AUDITING"),
                new SimpleGrantedAuthority("ROLE_GENERAL"));
        AuditLogger auditLogger = new ConsoleAuditLogger();

        PermissionGrantingStrategy permissionGrantingStrategy = new DefaultPermissionGrantingStrategy(auditLogger);
        SpringCacheBasedAclCache myCache = new SpringCacheBasedAclCache(cache, permissionGrantingStrategy, aclAuthorizationStrategy);
View Full Code Here

    }

    @Test
    public void deleteAceFailsForNonExistentElement() throws Exception {
        AclAuthorizationStrategyImpl strategy = new AclAuthorizationStrategyImpl(
                new SimpleGrantedAuthority("ROLE_OWNERSHIP"), new SimpleGrantedAuthority("ROLE_AUDITING"),
                new SimpleGrantedAuthority("ROLE_GENERAL"));
        MutableAcl acl = new AclImpl(objectIdentity, (1), strategy, pgs, null, null, true, new PrincipalSid(
                "joe"));
        try {
            acl.deleteAce(99);
            fail("It should have thrown NotFoundException");
View Full Code Here

    }

    @Before
    public void initializeBeans() {
        EhCacheBasedAclCache cache = new EhCacheBasedAclCache(getCache());
        AclAuthorizationStrategy authorizationStrategy = new AclAuthorizationStrategyImpl(new SimpleGrantedAuthority("ROLE_ADMINISTRATOR"));
        strategy = new BasicLookupStrategy(dataSource, cache, authorizationStrategy,
                new DefaultPermissionGrantingStrategy(new ConsoleAuditLogger()));
        strategy.setPermissionFactory(new DefaultPermissionFactory());
    }
View Full Code Here

    @Test
    public void testNullWithinGrantedAuthorityElementIsRejected() throws Exception {
        try {
            List<GrantedAuthority> auths = AuthorityUtils.createAuthorityList("ROLE_ONE");
            auths.add(null);
            auths.add(new SimpleGrantedAuthority("ROLE_THREE"));
            new User(null, "koala", true, true, true, true, auths);
            fail("Should have thrown IllegalArgumentException");
        } catch (IllegalArgumentException expected) {
        }
    }
View Full Code Here

    }

    private HashMap getValidAttributes2GrantedAuthoritiesMap() {
        HashMap m = new HashMap();
        m.put("role1","ga1");
        m.put("role2",new SimpleGrantedAuthority("ga2"));
        m.put("role3",Arrays.asList("ga3",new SimpleGrantedAuthority("ga4")));
        m.put("role4","ga5,ga6");
        m.put("role5",Arrays.asList("ga7","ga8",new Object[]{new SimpleGrantedAuthority("ga9")}));
        m.put("role6",new Object[]{"ga10","ga11",new Object[]{new SimpleGrantedAuthority("ga12")}});
        m.put("role7",new String[]{"ga13","ga14"});
        m.put("role8",new String[]{"ga13","ga14",null});
        m.put("role9",null);
        m.put("role10",new Object[]{});
        m.put("role11",Arrays.asList(new Object[]{null}));
View Full Code Here

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

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

            if (!rolesReachableInOneStepMap.containsKey(higherRole)) {
                rolesReachableInOneStepSet = new HashSet<GrantedAuthority>();
                rolesReachableInOneStepMap.put(higherRole, rolesReachableInOneStepSet);
View Full Code Here

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

                return new SimpleGrantedAuthority(roleName);
            }
        });
    }
View Full Code Here

     * @since 1.1
     */
    public void setAuthoritiesAsString(List<String> authoritiesAsStrings) {
        setAuthorities(new ArrayList<GrantedAuthority>(authoritiesAsStrings.size()));
        for(String authority : authoritiesAsStrings) {
            addAuthority(new SimpleGrantedAuthority(authority));
        }
    }
View Full Code Here

TOP

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

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.