spring security - How to add arguments to constructor of BCryptPasswordEncoder to make it stronger? -
i have bcryptpasswordencoder
implemented on spirngsecurity, @ present using simple constructor without argument, how can make stronger?
following question, tried use random , 512 strength not find declared namespace.
<beans:beans xmlns='http://www.springframework.org/schema/security' xmlns:beans='http://www.springframework.org/schema/beans' xmlns:xsi='http://www.w3.org/2001/xmlschema-instance' xsi:schemalocation='http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.1.xsd http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-3.1.xsd' xmlns:c='http://www.springframework.org/schema/c'> ..... </authentication-manager> <beans:bean id='bcryptpasswordencoder' class='org.springframework.security.crypto.bcrypt.bcryptpasswordencoder' c:strength="512" c:random="20"/> </beans:bean>
my code
securerandom random = new securerandom(); byte bytes[] = new byte[20]; random.nextbytes(bytes); passwordencoder passwordencoder = new bcryptpasswordencoder(512, random); string digest = passwordencoder.encode(rawpassword); system.our.println(digest);
error following
error: file not found in specified address : http://www.springframework.org/schema/c
pom.xml
<dependency> <groupid>org.springframework</groupid> <artifactid>spring-webmvc</artifactid> <version>3.1.1.release</version> </dependency> <dependency> <groupid>org.springframework.security</groupid> <artifactid>spring-security-web</artifactid> <version>3.1.1.release</version> </dependency> <dependency> <groupid>org.springframework.security</groupid> <artifactid>spring-security-core</artifactid> <version>3.1.4.release</version> </dependency> <dependency> <groupid>org.springframework.security</groupid> <artifactid>spring-security-taglibs</artifactid> <version>3.1.1.release</version> </dependency> <dependency> <groupid>org.springframework.security</groupid> <artifactid>spring-security-config</artifactid> <version>3.1.1.release</version> </dependency>
you missing schemalocation
declaration 'c' schema. remove , use plain bean declaration:
<beans:bean id='bcryptpasswordencoder' class='org.springframework.security.crypto.bcrypt.bcryptpasswordencoder'> <beans:constructor-arg value="12" /> </beans:bean>
you should read on bcrypt before trying configure "make stronger", , able explain why default isn't strong enough requirements. strength parameter logarithmic, , defaults 10. each time increment double amount of work needed, , time app take check password. value of 512 doesn't make sense. if supply value greater 31 error.
also, don't know why string set random
instance 20
in xml configuration. argument has securerandom
instance, should remove that.
Comments
Post a Comment