org.springframework.security.crypto.scrypt.SCryptPasswordEncoder Java Examples

The following examples show how to use org.springframework.security.crypto.scrypt.SCryptPasswordEncoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PasswordEncoderFactory.java    From authmore-framework with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
public static PasswordEncoder createDelegatingPasswordEncoder() {
    String encodingId = "pbkdf2";
    Map<String, PasswordEncoder> encoders = new HashMap<>();
    encoders.put(encodingId, new BCryptPasswordEncoder());
    encoders.put("ldap", new org.springframework.security.crypto.password.LdapShaPasswordEncoder());
    encoders.put("MD4", new org.springframework.security.crypto.password.Md4PasswordEncoder());
    encoders.put("MD5", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("MD5"));
    encoders.put("noop", org.springframework.security.crypto.password.NoOpPasswordEncoder.getInstance());
    encoders.put("pbkdf2", new Pbkdf2PasswordEncoder());
    encoders.put("scrypt", new SCryptPasswordEncoder());
    encoders.put("SHA-1", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-1"));
    encoders.put("SHA-256", new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-256"));
    encoders.put("sha256", new org.springframework.security.crypto.password.StandardPasswordEncoder());

    return new DelegatingPasswordEncoder(encodingId, encoders);
}
 
Example #2
Source File: PasswordEncoderFactoriesTest.java    From spring-boot-demo with MIT License 5 votes vote down vote up
public static PasswordEncoder newPasswordEncoder(final String encoderType) {

        switch (encoderType) {
            case "bcrypt":
                return new BCryptPasswordEncoder();
            case "ldap":
                return new org.springframework.security.crypto.password.LdapShaPasswordEncoder();
            case "MD4":
                return new org.springframework.security.crypto.password.Md4PasswordEncoder();
            case "MD5":
                return new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("MD5");
            case "noop":
                return org.springframework.security.crypto.password.NoOpPasswordEncoder.getInstance();
            case "pbkdf2":
                return new Pbkdf2PasswordEncoder();
            case "scrypt":
                return new SCryptPasswordEncoder();
            case "SHA-1":
                return new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-1");
            case "SHA-256":
                return new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-256");
            case "sha256":
                return new org.springframework.security.crypto.password.StandardPasswordEncoder();
            default:
                return NoOpPasswordEncoder.getInstance();
        }
    }
 
Example #3
Source File: WebSecurityConfig.java    From Spring-5.0-Projects with MIT License 5 votes vote down vote up
@Bean
public PasswordEncoder passwordEncoder() {
	
	  Map<String,PasswordEncoder> encoders = new HashMap<>();
	  encoders.put(PwdEncodingAlgo.BCrypt.getStatus(), new BCryptPasswordEncoder());
	  encoders.put(PwdEncodingAlgo.Pbkf2.getStatus(), new Pbkdf2PasswordEncoder());
	  encoders.put(PwdEncodingAlgo.SCrypt.getStatus(), new SCryptPasswordEncoder());
	 
	  return new DelegatingPasswordEncoder(PwdEncodingAlgo.BCrypt.getStatus(), encoders);
}
 
Example #4
Source File: SCryptExample.java    From code-examples with MIT License 5 votes vote down vote up
public String encode(String plainPassword) {
  int cpuCost = (int) Math.pow(2, 14); // factor to increase CPU costs
  int memoryCost = 8; // factor to increases memory usage
  int parallelization = 1; // currently  nor supported by Spring Security
  int keyLength = 32; // key length in bytes
  int saltLength = 64; // salt length in bytes

  SCryptPasswordEncoder sCryptPasswordEncoder =
      new SCryptPasswordEncoder(cpuCost, memoryCost, parallelization, keyLength, saltLength);
  return sCryptPasswordEncoder.encode(plainPassword);
}
 
Example #5
Source File: SecurityConfiguration.java    From code-examples with MIT License 5 votes vote down vote up
@Bean
public PasswordEncoder passwordEncoder() {
  // we must use deprecated encoder to support their encoding
  String encodingId = "bcrypt";
  Map<String, PasswordEncoder> encoders = new HashMap<>();
  encoders.put(encodingId, new BCryptPasswordEncoder(bcCryptWorkFactorService.calculateStrength()));
  encoders.put("ldap", new LdapShaPasswordEncoder());
  encoders.put("MD4", new Md4PasswordEncoder());
  encoders.put("MD5", new MessageDigestPasswordEncoder("MD5"));
  encoders.put("noop", NoOpPasswordEncoder.getInstance());
  encoders.put("pbkdf2", new Pbkdf2PasswordEncoder());
  encoders.put("scrypt", new SCryptPasswordEncoder());
  encoders.put("SHA-1", new MessageDigestPasswordEncoder("SHA-1"));
  encoders.put("SHA-256", new MessageDigestPasswordEncoder("SHA-256"));
  encoders.put("sha256", new StandardPasswordEncoder());
  encoders.put("argon2", new Argon2PasswordEncoder());

  return new DelegatingPasswordEncoder(encodingId, encoders);
}
 
Example #6
Source File: SecurityConfig.java    From Spring-Boot-2.0-Projects with MIT License 4 votes vote down vote up
@Bean
public PasswordEncoder passwordEncoder() {
    return new SCryptPasswordEncoder();
}
 
Example #7
Source File: WebSecurityConfig.java    From Auth-service with MIT License 2 votes vote down vote up
@Bean
public PasswordEncoder passwordEncoder(){

    return new SCryptPasswordEncoder();

}