]> git.argeo.org Git - lgpl/argeo-commons.git/blob - SecureApplicationActivator.java
1c8bd7c25e7a4c4be58896f0efb339f3c28abe67
[lgpl/argeo-commons.git] / SecureApplicationActivator.java
1 package org.argeo.security.ui.rcp;
2
3 import java.net.URL;
4
5 import org.eclipse.equinox.security.auth.ILoginContext;
6 import org.eclipse.equinox.security.auth.LoginContextFactory;
7 import org.osgi.framework.BundleActivator;
8 import org.osgi.framework.BundleContext;
9
10 /** Activator able to create {@link ILoginContext} */
11 public class SecureApplicationActivator implements BundleActivator {
12
13 public final static String CONTEXT_NIX = "NIX";
14 public final static String CONTEXT_WINDOWS = "WINDOWS";
15 private static final String JAAS_CONFIG_FILE = "/META-INF/jaas_default.txt";
16
17 private static BundleContext bundleContext;
18
19 public void start(BundleContext bundleContext) throws Exception {
20 SecureApplicationActivator.bundleContext = bundleContext;
21 }
22
23 public void stop(BundleContext context) throws Exception {
24 }
25
26 static ILoginContext createLoginContext(String context) {
27 URL configUrl = bundleContext.getBundle().getEntry(JAAS_CONFIG_FILE);
28 return LoginContextFactory.createContext(context, configUrl);
29 }
30 }