org.springframework.security.crypto.password.NoOpPasswordEncoder Java Examples

The following examples show how to use org.springframework.security.crypto.password.NoOpPasswordEncoder. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: InMemoryAuthenticationProviderConfiguration.java    From gravitee-management-rest-api with Apache License 2.0 6 votes vote down vote up
@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);
  }

}
 
Example #2
Source File: SecurityConfig.java    From dhis2-core with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Autowired
public void configureGlobal( AuthenticationManagerBuilder auth, UserService userService,
    UserDetailsService userDetailsService, SecurityService securityService,
    @Lazy CustomLdapAuthenticationProvider customLdapAuthenticationProvider )
    throws Exception
{
    TwoFactorAuthenticationProvider twoFactorAuthenticationProvider = new TwoFactorAuthenticationProvider();
    twoFactorAuthenticationProvider.setPasswordEncoder( encoder() );
    twoFactorAuthenticationProvider.setUserService( userService );
    twoFactorAuthenticationProvider.setUserDetailsService( userDetailsService );
    twoFactorAuthenticationProvider.setSecurityService( securityService );

    // configure the Authentication providers

    auth
        // Two factor
        .authenticationProvider( twoFactorAuthenticationProvider )
        // LDAP Authentication
        .authenticationProvider( customLdapAuthenticationProvider )
        //  OAUTH2
        .userDetailsService( defaultClientDetailsUserDetailsService )
            // Use a non-encoding password for oauth2 secrets, since the secret is generated by the client
            .passwordEncoder(NoOpPasswordEncoder.getInstance());
}
 
Example #3
Source File: GlobalSecurityConfig.java    From airsonic with GNU General Public License v3.0 6 votes vote down vote up
@Bean
public PasswordEncoder delegatingPasswordEncoder() {

    // Spring Security 5 require storing the encoder id alongside the encoded password
    // (e.g. "{md5}hash" for an MD5-encoded password hash), which differs from previous
    // versions.
    //
    // Airsonic unfortunately stores passwords in plain-text, which is why we are setting
    // the "no-op" (plain-text) password encoder as a default here. This default will be
    // used when no encoder id is present.
    //
    // This means that legacy Airsonic passwords (stored simply as "password" in the db)
    // will be matched like "{noop}password" and will be recognized successfully. In the
    // future password encoding updates will be done here.

    PasswordEncoder defaultEncoder = NoOpPasswordEncoder.getInstance();
    String defaultIdForEncode = "noop";

    Map<String, PasswordEncoder> encoders = new HashMap<>();
    encoders.put(defaultIdForEncode, defaultEncoder);
    DelegatingPasswordEncoder passworEncoder = new DelegatingPasswordEncoder(defaultIdForEncode, encoders);
    passworEncoder.setDefaultPasswordEncoderForMatches(defaultEncoder);

    return passworEncoder;
}
 
Example #4
Source File: SecurityConfig.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 6 votes vote down vote up
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.inMemoryAuthentication()
    .passwordEncoder(NoOpPasswordEncoder.getInstance())
    .withUser(username).password(password)
    .authorities("USER");
}
 
Example #5
Source File: OAuth2AuthorizationServerConfig.java    From gemini with Apache License 2.0 5 votes vote down vote up
@Override
public void configure(AuthorizationServerSecurityConfigurer security) {
    security
            .passwordEncoder(NoOpPasswordEncoder.getInstance()) // client id and secret dont need encryption
            .tokenKeyAccess("permitAll()")
            .checkTokenAccess("isAuthenticated()")
            .allowFormAuthenticationForClients(); // enable client_id / secret on request body form url encoded
}
 
Example #6
Source File: PasswordEncoderFactoryBean.java    From lemon with Apache License 2.0 5 votes vote down vote up
public void afterPropertiesSet() {
    if ("md5".equals(type)) {
        this.passwordEncoder = new Md5PasswordEncoder(salt);
    } else {
        this.passwordEncoder = NoOpPasswordEncoder.getInstance();
    }

    logger.info("choose {}", passwordEncoder.getClass());
}
 
Example #7
Source File: IdmEngineAutoConfigurationTest.java    From flowable-engine with Apache License 2.0 5 votes vote down vote up
@Test
public void standaloneIdmEngineWithBasicDataSource() {
    contextRunner.run(context -> {
        assertThat(context)
            .doesNotHaveBean(AppEngine.class)
            .doesNotHaveBean(ProcessEngine.class)
            .doesNotHaveBean("idmProcessEngineConfigurationConfigurer")
            .doesNotHaveBean("idmAppEngineConfigurationConfigurer");
        IdmEngine idmEngine = context.getBean(IdmEngine.class);
        assertThat(idmEngine).as("Idm engine").isNotNull();
        assertAllServicesPresent(context, idmEngine);

        assertThat(context).hasSingleBean(CustomUserEngineConfigurerConfiguration.class)
            .hasSingleBean(PasswordEncoder.class)
            .getBean(CustomUserEngineConfigurerConfiguration.class)
            .satisfies(configuration -> {
                assertThat(configuration.getInvokedConfigurations())
                    .containsExactly(
                        SpringIdmEngineConfiguration.class
                    );
            });

        org.flowable.idm.api.PasswordEncoder flowablePasswordEncoder = idmEngine.getIdmEngineConfiguration().getPasswordEncoder();
        PasswordEncoder passwordEncoder = context.getBean(PasswordEncoder.class);
        assertThat(flowablePasswordEncoder)
            .isInstanceOfSatisfying(SpringEncoder.class, springEncoder -> {
                assertThat(springEncoder.getSpringEncodingProvider()).isEqualTo(passwordEncoder);
            });
        assertThat(passwordEncoder).isInstanceOf(NoOpPasswordEncoder.class);
    });
}
 
Example #8
Source File: Oauth20AutoConfiguration.java    From MaxKey with Apache License 2.0 5 votes vote down vote up
/**
 * ProviderManager. 
 * @return oauth20ClientAuthenticationManager
 */
@Bean(name = "oauth20ClientAuthenticationManager")
public ProviderManager oauth20ClientAuthenticationManager(
        ClientDetailsUserDetailsService oauth20ClientDetailsUserService
        ) {
    DaoAuthenticationProvider daoAuthenticationProvider= new DaoAuthenticationProvider();
    PasswordEncoder passwordEncoder = NoOpPasswordEncoder.getInstance();
    daoAuthenticationProvider.setPasswordEncoder(passwordEncoder);
    daoAuthenticationProvider.setUserDetailsService(oauth20ClientDetailsUserService);
    ProviderManager clientAuthenticationManager = new ProviderManager(daoAuthenticationProvider);
    return clientAuthenticationManager;
}
 
Example #9
Source File: OAuth2AutoConfigurationTests.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@Autowired
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
	// @formatter:off
	auth.inMemoryAuthentication().passwordEncoder(NoOpPasswordEncoder.getInstance()).withUser("foo")
			.password("bar").roles("USER");
	// @formatter:on
}
 
Example #10
Source File: OAuth2AuthorizationServerConfiguration.java    From spring-security-oauth2-boot with Apache License 2.0 5 votes vote down vote up
@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());
	}
}
 
Example #11
Source File: SecurityConfig.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.inMemoryAuthentication()
    .passwordEncoder(NoOpPasswordEncoder.getInstance())
    .withUser(username).password(password)
    .authorities("USER");
}
 
Example #12
Source File: SecurityConfig.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.inMemoryAuthentication()
    .passwordEncoder(NoOpPasswordEncoder.getInstance())
    .withUser(username).password(password)
    .authorities("USER");
}
 
Example #13
Source File: SecurityConfig.java    From Hands-On-Microservices-with-Spring-Boot-and-Spring-Cloud with MIT License 5 votes vote down vote up
@Override
public void configure(AuthenticationManagerBuilder auth) throws Exception {
    auth.inMemoryAuthentication()
    .passwordEncoder(NoOpPasswordEncoder.getInstance())
    .withUser(username).password(password)
    .authorities("USER");
}
 
Example #14
Source File: PasswordEncoderFactoriesTest.java    From spring-boot-demo with MIT License 5 votes vote down vote up
public static PasswordEncoder newPasswordEncoder(final String encoderType) {

        switch (encoderType) {
            case "bcrypt":
                return new BCryptPasswordEncoder();
            case "ldap":
                return new org.springframework.security.crypto.password.LdapShaPasswordEncoder();
            case "MD4":
                return new org.springframework.security.crypto.password.Md4PasswordEncoder();
            case "MD5":
                return new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("MD5");
            case "noop":
                return org.springframework.security.crypto.password.NoOpPasswordEncoder.getInstance();
            case "pbkdf2":
                return new Pbkdf2PasswordEncoder();
            case "scrypt":
                return new SCryptPasswordEncoder();
            case "SHA-1":
                return new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-1");
            case "SHA-256":
                return new org.springframework.security.crypto.password.MessageDigestPasswordEncoder("SHA-256");
            case "sha256":
                return new org.springframework.security.crypto.password.StandardPasswordEncoder();
            default:
                return NoOpPasswordEncoder.getInstance();
        }
    }
 
Example #15
Source File: SecurityConfig.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
@Bean
  public PasswordEncoder encoder() {
//    return new StandardPasswordEncoder("53cr3t");
    return NoOpPasswordEncoder.getInstance();
  }
 
Example #16
Source File: WebSecurityConfig.java    From Mastering-Microservices-with-Java-Third-Edition with MIT License 4 votes vote down vote up
@Bean
public PasswordEncoder encoder() {
  return NoOpPasswordEncoder.getInstance();
}
 
Example #17
Source File: SecurityConfig.java    From Vaadin4Spring-MVP-Sample-SpringSecurity with Apache License 2.0 4 votes vote down vote up
@Bean
public PasswordEncoder passwordEncoder() {
	return NoOpPasswordEncoder.getInstance();
}
 
Example #18
Source File: WebSecurityConfig.java    From metron with Apache License 2.0 4 votes vote down vote up
@Bean
public PasswordEncoder passwordEncoder() {
    return NoOpPasswordEncoder.getInstance();
}
 
Example #19
Source File: SecurityConfig.java    From spring-boot-demo with MIT License 4 votes vote down vote up
@Bean
PasswordEncoder passwordEncoder(){
    return NoOpPasswordEncoder.getInstance();
}
 
Example #20
Source File: SecurityConfiguration.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public static NoOpPasswordEncoder passwordEncoder() {
    return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}
 
Example #21
Source File: SecurityConfiguration.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public static NoOpPasswordEncoder passwordEncoder() {
    return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}
 
Example #22
Source File: SecurityConfig.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
@Bean
  public PasswordEncoder encoder() {
//    return new StandardPasswordEncoder("53cr3t");
    return NoOpPasswordEncoder.getInstance();
  }
 
Example #23
Source File: SecurityConfiguration.java    From flowable-engine with Apache License 2.0 4 votes vote down vote up
@Bean
public static NoOpPasswordEncoder passwordEncoder() {
    return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}
 
Example #24
Source File: SecurityConfig.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
@Bean
  public PasswordEncoder encoder() {
//    return new StandardPasswordEncoder("53cr3t");
    return NoOpPasswordEncoder.getInstance();
  }
 
Example #25
Source File: ConfigServiceAutoConfiguration.java    From apollo with Apache License 2.0 4 votes vote down vote up
@Bean
public static NoOpPasswordEncoder passwordEncoder() {
  return (NoOpPasswordEncoder) NoOpPasswordEncoder.getInstance();
}
 
Example #26
Source File: SecurityConfig.java    From microservice-integration with MIT License 4 votes vote down vote up
@Bean
public PasswordEncoder passwordEncoder() {
    return NoOpPasswordEncoder.getInstance();
}
 
Example #27
Source File: WebSecurityConfig.java    From spring-cloud-docker-microservice-book-code with Apache License 2.0 4 votes vote down vote up
@Bean
public PasswordEncoder passwordEncoder() {
  // 明文编码器。这是一个不做任何操作的密码编码器,是Spring提供给我们做明文测试的。
  // A password encoder that does nothing. Useful for testing where working with plain text
  return NoOpPasswordEncoder.getInstance();
}
 
Example #28
Source File: WebSecurityConfig.java    From spring-cloud-docker-microservice-book-code with Apache License 2.0 4 votes vote down vote up
@Bean
public PasswordEncoder passwordEncoder() {
  // 明文编码器。这是一个不做任何操作的密码编码器,是Spring提供给我们做明文测试的。
  // A password encoder that does nothing. Useful for testing where working with plain text
  return NoOpPasswordEncoder.getInstance();
}
 
Example #29
Source File: ActuatorSecurityConfig.java    From spring-in-action-5-samples with Apache License 2.0 4 votes vote down vote up
@Bean
public PasswordEncoder passwordEncoder() {
  return NoOpPasswordEncoder.getInstance();
}
 
Example #30
Source File: SecurityConfig.java    From spring-5-examples with MIT License 4 votes vote down vote up
@Bean PasswordEncoder passwordEncoder() {
  return NoOpPasswordEncoder.getInstance();
}