Revision 86b2da34
Added by Andreas Kohlbecker almost 7 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/view/LoginPresenter.java | ||
---|---|---|
16 | 16 |
import org.springframework.security.authentication.AuthenticationManager; |
17 | 17 |
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken; |
18 | 18 |
import org.springframework.security.core.Authentication; |
19 |
import org.springframework.security.core.context.SecurityContext; |
|
20 |
import org.springframework.security.core.context.SecurityContextHolder; |
|
21 | 19 |
|
22 | 20 |
import com.vaadin.spring.annotation.SpringComponent; |
23 | 21 |
import com.vaadin.spring.annotation.UIScope; |
24 | 22 |
|
25 | 23 |
import eu.etaxonomy.cdm.vaadin.event.AuthenticationAttemptEvent; |
26 | 24 |
import eu.etaxonomy.cdm.vaadin.event.AuthenticationSuccessEvent; |
27 |
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper; |
|
28 | 25 |
import eu.etaxonomy.vaadin.mvp.AbstractPresenter; |
29 | 26 |
import eu.etaxonomy.vaadin.ui.navigation.NavigationManager; |
30 | 27 |
|
... | ... | |
59 | 56 |
@Autowired |
60 | 57 |
protected ApplicationEventPublisher eventBus; |
61 | 58 |
|
62 |
/** |
|
63 |
* @return |
|
64 |
* |
|
65 |
* FIXME is it ok to use the SecurityContextHolder or do we need to hold the context in the vaadin session? |
|
66 |
*/ |
|
67 |
private SecurityContext currentSecurityContext() { |
|
68 |
return SecurityContextHolder.getContext(); |
|
69 |
} |
|
70 |
|
|
71 | 59 |
public boolean authenticate(String userName, String password){ |
72 | 60 |
|
73 | 61 |
UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(userName, password); |
74 |
AuthenticationManager authenticationManager = (AuthenticationManager) CdmSpringContextHelper.getCurrent().getBean("authenticationManager");
|
|
62 |
AuthenticationManager authenticationManager = getRepo().getAuthenticationManager();
|
|
75 | 63 |
Authentication authentication = authenticationManager.authenticate(token); |
76 | 64 |
|
77 | 65 |
if(authentication != null && authentication.isAuthenticated()) { |
78 |
log.debug("user '" + userName + "' autheticated"); |
|
66 |
log.debug("user '" + userName + "' authenticated");
|
|
79 | 67 |
currentSecurityContext().setAuthentication(authentication); |
80 | 68 |
if(NavigationManager.class.isAssignableFrom(getNavigationManager().getClass())){ |
81 | 69 |
log.debug("reloading current view"); |
Also available in: Unified diff
ref #6169 filtering registration list by role, user and status in the 2 ListView modes