1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.acegisecurity.providers.rcp;
17
18 import org.acegisecurity.AuthenticationException;
19 import org.acegisecurity.AuthenticationManager;
20 import org.acegisecurity.GrantedAuthority;
21
22 import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
23
24 import org.springframework.beans.factory.InitializingBean;
25
26 import org.springframework.util.Assert;
27
28
29
30
31
32
33
34
35
36
37 public class RemoteAuthenticationManagerImpl implements RemoteAuthenticationManager, InitializingBean {
38
39
40 private AuthenticationManager authenticationManager;
41
42
43
44 public void afterPropertiesSet() throws Exception {
45 Assert.notNull(this.authenticationManager, "authenticationManager is required");
46 }
47
48 public GrantedAuthority[] attemptAuthentication(String username, String password)
49 throws RemoteAuthenticationException {
50 UsernamePasswordAuthenticationToken request = new UsernamePasswordAuthenticationToken(username, password);
51
52 try {
53 return authenticationManager.authenticate(request).getAuthorities();
54 } catch (AuthenticationException authEx) {
55 throw new RemoteAuthenticationException(authEx.getMessage());
56 }
57 }
58
59 public AuthenticationManager getAuthenticationManager() {
60 return authenticationManager;
61 }
62
63 public void setAuthenticationManager(AuthenticationManager authenticationManager) {
64 this.authenticationManager = authenticationManager;
65 }
66 }