Package org.springframework.security.userdetails

Examples of org.springframework.security.userdetails.User


      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
      PentahoSessionHolder.setSession( session );
      SecurityContextHolder.getContext().setAuthentication( auth );
View Full Code Here


    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
    SecurityContextHolder.getContext().setAuthentication( repositoryAdminAuthentication );
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

    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
    SecurityContextHolder.getContext().setAuthentication( repositoryAdminAuthentication );
View Full Code Here

          // auth is null so we are going to pass an empty auths array
          auths = new GrantedAuthority[ 0 ];
        }
        String password = user.getPassword() != null ? user.getPassword() : "";
        newUser =
          new User( user.getUsername(), password, user.isEnabled(), ACCOUNT_NON_EXPIRED, CREDS_NON_EXPIRED,
            ACCOUNT_NON_LOCKED, auths );
      }

    }
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

            return (String) userObj;
        } else if (userObj instanceof UserDetails) {
            UserDetails userDetails = (UserDetails) userObj;
            return userDetails.getUsername();
        }else {
            User user = (User) userObj;
            return user.getUsername();
        }
    }
View Full Code Here

            // ok
        }
    }
   
    public void testSetUser() throws Exception {
        dao.setUser(new User("wfs", "pwd", true, true, true, true,
                new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_WFS_ALL"), new GrantedAuthorityImpl("ROLE_WMS_ALL")}));
        UserDetails user = dao.loadUserByUsername("wfs");
        assertEquals("wfs", user.getUsername());
        assertEquals("pwd", user.getPassword());
        assertEquals(2, user.getAuthorities().length);
View Full Code Here

        assertEquals("ROLE_WMS_ALL", user.getAuthorities()[1].getAuthority());
    }
   
    public void testSetMissingUser() throws Exception {
        try {
            dao.setUser(new User("notther", "pwd", true, true, true, true,
                    new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_WFS_ALL")}));
            fail("The user is not there, setUser should fail");
        } catch(IllegalArgumentException e) {
            // cool
        }
View Full Code Here

TOP

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

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.