Skip to content

Commit

Permalink
Merge pull request jhipster#2 from rwinch/security-configuration-cleanup
Browse files Browse the repository at this point in the history
Cleanup SecurityConfiguration
  • Loading branch information
jmirc committed Mar 25, 2014
2 parents ec4d15c + 047576d commit 66eb7b2
Showing 1 changed file with 10 additions and 25 deletions.
35 changes: 10 additions & 25 deletions src/main/java/com/mycompany/myapp/config/SecurityConfiguration.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
package com.mycompany.myapp.config;

import com.mycompany.myapp.config.reload.condition.ConditionalOnSpringLoaded;
import com.mycompany.myapp.security.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.authentication.RememberMeAuthenticationProvider;
import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.method.configuration.EnableGlobalMethodSecurity;
import org.springframework.security.config.annotation.method.configuration.GlobalMethodSecurityConfiguration;
Expand Down Expand Up @@ -40,34 +37,22 @@ public class SecurityConfiguration extends WebSecurityConfigurerAdapter {
@Inject
private Http401UnauthorizedEntryPoint authenticationEntryPoint;

@Bean
public RememberMeServices rememberMeServices() {
return new CustomPersistentRememberMeServices(env, userDetailsService());
}

@Bean
public RememberMeAuthenticationProvider rememberMeAuthenticationProvider() {
return new RememberMeAuthenticationProvider(env.getProperty("jhipster.security.rememberme.key"));
}
@Inject
private UserDetailsService userDetailsService;

@Bean
public AuthenticationManager authenticationManager() throws Exception {
return super.authenticationManager();
}
@Inject
private RememberMeServices rememberMeServices;

@Bean
public PasswordEncoder passwordEncoder() {
return new StandardPasswordEncoder();
}

@Bean
public UserDetailsService userDetailsService() {
return new com.mycompany.myapp.security.UserDetailsService();
}

@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception {
auth.userDetailsService(userDetailsService()).passwordEncoder(passwordEncoder());
@Inject
public void configureGlobal(AuthenticationManagerBuilder auth) throws Exception {
auth
.userDetailsService(userDetailsService)
.passwordEncoder(passwordEncoder());
}

@Override
Expand All @@ -89,7 +74,7 @@ protected void configure(HttpSecurity http) throws Exception {
.authenticationEntryPoint(authenticationEntryPoint)
.and()
.rememberMe()
.rememberMeServices(rememberMeServices())
.rememberMeServices(rememberMeServices)
.key(env.getProperty("jhipster.security.rememberme.key"))
.and()
.formLogin()
Expand Down

0 comments on commit 66eb7b2

Please sign in to comment.