本文整理汇总了Java中org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder类的典型用法代码示例。如果您正苦于以下问题:Java BCryptPasswordEncoder类的具体用法?Java BCryptPasswordEncoder怎么用?Java BCryptPasswordEncoder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BCryptPasswordEncoder类属于org.springframework.security.crypto.bcrypt包,在下文中一共展示了BCryptPasswordEncoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: clientAuthenticationProvider
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
@Bean(name = "clientAuthenticationProvider")
public AuthenticationProvider clientAuthenticationProvider() {
DaoAuthenticationProvider provider = new DaoAuthenticationProvider();
provider.setPasswordEncoder(new BCryptPasswordEncoder());
provider.setUserDetailsService(new ClientDetailsUserDetailsService(clientAuthenticationService));
return provider;
}
示例2: passwordEncoder
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
@Bean(name="passwordEncoder")
@Autowired PasswordEncoder passwordEncoder(YadaConfiguration yadaConfiguration) {
if (yadaConfiguration.encodePassword()) {
return new BCryptPasswordEncoder();
}
return null;
}
示例3: Usuario
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
public Usuario(String n, String e, String p) {
name = n;
email = e;
puntos = PUNTOS_POR_DEFECTO;
passwordHash = new BCryptPasswordEncoder().encode(p);
roles = new ArrayList<>();
roles.add("ROLE_USER");
}
示例4: RestAuthenticationProvider
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
@Autowired
public RestAuthenticationProvider(final UserService userService, final CustomerService customerService,
final BCryptPasswordEncoder encoder) {
this.userService = userService;
this.customerService = customerService;
this.encoder = encoder;
}
示例5: User
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
public User(String email, String username, String password, boolean enabled, String fullname) {
this.email = email;
this.username = username;
this.password = new BCryptPasswordEncoder().encode(password);
this.enabled = enabled;
this.fullname = fullname;
}
示例6: gerarBCrypt
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
/**
* Gera um hash utilizando o BCrypt.
*
* @param senha
* @return String
*/
public static String gerarBCrypt(String senha) {
if (senha == null) {
return senha;
}
log.info("Gerando hash com o BCrypt.");
BCryptPasswordEncoder bCryptEncoder = new BCryptPasswordEncoder();
return bCryptEncoder.encode(senha);
}
示例7: passwordEncoder
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
@Bean
public BCryptPasswordEncoder passwordEncoder() {
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
return bCryptPasswordEncoder;
}
示例8: test02_CheckCredentials
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
@Test
public void test02_CheckCredentials() {
LOGGER.info("Running: test02_CheckCredentials");
YourEntity yourEntity = identityProviderEntityManager.findYourEntityByEmail(IntegrationTestSetupBean.USER_EMAIL);
assertNotNull(yourEntity);
BCryptPasswordEncoder encoder =
new BCryptPasswordEncoder(YourMicroserviceSecurityConstants.BCRYPT_STRENGTH_SETTING);
assertTrue(encoder.matches(IntegrationTestSetupBean.CLEAR_TEXT_CREDENTIALS, yourEntity.getCredentials()));
}
示例9: User
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
public User(String id, String userName, String password, String email, int enabled) {
this.id = id;
this.userName = userName;
this.password = new BCryptPasswordEncoder().encode(password);
this.email = email;
this.enabled = enabled;
}
示例10: encode
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
public static String encode(String password) {
BCryptPasswordEncoder encoder = new BCryptPasswordEncoder(4);
String encodedPassword = encoder.encode(password);
return encodedPassword;
}
示例11: passwordEncoder
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
/**
* BCryptPasswordEncoder password encoder
* @return
*/
@Bean
public PasswordEncoder passwordEncoder(){
return new BCryptPasswordEncoder(4);
}
示例12: insertDefaultUserAdministrator
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
@Scheduled(fixedRate = 3600000)
public void insertDefaultUserAdministrator() throws SQLException {
BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
connection = dataSource.getConnection();
preparedStatementSelectUser = connection.prepareStatement(selectTableUserSQL);
preparedStatementSelectUser.setString(1, "admin");
ResultSet resultSetUser = preparedStatementSelectUser.executeQuery();
preparedStatementSelectUserRole = connection.prepareStatement(selectTableUserRoleSQL);
preparedStatementSelectUserRole.setString(1, "admin");
ResultSet resultSetUserRole = preparedStatementSelectUserRole.executeQuery();
preparedStatementSelectOAuthClientDetails = connection.prepareStatement(selectTableOAuthClientDetailSQL);
preparedStatementSelectOAuthClientDetails.setString(1, "clientid");
ResultSet resultOAuthClientDetails = preparedStatementSelectOAuthClientDetails.executeQuery();
if (!resultOAuthClientDetails.next()) {
preparedStatementInsertOAuthClientDetails = connection.prepareStatement(insertTableOAuthClientDetailsSQL);
preparedStatementInsertOAuthClientDetails.setString(1, "clientid");
preparedStatementInsertOAuthClientDetails.setString(2, "customoauth2");
preparedStatementInsertOAuthClientDetails.setString(3, "secret");
preparedStatementInsertOAuthClientDetails.setString(4, "read,write");
preparedStatementInsertOAuthClientDetails.setString(5, "password,client_credentials,refresh_token");
preparedStatementInsertOAuthClientDetails.setString(6, " ");
preparedStatementInsertOAuthClientDetails.setString(7, " ");
preparedStatementInsertOAuthClientDetails.setInt(8, 3600);
preparedStatementInsertOAuthClientDetails.setInt(9, 3600);
preparedStatementInsertOAuthClientDetails.setString(10, "{\"additional_param\":\"hello OAuth2\"}");
preparedStatementInsertOAuthClientDetails.setBoolean(11, Boolean.TRUE);
preparedStatementInsertOAuthClientDetails.executeUpdate();
preparedStatementInsertOAuthClientDetails.close();
}
if (!resultSetUser.next() && !resultSetUserRole.next()) {
preparedStatementInsertUser = connection.prepareStatement(insertTableUserSQL);
preparedStatementInsertUser.setString(1, "admin");
preparedStatementInsertUser.setString(2, bCryptPasswordEncoder.encode("admin"));
preparedStatementInsertUser.setBoolean(3, Boolean.TRUE);
preparedStatementInsertUser.executeUpdate();
preparedStatementInsertUserRole = connection.prepareStatement(insertTableUserRoleSQL);
preparedStatementInsertUserRole.setString(1, UUID.randomUUID().toString());
preparedStatementInsertUserRole.setString(2, "ROLE_ADMIN");
preparedStatementInsertUserRole.setString(3, "admin");
preparedStatementInsertUserRole.executeUpdate();
preparedStatementInsertUser.close();
preparedStatementInsertUserRole.close();
}
preparedStatementSelectUser.close();
preparedStatementSelectUserRole.close();
connection.close();
}
示例13: passwordEncoder
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
/**
* BCryptPasswordEncoder password encoder
* @return
*/
@Description("Standard PasswordEncoder")
@Bean
public PasswordEncoder passwordEncoder(){
return new BCryptPasswordEncoder(4);
}
示例14: encryptPassword
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
/**
* 加密密码
*/
private void encryptPassword(SysUserBaseInfo userEntity) {
String password = userEntity.getPassword();
password = new BCryptPasswordEncoder().encode(password);
userEntity.setPassword(password);
}
示例15: passwordEncoder
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //导入依赖的package包/类
@Bean
public BCryptPasswordEncoder passwordEncoder() {
return new BCryptPasswordEncoder();
}