import java.io.File;
import java.io.IOException;
+import java.net.URI;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
import org.argeo.cms.CmsException;
import org.argeo.cms.KernelHeader;
import org.argeo.cms.internal.auth.GrantedAuthorityPrincipal;
-import org.osgi.framework.BundleContext;
import org.springframework.security.authentication.AnonymousAuthenticationToken;
import org.springframework.security.authentication.AuthenticationManager;
import org.springframework.security.core.Authentication;
/** Package utilities */
class KernelUtils implements KernelConstants {
private final static String OSGI_INSTANCE_AREA = "osgi.instance.area";
+ private final static String OSGI_CONFIGURATION_AREA = "osgi.configuration.area";
static Dictionary<String, ?> asDictionary(Properties props) {
Hashtable<String, Object> hashtable = new Hashtable<String, Object>();
return asDictionary(props);
}
- static File getOsgiInstanceDir(BundleContext bundleContext) {
- return new File(bundleContext.getProperty(OSGI_INSTANCE_AREA)
- .substring("file:".length())).getAbsoluteFile();
+ static File getOsgiInstanceDir() {
+ return new File(Activator.getBundleContext()
+ .getProperty(OSGI_INSTANCE_AREA).substring("file:".length()))
+ .getAbsoluteFile();
+ }
+
+ static File getOsgiConfigurationFile(String relativePath) {
+ try {
+ return new File(new URI(Activator.getBundleContext().getProperty(
+ OSGI_CONFIGURATION_AREA)
+ + relativePath)).getCanonicalFile();
+ } catch (Exception e) {
+ throw new CmsException("Cannot get configuration file for "
+ + relativePath, e);
+ }
+ }
+
+ static String getFrameworkProp(String key, String def) {
+ String value = Activator.getBundleContext().getProperty(key);
+ if (value == null)
+ return def;
+ return value;
+ }
+
+ static String getFrameworkProp(String key) {
+ return getFrameworkProp(key, null);
}
// Security