Package org.acegisecurity.userdetails

Examples of org.acegisecurity.userdetails.UserDetails


        if (users.size() == 0) {
            throw new UsernameNotFoundException("User not found");
        }

        UserDetails user = (UserDetails) users.get(0); // contains no GrantedAuthority[]

        List dbAuths = authoritiesByUsernameMapping.execute(user.getUsername());

        if (dbAuths.size() == 0) {
            throw new UsernameNotFoundException("User has no GrantedAuthority");
        }

        GrantedAuthority[] arrayAuths = {};

        addCustomauthorities(user.getUsername(), dbAuths);

        arrayAuths = (GrantedAuthority[]) dbAuths.toArray(arrayAuths);

        String returnUsername = user.getUsername();

        if (!usernameBasedPrimaryKey) {
            returnUsername = username;
        }

        return new User(returnUsername, user.getPassword(), user.isEnabled(),
            true, true, true, arrayAuths);
    }
View Full Code Here


        protected Object mapRow(ResultSet rs, int rownum)
            throws SQLException {
            String username = rs.getString(1);
            String password = rs.getString(2);
            boolean enabled = rs.getBoolean(3);
            UserDetails user = new User(username, password, enabled, true,
                    true, true,
                    new GrantedAuthority[] {new GrantedAuthorityImpl("HOLDER")});

            return user;
        }
View Full Code Here

          LdapAuthenticationProvider ldapAuthenticationProvider =
            new LdapAuthenticationProvider(authenticator, authoritiesPopulator);
          LdapUserInfo user = authenticator.authenticate(userDetails.getUsername(),
              (String)authentication.getCredentials());
          if (user != null) {
              UserDetails u = ldapAuthenticationProvider.retrieveUser(userDetails.getUsername(),
                  authentication);         
              System.out.println("user " + u);
          }
          else {         
              throw new BadCredentialsException(messages.getMessage(
View Full Code Here

    }

    protected final UserDetails retrieveUser(String username,
                                             UsernamePasswordAuthenticationToken authentication)
        throws AuthenticationException {
        UserDetails loadedUser = null;
       
        try {
            loadedUser = this.userDetailsService.loadUserByUsername(username);
        } catch (DataAccessException repositoryProblem) {
            throw new AuthenticationServiceException(
View Full Code Here

                            "SwitchUserProcessingFilter.noOriginalAuthentication",
                            "Could not find original Authentication object"));
                }

                // get the source user details
                UserDetails originalUser = null;
                Object obj = original.getPrincipal();

                if ((obj != null) && obj instanceof UserDetails) {
                    originalUser = (UserDetails) obj;
                }
View Full Code Here

                if (logger.isDebugEnabled()) {
                    logger.debug("Attempt to switch to user [" + username + "]");
                }

                // load the user by name
                UserDetails targetUser = this.userDetailsService
                        .loadUserByUsername(username);

                    // user not found
                    if (targetUser == null) {
                        throw new UsernameNotFoundException(messages.getMessage(
                                "SwitchUserProcessingFilter.usernameNotFound",
                                new Object[] {username},
                                "Username {0} not found"));
                    }

                    // account is expired
                    if (!targetUser.isAccountNonLocked()) {
                        throw new LockedException(messages.getMessage(
                                "SwitchUserProcessingFilter.locked",
                                "User account is locked"));
                    }

                    // user is disabled
                    if (!targetUser.isEnabled()) {
                        throw new DisabledException(messages.getMessage(
                                "SwitchUserProcessingFilter.disabled",
                                "User is disabled"));
                    }

                    // account is expired
                    if (!targetUser.isAccountNonExpired()) {
                        throw new AccountExpiredException(messages.getMessage(
                                "SwitchUserProcessingFilter.expired",
                                "User account has expired"));
                    }

                    // credentials expired
                    if (!targetUser.isCredentialsNonExpired()) {
                        throw new CredentialsExpiredException(messages
                                .getMessage(
                                    "SwitchUserProcessingFilter.credentialsExpired",
                                    "User credentials have expired"));
                        }
View Full Code Here

   */
  public UserDetails loadUserByUsername(String pUsername)
    throws UsernameNotFoundException,
      DataAccessException {

    UserDetails user = findUserByName(pUsername);
    if (user == null) {
      throw new UsernameNotFoundException("user not found:" + pUsername);
    }

    return user;
View Full Code Here

        super(authenticator, authoritiesPopulator);
    }

    @Override
    protected AccountUserDetails createUserDetails(LdapUserDetails ldapUser, String username, String password) {
        UserDetails userDetails = super.createUserDetails(ldapUser, username, password);
        return new AccountUserDetails((LdapUserDetails) userDetails);
    }
View Full Code Here

    public Authentication get() {
        Hudson h = Hudson.getInstance();
        Secret userName = Secret.decrypt(props.getProperty(getPropertyKey()));
        if (userName==null) return Hudson.ANONYMOUS; // failed to decrypt
        try {
            UserDetails u = h.getSecurityRealm().loadUserByUsername(userName.toString());
            return new UsernamePasswordAuthenticationToken(u.getUsername(), u.getPassword(), u.getAuthorities());
        } catch (AuthenticationException e) {
            return Hudson.ANONYMOUS;
        } catch (DataAccessException e) {
            return Hudson.ANONYMOUS;
        }
View Full Code Here

    public void set(Authentication a) throws IOException, InterruptedException {
        Hudson h = Hudson.getInstance();

        // make sure that this security realm is capable of retrieving the authentication by name,
        // as it's not required.
        UserDetails u = h.getSecurityRealm().loadUserByUsername(a.getName());
        props.setProperty(getPropertyKey(), Secret.fromString(u.getUsername()).getEncryptedValue());

        save();
    }
View Full Code Here

TOP

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