Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2018-05-09 15:45:58 +0000
committerThomas Watson2018-06-06 12:45:01 +0000
commitebe89f1f5f0cfe2a9c5a830ec8ad676dc0058785 (patch)
tree71f48eba628f4b91335c85b4fded40de57205c8f
parent4c920c4b017f0dd7710a784535fc85433028520a (diff)
downloadrt.equinox.framework-ebe89f1f5f0cfe2a9c5a830ec8ad676dc0058785.tar.gz
rt.equinox.framework-ebe89f1f5f0cfe2a9c5a830ec8ad676dc0058785.tar.xz
rt.equinox.framework-ebe89f1f5f0cfe2a9c5a830ec8ad676dc0058785.zip
Bug 532194 - Format using project settings
Change-Id: Ifb8e4fed844b3bc83bdc90572d04f7e5eba59aa5 Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityAdminUnitTests.java25
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EvaluationCacheKey.java44
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java49
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java18
-rw-r--r--bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTable.java89
5 files changed, 137 insertions, 88 deletions
diff --git a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityAdminUnitTests.java b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityAdminUnitTests.java
index fed04f2c7..386add007 100644
--- a/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityAdminUnitTests.java
+++ b/bundles/org.eclipse.osgi.tests/src/org/eclipse/osgi/tests/securityadmin/SecurityAdminUnitTests.java
@@ -14,15 +14,32 @@ import ext.framework.b.TestCondition;
import java.io.File;
import java.io.FilePermission;
import java.net.SocketPermission;
-import java.security.*;
-import java.util.*;
+import java.security.AccessControlContext;
+import java.security.AccessControlException;
+import java.security.AllPermission;
+import java.security.CodeSource;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Policy;
+import java.security.ProtectionDomain;
+import java.util.ArrayList;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.NoSuchElementException;
import junit.framework.Test;
import junit.framework.TestSuite;
import org.eclipse.osgi.launch.Equinox;
import org.eclipse.osgi.tests.OSGiTestsActivator;
import org.eclipse.osgi.tests.bundles.AbstractBundleTests;
-import org.osgi.framework.*;
-import org.osgi.service.condpermadmin.*;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.Constants;
+import org.osgi.service.condpermadmin.ConditionInfo;
+import org.osgi.service.condpermadmin.ConditionalPermissionAdmin;
+import org.osgi.service.condpermadmin.ConditionalPermissionInfo;
+import org.osgi.service.condpermadmin.ConditionalPermissionUpdate;
import org.osgi.service.permissionadmin.PermissionAdmin;
import org.osgi.service.permissionadmin.PermissionInfo;
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EvaluationCacheKey.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EvaluationCacheKey.java
index 04b87fcf4..d0db72521 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EvaluationCacheKey.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/EvaluationCacheKey.java
@@ -15,31 +15,29 @@ import java.util.Objects;
class EvaluationCacheKey {
- private final Permission permission;
+ private final Permission permission;
- private final Long bundleId;
+ private final Long bundleId;
- EvaluationCacheKey(BundlePermissions bundlePermissions, Permission permission) {
- this.permission = permission;
- this.bundleId = bundlePermissions.getBundle().getBundleId();
- }
+ EvaluationCacheKey(BundlePermissions bundlePermissions, Permission permission) {
+ this.permission = permission;
+ this.bundleId = bundlePermissions.getBundle().getBundleId();
+ }
- @Override
- public boolean equals(Object o) {
- if (this == o) {
- return true;
- }
- if (o == null || getClass() != o.getClass()) {
- return false;
- }
- EvaluationCacheKey that = (EvaluationCacheKey) o;
- return Objects.equals(bundleId, that.bundleId) && Objects.equals(
- permission,
- that.permission);
- }
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ EvaluationCacheKey that = (EvaluationCacheKey) o;
+ return Objects.equals(bundleId, that.bundleId) && Objects.equals(permission, that.permission);
+ }
- @Override
- public int hashCode() {
- return Objects.hash(bundleId, permission);
- }
+ @Override
+ public int hashCode() {
+ return Objects.hash(bundleId, permission);
+ }
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java
index 4b992175e..9881ad39a 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityAdmin.java
@@ -10,17 +10,54 @@
*******************************************************************************/
package org.eclipse.osgi.internal.permadmin;
-import java.io.*;
+import java.io.BufferedReader;
+import java.io.DataInputStream;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
import java.math.BigInteger;
import java.net.URL;
import java.nio.charset.StandardCharsets;
-import java.security.*;
-import java.security.cert.*;
-import java.util.*;
+import java.security.AccessControlContext;
+import java.security.AllPermission;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.security.NoSuchProviderException;
+import java.security.Permission;
+import java.security.PermissionCollection;
+import java.security.Principal;
+import java.security.ProtectionDomain;
+import java.security.PublicKey;
+import java.security.SignatureException;
+import java.security.cert.CertificateEncodingException;
+import java.security.cert.CertificateException;
+import java.security.cert.CertificateExpiredException;
+import java.security.cert.X509Certificate;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Date;
+import java.util.Dictionary;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
import org.eclipse.osgi.internal.framework.EquinoxBundle;
import org.eclipse.osgi.storage.PermissionData;
-import org.osgi.framework.*;
-import org.osgi.service.condpermadmin.*;
+import org.osgi.framework.AdminPermission;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.ServiceReference;
+import org.osgi.framework.Version;
+import org.osgi.service.condpermadmin.ConditionInfo;
+import org.osgi.service.condpermadmin.ConditionalPermissionAdmin;
+import org.osgi.service.condpermadmin.ConditionalPermissionInfo;
+import org.osgi.service.condpermadmin.ConditionalPermissionUpdate;
import org.osgi.service.permissionadmin.PermissionAdmin;
import org.osgi.service.permissionadmin.PermissionInfo;
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java
index e6f6f09d6..74f89c4c8 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityRow.java
@@ -11,11 +11,19 @@
*******************************************************************************/
package org.eclipse.osgi.internal.permadmin;
-import java.lang.reflect.*;
+import java.lang.reflect.Array;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
+import java.lang.reflect.Modifier;
import java.security.Permission;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import org.osgi.framework.Bundle;
-import org.osgi.service.condpermadmin.*;
+import org.osgi.service.condpermadmin.Condition;
+import org.osgi.service.condpermadmin.ConditionInfo;
+import org.osgi.service.condpermadmin.ConditionalPermissionInfo;
import org.osgi.service.permissionadmin.PermissionInfo;
public final class SecurityRow implements ConditionalPermissionInfo {
@@ -290,8 +298,8 @@ public final class SecurityRow implements ConditionalPermissionInfo {
private Method getConditionMethod(Class<?> clazz) {
for (Method checkMethod : clazz.getMethods()) {
- if (checkMethod.getName().equals("getCondition")
- && (checkMethod.getModifiers() & Modifier.STATIC) == Modifier.STATIC
+ if (checkMethod.getName().equals("getCondition") //$NON-NLS-1$
+ && (checkMethod.getModifiers() & Modifier.STATIC) == Modifier.STATIC //
&& checkParameterTypes(checkMethod.getParameterTypes())) {
return checkMethod;
}
diff --git a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTable.java b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTable.java
index 43dc91154..6a93c53d2 100644
--- a/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTable.java
+++ b/bundles/org.eclipse.osgi/container/src/org/eclipse/osgi/internal/permadmin/SecurityTable.java
@@ -16,7 +16,6 @@ import java.security.PermissionCollection;
import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
-
import org.eclipse.osgi.internal.permadmin.SecurityRow.Decision;
import org.osgi.service.condpermadmin.Condition;
@@ -32,8 +31,7 @@ public class SecurityTable extends PermissionCollection {
private final SecurityRow[] rows;
private final SecurityAdmin securityAdmin;
- private final transient Map<EvaluationCacheKey, Integer> evaluationCache =
- new ConcurrentHashMap<>(10000);
+ private final transient Map<EvaluationCacheKey, Integer> evaluationCache = new ConcurrentHashMap<>(10000);
public SecurityTable(SecurityAdmin securityAdmin, SecurityRow[] rows) {
if (rows == null)
@@ -50,8 +48,7 @@ public class SecurityTable extends PermissionCollection {
if (bundlePermissions == null) {
return ABSTAIN;
}
- EvaluationCacheKey evaluationCacheKey = new EvaluationCacheKey(bundlePermissions,
- permission);
+ EvaluationCacheKey evaluationCacheKey = new EvaluationCacheKey(bundlePermissions, permission);
if (isEmpty()) {
evaluationCache.put(evaluationCacheKey, ABSTAIN);
return ABSTAIN;
@@ -74,9 +71,7 @@ public class SecurityTable extends PermissionCollection {
for (int i = 0; i < rows.length && immediateDecisionIdx == -1; i++) {
if (result == null) {
//check all conditions for any that are mutable, this will turn off the cache
- hasMutable |= checkMutable(bundlePermissions,
- evaluationCacheKey,
- rows[i]);
+ hasMutable |= checkMutable(bundlePermissions, evaluationCacheKey, rows[i]);
}
try {
results[i] = rows[i].evaluate(bundlePermissions, permission);
@@ -102,11 +97,7 @@ public class SecurityTable extends PermissionCollection {
// no need to process the rest of the rows
immediateDecisionIdx = i;
}
- Integer immediateDecision = handlePostponedConditions(evaluationCacheKey,
- hasMutable,
- postponed,
- results,
- immediateDecisionIdx);
+ Integer immediateDecision = handlePostponedConditions(evaluationCacheKey, hasMutable, postponed, results, immediateDecisionIdx);
if (immediateDecision != null)
return immediateDecision;
int finalDecision = postponed ? POSTPONED : ABSTAIN;
@@ -116,8 +107,7 @@ public class SecurityTable extends PermissionCollection {
return finalDecision;
}
- private boolean checkMutable(BundlePermissions bundlePermissions,
- EvaluationCacheKey evaluationCacheKey, SecurityRow row) {
+ private boolean checkMutable(BundlePermissions bundlePermissions, EvaluationCacheKey evaluationCacheKey, SecurityRow row) {
Condition[] conditions = row.getConditions(bundlePermissions);
if (conditions != null) {
for (Condition condition : conditions) {
@@ -130,42 +120,41 @@ public class SecurityTable extends PermissionCollection {
return false;
}
- private Integer handlePostponedConditions(EvaluationCacheKey evaluationCacheKey,
- boolean hasMutable, boolean postponed, Decision[] results, int immediateDecisionIdx) {
+ private Integer handlePostponedConditions(EvaluationCacheKey evaluationCacheKey, boolean hasMutable, boolean postponed, Decision[] results, int immediateDecisionIdx) {
if (postponed) {
- int immediateDecision = immediateDecisionIdx < 0 ? DENIED : results[immediateDecisionIdx].decision;
- // iterate over all postponed conditions;
- // if they all provide the same decision as the immediate decision then return the immediate decision
- boolean allSameDecision = true;
- int i = immediateDecisionIdx < 0 ? results.length - 1 : immediateDecisionIdx - 1;
- for (; i >= 0 && allSameDecision; i--) {
- if ((results[i].decision & POSTPONED) == POSTPONED) {
- if ((results[i].decision & immediateDecision) == 0)
- allSameDecision = false;
- else
- results[i] = SecurityRow.DECISION_ABSTAIN; // we can clear postpones with the same decision as the immediate
- }
- }
- if (allSameDecision) {
- if (!hasMutable) {
- evaluationCache.put(evaluationCacheKey, immediateDecision);
- }
- return immediateDecision;
- }
-
- // we now are forced to postpone; we need to also remember the postponed decisions and
- // the immediate decision if there is one.
- EquinoxSecurityManager equinoxManager = securityAdmin.getSupportedSecurityManager();
- if (equinoxManager == null) {
- // TODO this is really an error condition.
- // This should never happen. We checked for a supported manager when the row was postponed
- if (!hasMutable) {
- evaluationCache.put(evaluationCacheKey, ABSTAIN);
- }
- return ABSTAIN;
- }
- equinoxManager.addConditionsForDomain(results);
- }
+ int immediateDecision = immediateDecisionIdx < 0 ? DENIED : results[immediateDecisionIdx].decision;
+ // iterate over all postponed conditions;
+ // if they all provide the same decision as the immediate decision then return the immediate decision
+ boolean allSameDecision = true;
+ int i = immediateDecisionIdx < 0 ? results.length - 1 : immediateDecisionIdx - 1;
+ for (; i >= 0 && allSameDecision; i--) {
+ if ((results[i].decision & POSTPONED) == POSTPONED) {
+ if ((results[i].decision & immediateDecision) == 0)
+ allSameDecision = false;
+ else
+ results[i] = SecurityRow.DECISION_ABSTAIN; // we can clear postpones with the same decision as the immediate
+ }
+ }
+ if (allSameDecision) {
+ if (!hasMutable) {
+ evaluationCache.put(evaluationCacheKey, immediateDecision);
+ }
+ return immediateDecision;
+ }
+
+ // we now are forced to postpone; we need to also remember the postponed decisions and
+ // the immediate decision if there is one.
+ EquinoxSecurityManager equinoxManager = securityAdmin.getSupportedSecurityManager();
+ if (equinoxManager == null) {
+ // TODO this is really an error condition.
+ // This should never happen. We checked for a supported manager when the row was postponed
+ if (!hasMutable) {
+ evaluationCache.put(evaluationCacheKey, ABSTAIN);
+ }
+ return ABSTAIN;
+ }
+ equinoxManager.addConditionsForDomain(results);
+ }
return null;
}

Back to the top