Examples of PasswordEncoder


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

            return;
        }

        if (passwordEncoderToSet instanceof org.springframework.security.crypto.password.PasswordEncoder) {
            final org.springframework.security.crypto.password.PasswordEncoder delegate = (org.springframework.security.crypto.password.PasswordEncoder) passwordEncoderToSet;
            passwordEncoder = new PasswordEncoder() {
                @Override
                public String encodePassword(final String rawPass, final Object salt) {
                    checkSalt(salt);
                    return delegate.encode(rawPass);
                }
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.authenticationManager");
            for (Object o : provider.getProviders()) {
                AuthenticationProvider p = (AuthenticationProvider) o;
                if (p instanceof RememberMeAuthenticationProvider) {
                    config.put("rememberMeEnabled", Boolean.FALSE);
                } 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

  CustomUserDetailsService customUserDetailsService;


  public String getMD5EncodedPasswordHash(String pass) {
    try {
      PasswordEncoder encoder = new Md5PasswordEncoder();
      String hashedPass = encoder.encodePassword(pass, null);
      return hashedPass.toLowerCase();
    }
    catch (Exception e) {

    }
View Full Code Here

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


  @Override
  public String encodePassword(String rawPass, Object salt) {
    try {
      PasswordEncoder encoder = new Md5PasswordEncoder();
      String hashedPass = encoder.encodePassword(rawPass, null);
      return hashedPass.toLowerCase();
    }
    catch (Exception e) {

    }
View Full Code Here

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

    }

   
    @Override
    protected PasswordEncoder createStringEncoder() {
        return new PasswordEncoder() {
           
            @Override
            public boolean isPasswordValid(String encPass, String rawPass, Object salt)
                    throws DataAccessException {
               return false;
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;
            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.crypto.password.PasswordEncoder

    }

    // SEC-2056
    public void testUserNotFoundEncodesPassword() {
        UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("missing", "koala");
        PasswordEncoder encoder = mock(PasswordEncoder.class);
        when(encoder.encode(anyString())).thenReturn("koala");
        DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
        provider.setHideUserNotFoundExceptions(false);
        provider.setPasswordEncoder(encoder);
        provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
        try {
View Full Code Here

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

        verify(encoder).matches(isA(String.class),  isA(String.class));
    }

    public void testUserNotFoundBCryptPasswordEncoder() {
        UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("missing", "koala");
        PasswordEncoder encoder =  new BCryptPasswordEncoder();
        DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
        provider.setHideUserNotFoundExceptions(false);
        provider.setPasswordEncoder(encoder);
        MockAuthenticationDaoUserrod userDetailsService = new MockAuthenticationDaoUserrod();
        userDetailsService.password = encoder.encode((CharSequence) token.getCredentials());
        provider.setUserDetailsService(userDetailsService);
        try {
            provider.authenticate(token);
            fail("Expected Exception");
        } catch(UsernameNotFoundException success) {}
View Full Code Here

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

     * deterministic and {@link #testUserNotFoundEncodesPassword()} ensures that SEC-2056 is fixed.
     */
    public void IGNOREtestSec2056() {
        UsernamePasswordAuthenticationToken foundUser = new UsernamePasswordAuthenticationToken("rod", "koala");
        UsernamePasswordAuthenticationToken notFoundUser = new UsernamePasswordAuthenticationToken("notFound", "koala");
        PasswordEncoder encoder = new BCryptPasswordEncoder(10,new SecureRandom());
        DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
        provider.setHideUserNotFoundExceptions(false);
        provider.setPasswordEncoder(encoder);
        MockAuthenticationDaoUserrod userDetailsService = new MockAuthenticationDaoUserrod();
        userDetailsService.password = encoder.encode((CharSequence) foundUser.getCredentials());
        provider.setUserDetailsService(userDetailsService);

        int sampleSize = 100;

        List<Long> userFoundTimes = new ArrayList<Long>(sampleSize);
View Full Code Here

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

        return sum / counts.size();
    }

    public void testUserNotFoundNullCredentials() {
        UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken("missing", null);
        PasswordEncoder encoder = mock(PasswordEncoder.class);
        DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
        provider.setHideUserNotFoundExceptions(false);
        provider.setPasswordEncoder(encoder);
        provider.setUserDetailsService(new MockAuthenticationDaoUserrod());
        try {
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.