You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by mi...@apache.org on 2008/10/18 02:18:57 UTC
svn commit: r705804 - in
/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2:
Properties.java SoapExternalService.java
Author: midon
Date: Fri Oct 17 17:18:57 2008
New Revision: 705804
URL: http://svn.apache.org/viewvc?rev=705804&view=rev
Log:
ODE-388: set the policy on the ServiceClient
Modified:
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java
ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
Modified: ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java?rev=705804&r1=705803&r2=705804&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java (original)
+++ ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/Properties.java Fri Oct 17 17:18:57 2008
@@ -71,6 +71,7 @@
public static final String PROP_HTTP_REQUEST_CHUNK = "http.request.chunk";
public static final String PROP_HTTP_REQUEST_GZIP = "http.request.gzip";
public static final String PROP_HTTP_ACCEPT_GZIP = "http.accept.gzip";
+ public static final String PROP_SECURITY_POLICY = "security.policy";
protected static final Log log = LogFactory.getLog(Properties.class);
Modified: ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java
URL: http://svn.apache.org/viewvc/ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java?rev=705804&r1=705803&r2=705804&view=diff
==============================================================================
--- ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java (original)
+++ ode/branches/APACHE_ODE_1.X/axis2/src/main/java/org/apache/ode/axis2/SoapExternalService.java Fri Oct 17 17:18:57 2008
@@ -19,30 +19,21 @@
package org.apache.ode.axis2;
-import java.util.concurrent.Callable;
-import java.util.concurrent.ExecutorService;
-import java.util.Map;
-import java.io.File;
-import java.io.InputStream;
-
-import javax.wsdl.Definition;
-import javax.wsdl.Operation;
-import javax.wsdl.Fault;
-import javax.xml.namespace.QName;
-
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.AxisFault;
-import org.apache.axis2.deployment.ServiceBuilder;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.OperationClient;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.deployment.ServiceBuilder;
import org.apache.axis2.engine.AxisConfiguration;
import org.apache.axis2.wsdl.WSDLConstants;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.neethi.Policy;
+import org.apache.neethi.PolicyEngine;
import org.apache.ode.axis2.util.SoapMessageConverter;
import org.apache.ode.bpel.epr.EndpointFactory;
import org.apache.ode.bpel.epr.MutableEndpoint;
@@ -50,20 +41,33 @@
import org.apache.ode.bpel.iapi.BpelServer;
import org.apache.ode.bpel.iapi.Message;
import org.apache.ode.bpel.iapi.MessageExchange;
+import org.apache.ode.bpel.iapi.MessageExchange.FailureType;
import org.apache.ode.bpel.iapi.PartnerRoleMessageExchange;
-import org.apache.ode.bpel.iapi.Scheduler;
import org.apache.ode.bpel.iapi.ProcessConf;
-import org.apache.ode.bpel.iapi.MessageExchange.FailureType;
+import org.apache.ode.bpel.iapi.Scheduler;
import org.apache.ode.il.OMUtils;
+import org.apache.ode.utils.CollectionUtils;
import org.apache.ode.utils.DOMUtils;
import org.apache.ode.utils.Namespaces;
import org.apache.ode.utils.WatchDog;
-import org.apache.ode.utils.CollectionUtils;
-import org.apache.ode.utils.wsdl.Messages;
import org.apache.ode.utils.uuid.UUID;
+import org.apache.ode.utils.wsdl.Messages;
+import org.apache.rampart.RampartMessageData;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
+import javax.wsdl.Definition;
+import javax.wsdl.Fault;
+import javax.wsdl.Operation;
+import javax.xml.namespace.QName;
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.Map;
+import java.util.concurrent.Callable;
+import java.util.concurrent.ExecutorService;
+
/**
* Acts as a service not provided by ODE. Used mainly for invocation as a way to maintain the WSDL description of used
* services.
@@ -130,8 +134,8 @@
__log.debug("Message: " + soapEnv);
}
-
ServiceClient client = getServiceClient();
+
final OperationClient operationClient = client.createClient(isTwoWay ? ServiceClient.ANON_OUT_IN_OP
: ServiceClient.ANON_OUT_ONLY_OP);
operationClient.addMessageContext(mctx);
@@ -144,7 +148,6 @@
operationOptions.setAction(mctx.getSoapAction());
operationOptions.setTo(axisEPR);
-
if (isTwoWay) {
final String mexId = odeMex.getMessageExchangeId();
final Operation operation = odeMex.getOperation();
@@ -247,9 +250,32 @@
// apply the options to the service client
ServiceClient serviceClient = serviceClientWatchDog.getObserver().client;
serviceClient.setOptions(optionsWatchDog.getObserver().options);
+ prepareSecurityPolicy(optionsWatchDog.getObserver().options, serviceClient);
return serviceClient;
}
+ private void prepareSecurityPolicy(Options options, ServiceClient serviceClient) throws AxisFault {
+ if (options.getProperty(Properties.PROP_SECURITY_POLICY) != null) {
+ String policy = (String) options.getProperty(Properties.PROP_SECURITY_POLICY);
+ URI policyUri = _pconf.getBaseURI().resolve(policy);
+ try {
+ InputStream policyStream = policyUri.toURL().openStream();
+ try {
+ Policy policyDoc = PolicyEngine.getPolicy(policyStream);
+ options.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policyDoc);
+
+ // make sure the proper modules are engaged
+ if (!serviceClient.getAxisConfiguration().isEngaged("rampart")) serviceClient.engageModule("rampart");
+ if (!serviceClient.getAxisConfiguration().isEngaged("addressing")) serviceClient.engageModule("addressing");
+ } finally {
+ policyStream.close();
+ }
+ } catch (IOException e) {
+ throw new IllegalArgumentException("Exception while parsing policy: " + policyUri, e);
+ }
+ }
+ }
+
/**
* Extracts the action to be used for the given operation. It first checks to see
* if a value is specified using WS-Addressing in the portType, it then falls back onto
@@ -310,7 +336,7 @@
}
public org.apache.ode.bpel.iapi.EndpointReference getInitialEndpointReference() {
-return endpointReference;
+ return endpointReference;
}
public void close() {
@@ -362,8 +388,8 @@
if (fault != null) {
if (__log.isWarnEnabled())
- __log.warn("Fault response: faultName=" + fault.getName() + " faultType="+fault.getMessage().getQName()+ "\n" + DOMUtils.domToString(odeMsgEl));
-
+ __log.warn("Fault response: faultName=" + fault.getName() + " faultType=" + fault.getMessage().getQName() + "\n" + DOMUtils.domToString(odeMsgEl));
+
QName faultType = fault.getMessage().getQName();
QName faultName = new QName(_definition.getTargetNamespace(), fault.getName());
Message response = odeMex.createMessage(faultType);