]> git.argeo.org Git - lgpl/argeo-commons.git/blob - InternalAuthenticationProvider.java
4b7e047baecbd5fe0ee843bec8fbc670b4dad37f
[lgpl/argeo-commons.git] / InternalAuthenticationProvider.java
1 package org.argeo.security.core;
2
3 import org.springframework.security.authentication.AuthenticationProvider;
4 import org.springframework.security.core.Authentication;
5 import org.springframework.security.core.AuthenticationException;
6
7 public class InternalAuthenticationProvider implements AuthenticationProvider {
8 private String key;
9
10 public InternalAuthenticationProvider() {
11 }
12
13 public InternalAuthenticationProvider(String key) {
14 this.key = key;
15 }
16
17 @Override
18 public Authentication authenticate(Authentication arg0)
19 throws AuthenticationException {
20 InternalAuthentication authentication = (InternalAuthentication) arg0;
21 if (authentication.getCredentials().toString().equals(key))
22 return authentication;
23 return null;
24 }
25
26 public void setKey(String key) {
27 this.key = key;
28 }
29
30 @Override
31 public boolean supports(Class<?> authentication) {
32 return InternalAuthentication.class.isAssignableFrom(authentication);
33 }
34
35 }