1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.client.acegi;
17
18 import org.acegisecurity.Authentication;
19 import org.acegisecurity.AuthenticationException;
20 import org.acegisecurity.GrantedAuthority;
21 import org.acegisecurity.GrantedAuthorityImpl;
22 import org.acegisecurity.providers.AuthenticationProvider;
23 import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
24 import org.apache.commons.logging.Log;
25 import org.apache.commons.logging.LogFactory;
26
27
28
29
30
31
32
33 public class KualiTestAuthenticationProvider implements AuthenticationProvider {
34
35 public Authentication authenticate(Authentication authentication)
36 throws AuthenticationException {
37
38 if (authentication.getPrincipal().equals(authentication.getCredentials())) {
39 Authentication auth = authenticateNow(authentication);
40 return auth;
41 } else {
42 return authentication;
43 }
44 }
45
46 private UsernamePasswordAuthenticationToken authenticateNow(Authentication authentication) throws AuthenticationException {
47 return new UsernamePasswordAuthenticationToken(authentication.getPrincipal(), authentication.getCredentials(), new GrantedAuthority[] {new GrantedAuthorityImpl("ROLE_KUALI_USER")});
48 }
49
50 public boolean supports(Class authentication) {
51 if (UsernamePasswordAuthenticationToken.class.isAssignableFrom(authentication)) {
52 return true;
53 } else {
54 return false;
55 }
56 }
57 }