sylvain 2003/10/19 05:42:58
Modified: src/java/org/apache/cocoon/components/language/markup/xsp
SOAPHelper.java
src/java/org/apache/cocoon/components/language/markup/xsp/java
soap.xsl
Log:
Add @authentication on soap:call to allow basic authentication
Revision Changes Path
1.3 +9 -2
cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/SOAPHelper.java
Index: SOAPHelper.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/SOAPHelper.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- SOAPHelper.java 5 Jul 2003 04:28:54 -0000 1.2
+++ SOAPHelper.java 19 Oct 2003 12:42:58 -0000 1.3
@@ -60,6 +60,7 @@
import org.apache.commons.httpclient.HttpConnection;
import org.apache.commons.httpclient.HttpState;
import org.apache.commons.httpclient.methods.PostMethod;
+import org.apache.excalibur.source.SourceUtil;
import org.xml.sax.InputSource;
import java.io.InputStreamReader;
@@ -80,15 +81,17 @@
URL url;
String action = "";
XScriptObject xscriptObject;
+ String authorization = "";
public SOAPHelper(ComponentManager manager, String urlContext, String
url,
- String action, XScriptObject xscriptObject)
+ String action, String authorization, XScriptObject
xscriptObject)
throws MalformedURLException, ComponentException
{
this.xscriptManager = (XScriptManager)
manager.lookup(XScriptManager.ROLE);
URL context = new URL(urlContext);
this.url = new URL(context, url);
this.action = action;
+ this.authorization = authorization;
this.xscriptObject = xscriptObject;
}
@@ -154,6 +157,10 @@
new Header("Content-type", "text/xml;
charset=\"utf-8\""));
method.setRequestHeader(new Header("SOAPAction", action));
method.setRequestBody(request);
+
+ if (authorization != null && !authorization.equals("")) {
+ method.setRequestHeader(new Header("Authorization","Basic
"+SourceUtil.encodeBASE64(authorization)));
+ }
method.execute(new HttpState(), conn);
1.3 +13 -2
cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/java/soap.xsl
Index: soap.xsl
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/java/org/apache/cocoon/components/language/markup/xsp/java/soap.xsl,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- soap.xsl 22 May 2003 21:26:26 -0000 1.2
+++ soap.xsl 19 Oct 2003 12:42:58 -0000 1.3
@@ -91,6 +91,14 @@
</xsl:choose>
</xsl:variable>
+ <xsl:variable name="authorization">
+ <xsl:choose>
+ <xsl:when test="soap:authorization"><xsl:value-of
select="soap:authorization"/></xsl:when>
+ <xsl:when test="@authorization">"<xsl:value-of
select="@authorization"/>"</xsl:when>
+ <xsl:otherwise>""</xsl:otherwise>
+ </xsl:choose>
+ </xsl:variable>
+
<xsl:variable name="method">
<xsl:choose>
<xsl:when test="soap:method"><xsl:value-of
select="soap:method"/></xsl:when>
@@ -133,6 +141,7 @@
XSPRequestHelper.getRequestedURL(objectModel),
String.valueOf(<xsl:value-of select="$url"/>),
<xsl:value-of select="$method"/>,
+ <xsl:value-of select="$authorization"/>,
<xscript:get scope="request" name="{$tempvar}"
as="object"/>).invoke(),
<xsl:value-of select="$scope"/>);
if (getLogger().isDebugEnabled()) {
@@ -168,6 +177,7 @@
<SOAP-ENV:Header
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:apply-templates select="*[name() != 'soap:url'
and name() != 'soap:method'
+ and name() != 'soap:authorization'
and name() != 'soap:namespace']"/>
</SOAP-ENV:Header>
</xsl:template>
@@ -184,6 +194,7 @@
<SOAP-ENV:Body
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/">
<xsl:apply-templates select="*[name() != 'soap:url'
and name() != 'soap:method'
+ and name() != 'soap:authorization'
and name() != 'soap:namespace']"/>
</SOAP-ENV:Body>
<xsp:logic>