Package org.springframework.security.userdetails

Examples of org.springframework.security.userdetails.UserDetails


  @Resource
  private AccountService accountService;

  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
    Account account = accountService.getByLoginName(username);
    UserDetails userDetails = new UserDetailsImpl(account);
    return userDetails;   
  }
View Full Code Here


public final class MockUserDetailsService implements UserDetailsService {

  @SuppressWarnings("serial")
  @Override
  public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException, DataAccessException {
    return new UserDetails() {

      @Override
      public boolean isEnabled() {
        return false;
      }
View Full Code Here

    FacebookAuthenticationToken token = (FacebookAuthenticationToken)authentication;
    FacebookAuthenticationToken.Status status = token.getStatus();

    switch (status) {
      case success:
        UserDetails userDetails = _userDetailsService.loadUserByUsername(String.valueOf(token.getUserId()));
        return new FacebookAuthenticationToken(userDetails.getAuthorities(),
            token.getUserId(), token.getSessionKey());
      case failure:
        throw new BadCredentialsException("Log in failed - identity could not be verified");
      case error:
        throw new AuthenticationServiceException("Error message from server: " + token.getErrorMessage());
View Full Code Here

        FacebookAuthenticationToken token = (FacebookAuthenticationToken) authentication;
        FacebookAuthenticationToken.Status status = token.getStatus();

        switch (status) {
            case success:
                UserDetails userDetails = _userDetailsService.loadUserByUsername(String.valueOf(token.getUserId()));
                return new FacebookAuthenticationToken(userDetails.getAuthorities(),
                        token.getUserId(), token.getSessionKey());
            case failure:
                throw new BadCredentialsException("Log in failed - identity could not be verified");
            case error:
                throw new AuthenticationServiceException("Error message from server: " + token.getErrorMessage());
View Full Code Here

  }

  public static class TestUserDetailsService implements UserDetailsService {
    public UserDetails loadUserByUsername( final String username ) throws UsernameNotFoundException,
      DataAccessException {
      return new UserDetails() {
        private static final long serialVersionUID = 1L;

        public boolean isEnabled() {
          return true;
        }
View Full Code Here

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

  public UserDetails loadUserByUsername( String username ) {
    boolean tenanted = JcrTenantUtils.isTenantedUser( username );
    String principleName = tenanted ? JcrTenantUtils.getPrincipalName( username, true ) : username;

    UserDetails user = userCache.getUserFromCache( principleName );

    if ( user == null ) {
      String principleId = tenanted ? username : getPrincipleId( username );
      try {
        user = delegate.loadUserByUsername( principleId );
View Full Code Here


  @Override public UserDetails loadUserByUsername( String s ) throws UsernameNotFoundException, DataAccessException {
    for ( UserDetailsService delegate : delegates ) {
      try {
        UserDetails details = delegate.loadUserByUsername( s );
        if ( details != null ) {
          return details;
        }
      } catch ( UsernameNotFoundException ignored ) {
        // ignore and continue;
View Full Code Here

  @Override
  public List<String> getRolesForUser( final ITenant tenant, final String username ) {
    if ( tenant != null && !tenant.equals( JcrTenantUtils.getDefaultTenant() ) ) {
      throw new UnsupportedOperationException( "only allowed to access to default tenant" );
    }
    UserDetails user = userDetailsService.loadUserByUsername( userNameUtils.getPrincipleName( username ) );
    List<GrantedAuthority> results = Arrays.asList( user.getAuthorities() );
    List<String> roles = new ArrayList<String>( results.size() );
    for ( GrantedAuthority role : results ) {
      roles.add( role.getAuthority() );
    }
    // TODO don't set the comparator from spring xml for build 6.0. UserRoleListService sorting roles after that.
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.