本文整理匯總了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();
}