Project

General

Profile

Download (1.11 KB) Statistics
| Branch: | Tag: | Revision:
1
package eu.etaxonomy.cdm.vaadin.presenter;
2

    
3
import org.springframework.security.authentication.AuthenticationManager;
4
import org.springframework.security.authentication.UsernamePasswordAuthenticationToken;
5
import org.springframework.security.core.Authentication;
6

    
7
import eu.etaxonomy.cdm.vaadin.util.CdmSpringContextHelper;
8
import eu.etaxonomy.cdm.vaadin.view.AuthenticationView;
9
import eu.etaxonomy.cdm.vaadin.view.IAuthenticationComponent;
10

    
11

    
12

    
13
public class AuthenticationPresenter implements IAuthenticationComponent.AuthenticationComponentListener{
14

    
15
	private final AuthenticationView view;
16

    
17
	public AuthenticationPresenter(AuthenticationView view) {
18
		this.view = view;
19
		view.addListener(this);
20
	}
21

    
22
	@Override
23
	public Authentication login(String userName, String password) {
24
		UsernamePasswordAuthenticationToken token = new UsernamePasswordAuthenticationToken(userName, password);
25
		AuthenticationManager authenticationManager = (AuthenticationManager) CdmSpringContextHelper.getCurrent().getBean("authenticationManager");
26
		Authentication authentication = authenticationManager.authenticate(token);
27
		return authentication;
28
	}
29

    
30
}
(1-1/5)