summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany
diff options
context:
space:
mode:
authorlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-02-26 04:41:26 +0000
committerlresende <lresende@13f79535-47bb-0310-9956-ffa450edef68>2009-02-26 04:41:26 +0000
commit750e2e19dddb236c49d458ff27c2ab50b1848a63 (patch)
tree95acb6f1b3b9d9e0b38c1dbd96227c70a039fd6f /branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany
parentccdb9264ce71a776d4bb1cbf66a4e3f5012b48fd (diff)
Adding support for enabling and configuring authentication for embedded http server using policy
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@748014 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany')
-rw-r--r--branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java30
1 files changed, 27 insertions, 3 deletions
diff --git a/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java b/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
index 67c782ef05..6e01ac5f9f 100644
--- a/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
+++ b/branches/sca-java-1.x/modules/binding-http-runtime/src/main/java/org/apache/tuscany/sca/binding/http/provider/HTTPServiceBindingProvider.java
@@ -22,6 +22,7 @@ package org.apache.tuscany.sca.binding.http.provider;
import java.util.List;
import javax.servlet.Servlet;
+import javax.xml.namespace.QName;
import org.apache.tuscany.sca.binding.http.HTTPBinding;
import org.apache.tuscany.sca.host.http.SecurityContext;
@@ -31,8 +32,10 @@ import org.apache.tuscany.sca.interfacedef.Operation;
import org.apache.tuscany.sca.invocation.InvocationChain;
import org.apache.tuscany.sca.invocation.Invoker;
import org.apache.tuscany.sca.invocation.MessageFactory;
+import org.apache.tuscany.sca.policy.Intent;
import org.apache.tuscany.sca.policy.PolicySet;
import org.apache.tuscany.sca.policy.PolicySetAttachPoint;
+import org.apache.tuscany.sca.policy.authentication.AuthenticationConfigurationPolicy;
import org.apache.tuscany.sca.policy.confidentiality.ConfidentialityPolicy;
import org.apache.tuscany.sca.provider.ServiceBindingProvider;
import org.apache.tuscany.sca.runtime.RuntimeComponent;
@@ -45,6 +48,9 @@ import org.apache.tuscany.sca.runtime.RuntimeWire;
* @version $Rev$ $Date$
*/
public class HTTPServiceBindingProvider implements ServiceBindingProvider {
+ private static final QName AUTEHTICATION_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0","authentication");
+ private static final QName CONFIDENTIALITY_INTENT = new QName("http://www.osoa.org/xmlns/sca/1.0","confidentiality");
+
private RuntimeComponentService service;
private HTTPBinding binding;
private MessageFactory messageFactory;
@@ -127,19 +133,37 @@ public class HTTPServiceBindingProvider implements ServiceBindingProvider {
SecurityContext securityContext = new SecurityContext();
+ boolean isConfidentialityRequired = false;
+ boolean isAuthenticationRequired = false;
+
// find out which policies are active
if (binding instanceof PolicySetAttachPoint) {
+ List<Intent> intents = ((PolicySetAttachPoint)binding).getRequiredIntents();
+ for(Intent intent : intents) {
+ if (intent.getName().equals(AUTEHTICATION_INTENT)) {
+ isAuthenticationRequired = true;
+ } else if (intent.getName().equals(CONFIDENTIALITY_INTENT)) {
+ isConfidentialityRequired = true;
+ }
+ }
+
List<PolicySet> policySets = ((PolicySetAttachPoint)binding).getApplicablePolicySets();
for (PolicySet ps : policySets) {
for (Object p : ps.getPolicies()) {
- if (ConfidentialityPolicy.class.isInstance(p)) {
+ if (ConfidentialityPolicy.class.isInstance(p) && isConfidentialityRequired) {
+ //Handle enabling and configuring SSL
ConfidentialityPolicy confidentialityPolicy = (ConfidentialityPolicy)p;
securityContext.setSSLEnabled(true);
securityContext.setSSLProperties(confidentialityPolicy.toProperties());
- } else {
- // etc. check for other types of policy being present
+ } else if(AuthenticationConfigurationPolicy.class.isInstance(p) && isAuthenticationRequired) {
+ // Handle authentication and user configuration
+ AuthenticationConfigurationPolicy authenticationConfiguration = (AuthenticationConfigurationPolicy)p;
+
+ securityContext.setAuthenticationEnabled(true);
+ securityContext.getUsers().clear();
+ securityContext.getUsers().addAll(authenticationConfiguration.getUsers());
}
}
}