Package org.springframework.security.core.userdetails

Examples of org.springframework.security.core.userdetails.User$AuthorityComparator


                password = EncryptionUtils.encrypt(EncryptionUtils.encrypt(password, MessageDigestAlgorithm.MD5), MessageDigestAlgorithm.SHA_512);
            }
            if (user.getPassword().equals(password)) {
                // security context
                final Collection<GrantedAuthority> authorities = getAuthorities(user);
                final User springUser = new User(email, password, authorities);
                final Authentication auth = new UsernamePasswordAuthenticationToken(springUser, password, authorities);
                final SecurityContext sc = new SecurityContextImpl();

                sc.setAuthentication(auth);
                SecurityContextHolder.setContext(sc);
View Full Code Here


    boolean enabled = true;
    boolean accountNonExpired = true;
    boolean credentialsNonExpired = true;
    boolean accountNonLocked = true;

    return new User(
        domainUser.getLogin(),
        domainUser.getPassword(),
        enabled,
        accountNonExpired,
        credentialsNonExpired,
View Full Code Here

        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        for (Entitlement entitlement : entitlementDAO.findAll()) {
            authorities.add(new SimpleGrantedAuthority(entitlement.getName()));
        }

        UserDetails userDetails = new User(adminUser, "FAKE_PASSWORD", true, true, true, true, authorities);
        Authentication authentication = new TestingAuthenticationToken(userDetails, "FAKE_PASSWORD", authorities);
        SecurityContextHolder.getContext().setAuthentication(authentication);
    }
View Full Code Here

        for (Entitlement entitlement : entitlementDAO.findAll()) {
            authorities.add(new SimpleGrantedAuthority(entitlement.getName()));
        }

        final UserDetails userDetails = new User("admin", "FAKE_PASSWORD", true, true, true, true, authorities);

        SecurityContextHolder.getContext().setAuthentication(
                new UsernamePasswordAuthenticationToken(userDetails, "FAKE_PASSWORD", authorities));
    }
View Full Code Here

      if (name.startsWith(prefix)) {
        editor.setAsText(properties.getProperty(name));
        final UserAttribute attr = (UserAttribute) editor.getValue();
        // rename the name after the editor extracted the attributes
        name = name.replaceFirst(prefix, "");
        final UserDetails user = new User(name, attr.getPassword(), attr.isEnabled(), true, true, true, attr.getAuthorities());
       
        users.add(user);
      }
    }
   
View Full Code Here

  }
 
  private UserDetails makeRootUser(InternalUser user) {
    Object salt = null;
    Md5PasswordEncoder encoder = new Md5PasswordEncoder();
    return new User(user.getEmail(), encoder.encodePassword(user.getPassword(), salt),
        true, true, true, true, makeRootGrantedAuthorities());
  }
View Full Code Here

  private UserDetails makeUser(InternalUser user) throws Exception {
    Object salt = null;
    Md5PasswordEncoder encoder = new Md5PasswordEncoder();
   
    if(user.getAdmin() != null && user.getAdmin()) {
      return new User(user.getEmail(), encoder.encodePassword(user.getPassword(), salt),
          true, true, true, true, makeAdminGrantedAuthorities());
    }
   
    // TODO change it! By default it's a provider user
    return new User(user.getEmail(), encoder.encodePassword(user.getPassword(), salt),
        true, true, true, true, makeProviderGrantedAuthorities(user));
  }
View Full Code Here

        List<GrantedAuthority> authorities = new ArrayList<GrantedAuthority>();
        for (Entitlement entitlement : entitlementDAO.findAll()) {
            authorities.add(new SimpleGrantedAuthority(entitlement.getName()));
        }

        UserDetails userDetails = new User(adminUser, "FAKE_PASSWORD", true, true, true, true, authorities);
        Authentication authentication = new TestingAuthenticationToken(userDetails, "FAKE_PASSWORD", authorities);
        SecurityContextHolder.getContext().setAuthentication(authentication);
    }
View Full Code Here

                String roleName = role.getRoleId();
                GrantedAuthority grantedAuthority = new SimpleGrantedAuthority(roleName);
                authorities.add(grantedAuthority);
            }  
           
            userDetails = new User(userName, password, authorities);
     
    } else {
            // If username not found, throw exception
            throw new UsernameNotFoundException("User " + userName + " not found");
    }
View Full Code Here

        authorities = new ArrayList<GrantedAuthority>();
        GrantedAuthority roleClient = new SimpleGrantedAuthority("ROLE_CLIENT");
        authorities.add(roleClient);
      }

      return new User(clientId, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
    } else {
      throw new UsernameNotFoundException("Client not found: " + clientId);
    }

  }
View Full Code Here

TOP

Related Classes of org.springframework.security.core.userdetails.User$AuthorityComparator

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.