本文整理汇总了Java中org.springframework.security.authentication.encoding.ShaPasswordEncoder.setEncodeHashAsBase64方法的典型用法代码示例。如果您正苦于以下问题:Java ShaPasswordEncoder.setEncodeHashAsBase64方法的具体用法?Java ShaPasswordEncoder.setEncodeHashAsBase64怎么用?Java ShaPasswordEncoder.setEncodeHashAsBase64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.security.authentication.encoding.ShaPasswordEncoder
的用法示例。
在下文中一共展示了ShaPasswordEncoder.setEncodeHashAsBase64方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入方法依赖的package包/类
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
ShaPasswordEncoder encoder = new ShaPasswordEncoder();
encoder.setEncodeHashAsBase64(true);
auth
.inMemoryAuthentication()
.passwordEncoder(encoder)
.withUser("admin").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("ADMIN").and()
.withUser("coordinator").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("COORDINATOR");
User coordinator = new Coordinator();
coordinator.setUsername("coordinator");
userRepository.save(coordinator);
auth
.ldapAuthentication()
.userSearchFilter("uid={0}")
.contextSource().url("ldap://dir3.udl.net:389/dc=UdL,dc=es")
.and()
.userDetailsContextMapper(userDetailsContextMapper);
}
示例2: main
import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入方法依赖的package包/类
public static void main(String[] args) {
ShaPasswordEncoder enc = new ShaPasswordEncoder(512);
enc.setIterations(1000);
enc.setEncodeHashAsBase64(true);
String encodedPass = enc.encodePassword("nesa", "nesa");
System.out.println(encodedPass);
System.out.println(enc.isPasswordValid(encodedPass, "nesa", "nesa"));
}
示例3: init
import org.springframework.security.authentication.encoding.ShaPasswordEncoder; //导入方法依赖的package包/类
@Override
public void init(AuthenticationManagerBuilder auth) throws Exception {
ShaPasswordEncoder encoder = new ShaPasswordEncoder();
encoder.setEncodeHashAsBase64(true);
auth
.inMemoryAuthentication()
.passwordEncoder(encoder)
.withUser("admin").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("ADMIN").and()
.withUser("coordinator1").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("COORDINATOR").and()
.withUser("professor1").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("PROFESSOR", "PROPONENT").and()
.withUser("student1").password("18LcJuI3xeanShlrg/oherDmVf4=").roles("STUDENT", "PROFESSOR");
}