Skip to content

Commit

Permalink
change passwordencoder fot bcrypt to delegating(pbkdf2) #424
Browse files Browse the repository at this point in the history
  • Loading branch information
btkobayashirun committed Aug 22, 2018
1 parent cf1124e commit d997278
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package xxxxxx.yyyyyy.zzzzzz.domain.common;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.FactoryBean;
import org.springframework.security.crypto.password.DelegatingPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;
import org.springframework.security.crypto.password.Pbkdf2PasswordEncoder;

public class PasswordEncoderFactoryBean implements FactoryBean<PasswordEncoder>{

private PasswordEncoder passwordencoder;

public PasswordEncoderFactoryBean(){
String encodingId = "pbkdf2";
Map<String, PasswordEncoder> encoders = new HashMap<>();
encoders.put(encodingId, new Pbkdf2PasswordEncoder());
passwordencoder = new DelegatingPasswordEncoder(encodingId, encoders);
}

@Override
public PasswordEncoder getObject() throws Exception {
return passwordencoder;
}

@Override
public Class<?> getObjectType() {
return PasswordEncoder.class;
}

@Override
public boolean isSingleton() {
return true;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

<import resource="classpath:/META-INF/spring/projectName-domain.xml" />

<bean id="passwordEncoder" class="org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder" />
<bean id="passwordEncoder" class="xxxxxx.yyyyyy.zzzzzz.domain.common.PasswordEncoderFactoryBean" />

<context:property-placeholder
location="classpath*:/META-INF/spring/*.properties" />
Expand Down

0 comments on commit d997278

Please sign in to comment.