Package org.springframework.security

Examples of org.springframework.security.GrantedAuthorityImpl


    List<String> authorities = dao.getRolesForUser( null, "scott" ); //$NON-NLS-1$
    if ( logger.isDebugEnabled() ) {
      logger.debug( "testGetRolesForUser(): Roles: " + authorities ); //$NON-NLS-1$
    }

    assertTrue( authorities.indexOf( new GrantedAuthorityImpl( "ROLE_ONE" ) ) < authorities
        .indexOf( new GrantedAuthorityImpl( "ROLE_THREE" ) ) );
  }
View Full Code Here


      ISystemSettings settings = PentahoSystem.getSystemSettings();
      String roleName = ( settings != null ) ? settings.getSystemSetting( "acl-voter/admin-role", "Admin" ) : "Admin";

      roles = new GrantedAuthority[1];
      roles[0] = new GrantedAuthorityImpl( roleName );

      User user = new User( name, "", true, true, true, true, roles );
      UsernamePasswordAuthenticationToken auth = new UsernamePasswordAuthenticationToken( user, "", roles ); //$NON-NLS-1$

      // set holders
View Full Code Here

            "ou=roles", "roleoccupant={0}", new String[] { "uid=suzy,ou=users,dc=pentaho,dc=org", "suzy" }, "cn" ); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$

    GrantedAuthority[] authorities = new GrantedAuthority[extraRoles.size()];
    int i = 0;
    for ( String extraRole : extraRoles ) {
      authorities[i++] = new GrantedAuthorityImpl( extraRole );
    }

    // use the mapper to create a UserDetails instance
    UserDetails userDetails = mapper.mapUserFromContext( ctx, "suzy", authorities ); //$NON-NLS-1$
    System.out.println( userDetails );

    // this asserts the ordering too; not strictly necessary
    GrantedAuthority[] expected =
        new GrantedAuthority[] { new GrantedAuthorityImpl( "A" ), new GrantedAuthorityImpl( "cto" ), //$NON-NLS-1$ //$NON-NLS-2$
          new GrantedAuthorityImpl( "is" ), new GrantedAuthorityImpl( "Authenticated" ) }; //$NON-NLS-1$//$NON-NLS-2$
    assertTrue( Arrays.equals( expected, userDetails.getAuthorities() ) );
  }
View Full Code Here

          secOwn = entry.getKey();
          int rights = entry.getValue().intValue();
          if ( secOwn.getOwnerType() == SecurityOwner.OwnerType.USER ) {
            accessControls.add( new PentahoAclEntry( secOwn.getOwnerName(), rights ) );
          } else {
            accessControls.add( new PentahoAclEntry( new GrantedAuthorityImpl( secOwn.getOwnerName() ), rights ) );
          }
        }
      }
    } catch ( Throwable th ) {
      // Just being paranoid here in case something doesn't support it.
View Full Code Here

    GrantedAuthority[] auths = unionizer.getGrantedAuthorities( ctx, "suzy" ); //$NON-NLS-1$

    assertTrue( null != auths && auths.length > 0 );

    List authsList = Arrays.asList( auths );
    assertTrue( authsList.contains( new GrantedAuthorityImpl( "ROLE_POWER_USER" ) ) ); //$NON-NLS-1$
    assertTrue( authsList.contains( new GrantedAuthorityImpl( "ROLE_MARKETING" ) ) ); //$NON-NLS-1$

    System.out.println( authsList );
  }
View Full Code Here

  }

  public void init( final IPentahoSession session ) {
    ISystemSettings settings = PentahoSystem.getSystemSettings();
    String roleName = settings.getSystemSetting( "acl-voter/admin-role", "Administrator" ); //$NON-NLS-1$ //$NON-NLS-2$
    adminRole = new GrantedAuthorityImpl( roleName );
  }
View Full Code Here

    assertEquals( aclEntry.printPermissionsBlock(), "X-CUDP" ); //$NON-NLS-1$

    aclEntry = new PentahoAclEntry( "admin", IPentahoAclEntry.PERM_FULL_CONTROL ); //$NON-NLS-1$
    assertEquals( aclEntry.printPermissionsBlock(), "XSCUDP" ); //$NON-NLS-1$

    aclEntry.setRecipient( new GrantedAuthorityImpl( "ROLE_ADMIN" ) ); //$NON-NLS-1$
    Object recip = aclEntry.getRecipient();
    if ( !( recip instanceof GrantedAuthority ) ) {
      fail( "setRecipientString failed - GrantedAuthority." ); //$NON-NLS-1$
    }
    aclEntry.setRecipient( "suzy" ); //$NON-NLS-1$
View Full Code Here

public class StubUserDetailsService implements UserDetailsService {

  @Override
  public UserDetails loadUserByUsername( String username ) throws UsernameNotFoundException, DataAccessException {
    GrantedAuthority[] auths = new GrantedAuthority[2];
    auths[0] = new GrantedAuthorityImpl( "Authenticated" );
    auths[1] = new GrantedAuthorityImpl( "Administrator" );

    UserDetails user = new User( "admin", "password", true, true, true, true, auths );

    return user;
  }
View Full Code Here

    pentahoSession.setAttribute( IPentahoSession.TENANT_ID_KEY, tenant.getId() );

    List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();

    for ( String roleName : roles ) {
      authList.add( new GrantedAuthorityImpl( roleName ) );
    }
    GrantedAuthority[] authorities = authList.toArray( new GrantedAuthority[0] );
    UserDetails userDetails = new User( username, PASSWORD, true, true, true, true, authorities );
    Authentication auth = new UsernamePasswordAuthenticationToken( userDetails, PASSWORD, authorities );
    PentahoSessionHolder.setSession( pentahoSession );
View Full Code Here

  public void loginAsRepositoryAdmin() {
    StandaloneSession pentahoSession = new StandaloneSession( repositoryAdminUsername );
    pentahoSession.setAuthenticated( repositoryAdminUsername );
    final GrantedAuthority[] repositoryAdminAuthorities =
      new GrantedAuthority[] { new GrantedAuthorityImpl( superAdminRoleName ) };
    final String password = "ignored";
    UserDetails repositoryAdminUserDetails =
      new User( repositoryAdminUsername, password, true, true, true, true, repositoryAdminAuthorities );
    Authentication repositoryAdminAuthentication =
      new UsernamePasswordAuthenticationToken( repositoryAdminUserDetails, password, repositoryAdminAuthorities );
View Full Code Here

TOP

Related Classes of org.springframework.security.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.