本文整理汇总了Java中org.springframework.security.crypto.password.NoOpPasswordEncoder类的典型用法代码示例。如果您正苦于以下问题:Java NoOpPasswordEncoder类的具体用法?Java NoOpPasswordEncoder怎么用?Java NoOpPasswordEncoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NoOpPasswordEncoder类属于org.springframework.security.crypto.password包,在下文中一共展示了NoOpPasswordEncoder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: passwordEncoder
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
@Bean
public PasswordEncoder passwordEncoder() {
String encodingAlgo = environment.getProperty(ENCODING_ALGORITHM_PROPERTY_NAME, BCRYPT_ALGORITHM);
if ( encodingAlgo == null || encodingAlgo.isEmpty() ) {
encodingAlgo = BCRYPT_ALGORITHM;
}
switch (encodingAlgo.toLowerCase()) {
case BCRYPT_ALGORITHM:
return new BCryptPasswordEncoder();
case NOOP_ALGORITHM:
return NoOpPasswordEncoder.getInstance();
default:
throw new IllegalArgumentException("Unsupported password encoding algorithm : " + encodingAlgo);
}
}
开发者ID:gravitee-io,项目名称:gravitee-management-rest-api,代码行数:17,代码来源:InMemoryAuthenticationProviderConfiguration.java
示例2: getPasswordEncoder
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
public static PasswordEncoder getPasswordEncoder(String algorithm) {
if (algorithm == null) {
algorithm = "";
}
switch (algorithm) {
case BCRYPT_ENCODER:
return new BCryptPasswordEncoder();
case NO_ENCODER:
return NoOpPasswordEncoder.getInstance();
case SHA_256_ENCODER:
return new StandardPasswordEncoder();
default: {
LOGGER.error("No password encoder for algorithm " + algorithm + " found. "
+ "Password encoding is switched off.");
return NoOpPasswordEncoder.getInstance();
}
}
}
示例3: configure
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
@Override
public void configure(AuthorizationServerSecurityConfigurer security)
throws Exception {
security.passwordEncoder(NoOpPasswordEncoder.getInstance());
if (this.properties.getCheckTokenAccess() != null) {
security.checkTokenAccess(this.properties.getCheckTokenAccess());
}
if (this.properties.getTokenKeyAccess() != null) {
security.tokenKeyAccess(this.properties.getTokenKeyAccess());
}
if (this.properties.getRealm() != null) {
security.realm(this.properties.getRealm());
}
}
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:15,代码来源:OAuth2AuthorizationServerConfiguration.java
示例4: passwordEncoder
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
@Bean
public static PasswordEncoder passwordEncoder() {
return NoOpPasswordEncoder.getInstance();
}
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:5,代码来源:OAuth2AutoConfigurationTests.java
示例5: afterPropertiesSet
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
public void afterPropertiesSet() {
if ("md5".equals(type)) {
this.passwordEncoder = new Md5PasswordEncoder(salt);
} else {
this.passwordEncoder = NoOpPasswordEncoder.getInstance();
}
logger.info("choose {}", passwordEncoder.getClass());
}
示例6: createAuthentication
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
public static Authentication createAuthentication(final String username,
final String plaintextPassword,
final Long userId,
final SystemUser.Role role,
final boolean authenticated) {
final SystemUser user = new SystemUser();
user.setUsername(username);
user.setId(userId);
user.setRole(role);
user.setPasswordAsPlaintext(plaintextPassword, NoOpPasswordEncoder.getInstance());
final List<GrantedAuthority> grantedAuthorities = (role != null)
? AuthorityUtils.createAuthorityList(role.name())
: new LinkedList<>();
final UserInfo.UserInfoBuilder builder =
new UserInfo.UserInfoBuilder(user);
final UserInfo principal = builder.createUserInfo();
final TestingAuthenticationToken authenticationToken =
new TestingAuthenticationToken(principal, plaintextPassword, grantedAuthorities);
authenticationToken.setAuthenticated(authenticated);
return authenticationToken;
}
示例7: testInsert
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
@Test
public void testInsert() throws Exception {
PasswordEncoder encoder = NoOpPasswordEncoder.getInstance();
ClientDocument clientDocument = new ClientDocument()
.setAuthorities(Arrays.asList("USER"))
.setClientId("angularClient")
.setClientSecret(encoder.encode("secret123"))
.setGrantTypes(Arrays.asList("password", "refresh_token"))
.setScopes(Arrays.asList("user_actions"))
.setResourceIds(Arrays.asList("PIMP_RESOURCE"));
clientDetailsService.saveClientDetails(clientDocument);
}
示例8: passwordEncoder
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
@Bean
public PasswordEncoder passwordEncoder() {
String encoderConfig = environment.getProperty("security.passwordencoder", String.class, "");
if ("spring_bcrypt".equalsIgnoreCase(encoderConfig)) {
return new BCryptPasswordEncoder();
} else {
return NoOpPasswordEncoder.getInstance();
}
}
示例9: shouldReturnNoOpEncoderWhenNullGiven
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
@Test
public void shouldReturnNoOpEncoderWhenNullGiven() {
PasswordEncoder encoder = PasswordEncoderFactory.getPasswordEncoder(null);
verifyErrorWasLogged();
assertTrue(encoder instanceof NoOpPasswordEncoder);
}
示例10: JdbcAccountRepositoryTest
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
public JdbcAccountRepositoryTest() {
EmbeddedDatabase db = new GreenhouseTestDatabaseBuilder().member().testData(getClass()).getDatabase();
transactional = new Transactional(db);
jdbcTemplate = new JdbcTemplate(db);
AccountMapper accountMapper = new AccountMapper(new StubFileStorage(), "http://localhost:8080/members/{profileKey}");
accountRepository = new JdbcAccountRepository(jdbcTemplate, NoOpPasswordEncoder.getInstance(), accountMapper);
}
示例11: configureGlobal
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth.inMemoryAuthentication()
.passwordEncoder(NoOpPasswordEncoder.getInstance())
.withUser("foo").password("bar").roles("USER");
}
开发者ID:spring-projects,项目名称:spring-security-oauth2-boot,代码行数:7,代码来源:OAuth2AutoConfigurationTests.java
示例12: newPasswordEncoder
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
/**
* New password encoder password encoder.
*
* @param properties the properties
* @return the password encoder
*/
public static PasswordEncoder newPasswordEncoder(final PasswordEncoderProperties properties) {
final String type = properties.getType();
if (StringUtils.isBlank(type)) {
LOGGER.debug("No password encoder type is defined, and so none shall be created");
return NoOpPasswordEncoder.getInstance();
}
if (type.contains(".")) {
try {
LOGGER.debug("Configuration indicates use of a custom password encoder [{}]", type);
final Class<PasswordEncoder> clazz = (Class<PasswordEncoder>) Class.forName(type);
return clazz.newInstance();
} catch (final Exception e) {
LOGGER.error("Falling back to a no-op password encoder as CAS has failed to create "
+ "an instance of the custom password encoder class " + type, e);
return NoOpPasswordEncoder.getInstance();
}
}
final PasswordEncoderProperties.PasswordEncoderTypes encoderType = PasswordEncoderProperties.PasswordEncoderTypes.valueOf(type);
switch (encoderType) {
case DEFAULT:
LOGGER.debug("Creating default password encoder with encoding alg [{}] and character encoding [{}]",
properties.getEncodingAlgorithm(), properties.getCharacterEncoding());
return new DefaultPasswordEncoder(properties.getEncodingAlgorithm(), properties.getCharacterEncoding());
case STANDARD:
LOGGER.debug("Creating standard password encoder with the secret defined in the configuration");
return new StandardPasswordEncoder(properties.getSecret());
case BCRYPT:
LOGGER.debug("Creating BCRYPT password encoder given the strength [{}] and secret in the configuration",
properties.getStrength());
if (StringUtils.isBlank(properties.getSecret())) {
LOGGER.debug("Creating BCRYPT encoder without secret");
return new BCryptPasswordEncoder(properties.getStrength());
}
LOGGER.debug("Creating BCRYPT encoder with secret");
return new BCryptPasswordEncoder(properties.getStrength(),
new SecureRandom(properties.getSecret().getBytes(StandardCharsets.UTF_8)));
case SCRYPT:
LOGGER.debug("Creating SCRYPT encoder");
return new SCryptPasswordEncoder();
case PBKDF2:
if (StringUtils.isBlank(properties.getSecret())) {
LOGGER.debug("Creating PBKDF2 encoder without secret");
return new Pbkdf2PasswordEncoder();
}
final int hashWidth = 256;
return new Pbkdf2PasswordEncoder(properties.getSecret(), properties.getStrength(), hashWidth);
case NONE:
default:
LOGGER.debug("No password encoder shall be created given the requested encoder type [{}]", type);
return NoOpPasswordEncoder.getInstance();
}
}
示例13: passwordEncoder
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
@Bean
public PasswordEncoder passwordEncoder() {
// 明文编码器。这是一个不做任何操作的密码编码器,是Spring提供给我们做明文测试的。
// A password encoder that does nothing. Useful for testing where working with plain text
return NoOpPasswordEncoder.getInstance();
}
示例14: passwordEncoder
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
@Bean
@Primary
public PasswordEncoder passwordEncoder() {
return NoOpPasswordEncoder.getInstance();
}
示例15: passwordEncoder
import org.springframework.security.crypto.password.NoOpPasswordEncoder; //导入依赖的package包/类
@Primary
@Bean
public PasswordEncoder passwordEncoder() {
return NoOpPasswordEncoder.getInstance();
}