]> git.aero2k.de Git - tmp/jakarta-migration.git/blob
d1d23f7fc1c454b41af282545f12a83ef263f385
[tmp/jakarta-migration.git] /
1 /*
2  * To change this template, choose Tools | Templates
3  * and open the template in the editor.
4  */
5
6 package org.collectionspace.hello.services.nuxeo;
7
8 /**
9  *
10  * @author sanjaydalal
11  */
12
13 import javax.security.auth.callback.CallbackHandler;
14 import javax.security.auth.login.Configuration;
15 import javax.security.auth.login.LoginContext;
16 import javax.security.auth.login.LoginException;
17
18 public class NuxeoLoginContextFactory {
19
20
21     private static boolean initDone=false;
22
23     private static void initLoginConfig()
24     {
25         if (initDone)
26             return;
27
28         Configuration parentConfig = null;
29         try {
30             parentConfig = Configuration.getConfiguration();
31         } catch (Exception e) {
32             // do nothing - this can happen if default configuration provider is not correctly configured
33             // for examnple FileConfig fails if no config file was defined
34         }
35         Configuration config = new NuxeoLoginConfiguration(parentConfig);
36         Configuration.setConfiguration(config);
37
38         initDone=true;
39
40     }
41
42
43     public static LoginContext getLoginContext(CallbackHandler handler) throws LoginException
44     {
45         initLoginConfig();
46         return  new LoginContext(NuxeoLoginConfiguration.LOGIN_DOMAIN, handler);
47     }
48 }