Package org.springframework.security.authentication.encoding

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


     * @return
     */
    public PasswordCompareConfigurer passwordCompare() {
        return new PasswordCompareConfigurer()
            .passwordAttribute("password")
            .passwordEncoder(new PlaintextPasswordEncoder());
    }
View Full Code Here


    private SaltSource saltSource;

    private UserDetailsService userDetailsService;

    public DaoAuthenticationProvider() {
        setPasswordEncoder(new PlaintextPasswordEncoder());
    }
View Full Code Here

            auth
                .ldapAuthentication()
                    .groupSearchBase("ou=groups")
                    .userSearchFilter("(uid={0})")
                    .passwordCompare()
                        .passwordEncoder(new PlaintextPasswordEncoder()) // ldap-authentication-provider/password-compare/password-encoder@ref
                        .passwordAttribute("userPassword"); // ldap-authentication-provider/password-compare@password-attribute
        }
View Full Code Here

*/
public class PlaintextPasswordEncoderTests extends TestCase {
    //~ Methods ========================================================================================================

    public void testBasicFunctionality() {
        PlaintextPasswordEncoder pe = new PlaintextPasswordEncoder();

        String raw = "abc123";
        String rawDiffCase = "AbC123";
        String badRaw = "abc321";
        String salt = "THIS_IS_A_SALT";

        String encoded = pe.encodePassword(raw, salt);
        assertEquals("abc123{THIS_IS_A_SALT}", encoded);
        assertTrue(pe.isPasswordValid(encoded, raw, salt));
        assertFalse(pe.isPasswordValid(encoded, badRaw, salt));

        // make sure default is not to ignore password case
        assertFalse(pe.isIgnorePasswordCase());
        encoded = pe.encodePassword(rawDiffCase, salt);
        assertFalse(pe.isPasswordValid(encoded, raw, salt));

        // now check for ignore password case
        pe = new PlaintextPasswordEncoder();
        pe.setIgnorePasswordCase(true);

        // should be able to validate even without encoding
        encoded = pe.encodePassword(rawDiffCase, salt);
        assertTrue(pe.isPasswordValid(encoded, raw, salt));
        assertFalse(pe.isPasswordValid(encoded, badRaw, salt));
    }
View Full Code Here

        assertTrue(pe.isPasswordValid(encoded, raw, salt));
        assertFalse(pe.isPasswordValid(encoded, badRaw, salt));
    }

    public void testMergeDemerge() {
        PlaintextPasswordEncoder pwd = new PlaintextPasswordEncoder();

        String merged = pwd.encodePassword("password", "foo");
        String[] demerged = pwd.obtainPasswordAndSalt(merged);
        assertEquals("password", demerged[0]);
        assertEquals("foo", demerged[1]);
    }
View Full Code Here

    //~ Methods ========================================================================================================

    @Before
    public void setUp() throws Exception {
        authenticator = new PasswordComparisonAuthenticator(getContextSource());
        authenticator.setPasswordEncoder(new PlaintextPasswordEncoder());
        authenticator.setUserDnPatterns(new String[] {"uid={0},ou=people"});
        bob = new UsernamePasswordAuthenticationToken("bob", "bobspassword");
        ben = new UsernamePasswordAuthenticationToken("ben", "benspassword");
    }
View Full Code Here

    }

    @Test
    public void testWithUserSearch() {
        authenticator = new PasswordComparisonAuthenticator(getContextSource());
        authenticator.setPasswordEncoder(new PlaintextPasswordEncoder());
        assertTrue("User DN matches shouldn't be available", authenticator.getUserDns("Bob").isEmpty());

        DirContextAdapter ctx = new DirContextAdapter(new DistinguishedName("uid=Bob,ou=people"));
        ctx.setAttributeValue("userPassword", "bobspassword");
View Full Code Here

      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

    super.setUp();

    realm = new DefaultSecurityRealm();
    realm.setConfiguration(PebbleContext.getInstance().getConfiguration());

    passwordEncoder = new PlaintextPasswordEncoder();
    realm.setPasswordEncoder(passwordEncoder);
    saltSource = new ReflectionSaltSource();
    saltSource.setUserPropertyToUse("getUsername");
    realm.setSaltSource(saltSource);
View Full Code Here

    context.setAuthentication(oriAuth);
  }
 
  @Test
  public void testSetPasswordEncoder() {
    org.springframework.security.authentication.encoding.PasswordEncoder enc1 = new PlaintextPasswordEncoder();
    provider.setPasswordEncoder(enc1);

    org.springframework.security.crypto.password.PasswordEncoder enc2 = new StandardPasswordEncoder();
    provider.setPasswordEncoder(enc2);
   
View Full Code Here

TOP

Related Classes of org.springframework.security.authentication.encoding.PlaintextPasswordEncoder

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.