felix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pa...@apache.org
Subject svn commit: r1169675 - /felix/trunk/framework.security/src/main/java/org/apache/felix/framework/security/condpermadmin/ConditionalPermissionInfoImpl.java
Date Mon, 12 Sep 2011 10:12:16 GMT
Author: pauls
Date: Mon Sep 12 10:12:16 2011
New Revision: 1169675

URL: http://svn.apache.org/viewvc?rev=1169675&view=rev
Log:
Allow for empty condition/permission infos, make the name optional, and parse ALLOW/DENY policy
case insensitv (FELIX-2922).

Modified:
    felix/trunk/framework.security/src/main/java/org/apache/felix/framework/security/condpermadmin/ConditionalPermissionInfoImpl.java

Modified: felix/trunk/framework.security/src/main/java/org/apache/felix/framework/security/condpermadmin/ConditionalPermissionInfoImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/framework.security/src/main/java/org/apache/felix/framework/security/condpermadmin/ConditionalPermissionInfoImpl.java?rev=1169675&r1=1169674&r2=1169675&view=diff
==============================================================================
--- felix/trunk/framework.security/src/main/java/org/apache/felix/framework/security/condpermadmin/ConditionalPermissionInfoImpl.java
(original)
+++ felix/trunk/framework.security/src/main/java/org/apache/felix/framework/security/condpermadmin/ConditionalPermissionInfoImpl.java
Mon Sep 12 10:12:16 2011
@@ -253,11 +253,12 @@ public final class ConditionalPermission
     public ConditionalPermissionInfoImpl(String encoded)
     {
         encoded = encoded.trim();
-        if (!(encoded.startsWith("ALLOW {") || encoded.startsWith("DENY {")))
+        String toUpper = encoded.toUpperCase();
+        if (!(toUpper.startsWith("ALLOW {") || toUpper.startsWith("DENY {")))
         {
             throw new IllegalArgumentException();
         }
-        m_allow = encoded.startsWith("ALLOW {");
+        m_allow = toUpper.startsWith("ALLOW {");
         m_cpai = null;
         List conditions = new ArrayList();
         List permissions = new ArrayList();
@@ -302,7 +303,7 @@ public final class ConditionalPermission
             m_name = unescapeString(chars, begin, idx);
         }
         else {
-            throw new IllegalArgumentException("Expected conditional permission info name");
+            m_name = Long.toString(RANDOM.nextLong() ^ System.currentTimeMillis());
         }
         } catch (ArrayIndexOutOfBoundsException ex) {
             ex.printStackTrace();
@@ -333,8 +334,8 @@ public final class ConditionalPermission
         m_allow = access;
         m_name = Long.toString(RANDOM.nextLong() ^ System.currentTimeMillis());
         m_cpai = cpai;
-        m_conditions = conditions;
-        m_permissions = permisions;
+        m_conditions = conditions == null ? CONDITION_INFO : conditions;
+        m_permissions = permisions == null ? PERMISSION_INFO : permisions;
     }
 
     public ConditionalPermissionInfoImpl(String name,
@@ -344,8 +345,8 @@ public final class ConditionalPermission
         m_allow = access;
         m_name = (name != null) ? name : Long.toString(RANDOM.nextLong()
             ^ System.currentTimeMillis());
-        m_conditions = conditions;
-        m_permissions = permisions;
+        m_conditions = conditions == null ? CONDITION_INFO : conditions;
+        m_permissions = permisions == null ? PERMISSION_INFO : permisions;
         m_cpai = cpai;
     }
 



Mime
View raw message