summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarsten Drossel2009-01-09 08:23:28 (EST)
committerCarsten Drossel2009-01-09 08:23:28 (EST)
commit8b3d736c007a4eb23eaf7f47beaf7fbe7eaaaf3d (patch)
tree44480bc87f3a15f7887e33ec2cdea4409eacf0d1
parent2a921e1abdac76cd24cd272b9df8f07cdd4be70c (diff)
downloadorg.eclipse.riena-8b3d736c007a4eb23eaf7f47beaf7fbe7eaaaf3d.zip
org.eclipse.riena-8b3d736c007a4eb23eaf7f47beaf7fbe7eaaaf3d.tar.gz
org.eclipse.riena-8b3d736c007a4eb23eaf7f47beaf7fbe7eaaaf3d.tar.bz2
fixed findbugs warning (with the help of sliebig)
-rw-r--r--org.eclipse.riena.sample.app.server/src/org/eclipse/riena/internal/sample/app/server/Customers.java4
-rw-r--r--org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/Sentinel.java29
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/BusinessTestCase.java6
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/SentinelTest.java7
4 files changed, 23 insertions, 23 deletions
diff --git a/org.eclipse.riena.sample.app.server/src/org/eclipse/riena/internal/sample/app/server/Customers.java b/org.eclipse.riena.sample.app.server/src/org/eclipse/riena/internal/sample/app/server/Customers.java
index 2e7b0b0..65b1f6b 100644
--- a/org.eclipse.riena.sample.app.server/src/org/eclipse/riena/internal/sample/app/server/Customers.java
+++ b/org.eclipse.riena.sample.app.server/src/org/eclipse/riena/internal/sample/app/server/Customers.java
@@ -98,8 +98,8 @@ public class Customers implements ICustomers, ICustomerSearch {
}
public Customer[] findCustomerWithPermission(Customer searchedCustomer) {
- if (!Sentinel.checkAccess(new CustomersPermission("riena.sample", "find"))) {
- throw new AccessControlException("no rights for current user for this operation");
+ if (!Sentinel.getInstance().checkAccess(new CustomersPermission("riena.sample", "find"))) { //$NON-NLS-1$ //$NON-NLS-2$
+ throw new AccessControlException("no rights for current user for this operation"); //$NON-NLS-1$
}
return findCustomer(searchedCustomer);
}
diff --git a/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/Sentinel.java b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/Sentinel.java
index f766a47..473dbbd 100644
--- a/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/Sentinel.java
+++ b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/Sentinel.java
@@ -23,26 +23,19 @@ import org.eclipse.riena.internal.security.common.Activator;
*/
public final class Sentinel {
- private static ISentinelService sentinelService;
+ private Helper helper = new Helper();
+ private ISentinelService sentinelService;
private static Sentinel myself = new Sentinel();
private Sentinel() {
super();
- Inject.service(ISentinelService.class).useRanking().into(this).andStart(Activator.getDefault().getContext());
+ Inject.service(ISentinelService.class).useRanking().into(helper).andStart(Activator.getDefault().getContext());
}
- protected Sentinel getInstance() {
+ public static Sentinel getInstance() {
return myself;
}
- public void bind(ISentinelService sentinelServiceParm) {
- sentinelService = sentinelServiceParm;
- }
-
- public void unbind(ISentinelService sentinelServiceParm) {
- sentinelService = null;
- }
-
/**
* checkAccess reads the current Subject from the SubjectHolderService,
* reads all its permissions from the cache and checks if this permission is
@@ -52,11 +45,23 @@ public final class Sentinel {
* permission to be checked
* @return
*/
- public static boolean checkAccess(Permission permission) {
+ public boolean checkAccess(Permission permission) {
if (sentinelService == null) {
return false;
}
return sentinelService.checkAccess(permission);
}
+ private class Helper {
+
+ public void bind(ISentinelService sentinelServiceParm) {
+ sentinelService = sentinelServiceParm;
+ }
+
+ public void unbind(ISentinelService sentinelServiceParm) {
+ sentinelService = null;
+ }
+
+ }
+
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/BusinessTestCase.java b/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/BusinessTestCase.java
index aabec09..abcdb11 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/BusinessTestCase.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/BusinessTestCase.java
@@ -18,10 +18,6 @@ import org.eclipse.riena.security.common.authorization.Sentinel;
public class BusinessTestCase {
boolean hasPermission() {
- if (Sentinel.checkAccess(new TestcasePermission("testPerm"))) {
- return true;
- } else {
- return false;
- }
+ return Sentinel.getInstance().checkAccess(new TestcasePermission("testPerm"));
}
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/SentinelTest.java b/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/SentinelTest.java
index 1483679..33b8464 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/SentinelTest.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/security/authorizationservice/SentinelTest.java
@@ -22,7 +22,6 @@ import org.eclipse.riena.security.common.authorization.IAuthorizationService;
import org.eclipse.riena.security.common.authorization.Sentinel;
import org.eclipse.riena.security.simpleservices.authorizationservice.store.FilePermissionStore;
import org.eclipse.riena.tests.RienaTestCase;
-
import org.osgi.framework.Bundle;
import org.osgi.framework.ServiceReference;
import org.osgi.framework.ServiceRegistration;
@@ -69,7 +68,7 @@ public class SentinelTest extends RienaTestCase {
}
public void testWithoutUser() {
- boolean result = Sentinel.checkAccess(new TestcasePermission("testPerm"));
+ boolean result = Sentinel.getInstance().checkAccess(new TestcasePermission("testPerm"));
assertFalse("no permission if there is no subject", result);
}
@@ -78,7 +77,7 @@ public class SentinelTest extends RienaTestCase {
subject.getPrincipals().add(new SimplePrincipal("testuser"));
SubjectAccessor.setSubject(subject);
- boolean result = Sentinel.checkAccess(new TestcasePermission("testPerm"));
+ boolean result = Sentinel.getInstance().checkAccess(new TestcasePermission("testPerm"));
assertTrue("has permission since valid subject", result);
}
@@ -87,7 +86,7 @@ public class SentinelTest extends RienaTestCase {
subject.getPrincipals().add(new SimplePrincipal("anotheruser"));
SubjectAccessor.setSubject(subject);
- boolean result = Sentinel.checkAccess(new TestcasePermission("testPerm"));
+ boolean result = Sentinel.getInstance().checkAccess(new TestcasePermission("testPerm"));
assertFalse("has no permission since subject has no permission", result);
}