Package org.springframework.security

Examples of org.springframework.security.GrantedAuthority


    public static Set authoritiesToRoles(Collection c) {
        Set target = new HashSet();

        for (Iterator iterator = c.iterator(); iterator.hasNext();) {
            GrantedAuthority authority = (GrantedAuthority) iterator.next();

            if (null == authority.getAuthority()) {
                throw new IllegalArgumentException(
                        "Cannot process GrantedAuthority objects which return null from getAuthority() - attempting to process "
                                + authority.toString());
            }

            target.add(authority.getAuthority());
        }

        return target;
    }
View Full Code Here


        for (Iterator iterator = grantedRoles.iterator(); iterator.hasNext();) {
            String role = (String) iterator.next();

            for (Iterator grantedIterator = granted.iterator(); grantedIterator.hasNext();) {
                GrantedAuthority authority = (GrantedAuthority) grantedIterator.next();

                if (authority.getAuthority().equals(role)) {
                    target.add(authority);

                    break;
                }
            }
View Full Code Here

    if(obj instanceof String) {
      return obj.equals(this.authority);
    }

    if(obj instanceof GrantedAuthority && this.authority != null) {
      final GrantedAuthority attr = (GrantedAuthority) obj;
      return this.authority.equals(attr.getAuthority());
    }

    return super.equals(obj);
  }
View Full Code Here

    if ( roleMapper != null ) {
      List<GrantedAuthority> currentAuthorities = new ArrayList<GrantedAuthority>();
      currentAuthorities.addAll( authorities );

      for ( GrantedAuthority role : currentAuthorities ) {
        GrantedAuthority mappedRole = new GrantedAuthorityImpl( roleMapper.toPentahoRole( role.getAuthority() ) );
        if ( !authorities.contains( mappedRole ) ) {
          authorities.add( mappedRole );
        }
      }
    }
View Full Code Here

                // We are not throwing UsernameNotFound exception in case of
                // openid authentication in order to recieve user SREG attributes
                // from the authentication filter and save them               
                if (userData == null) {
                     authorities = new GrantedAuthority[1];
                     GrantedAuthority g = new GrantedAuthorityImpl("openidLogin");
                     authorities[0] = g;
                     name = "openid";
                     password = "openid";
                } else {
                     authorities =  getAuthorities(userData, umgr);
View Full Code Here

      role = new UserRole(name);
      _userDao.saveOrUpdateUserRole(role);
    }
    _userRoles.put(name, role);

    final GrantedAuthority auth = new GrantedAuthorityImpl(name);
    _standardAuthoritiesMap.put(name, auth);
    return auth;
  }
View Full Code Here

    _standardAuthoritiesMap.put(name, auth);
    return auth;
  }

  public GrantedAuthority getNameBasedAuthority(final String name) {
    final GrantedAuthority auth = _standardAuthoritiesMap.get(name);
    if (null == auth) {
      return new GrantedAuthorityImpl(name);
    } else {
      return auth;
    }
View Full Code Here

    }

    @Override
    protected void authenticate(String username, String password) {
        // override as this is not a test going through the servlet filters
        GrantedAuthority ga = new GrantedAuthorityImpl("MOCKROLE");
        UsernamePasswordAuthenticationToken user = new UsernamePasswordAuthenticationToken(
                username, null, new GrantedAuthority[] { ga });
        SecurityContextHolder.getContext().setAuthentication(user);
    }
View Full Code Here

     */
    @Test
    public void testGetAuthoritiesNonNull()
    {
        GrantedAuthority[] auths = new GrantedAuthority[1];
        GrantedAuthority gaMock = context.mock(GrantedAuthority.class);
        auths[0] = gaMock;
        ExtendedUserDetailsImpl sut = new ExtendedUserDetailsImpl(person, null, auths, null);
        assertEquals(1, sut.getAuthorities().length);
        assertEquals(gaMock, sut.getAuthorities()[0]);
    }
View Full Code Here

TOP

Related Classes of org.springframework.security.GrantedAuthority

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.