Package org.springframework.security.userdetails

Examples of org.springframework.security.userdetails.UserDetails


    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


        // No tenant provided so we assume default tenant
        tenant = JcrTenantUtils.getDefaultTenant();
      }
      userToSearch = usernamePrincipalResolver.getPrincipleId( tenant, username );
    }
    UserDetails user = userDetailsService.loadUserByUsername( userToSearch );
    List<String> roles = new ArrayList<String>( user.getAuthorities().length );
    for ( GrantedAuthority role : user.getAuthorities() ) {
      String principalName = role.getAuthority();
      roles.add( principalName );
    }
    return roles;
  }
View Full Code Here

  protected void loginAsRepositoryAdmin() {
    StandaloneSession pentahoSession = new StandaloneSession( repositoryAdminUsername );
    pentahoSession.setAuthenticated( repositoryAdminUsername );
    final GrantedAuthority[] repositoryAdminAuthorities = new GrantedAuthority[] {};
    final String password = "ignored";
    UserDetails repositoryAdminUserDetails =
        new User( repositoryAdminUsername, password, true, true, true, true, repositoryAdminAuthorities );
    Authentication repositoryAdminAuthentication =
        new UsernamePasswordAuthenticationToken( repositoryAdminUserDetails, password, repositoryAdminAuthorities );
    PentahoSessionHolder.setSession( pentahoSession );
    // this line necessary for Spring Security's MethodSecurityInterceptor
View Full Code Here

  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

    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 );
    // this line necessary for Spring Security's MethodSecurityInterceptor
    SecurityContextHolder.getContext().setAuthentication( auth );
View Full Code Here

    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 );
    PentahoSessionHolder.setSession( pentahoSession );
    // this line necessary for Spring Security's MethodSecurityInterceptor
View Full Code Here

          }
        }

        // 2. then try the springSecurityUserCache and, failing that, actual
        // back-end user lookup
        final UserDetails userDetails = internalGetUserDetails( principalName );
        if ( userDetails != null ) {
          final Principal user = new UserPrincipal( principalName );
          synchronized ( userCache ) {
            userCache.put( principalName, user );
          }
View Full Code Here

    // make sure it's a user; also, repo admins are never in back-end--no
    // need to attempt to look them up; also acl
    // metadata principals never have group membership
    if ( !( principal instanceof Group ) && !( principal instanceof AdminPrincipal )
      && !( principal instanceof AclMetadataPrincipal ) ) {
      UserDetails user = internalGetUserDetails( principal.getName() );
      if ( user == null ) {
        return new PrincipalIteratorAdapter( groups );
      }
      for ( final GrantedAuthority role : user.getAuthorities() ) {

        final String roleAuthority = role.getAuthority();
        Principal fromCache;
        synchronized ( roleCache ) {
          fromCache = (Principal) roleCache.get( roleAuthority );
View Full Code Here

          return (UserDetails) ssPrincipal;
        }
      }
    }

    UserDetails user = null;
    // user cache not available or user not in cache; do lookup
    GrantedAuthority[] auths = null;
    GrantedAuthority[] authorities = null;
    UserDetails newUser = null;
    if ( getUserDetailsService() != null ) {
      try {
        user = getUserDetailsService().loadUserByUsername( username );
        // We will use the authorities from the Authentication object of SecurityContextHolder.
        //Authentication object is null then we will get it from IUserRoleListService
View Full Code Here

    final String password = "ignored";

    List<GrantedAuthority> authList = new ArrayList<GrantedAuthority>();
    authList.add( new GrantedAuthorityImpl( tenantAdminRoleId ) );
    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 );
    // this line necessary for Spring Security's MethodSecurityInterceptor
    SecurityContextHolder.getContext().setAuthentication( auth );
  }
View Full Code Here

TOP

Related Classes of org.springframework.security.userdetails.UserDetails

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.