Examples of PasswordEncoder


Examples of org.springframework.security.crypto.password.PasswordEncoder

        }

        ApplicationContext ctx =
                WebApplicationContextUtils.getRequiredWebApplicationContext(context);

        PasswordEncoder passwordEncoder = null;
        try {
            ProviderManager provider = (ProviderManager) ctx.getBean("org.springframework.security.authentication.ProviderManager#0");
            for (Object o : provider.getProviders()) {
                AuthenticationProvider p = (AuthenticationProvider) o;
                if (p instanceof RememberMeAuthenticationProvider) {
                    config.put("rememberMeEnabled", Boolean.TRUE);
                } else if (ctx.getBean("passwordEncoder") != null) {
                    passwordEncoder = (PasswordEncoder) ctx.getBean("passwordEncoder");
                }
            }
        } catch (NoSuchBeanDefinitionException n) {
            log.debug("authenticationManager bean not found, assuming test and ignoring...");
            // ignore, should only happen when testing
        }

        context.setAttribute(Constants.CONFIG, config);

        // output the retrieved values for the Init and Context Parameters
        if (log.isDebugEnabled()) {
            log.debug("Remember Me Enabled? " + config.get("rememberMeEnabled"));
            if (passwordEncoder != null) {
                log.debug("Password Encoder: " + passwordEncoder.getClass().getSimpleName());
            }
            log.debug("Populating drop-downs...");
        }

        setupContext(context);
View Full Code Here

Examples of org.springframework.security.crypto.password.PasswordEncoder

  }

  @Transactional
  public void createTestUsers() {
    PasswordEncoder encoder = injector.getInstance(PasswordEncoder.class);

    RoleEntity adminRole = new RoleEntity();
    adminRole.setRoleName("admin");

    UserEntity admin = new UserEntity();
    admin.setUserName("administrator");
    admin.setUserPassword(encoder.encode("admin"));

    Set<RoleEntity> roles = new HashSet<RoleEntity>();
    Set<UserEntity> users = new HashSet<UserEntity>();

    roles.add(adminRole);
    users.add(admin);

    admin.setRoleEntities(roles);
    adminRole.setUserEntities(users);

    userDAO.create(admin);
    roleDAO.create(adminRole);

    UserEntity userWithoutRoles = new UserEntity();
    userWithoutRoles.setUserName("userWithoutRoles");
    userWithoutRoles.setUserPassword(encoder.encode("test"));
    userDAO.create(userWithoutRoles);

  }
View Full Code Here

Examples of org.springframework.security.crypto.password.PasswordEncoder

     */
    @Override
    public boolean isPaswordCorrect(User user, String password) {
        // load fresh user version from db to be sure to have current password.
        User userFromDb = findById(user.getId());
        PasswordEncoder encoder = new StandardPasswordEncoder();
        String encodedPassword = encoder.encode(password);
        return encodedPassword.equals(userFromDb.getPassword());
    }
View Full Code Here

Examples of org.springframework.security.crypto.password.PasswordEncoder

     * @see ${package}.services.IUserService${symbol_pound}changePassword(${package}.domain.User, java.lang.String)
     */
    @Override
    @Transactional(readOnly = false)
    public void changePassword(User user, String newPassword) {
        PasswordEncoder encoder = new StandardPasswordEncoder();
        String encodedPassword = encoder.encode(newPassword);
        // load fresh user version from db to have managed version and avoid optimistic lock exception.
        User userFromDb = findById(user.getId());
        userFromDb.setPassword(encodedPassword);
        update(userFromDb);
    }
View Full Code Here

Examples of org.springframework.security.crypto.password.PasswordEncoder

     */
    @Override
    public boolean isPaswordCorrect(User user, String password) {
        // load fresh user version from db to be sure to have current password.
        User userFromDb = findById(user.getId());
        PasswordEncoder encoder = new StandardPasswordEncoder();
        String encodedPassword = encoder.encode(password);
        return encodedPassword.equals(userFromDb.getPassword());
    }
View Full Code Here

Examples of org.springframework.security.crypto.password.PasswordEncoder

     * @see org.happyfaces.services.IUserService#changePassword(org.happyfaces.domain.User, java.lang.String)
     */
    @Override
    @Transactional(readOnly = false)
    public void changePassword(User user, String newPassword) {
        PasswordEncoder encoder = new StandardPasswordEncoder();
        String encodedPassword = encoder.encode(newPassword);
        // load fresh user version from db to have managed version and avoid optimistic lock exception.
        User userFromDb = findById(user.getId());
        userFromDb.setPassword(encodedPassword);
        update(userFromDb);
    }
View Full Code Here

Examples of org.springframework.security.crypto.password.PasswordEncoder

  public void testUpdateClientSecret() {

    BaseClientDetails clientDetails = new BaseClientDetails();
    clientDetails.setClientId("newClientIdWithNoDetails");

    service.setPasswordEncoder(new PasswordEncoder() {

      public boolean matches(CharSequence rawPassword,
          String encodedPassword) {
        return true;
      }
View Full Code Here

Examples of org.springframework.security.crypto.password.PasswordEncoder

        User user = repo.findOne(iUserId);
        if (user == null) {
            throw new UserNotFoundEx(""+iUserId);
        }

        PasswordEncoder encoder = encoder(appContext);
    return updatePasswordWithNew(matchOldPassword, oldPassword, newPassword, user, encoder, repo);
  }
View Full Code Here

Examples of org.springframework.security.crypto.password.PasswordEncoder

  }

  @Transactional
  public void createTestUsers() {
    PasswordEncoder encoder = injector.getInstance(PasswordEncoder.class);

    RoleEntity adminRole = new RoleEntity();
    adminRole.setRoleName("admin");

    UserEntity admin = new UserEntity();
    admin.setUserName("administrator");
    admin.setUserPassword(encoder.encode("admin"));

    Set<RoleEntity> roles = new HashSet<RoleEntity>();
    Set<UserEntity> users = new HashSet<UserEntity>();

    roles.add(adminRole);
    users.add(admin);

    admin.setRoleEntities(roles);
    adminRole.setUserEntities(users);

    userDAO.create(admin);
    roleDAO.create(adminRole);

    UserEntity userWithoutRoles = new UserEntity();
    userWithoutRoles.setUserName("userWithoutRoles");
    userWithoutRoles.setUserPassword(encoder.encode("test"));
    userDAO.create(userWithoutRoles);

  }
View Full Code Here

Examples of org.springframework.security.crypto.password.PasswordEncoder

  }

  @Transactional
  public void createTestUsers() {
    PasswordEncoder encoder = injector.getInstance(PasswordEncoder.class);

    RoleEntity adminRole = new RoleEntity();
    adminRole.setRoleName("admin");

    UserEntity admin = new UserEntity();
    admin.setUserName("administrator");
    admin.setUserPassword(encoder.encode("admin"));

    Set<RoleEntity> roles = new HashSet<RoleEntity>();
    Set<UserEntity> users = new HashSet<UserEntity>();

    roles.add(adminRole);
    users.add(admin);

    admin.setRoleEntities(roles);
    adminRole.setUserEntities(users);

    userDAO.create(admin);
    roleDAO.create(adminRole);

    UserEntity userWithoutRoles = new UserEntity();
    userWithoutRoles.setUserName("userWithoutRoles");
    userWithoutRoles.setUserPassword(encoder.encode("test"));
    userDAO.create(userWithoutRoles);

  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.