summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Liebig2008-02-12 10:10:05 (EST)
committerStefan Liebig2008-02-12 10:10:05 (EST)
commit66a2bf7f1d125c5f70203e2c18bfc8a8e1246c3b (patch)
treefb8b5b7c9dcb84d1ed3188221a55bd6bc9179dbe
parent5c84f4053f8e257211cd250d74e46cdd979bbc85 (diff)
downloadorg.eclipse.riena-66a2bf7f1d125c5f70203e2c18bfc8a8e1246c3b.zip
org.eclipse.riena-66a2bf7f1d125c5f70203e2c18bfc8a8e1246c3b.tar.gz
org.eclipse.riena-66a2bf7f1d125c5f70203e2c18bfc8a8e1246c3b.tar.bz2
uses new service injector
-rw-r--r--org.eclipse.riena.security.common/src/org/eclipse/riena/internal/security/common/SecurityCallHook.java83
-rw-r--r--org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authentication/ClientLogin.java14
-rw-r--r--org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/RienaPolicy.java9
-rw-r--r--org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/Sentinel.java14
-rw-r--r--org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/internal/PermissionCache.java8
-rw-r--r--org.eclipse.riena.security.server/src/org/eclipse/riena/internal/security/server/SecurityServiceHook.java64
-rw-r--r--org.eclipse.riena.tests/src/org/eclipse/riena/core/AllTests.java2
7 files changed, 99 insertions, 95 deletions
diff --git a/org.eclipse.riena.security.common/src/org/eclipse/riena/internal/security/common/SecurityCallHook.java b/org.eclipse.riena.security.common/src/org/eclipse/riena/internal/security/common/SecurityCallHook.java
index 4da2a69..5933442 100644
--- a/org.eclipse.riena.security.common/src/org/eclipse/riena/internal/security/common/SecurityCallHook.java
+++ b/org.eclipse.riena.security.common/src/org/eclipse/riena/internal/security/common/SecurityCallHook.java
@@ -14,60 +14,61 @@ import java.util.Map;
import org.eclipse.riena.communication.core.hooks.CallContext;
import org.eclipse.riena.communication.core.hooks.ICallHook;
-import org.eclipse.riena.core.service.ServiceInjector;
+import org.eclipse.riena.core.service.ServiceId;
import org.eclipse.riena.security.common.session.ISessionHolder;
import org.eclipse.riena.security.common.session.ISessionHolderService;
import org.eclipse.riena.security.common.session.Session;
/**
- * This Call Hook deals with security issues of a webservice calls, it sets the cookie of the session and principal
- * location before the call and checks for set-cookies after the call returns.
+ * This Call Hook deals with security issues of a webservice calls, it sets the
+ * cookie of the session and principal location before the call and checks for
+ * set-cookies after the call returns.
*
*/
public class SecurityCallHook implements ICallHook {
- private static final String SSOID = "x-compeople-ssoid";
- private ISessionHolderService shService;
+ private static final String SSOID = "x-compeople-ssoid";
+ private ISessionHolderService shService;
- public SecurityCallHook() {
- super();
- new ServiceInjector(Activator.getContext(), ISessionHolderService.ID, this, "bindSHS", "unbindSHS").start();
- }
+ public SecurityCallHook() {
+ super();
+ new ServiceId(ISessionHolderService.ID).injectInto(this).start(Activator.getContext());
+ }
- public void bindSHS(ISessionHolderService shService) {
- this.shService = shService;
- }
+ public void bind(ISessionHolderService shService) {
+ this.shService = shService;
+ }
- public void unbindSHS(ISessionHolderService shService) {
- if (this.shService == shService) {
- this.shService = null;
- }
- }
+ public void unbind(ISessionHolderService shService) {
+ if (this.shService == shService) {
+ this.shService = null;
+ }
+ }
- /**
- * @see de.compeople.spirit.communication.base.hook.ICallHook#beforeCall(de.compeople.spirit.communication.base.hook.ICallContext)
- */
- public void beforeCall(CallContext callback) {
- ISessionHolder sessionHolder = shService.fetchSessionHolder();
- Session session = sessionHolder.getSession();
+ /**
+ * @see de.compeople.spirit.communication.base.hook.ICallHook#beforeCall(de.compeople.spirit.communication.base.hook.ICallContext)
+ */
+ public void beforeCall(CallContext callback) {
+ ISessionHolder sessionHolder = shService.fetchSessionHolder();
+ Session session = sessionHolder.getSession();
- if (session != null) {
- callback.setCookie(SSOID, session.getSessionId());
- }
- }
+ if (session != null) {
+ callback.setCookie(SSOID, session.getSessionId());
+ }
+ }
- /**
- * @see de.compeople.spirit.communication.base.hook.ICallHook#afterCall(de.compeople.spirit.communication.base.hook.ICallContext)
- */
- public void afterCall(CallContext callback) {
- ISessionHolder sessionHolder = shService.fetchSessionHolder();
- Map<String, String> map = callback.getSetCookies();
- if (map == null) {
- return;
- }
- String temp = (String) map.get(SSOID);
- if (temp != null) {
- sessionHolder.setSession(new Session(temp));
- }
- }
+ /**
+ * @see de.compeople.spirit.communication.base.hook.ICallHook#afterCall(de.compeople.spirit.communication.base.hook.ICallContext)
+ */
+ public void afterCall(CallContext callback) {
+ ISessionHolder sessionHolder = shService.fetchSessionHolder();
+ Map<String, String> map = callback.getSetCookies();
+ if (map == null) {
+ return;
+ }
+ String temp = (String) map.get(SSOID);
+ if (temp != null) {
+ sessionHolder.setSession(new Session(temp));
+ }
+ }
} \ No newline at end of file
diff --git a/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authentication/ClientLogin.java b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authentication/ClientLogin.java
index 9141c32..0da4bff 100644
--- a/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authentication/ClientLogin.java
+++ b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authentication/ClientLogin.java
@@ -17,7 +17,7 @@ import javax.security.auth.Subject;
import javax.security.auth.callback.Callback;
import javax.security.auth.login.LoginException;
-import org.eclipse.riena.core.service.ServiceInjector;
+import org.eclipse.riena.core.service.ServiceId;
import org.eclipse.riena.internal.security.common.Activator;
import org.eclipse.riena.security.common.ISubjectHolderService;
import org.eclipse.riena.security.common.authentication.credentials.AbstractCredential;
@@ -37,25 +37,25 @@ public class ClientLogin {
super();
this.loginContext = loginContext;
this.subject = subject;
- new ServiceInjector(Activator.getContext(), IAuthenticationService.ID, this, "bindAuthenticationService", "unbindAuthenticationService").start();
- new ServiceInjector(Activator.getContext(), ISubjectHolderService.ID, this, "bindSubjectHolderService", "unbindSubjectHolderService").start();
+ new ServiceId(IAuthenticationService.ID).injectInto(this).start(Activator.getContext());
+ new ServiceId(ISubjectHolderService.ID).injectInto(this).start(Activator.getContext());
}
- public void bindAuthenticationService(IAuthenticationService authenticationService) {
+ public void bind(IAuthenticationService authenticationService) {
this.authenticationService = authenticationService;
}
- public void unbindAuthenticationService(IAuthenticationService subHolderService) {
+ public void unbind(IAuthenticationService authenticationService) {
if (this.authenticationService == authenticationService) {
authenticationService = null;
}
}
- public void bindSubjectHolderService(ISubjectHolderService subjectHolderService) {
+ public void bind(ISubjectHolderService subjectHolderService) {
this.subjectHolderService = subjectHolderService;
}
- public void unbindSubjectHolderService(ISubjectHolderService subjectHolderService) {
+ public void unbind(ISubjectHolderService subjectHolderService) {
if (this.subjectHolderService == subjectHolderService) {
this.subjectHolderService = null;
}
diff --git a/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/RienaPolicy.java b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/RienaPolicy.java
index c84c36e..bacdb29 100644
--- a/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/RienaPolicy.java
+++ b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/RienaPolicy.java
@@ -21,7 +21,7 @@ import java.security.Principal;
import java.security.ProtectionDomain;
import org.eclipse.equinox.log.Logger;
-import org.eclipse.riena.core.service.ServiceInjector;
+import org.eclipse.riena.core.service.ServiceId;
import org.eclipse.riena.internal.security.common.Activator;
import org.osgi.service.log.LogService;
@@ -38,15 +38,14 @@ public class RienaPolicy extends Policy {
public RienaPolicy() {
super();
- new ServiceInjector(Activator.getContext(), IPermissionCache.ID, this, "bindPermCache", "unbindPermCache")
- .start();
+ new ServiceId(IPermissionCache.ID).injectInto(this).start(Activator.getContext());
}
- public void bindPermCache(IPermissionCache permCache) {
+ public void bind(IPermissionCache permCache) {
this.permCache = permCache;
}
- public void unbindPermCache(IPermissionCache permCache) {
+ public void unbind(IPermissionCache permCache) {
if (permCache == this.permCache) {
this.permCache = null;
}
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 578edcd..11a43d8 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
@@ -15,7 +15,7 @@ import java.security.Permissions;
import javax.security.auth.Subject;
-import org.eclipse.riena.core.service.ServiceInjector;
+import org.eclipse.riena.core.service.ServiceId;
import org.eclipse.riena.internal.security.common.Activator;
import org.eclipse.riena.security.common.ISubjectHolder;
import org.eclipse.riena.security.common.ISubjectHolderService;
@@ -34,25 +34,25 @@ public class Sentinel {
private Sentinel() {
super();
- new ServiceInjector(Activator.getContext(), IPermissionCache.ID, this, "bindPermCache", "unbindPermCache").start();
- new ServiceInjector(Activator.getContext(), ISubjectHolderService.ID, this, "bindSubjectHolderService", "unbindSubjectHolderService").start();
+ new ServiceId(IPermissionCache.ID).injectInto(this).start(Activator.getContext());
+ new ServiceId(ISubjectHolderService.ID).injectInto(this).start(Activator.getContext());
}
- public void bindPermCache(IPermissionCache permCache) {
+ public void bind(IPermissionCache permCache) {
this.permCache = permCache;
}
- public void unbindPermCache(IPermissionCache permCache) {
+ public void unbind(IPermissionCache permCache) {
if (permCache == this.permCache) {
this.permCache = null;
}
}
- public void bindSubjectHolderService(ISubjectHolderService subjectHolderService) {
+ public void bind(ISubjectHolderService subjectHolderService) {
this.subjectHolderService = subjectHolderService;
}
- public void unbindSubjectHolderService(ISubjectHolderService subjectHolderService) {
+ public void unbind(ISubjectHolderService subjectHolderService) {
if (subjectHolderService == this.subjectHolderService) {
this.subjectHolderService = null;
}
diff --git a/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/internal/PermissionCache.java b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/internal/PermissionCache.java
index 1e206f1..caad04d 100644
--- a/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/internal/PermissionCache.java
+++ b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/authorization/internal/PermissionCache.java
@@ -22,7 +22,7 @@ import javax.security.auth.Subject;
import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.core.cache.GenericObjectCache;
-import org.eclipse.riena.core.service.ServiceInjector;
+import org.eclipse.riena.core.service.ServiceId;
import org.eclipse.riena.core.util.ContainerModel;
import org.eclipse.riena.internal.security.common.Activator;
import org.eclipse.riena.security.common.authorization.IAuthorizationService;
@@ -48,14 +48,14 @@ public class PermissionCache implements IPermissionCache {
permCache.setMinimumSize(100);
permCache.setTimeout(360000);
}
- new ServiceInjector(Activator.getContext(), IAuthorizationService.ID, this, "bindAuthService", "unbindAuthService").start();
+ new ServiceId(IAuthorizationService.ID).injectInto(this).start(Activator.getContext());
}
- public void bindAuthService(IAuthorizationService authService) {
+ public void bind(IAuthorizationService authService) {
this.authService = authService;
}
- public void unbindAuthService(IAuthorizationService authService) {
+ public void unbind(IAuthorizationService authService) {
if (authService == this.authService) {
this.authService = null;
}
diff --git a/org.eclipse.riena.security.server/src/org/eclipse/riena/internal/security/server/SecurityServiceHook.java b/org.eclipse.riena.security.server/src/org/eclipse/riena/internal/security/server/SecurityServiceHook.java
index 14f4c83..46f30a6 100644
--- a/org.eclipse.riena.security.server/src/org/eclipse/riena/internal/security/server/SecurityServiceHook.java
+++ b/org.eclipse.riena.security.server/src/org/eclipse/riena/internal/security/server/SecurityServiceHook.java
@@ -11,6 +11,7 @@
package org.eclipse.riena.internal.security.server;
import java.security.Principal;
+import java.util.Arrays;
import javax.security.auth.Subject;
import javax.servlet.http.Cookie;
@@ -19,11 +20,9 @@ import org.eclipse.equinox.log.Logger;
import org.eclipse.riena.communication.core.hooks.IServiceHook;
import org.eclipse.riena.communication.core.hooks.ServiceContext;
import org.eclipse.riena.core.cache.IGenericObjectCache;
-import org.eclipse.riena.core.service.ServiceInjector;
-import org.eclipse.riena.security.common.ISubjectHolder;
+import org.eclipse.riena.core.service.ServiceId;
import org.eclipse.riena.security.common.ISubjectHolderService;
import org.eclipse.riena.security.common.NotAuthorizedFailure;
-import org.eclipse.riena.security.common.session.ISessionHolder;
import org.eclipse.riena.security.common.session.ISessionHolderService;
import org.eclipse.riena.security.common.session.Session;
import org.eclipse.riena.security.server.session.ISessionService;
@@ -58,7 +57,8 @@ public class SecurityServiceHook implements IServiceHook {
private ISubjectHolderService subjectHolderService;
private ISessionHolderService sessionHolderService;
-// private HashMap<String, Boolean> freeHivemindWebservices = new HashMap<String, Boolean>();
+ // private HashMap<String, Boolean> freeHivemindWebservices = new
+ // HashMap<String, Boolean>();
private boolean requiresSSOIDbyDefault = false;
private static final Logger LOGGER = Activator.getDefault().getLogger(SecurityServiceHook.class.getName());
@@ -68,11 +68,11 @@ public class SecurityServiceHook implements IServiceHook {
*/
public SecurityServiceHook() {
super();
- new ServiceInjector(Activator.getContext(), IGenericObjectCache.ID, "(cache.type=PrincipalCache)", this, "bindPrincipalCache", "unbindPrincipalCache")
- .start();
- new ServiceInjector(Activator.getContext(), ISessionService.ID, this, "bindSessionService", "unbindSessionService").start();
- new ServiceInjector(Activator.getContext(), ISubjectHolderService.ID, this, "bindSubjectHolderService", "unbindSubjectHolderService").start();
- new ServiceInjector(Activator.getContext(), ISessionHolderService.ID, this, "bindSessionHolderService", "unbindSessionHolderService").start();
+ new ServiceId(IGenericObjectCache.ID).useFilter("(cache.type=PrincipalCache)").injectInto(this).start(
+ Activator.getContext());
+ new ServiceId(ISessionService.ID).injectInto(this).start(Activator.getContext());
+ new ServiceId(ISubjectHolderService.ID).injectInto(this).start(Activator.getContext());
+ new ServiceId(ISessionHolderService.ID).injectInto(this).start(Activator.getContext());
// List<UnsecureWebservice> tempList =
// RegistryAccessor.fetchRegistry().getConfiguration(UNSECURE_WEBSERVICES_ID);
@@ -113,45 +113,46 @@ public class SecurityServiceHook implements IServiceHook {
// }
if (!requiresSSOIDbyDefault) {
- LOGGER.log(LogService.LOG_INFO, appName + ": defining ALL WEBSERVICES in this Webapp as unsecure (SSOID is not required).");
+ LOGGER.log(LogService.LOG_INFO, appName
+ + ": defining ALL WEBSERVICES in this Webapp as unsecure (SSOID is not required).");
}
}
- public void bindPrincipalCache(IGenericObjectCache principalCache) {
+ public void bind(IGenericObjectCache principalCache) {
this.principalCache = principalCache;
}
- public void unbindPrincipalCache(IGenericObjectCache principalCache) {
+ public void unbind(IGenericObjectCache principalCache) {
if (this.principalCache == principalCache) {
this.principalCache = null;
}
}
- public void bindSessionService(ISessionService sessionService) {
+ public void bind(ISessionService sessionService) {
this.sessionService = sessionService;
}
- public void unbindSessionService(ISessionService sessionService) {
+ public void unbind(ISessionService sessionService) {
if (this.sessionService == sessionService) {
this.sessionService = null;
}
}
- public void bindSubjectHolderService(ISubjectHolderService subjectHolderService) {
+ public void bind(ISubjectHolderService subjectHolderService) {
this.subjectHolderService = subjectHolderService;
}
- public void unbindSubjectHolderService(ISubjectHolderService subjectHolderService) {
+ public void unbind(ISubjectHolderService subjectHolderService) {
if (this.subjectHolderService == subjectHolderService) {
this.subjectHolderService = null;
}
}
- public void bindSessionHolderService(ISessionHolderService ISessionHolderService) {
+ public void bind(ISessionHolderService ISessionHolderService) {
this.sessionHolderService = ISessionHolderService;
}
- public void unbindSessionHolderService(ISessionHolderService ISessionHolderService) {
+ public void unbind(ISessionHolderService ISessionHolderService) {
if (this.sessionHolderService == ISessionHolderService) {
this.sessionHolderService = null;
}
@@ -169,8 +170,6 @@ public class SecurityServiceHook implements IServiceHook {
// requiresSSOID = false;
// }
// }
- ISessionHolder sessionHolder = null;
- ISubjectHolder subjectHolder = null;
// first extract the cookies
Cookie[] cookies = callback.getCookies();
@@ -192,8 +191,10 @@ public class SecurityServiceHook implements IServiceHook {
if (ssoid == null && requiresSSOID) {
LOGGER.log(LogService.LOG_ERROR, "error in call to webservice {" + callback.getInterfaceName()
+ "} since it is not in the list of webservices that do not require a session but SSOID=null !!!");
- if (System.getProperty("spirit.secure.webservices") == null || System.getProperty("spirit.secure.webservices").equals("true")) {
- throw new NotAuthorizedFailure("call to webservice " + callback.getInterfaceName() + " failed, no valid session was given but is required.");
+ if (System.getProperty("spirit.secure.webservices") == null
+ || System.getProperty("spirit.secure.webservices").equals("true")) {
+ throw new NotAuthorizedFailure("call to webservice " + callback.getInterfaceName()
+ + " failed, no valid session was given but is required.");
}
}
@@ -204,16 +205,17 @@ public class SecurityServiceHook implements IServiceHook {
Principal[] principals = (Principal[]) principalCache.get(ssoid, SecurityServiceHook.class);
if (principals == null) {
principals = sessionService.findPrincipals(new Session(ssoid));
- LOGGER.log(LogService.LOG_DEBUG, "sessionService found principal = " + principals);
+ LOGGER.log(LogService.LOG_DEBUG, "sessionService found principal = " + Arrays.toString(principals));
if (principals == null && requiresSSOID) {
- LOGGER.log(LogService.LOG_ERROR, "ssoid {" + ssoid + "} found in request but SessionService could not find a Principal.");
+ LOGGER.log(LogService.LOG_ERROR, "ssoid {" + ssoid
+ + "} found in request but SessionService could not find a Principal.");
throw new NotAuthorizedFailure("call to webservice with invalid ssoid");
}
if (principals != null) {
principalCache.put(ssoid, principals);
}
} else {
- LOGGER.log(LogService.LOG_DEBUG, "found principal in cache = " + principals);
+ LOGGER.log(LogService.LOG_DEBUG, "found principal in cache = " + Arrays.toString(principals));
}
if (principals != null) {
Subject subject = new Subject();
@@ -245,10 +247,13 @@ public class SecurityServiceHook implements IServiceHook {
ssoid = afterSession.getSessionId();
}
if (beforeSession != null) {
- LOGGER.log(LogService.LOG_DEBUG, "afterService after_ssoid=" + ssoid + " before_ssoid=" + beforeSession.getSessionId());
+ LOGGER.log(LogService.LOG_DEBUG, "afterService after_ssoid=" + ssoid + " before_ssoid="
+ + beforeSession.getSessionId());
}
- LOGGER.log(LogService.LOG_DEBUG, "afterService compare session instance before=" + beforeSession + " after=" + afterSession);
- if (beforeSession != afterSession || (beforeSession != null && afterSession != null && !(beforeSession.getSessionId().equals(ssoid)))) {
+ LOGGER.log(LogService.LOG_DEBUG, "afterService compare session instance before=" + beforeSession + " after="
+ + afterSession);
+ if (beforeSession != afterSession
+ || (beforeSession != null && afterSession != null && !(beforeSession.getSessionId().equals(ssoid)))) {
if (ssoid == null || ssoid.equals("0")) {
// delete cookie
Cookie cookie = new Cookie(SSOID, "");
@@ -260,7 +265,8 @@ public class SecurityServiceHook implements IServiceHook {
cookie.setPath("/");
context.addCookie(cookie);
if (beforeSession != null && !(beforeSession.getSessionId().equals("0"))) {
- LOGGER.log(LogService.LOG_WARNING, "CHANGING cookie setting from '" + beforeSession.getSessionId() + "' to '" + ssoid + "'");
+ LOGGER.log(LogService.LOG_WARNING, "CHANGING cookie setting from '" + beforeSession.getSessionId()
+ + "' to '" + ssoid + "'");
} else {
LOGGER.log(LogService.LOG_DEBUG, "setting cookie to '" + ssoid + "'");
}
diff --git a/org.eclipse.riena.tests/src/org/eclipse/riena/core/AllTests.java b/org.eclipse.riena.tests/src/org/eclipse/riena/core/AllTests.java
index b5837cf..999f71b 100644
--- a/org.eclipse.riena.tests/src/org/eclipse/riena/core/AllTests.java
+++ b/org.eclipse.riena.tests/src/org/eclipse/riena/core/AllTests.java
@@ -18,7 +18,6 @@ import org.eclipse.riena.core.config.ConfigTest;
import org.eclipse.riena.core.exception.ExceptionHandlerManagerTest;
import org.eclipse.riena.core.extension.util.ExtensionUtilTest;
import org.eclipse.riena.core.service.InjectorTest;
-import org.eclipse.riena.core.service.ServiceInjectorTest;
/**
* Tests all test cases within package:
@@ -32,7 +31,6 @@ public class AllTests extends TestCase {
suite.addTestSuite(ConfigTest.class);
suite.addTestSuite(ExceptionHandlerManagerTest.class);
suite.addTestSuite(ExtensionUtilTest.class);
- suite.addTestSuite(ServiceInjectorTest.class);
suite.addTestSuite(InjectorTest.class);
return suite;
}