FELIX-2771 Fix Foundation and Mika platform issues:
   PrivilegedActionException: use getException() instead of getCause()
   Boolean.valueOf(boolean): use boolean ? TRUE : FALSE
   SecureRandom: fall back to Random

git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@1067154 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java b/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java
index 1a0234a..ffef4d0 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/file/FilePersistenceManager.java
@@ -449,7 +449,8 @@
         {
             public Object run()
             {
-                return Boolean.valueOf( _exists( pid ) );
+                // FELIX-2771: Boolean.valueOf(boolean) is not in Foundation
+                return _exists( pid ) ? Boolean.TRUE : Boolean.FALSE;
             }
         } );
         return ( ( Boolean ) result ).booleanValue();
@@ -504,7 +505,8 @@
         }
         catch ( PrivilegedActionException pae )
         {
-            throw ( IOException ) pae.getCause();
+            // FELIX-2771: getCause() is not available in Foundation
+            throw ( IOException ) pae.getException();
         }
     }
 
@@ -597,7 +599,8 @@
         }
         catch ( PrivilegedActionException pae )
         {
-            throw ( IOException ) pae.getCause();
+            // FELIX-2771: getCause() is not available in Foundation
+            throw ( IOException ) pae.getException();
         }
     }
 
diff --git a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
index 9786d2c..fa8cb9b 100644
--- a/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
+++ b/configadmin/src/main/java/org/apache/felix/cm/impl/ConfigurationManager.java
@@ -93,7 +93,7 @@
 
     // random number generator to create configuration PIDs for factory
     // configurations
-    private static SecureRandom numberGenerator;
+    private static Random numberGenerator;
 
     // comparator used to keep the ordered persistence manager map
     private static final Comparator cmRankComp = new RankingComparator( true, ConfigurationPlugin.CM_RANKING );
@@ -870,10 +870,19 @@
      */
     private static String createPid( String factoryPid )
     {
-        SecureRandom ng = numberGenerator;
+        Random ng = numberGenerator;
         if ( ng == null )
         {
-            numberGenerator = ng = new SecureRandom();
+            // FELIX-2771 Secure Random not available on Mika
+            try
+            {
+                ng = new SecureRandom();
+            }
+            catch ( Throwable t )
+            {
+                // fall back to Random
+                ng = new Random();
+            }
         }
 
         byte[] randomBytes = new byte[16];