Package org.springframework.security.authentication.encoding

Examples of org.springframework.security.authentication.encoding.PlaintextPasswordEncoder.encodePassword()


        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
View Full Code Here


        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);
View Full Code Here

        // 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));
    }

    public void testMergeDemerge() {
View Full Code Here

    }

    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

    } 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

                return encoder.isPasswordValid(encPass, new String(rawPass), salt);
            }
           
            @Override
            public String encodePassword(char[] rawPass, Object salt) {
                return encoder.encodePassword(new String(rawPass), salt);
            }
        };
    }

    @Override
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.