]> git.argeo.org Git - lgpl/argeo-commons.git/blob - rap/SecureRapActivator.java
Prepare next development cycle
[lgpl/argeo-commons.git] / rap / SecureRapActivator.java
1 package org.argeo.security.ui.rap;
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 /** Configure Equinox login context from the bundle context. */
11 public class SecureRapActivator implements BundleActivator {
12
13 public final static String ID = "org.argeo.security.ui.rap";
14 public final static String CONTEXT_SPRING = "SPRING";
15 public final static String CONTEXT_SPRING_ANONYMOUS = "SPRING_ANONYMOUS";
16 private static final String JAAS_CONFIG_FILE = "/META-INF/jaas_default.txt";
17
18 private BundleContext bundleContext;
19 private static SecureRapActivator activator = null;
20
21 public void start(BundleContext bundleContext) throws Exception {
22 activator = this;
23 this.bundleContext = bundleContext;
24 }
25
26 public void stop(BundleContext context) throws Exception {
27 bundleContext = null;
28 activator = null;
29 }
30
31 public BundleContext getBundleContext() {
32 return bundleContext;
33 }
34
35 public static SecureRapActivator getActivator() {
36 return activator;
37 }
38
39 static ILoginContext createLoginContext(String contextName) {
40 URL configUrl = getActivator().getBundleContext().getBundle()
41 .getEntry(JAAS_CONFIG_FILE);
42 return LoginContextFactory.createContext(contextName, configUrl);
43 }
44 }