2252 |
25 Feb 14 |
nicklas |
1 |
package net.sf.basedb.yubikey; |
2252 |
25 Feb 14 |
nicklas |
2 |
|
2257 |
27 Feb 14 |
nicklas |
3 |
|
2252 |
25 Feb 14 |
nicklas |
4 |
import net.sf.basedb.core.AuthenticationContext; |
2252 |
25 Feb 14 |
nicklas |
5 |
import net.sf.basedb.core.authentication.AuthenticationManager; |
2252 |
25 Feb 14 |
nicklas |
6 |
import net.sf.basedb.util.extensions.ActionFactory; |
2252 |
25 Feb 14 |
nicklas |
7 |
import net.sf.basedb.util.extensions.InvokationContext; |
2252 |
25 Feb 14 |
nicklas |
8 |
|
2252 |
25 Feb 14 |
nicklas |
9 |
/** |
2252 |
25 Feb 14 |
nicklas |
Action factory for the YubiKey authentication. |
2252 |
25 Feb 14 |
nicklas |
Returns an {@link YubiKeyAuthenticationManager} action. |
2252 |
25 Feb 14 |
nicklas |
12 |
|
2252 |
25 Feb 14 |
nicklas |
@author nicklas |
2252 |
25 Feb 14 |
nicklas |
@since 1.0 |
2252 |
25 Feb 14 |
nicklas |
15 |
*/ |
2252 |
25 Feb 14 |
nicklas |
16 |
public class YubiKeyAuthenticationManagerFactory |
2252 |
25 Feb 14 |
nicklas |
17 |
implements ActionFactory<AuthenticationManager> |
2252 |
25 Feb 14 |
nicklas |
18 |
{ |
2252 |
25 Feb 14 |
nicklas |
19 |
|
2252 |
25 Feb 14 |
nicklas |
20 |
|
2252 |
25 Feb 14 |
nicklas |
21 |
public YubiKeyAuthenticationManagerFactory() |
5182 |
06 Dec 18 |
nicklas |
22 |
{} |
2252 |
25 Feb 14 |
nicklas |
23 |
|
2252 |
25 Feb 14 |
nicklas |
24 |
/** |
2511 |
17 Jun 14 |
nicklas |
Checks if YubiKey has been properly configured and |
2511 |
17 Jun 14 |
nicklas |
if the currently used client application has been disabled for |
2511 |
17 Jun 14 |
nicklas |
use with YubiKey. |
2511 |
17 Jun 14 |
nicklas |
@return TRUE if YubiKey is enabled, FALSE otherwise |
2252 |
25 Feb 14 |
nicklas |
29 |
*/ |
2252 |
25 Feb 14 |
nicklas |
30 |
@Override |
2252 |
25 Feb 14 |
nicklas |
31 |
public boolean prepareContext(InvokationContext<? super AuthenticationManager> context) |
2252 |
25 Feb 14 |
nicklas |
32 |
{ |
2511 |
17 Jun 14 |
nicklas |
33 |
String clientId = context.getClientContext().getSessionControl().getExternalClientId(); |
5184 |
06 Dec 18 |
nicklas |
34 |
return YubiKey.getConfig(true) != null && !YubiKey.isYubiKeyDisabledForClient(clientId); |
2252 |
25 Feb 14 |
nicklas |
35 |
} |
2252 |
25 Feb 14 |
nicklas |
36 |
|
2252 |
25 Feb 14 |
nicklas |
37 |
/** |
2252 |
25 Feb 14 |
nicklas |
@return A single {@link YubiKeyAuthenticationManager} instance |
2252 |
25 Feb 14 |
nicklas |
39 |
*/ |
2252 |
25 Feb 14 |
nicklas |
40 |
@Override |
2252 |
25 Feb 14 |
nicklas |
41 |
public AuthenticationManager[] getActions(InvokationContext<? super AuthenticationManager> context) |
2252 |
25 Feb 14 |
nicklas |
42 |
{ |
2252 |
25 Feb 14 |
nicklas |
43 |
AuthenticationContext authContext = (AuthenticationContext)context.getClientContext(); |
2252 |
25 Feb 14 |
nicklas |
44 |
return new AuthenticationManager[] { new YubiKeyAuthenticationManager(authContext) }; |
2252 |
25 Feb 14 |
nicklas |
45 |
} |
2252 |
25 Feb 14 |
nicklas |
46 |
|
2252 |
25 Feb 14 |
nicklas |
47 |
|
2252 |
25 Feb 14 |
nicklas |
48 |
} |