- Introduce PKI utils
[lgpl/argeo-commons.git] / org.argeo.cms / src / org / argeo / cms / internal / kernel / KernelUtils.java
index 0a9e6c53e44a2c24d7b438b526ce15ddda5f8214..912d9fa995d2c58ea38fb350361ca4c219fa5092 100644 (file)
@@ -2,6 +2,7 @@ package org.argeo.cms.internal.kernel;
 
 import java.io.File;
 import java.io.IOException;
+import java.net.URI;
 import java.util.Collections;
 import java.util.Dictionary;
 import java.util.Enumeration;
@@ -25,6 +26,7 @@ import org.springframework.security.core.userdetails.UserDetails;
 /** 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>();
@@ -51,6 +53,17 @@ class KernelUtils implements KernelConstants {
                                .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)