summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Campo2008-04-04 09:48:57 (EDT)
committerChristian Campo2008-04-04 09:48:57 (EDT)
commit89f746ac6e11acdd25febf7cd58d648f17900f02 (patch)
treea8ebeee49704fbf7d5e2349b06f85bbae3d5c5c2
parent70c253ddfe90e4b8f5cf6b7ce6a613cf591f32a2 (diff)
downloadorg.eclipse.riena-89f746ac6e11acdd25febf7cd58d648f17900f02.zip
org.eclipse.riena-89f746ac6e11acdd25febf7cd58d648f17900f02.tar.gz
org.eclipse.riena-89f746ac6e11acdd25febf7cd58d648f17900f02.tar.bz2
new BasicAuthenticationCallHook that send userid and password as HTTP Header....remote service errors now throw a RemoteFailure
-rw-r--r--org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/RemoteFailure.java45
-rw-r--r--org.eclipse.riena.communication.core/src/org/eclipse/riena/internal/communication/core/factory/CallHooksProxy.java3
-rw-r--r--org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/BasicAuthenticationCallHook.java79
3 files changed, 126 insertions, 1 deletions
diff --git a/org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/RemoteFailure.java b/org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/RemoteFailure.java
new file mode 100644
index 0000000..6340eb5
--- /dev/null
+++ b/org.eclipse.riena.communication.core/src/org/eclipse/riena/communication/core/RemoteFailure.java
@@ -0,0 +1,45 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.communication.core;
+
+import org.eclipse.riena.core.exception.Failure;
+
+/**
+ *
+ */
+public class RemoteFailure extends Failure {
+
+ public RemoteFailure(String msg, Object arg1, Object arg2, Throwable cause) {
+ super(msg, arg1, arg2, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public RemoteFailure(String msg, Object arg1, Throwable cause) {
+ super(msg, arg1, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public RemoteFailure(String msg, Object[] args, Throwable cause) {
+ super(msg, args, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public RemoteFailure(String msg, Throwable cause) {
+ super(msg, cause);
+ // TODO Auto-generated constructor stub
+ }
+
+ public RemoteFailure(String msg) {
+ super(msg);
+ // TODO Auto-generated constructor stub
+ }
+
+}
diff --git a/org.eclipse.riena.communication.core/src/org/eclipse/riena/internal/communication/core/factory/CallHooksProxy.java b/org.eclipse.riena.communication.core/src/org/eclipse/riena/internal/communication/core/factory/CallHooksProxy.java
index ac04af2..360ac1c 100644
--- a/org.eclipse.riena.communication.core/src/org/eclipse/riena/internal/communication/core/factory/CallHooksProxy.java
+++ b/org.eclipse.riena.communication.core/src/org/eclipse/riena/internal/communication/core/factory/CallHooksProxy.java
@@ -16,6 +16,7 @@ import java.util.HashSet;
import javax.security.auth.Subject;
+import org.eclipse.riena.communication.core.RemoteFailure;
import org.eclipse.riena.communication.core.RemoteServiceDescription;
import org.eclipse.riena.communication.core.hooks.AbstractHooksProxy;
import org.eclipse.riena.communication.core.hooks.CallContext;
@@ -56,7 +57,7 @@ public class CallHooksProxy extends AbstractHooksProxy {
try {
return super.invoke(proxy, method, args);
} catch (InvocationTargetException e) {
- throw e.getTargetException();
+ throw new RemoteFailure("error while invoke remote service", e.getTargetException()); //$NON-NLS-1$
} finally {
// context might be null and callHooks were injected during invoke
if (context != null) {
diff --git a/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/BasicAuthenticationCallHook.java b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/BasicAuthenticationCallHook.java
new file mode 100644
index 0000000..a5f52c4
--- /dev/null
+++ b/org.eclipse.riena.security.common/src/org/eclipse/riena/security/common/BasicAuthenticationCallHook.java
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2008 compeople AG and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * compeople AG - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.riena.security.common;
+
+import java.security.Principal;
+
+import javax.security.auth.Subject;
+
+import org.eclipse.riena.communication.core.hooks.CallContext;
+import org.eclipse.riena.communication.core.hooks.ICallHook;
+import org.eclipse.riena.core.injector.Inject;
+import org.eclipse.riena.internal.security.common.Activator;
+
+import sun.misc.BASE64Encoder;
+
+/**
+ * This optional hook implements authentication by
+ */
+public class BasicAuthenticationCallHook implements ICallHook {
+
+ private ISubjectHolderService subjectHolderService = null;
+
+ public BasicAuthenticationCallHook() {
+ super();
+ Inject.service(ISubjectHolderService.class.getName()).useRanking().into(this).andStart(Activator.getContext());
+ }
+
+ public void bind(ISubjectHolderService subjectHolderService) {
+ this.subjectHolderService = subjectHolderService;
+ }
+
+ public void unbind(ISubjectHolderService subjectHolderService) {
+ this.subjectHolderService = null;
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.riena.communication.core.hooks.ICallHook#afterCall(org.eclipse.riena.communication.core.hooks.CallContext)
+ */
+ public void afterCall(CallContext context) {
+ // TODO Auto-generated method stub
+ }
+
+ /*
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.riena.communication.core.hooks.ICallHook#beforeCall(org.eclipse.riena.communication.core.hooks.CallContext)
+ */
+ public void beforeCall(CallContext context) {
+ ISubjectHolder subjectHolder = subjectHolderService.fetchSubjectHolder();
+ if (subjectHolder != null) {
+ Subject subject = subjectHolder.getSubject();
+ if (subject != null) {
+ Object psw = (String) subject.getPrivateCredentials().iterator().next();
+ String password;
+ if (psw != null && psw instanceof String) {
+ password = (String) psw;
+ } else {
+ password = ""; //$NON-NLS-1$
+ }
+ for (Principal principal : subject.getPrincipals()) {
+ String useridPlusPassword = principal.getName() + ":" + password; //$NON-NLS-1$
+ String authorizationInBase64 = new BASE64Encoder().encode(useridPlusPassword.getBytes());
+ context.getMessageContext().addRequestHeader("Authorization", "Basic " + authorizationInBase64); //$NON-NLS-1$//$NON-NLS-2$
+ }
+ }
+ }
+ }
+
+}