cleanup work (mostly formating)
This commit is contained in:
parent
f0b106ab60
commit
bb662b4252
|
@ -18,13 +18,11 @@ public class MyController {
|
|||
* information in the event of an unsuccessful login attempt).
|
||||
*/
|
||||
@RequestMapping(value = "/login", method = RequestMethod.GET)
|
||||
public ModelAndView login(
|
||||
@RequestParam(value = "error", required = false) String error) {
|
||||
public ModelAndView login(@RequestParam(value = "error", required = false) String error) {
|
||||
|
||||
ModelAndView model = new ModelAndView();
|
||||
if (error != null) {
|
||||
model.addObject("message",
|
||||
"Username or password not recognised - please try again.");
|
||||
model.addObject("message", "Username or password not recognised - please try again.");
|
||||
}
|
||||
|
||||
model.setViewName("login");
|
||||
|
|
|
@ -17,7 +17,7 @@ import org.springframework.security.web.WebAttributes;
|
|||
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component(value="mySimpleUrlAuthenticationSuccessHandler")
|
||||
@Component(value = "mySimpleUrlAuthenticationSuccessHandler")
|
||||
public class MySimpleUrlAuthenticationSuccessHandler implements AuthenticationSuccessHandler {
|
||||
|
||||
private final Log logger = LogFactory.getLog(this.getClass());
|
||||
|
|
|
@ -6,7 +6,6 @@ package org.baeldung.security;
|
|||
*/
|
||||
public enum SecurityRole {
|
||||
|
||||
ROLE_USER,
|
||||
ROLE_ADMIN;
|
||||
ROLE_USER, ROLE_ADMIN;
|
||||
|
||||
}
|
||||
|
|
|
@ -6,6 +6,6 @@ import org.springframework.security.web.context.AbstractSecurityWebApplicationIn
|
|||
* Registers the springSecurityFilterChain Filter for every URL in the application.
|
||||
*
|
||||
*/
|
||||
public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer{
|
||||
public class SecurityWebApplicationInitializer extends AbstractSecurityWebApplicationInitializer {
|
||||
|
||||
}
|
||||
|
|
|
@ -34,8 +34,7 @@ public class MyUserDetailsService implements UserDetailsService {
|
|||
}
|
||||
|
||||
@Override
|
||||
public UserDetails loadUserByUsername(String username)
|
||||
throws UsernameNotFoundException {
|
||||
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
|
||||
|
||||
logger.info("Load user by username " + username);
|
||||
|
||||
|
@ -52,17 +51,14 @@ public class MyUserDetailsService implements UserDetailsService {
|
|||
* Create demo users (note: obviously in a real system these would be persisted
|
||||
* in database or retrieved from another system).
|
||||
*/
|
||||
private void populateDemoUsers(){
|
||||
private void populateDemoUsers() {
|
||||
|
||||
logger.info("Populate demo users");
|
||||
|
||||
availableUsers.put("user",
|
||||
createUser("user", "password", Arrays.asList(SecurityRole.ROLE_USER)));
|
||||
availableUsers.put("admin",
|
||||
createUser("admin", "password", Arrays.asList(SecurityRole.ROLE_ADMIN)));
|
||||
availableUsers.put("user", createUser("user", "password", Arrays.asList(SecurityRole.ROLE_USER)));
|
||||
availableUsers.put("admin", createUser("admin", "password", Arrays.asList(SecurityRole.ROLE_ADMIN)));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create a demo User.
|
||||
*
|
||||
|
|
|
@ -23,5 +23,3 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue