Examples of PasswordEncoder


Examples of org.springframework.security.authentication.encoding.PasswordEncoder

        }

        if (passwordEncoder instanceof org.springframework.security.crypto.password.PasswordEncoder) {
            final org.springframework.security.crypto.password.PasswordEncoder delegate =
                    (org.springframework.security.crypto.password.PasswordEncoder)passwordEncoder;
            setPasswordEncoder(new PasswordEncoder() {
                public String encodePassword(String rawPass, Object salt) {
                    checkSalt(salt);
                    return delegate.encode(rawPass);
                }
View Full Code Here

Examples of org.springframework.security.authentication.encoding.PasswordEncoder

        }

        if (passwordEncoder instanceof org.springframework.security.crypto.password.PasswordEncoder) {
            final org.springframework.security.crypto.password.PasswordEncoder delegate =
                    (org.springframework.security.crypto.password.PasswordEncoder)passwordEncoder;
            setPasswordEncoder(new PasswordEncoder() {
                public String encodePassword(String rawPass, Object salt) {
                    checkSalt(salt);
                    return delegate.encode(rawPass);
                }
View Full Code Here

Examples of org.springframework.security.authentication.encoding.PasswordEncoder

        SaltSource saltSource = createNiceMock(SaltSource.class);
        UserDetails userDetails = createNiceMock(UserDetails.class);
        expect(userDetails.getUsername()).andReturn("valid.user");
        expect(userDetails.getPassword()).andReturn("valid.password");
        expect(saltSource.getSalt(userDetails)).andReturn("salt");
        PasswordEncoder passwordEncoder = createNiceMock(PasswordEncoder.class);
        expect(passwordEncoder.encodePassword("valid.password", "salt")).andReturn("valid.password");
        replay(saltSource, userDetails, passwordEncoder);

        ReflectionTestUtils.setField(newAccountService, "saltSource", saltSource);
        ReflectionTestUtils.setField(newAccountService, "passwordEncoder", passwordEncoder);
View Full Code Here

Examples of org.springframework.security.authentication.encoding.PasswordEncoder

        }
    }

    private String getHash() throws NoSuchAlgorithmException, UnsupportedEncodingException
    {
        PasswordEncoder encoder = new Md5PasswordEncoder();
        String hashedPass = encoder.encodePassword(password, null);

        password = password.replaceAll(".*", "0");
        passwordConf = passwordConf.replaceAll(".*", "0");
        return hashedPass;
    }
View Full Code Here

Examples of org.springframework.security.authentication.encoding.PasswordEncoder

    private UserDTO user;
      
        @DefaultHandler
        public Resolution registerAdmin(){
        user.setAuthority("ROLE_SUPERVISOR");
        PasswordEncoder encoder = new ShaPasswordEncoder();
        String hashedPass = encoder.encodePassword(user.getPassword(), user.getName());
        user.setPassword(hashedPass);
       
        try{
        service.create(user);}
        catch(PersistenceException ex){
View Full Code Here

Examples of org.springframework.security.authentication.encoding.PasswordEncoder

    private UserDTO user;
      
        @DefaultHandler
    public Resolution register(){
        user.setAuthority("ROLE_USER");
        PasswordEncoder encoder = new ShaPasswordEncoder();
        String hashedPass = encoder.encodePassword(user.getPassword(), user.getName());
        user.setPassword(hashedPass);
        //service.create(user);
       
        try{
        service.create(user);}
View Full Code Here

Examples of org.springframework.security.authentication.encoding.PasswordEncoder

        /*String[] beans = ctx.getBeanDefinitionNames();
        for (String bean : beans) {
            log.debug(bean);
        }*/

        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.authentication.encoding.PasswordEncoder

  public static void main(String[] args) {
    if (args.length != 3) {
      System.out.println("Usage : [md5|sha|plaintext] username password");
    } else if (args[0].equals("md5")) {
      PasswordEncoder encoder = new Md5PasswordEncoder();
      System.out.println(encoder.encodePassword(args[2], args[1]));
    } else if (args[0].equals("sha")) {
      PasswordEncoder encoder = new ShaPasswordEncoder();
      System.out.println(encoder.encodePassword(args[2], args[1]));
    } else if (args[0].equals("plaintext")) {
      PasswordEncoder encoder = new PlaintextPasswordEncoder();
      System.out.println(encoder.encodePassword(args[2], args[1]));
    } else {
      System.out.println("Algorithm must be md5, sha or plaintext");
    }
  }
View Full Code Here

Examples of org.springframework.security.authentication.encoding.PasswordEncoder

      return;
    }

    if (passwordEncoder instanceof org.springframework.security.crypto.password.PasswordEncoder) {
      final org.springframework.security.crypto.password.PasswordEncoder delegate = cast(passwordEncoder);
      this.passwordEncoder = new PasswordEncoder() {
        public String encodePassword(String rawPass, Object salt) {
          checkSalt(salt);
          return delegate.encode(rawPass);
        }
View Full Code Here

Examples of org.springframework.security.authentication.encoding.PasswordEncoder

   * 如果用户名或密码错误则抛出异常.
   */
  public void handle(Callback[] callbacks) throws IOException, UnsupportedCallbackException {

    WSPasswordCallback pc = (WSPasswordCallback) callbacks[0];
    PasswordEncoder encoder = new ShaPasswordEncoder();
    User user = accountManager.findUserByLoginName(pc.getIdentifier());

    if (user == null) {
      throw new IOException("wrong login name " + pc.getIdentifier());
    }
    //对WSPasswordCallback中的明文密码进行sha1散列, 再与数据库中保存的用户sha1散列密码进行比较.
    if (!encoder.isPasswordValid(user.getShaPassword(), pc.getPassword(), null)) {
      throw new IOException("wrong password " + pc.getPassword() + " for " + pc.getIdentifier());
    }
  }
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.