當前位置: 首頁>>代碼示例>>Java>>正文


Java BCryptPasswordEncoder類代碼示例

本文整理匯總了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;
}
 
開發者ID:PatternFM,項目名稱:tokamak,代碼行數:8,代碼來源:AuthorizationServerConfiguration.java

示例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;
}
 
開發者ID:xtianus,項目名稱:yadaframework,代碼行數:8,代碼來源:YadaSecurityConfig.java

示例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");
}
 
開發者ID:arubioVK,項目名稱:La-Apostada,代碼行數:9,代碼來源:Usuario.java

示例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;
}
 
開發者ID:osswangxining,項目名稱:iotplatform,代碼行數:8,代碼來源:RestAuthenticationProvider.java

示例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;
}
 
開發者ID:atereshkov,項目名稱:Diber-backend,代碼行數:8,代碼來源:User.java

示例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);
}
 
開發者ID:m4rciosouza,項目名稱:ponto-inteligente-api,代碼行數:16,代碼來源:PasswordUtils.java

示例7: passwordEncoder

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //導入依賴的package包/類
@Bean
public BCryptPasswordEncoder passwordEncoder() {
	BCryptPasswordEncoder bCryptPasswordEncoder = new BCryptPasswordEncoder();
	return bCryptPasswordEncoder;
}
 
開發者ID:oojorgeoo89,項目名稱:QuizZz,代碼行數:6,代碼來源:WebMvcConfig.java

示例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()));
}
 
開發者ID:jaschenk,項目名稱:Your-Microservice,代碼行數:11,代碼來源:IdPCredentialIT.java

示例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;
}
 
開發者ID:tadeucruz,項目名稱:spring-oauth2-jwt,代碼行數:8,代碼來源:User.java

示例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;
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:6,代碼來源:BCryptPasswordEncoderMain.java

示例11: passwordEncoder

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //導入依賴的package包/類
/**
 * BCryptPasswordEncoder password encoder
 * @return
 */
@Bean
public PasswordEncoder passwordEncoder(){
    return new BCryptPasswordEncoder(4);
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:9,代碼來源:SecurityConfig.java

示例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();

}
 
開發者ID:RizkiMufrizal,項目名稱:Spring-OAuth2-Custom,代碼行數:60,代碼來源:ScheduledTaskConfiguration.java

示例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);
}
 
開發者ID:PacktPublishing,項目名稱:Spring-Security-Third-Edition,代碼行數:10,代碼來源:SecurityConfig.java

示例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);
}
 
開發者ID:514840279,項目名稱:danyuan-application,代碼行數:9,代碼來源:SysUserBaseController.java

示例15: passwordEncoder

import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; //導入依賴的package包/類
@Bean
public BCryptPasswordEncoder passwordEncoder() {
	return new BCryptPasswordEncoder();

}
 
開發者ID:514840279,項目名稱:danyuan-application,代碼行數:6,代碼來源:WebSecurityConfig.java


注:本文中的org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。