|
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 |
| import org.acegisecurity.providers.UsernamePasswordAuthenticationToken; |
|
22 |
| |
|
23 |
| import org.springframework.beans.factory.InitializingBean; |
|
24 |
| import org.springframework.util.Assert; |
|
25 |
| |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| |
|
38 |
| |
|
39 |
| public class RemoteAuthenticationManagerImpl |
|
40 |
| implements RemoteAuthenticationManager, InitializingBean { |
|
41 |
| |
|
42 |
| |
|
43 |
| private AuthenticationManager authenticationManager; |
|
44 |
| |
|
45 |
| |
|
46 |
| |
|
47 |
4
| public void setAuthenticationManager(
|
|
48 |
| AuthenticationManager authenticationManager) { |
|
49 |
4
| this.authenticationManager = authenticationManager;
|
|
50 |
| } |
|
51 |
| |
|
52 |
1
| public AuthenticationManager getAuthenticationManager() {
|
|
53 |
1
| return authenticationManager;
|
|
54 |
| } |
|
55 |
| |
|
56 |
2
| public void afterPropertiesSet() throws Exception {
|
|
57 |
2
| Assert.notNull(this.authenticationManager, "authenticationManager is required");
|
|
58 |
| } |
|
59 |
| |
|
60 |
2
| public GrantedAuthority[] attemptAuthentication(String username,
|
|
61 |
| String password) throws RemoteAuthenticationException { |
|
62 |
2
| UsernamePasswordAuthenticationToken request = new UsernamePasswordAuthenticationToken(username,
|
|
63 |
| password); |
|
64 |
| |
|
65 |
2
| try {
|
|
66 |
2
| return authenticationManager.authenticate(request).getAuthorities();
|
|
67 |
| } catch (AuthenticationException authEx) { |
|
68 |
1
| throw new RemoteAuthenticationException(authEx.getMessage());
|
|
69 |
| } |
|
70 |
| } |
|
71 |
| } |