Package org.springframework.security

Examples of org.springframework.security.GrantedAuthorityImpl


   
    User userDetails = new User();
    userDetails.setUsername(user.getName());
    userDetails.setPassword(user.getPassword());
    List<GrantedAuthority> authorities = new LinkedList<GrantedAuthority>();
    authorities.add(new GrantedAuthorityImpl("ROLE_USER"));
    for(Groups group : user.getGroups()) {
      String securityRole = Authentication.getSpringSecuirtyRoleFromOldRoleName(group.getName());
      authorities.add(new GrantedAuthorityImpl(securityRole));
    }
    userDetails.setAuthorities(authorities.toArray(new GrantedAuthority[authorities.size()]));
   
    return userDetails;
  }
View Full Code Here


    Map<IPermissionRecipient, IPermissionMask> permissionsMap =
        new LinkedHashMap<IPermissionRecipient, IPermissionMask>();
    for ( IPentahoAclEntry pentahoAclEntry : entriesFromHolder ) {
      IPermissionRecipient permissionRecipient = null;
      if ( pentahoAclEntry.getRecipient() instanceof GrantedAuthorityImpl ) {
        GrantedAuthorityImpl grantedAuthorityImpl = (GrantedAuthorityImpl) pentahoAclEntry.getRecipient();
        permissionRecipient = new SimpleRole( grantedAuthorityImpl.toString() );
      } else if ( pentahoAclEntry.getRecipient() instanceof SimpleRole ) {
        permissionRecipient = new SimpleRole( (String) pentahoAclEntry.getRecipient() );
      } else {
        permissionRecipient = new SimpleUser( (String) pentahoAclEntry.getRecipient() );
      }
View Full Code Here

    }
    IAclHolder aclHolder = (IAclHolder) object;
    PentahoAclEntry entry = new PentahoAclEntry();
    // TODO mlowery instanceof is undesirable as it doesn't allow new concrete classes.
    if ( permissionRecipient instanceof SimpleRole ) {
      entry.setRecipient( new GrantedAuthorityImpl( permissionRecipient.getName() ) );
    } else {
      entry.setRecipient( permissionRecipient.getName() );
    }
    entry.addPermission( permission.getMask() );
    // HibernateUtil.beginTransaction(); - This is now handled by the RepositoryFile
View Full Code Here

    ArrayList<IPentahoAclEntry> aclList = new ArrayList<IPentahoAclEntry>();
    for ( Entry<IPermissionRecipient, IPermissionMask> mapEntry : mapEntrySet ) {
      PentahoAclEntry pentahoAclEntry = new PentahoAclEntry();
      IPermissionRecipient permissionRecipient = mapEntry.getKey();
      if ( permissionRecipient instanceof SimpleRole ) {
        pentahoAclEntry.setRecipient( new GrantedAuthorityImpl( permissionRecipient.getName() ) );
      } else {
        pentahoAclEntry.setRecipient( permissionRecipient.getName() );
      }
      pentahoAclEntry.addPermission( mapEntry.getValue().getMask() );
      aclList.add( pentahoAclEntry );
View Full Code Here

      // get anonymous username/role defined in pentaho.xml
      String user = PentahoSystem
        .getSystemSetting( "anonymous-authentication/anonymous-user", "anonymousUser" ); //$NON-NLS-1$//$NON-NLS-2$
      String role = PentahoSystem
        .getSystemSetting( "anonymous-authentication/anonymous-role", "Anonymous" ); //$NON-NLS-1$//$NON-NLS-2$
      GrantedAuthority[] authorities = new GrantedAuthority[] { new GrantedAuthorityImpl( role ) };

      Authentication auth =
        new AnonymousAuthenticationToken( "anonymousUser", new User( user, "ignored", true, true, true, true,
          authorities ), authorities );
View Full Code Here

      SecurityHelper.logger.debug( "rolesForUser:" + roles ); //$NON-NLS-1$
    }

    GrantedAuthority[] grantedAuthorities = new GrantedAuthority[ roles.size() ];
    for ( int i = 0; i < roles.size(); i++ ) {
      grantedAuthorities[ i ] = new GrantedAuthorityImpl( roles.get( i ) );
    }

    User user = new User( principalName, "", true, true, true, true, grantedAuthorities );
    Authentication auth = new UsernamePasswordAuthenticationToken( user, null, grantedAuthorities );
    return auth;
View Full Code Here

        public GrantedAuthority[] getAuthorities() {
          if ( username == null ) {
            return new GrantedAuthority[0];
          }
          if ( username.equals( "admin" ) ) {
            return new GrantedAuthority[] { new GrantedAuthorityImpl( "ceo" ), new GrantedAuthorityImpl( "Admin" ),
              new GrantedAuthorityImpl( "Authenticated" ) };
          } else if ( username.equals( "simplebob" ) ) {
            return new GrantedAuthority[] { new GrantedAuthorityImpl( "Role1" ), new GrantedAuthorityImpl( "Role2" ) };
          }
          return new GrantedAuthority[0];
        }
      };
    }
View Full Code Here

  protected void loginAsRepositoryAdmin() {
    StandaloneSession pentahoSession = new StandaloneSession( repositoryAdminUsername );
    pentahoSession.setAuthenticated( repositoryAdminUsername );
    final GrantedAuthority[] repositoryAdminAuthorities =
        new GrantedAuthority[]{new GrantedAuthorityImpl( sysAdminRoleName )};
    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

    final String password = "password";

    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

  protected GrantedAuthority[] loadUserAuthorities( DirContextOperations userData, String username, String password ) {
    GrantedAuthority[] authorities = super.loadUserAuthorities( userData, username, password );
    if ( roleMapper != null ) {
      for ( int i = 0; i < authorities.length; i++ ) {
        if ( authorities[i] != null ) {
          authorities[i] = new GrantedAuthorityImpl( roleMapper.toPentahoRole( authorities[i].getAuthority() ) );
        }
      }
    }
    return authorities;
  }
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.