You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2017/01/30 17:50:59 UTC
svn commit: r1780953 [6/9] - in
/axis/axis2/java/rampart/branches/RAMPART-289: ./ apidocs/ code-coverage/
etc/ legal/ modules/distribution/ modules/distribution/src/
modules/documentation/ modules/rampart-core/
modules/rampart-core/src/main/java/META-I...
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample03/src/org/apache/rampart/samples/policy/sample03/Client.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample03/src/org/apache/rampart/samples/policy/sample03/Client.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample03/src/org/apache/rampart/samples/policy/sample03/Client.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample03/src/org/apache/rampart/samples/policy/sample03/Client.java Mon Jan 30 17:50:58 2017
@@ -20,7 +20,8 @@ import org.apache.axiom.om.OMAbstractFac
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
@@ -30,6 +31,8 @@ import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
import org.apache.rampart.RampartMessageData;
+import java.io.FileInputStream;
+
import javax.xml.namespace.QName;
public class Client {
@@ -59,7 +62,7 @@ public class Client {
}
private static Policy loadPolicy(String xmlPath) throws Exception {
- StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new FileInputStream(xmlPath));
return PolicyEngine.getPolicy(builder.getDocumentElement());
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample03/src/org/apache/rampart/samples/policy/sample03/PWCBHandler.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample03/src/org/apache/rampart/samples/policy/sample03/PWCBHandler.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample03/src/org/apache/rampart/samples/policy/sample03/PWCBHandler.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample03/src/org/apache/rampart/samples/policy/sample03/PWCBHandler.java Mon Jan 30 17:50:58 2017
@@ -30,7 +30,7 @@ public class PWCBHandler implements Call
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
- String id = pwcb.getIdentifer();
+ String id = pwcb.getIdentifier();
if("client".equals(id)) {
pwcb.setPassword("apache");
} else if("service".equals(id)) {
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample04/src/org/apache/rampart/samples/policy/sample04/Client.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample04/src/org/apache/rampart/samples/policy/sample04/Client.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample04/src/org/apache/rampart/samples/policy/sample04/Client.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample04/src/org/apache/rampart/samples/policy/sample04/Client.java Mon Jan 30 17:50:58 2017
@@ -20,7 +20,8 @@ import org.apache.axiom.om.OMAbstractFac
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axis2.Constants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
@@ -31,6 +32,8 @@ import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
import org.apache.rampart.RampartMessageData;
+import java.io.FileInputStream;
+
import javax.xml.namespace.QName;
public class Client {
@@ -67,7 +70,7 @@ public class Client {
}
private static Policy loadPolicy(String xmlPath) throws Exception {
- StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new FileInputStream(xmlPath));
return PolicyEngine.getPolicy(builder.getDocumentElement());
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample04/src/org/apache/rampart/samples/policy/sample04/PWCBHandler.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample04/src/org/apache/rampart/samples/policy/sample04/PWCBHandler.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample04/src/org/apache/rampart/samples/policy/sample04/PWCBHandler.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample04/src/org/apache/rampart/samples/policy/sample04/PWCBHandler.java Mon Jan 30 17:50:58 2017
@@ -30,7 +30,7 @@ public class PWCBHandler implements Call
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
- String id = pwcb.getIdentifer();
+ String id = pwcb.getIdentifier();
if("client".equals(id)) {
pwcb.setPassword("apache");
} else if("service".equals(id)) {
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/policy.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/policy.xml?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/policy.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/policy.xml Mon Jan 30 17:50:58 2017
@@ -35,7 +35,7 @@
<wsp:Policy>
<sp:IssuedToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<Issuer xmlns="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
- <Address xmlns="http://www.w3.org/2005/08/addressing">http://localhost:8080/axis2/services/STS</Address>
+ <Address xmlns="http://www.w3.org/2005/08/addressing">http://localhost:@port@/axis2/services/STS</Address>
</Issuer>
<sp:RequestSecurityTokenTemplate>
<t:TokenType xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV1.1</t:TokenType>
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/src/org/apache/rampart/samples/policy/sample05/Client.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/src/org/apache/rampart/samples/policy/sample05/Client.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/src/org/apache/rampart/samples/policy/sample05/Client.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/src/org/apache/rampart/samples/policy/sample05/Client.java Mon Jan 30 17:50:58 2017
@@ -20,9 +20,8 @@ import org.apache.axiom.om.OMAbstractFac
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axis2.addressing.AddressingConstants;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
@@ -33,13 +32,14 @@ import org.apache.neethi.PolicyEngine;
import org.apache.rahas.RahasConstants;
import org.apache.rahas.Token;
import org.apache.rahas.TokenStorage;
-import org.apache.rahas.TrustException;
import org.apache.rahas.TrustUtil;
import org.apache.rahas.client.STSClient;
import org.apache.rampart.RampartMessageData;
import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.opensaml.XML;
+import org.opensaml.common.xml.SAMLConstants;
+
+import java.io.FileInputStream;
+import java.net.URL;
import javax.xml.namespace.QName;
@@ -59,7 +59,7 @@ public class Client {
String action = TrustUtil.getActionValue(RahasConstants.VERSION_05_02, RahasConstants.RST_ACTION_ISSUE);
stsClient.setAction(action);
- Token responseToken = stsClient.requestSecurityToken(loadPolicy("sample05/policy.xml"), "http://localhost:8080/axis2/services/STS", loadPolicy("sample05/sts_policy.xml"), null);
+ Token responseToken = stsClient.requestSecurityToken(loadPolicy("sample05/policy.xml"), new URL(new URL(args[0]), "/axis2/services/STS").toString(), loadPolicy("sample05/sts_policy.xml"), null);
System.out.println("\n############################# Requested Token ###################################\n");
System.out.println(responseToken.getToken().toString());
@@ -87,7 +87,7 @@ public class Client {
}
private static Policy loadPolicy(String xmlPath) throws Exception {
- StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new FileInputStream(xmlPath));
return PolicyEngine.getPolicy(builder.getDocumentElement());
}
@@ -95,7 +95,7 @@ public class Client {
OMElement rst = resp.getFirstChildWithName(new QName(RahasConstants.WST_NS_05_02,
RahasConstants.IssuanceBindingLocalNames.
REQUESTED_SECURITY_TOKEN));
- OMElement elem = rst.getFirstChildWithName(new QName(XML.SAML_NS, "Assertion"));
+ OMElement elem = rst.getFirstChildWithName(new QName( SAMLConstants.SAML20_NS , "Assertion"));
return elem;
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/src/org/apache/rampart/samples/policy/sample05/PWCBHandler.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/src/org/apache/rampart/samples/policy/sample05/PWCBHandler.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/src/org/apache/rampart/samples/policy/sample05/PWCBHandler.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample05/src/org/apache/rampart/samples/policy/sample05/PWCBHandler.java Mon Jan 30 17:50:58 2017
@@ -30,7 +30,7 @@ public class PWCBHandler implements Call
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
- String id = pwcb.getIdentifer();
+ String id = pwcb.getIdentifier();
if("client".equals(id)) {
pwcb.setPassword("apache");
} else if("service".equals(id)) {
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/policy.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/policy.xml?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/policy.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/policy.xml Mon Jan 30 17:50:58 2017
@@ -35,7 +35,7 @@
<wsp:Policy>
<sp:IssuedToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<Issuer xmlns="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
- <Address xmlns="http://www.w3.org/2005/08/addressing">http://localhost:8080/axis2/services/STS</Address>
+ <Address xmlns="http://www.w3.org/2005/08/addressing">http://localhost:@port@/axis2/services/STS</Address>
<Metadata xmlns="http://www.w3.org/2005/08/addressing">
<mex:Metadata
xmlns:mex="http://schemas.xmlsoap.org/ws/2004/09/mex"
@@ -43,7 +43,7 @@
<mex:MetadataSection Dialect="http://schemas.xmlsoap.org/ws/2004/09/mex">
<mex:MetadataReference>
<Address
- xmlns="http://www.w3.org/2005/08/addressing">http://localhost:8080/axis2/services/mex</Address>
+ xmlns="http://www.w3.org/2005/08/addressing">http://localhost:@port@/axis2/services/mex</Address>
</mex:MetadataReference>
</mex:MetadataSection>
</mex:Metadata>
@@ -104,4 +104,4 @@
</ramp:RampartConfig>
</wsp:All>
</wsp:ExactlyOne>
-</wsp:Policy>
\ No newline at end of file
+</wsp:Policy>
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/services.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/services.xml?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/services.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/services.xml Mon Jan 30 17:50:58 2017
@@ -183,7 +183,7 @@
<mex:MetadataSection Dialect="http://schemas.xmlsoap.org/ws/2004/09/mex">
<mex:MetadataReference>
<Address
- xmlns="http://www.w3.org/2005/08/addressing">http://localhost:8080/axis2/services/mex</Address>
+ xmlns="http://www.w3.org/2005/08/addressing">http://localhost:@port@/axis2/services/mex</Address>
</mex:MetadataReference>
</mex:MetadataSection>
</mex:Metadata>
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/Client.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/Client.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/Client.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/Client.java Mon Jan 30 17:50:58 2017
@@ -20,9 +20,9 @@ import org.apache.axiom.om.OMAbstractFac
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
@@ -31,15 +31,12 @@ import org.apache.axis2.context.Configur
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
import org.apache.rahas.RahasConstants;
-import org.apache.rahas.Token;
-import org.apache.rahas.TokenStorage;
-import org.apache.rahas.TrustException;
import org.apache.rahas.TrustUtil;
-import org.apache.rahas.client.STSClient;
import org.apache.rampart.RampartMessageData;
import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.opensaml.XML;
+import org.opensaml.common.xml.SAMLConstants;
+
+import java.io.FileInputStream;
import javax.xml.namespace.QName;
@@ -72,7 +69,7 @@ public class Client {
}
private static Policy loadPolicy(String xmlPath) throws Exception {
- StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new FileInputStream(xmlPath));
return PolicyEngine.getPolicy(builder.getDocumentElement());
}
@@ -80,7 +77,7 @@ public class Client {
OMElement rst = resp.getFirstChildWithName(new QName(RahasConstants.WST_NS_05_02,
RahasConstants.IssuanceBindingLocalNames.
REQUESTED_SECURITY_TOKEN));
- OMElement elem = rst.getFirstChildWithName(new QName(XML.SAML_NS, "Assertion"));
+ OMElement elem = rst.getFirstChildWithName(new QName(SAMLConstants.SAML20_NS, "Assertion"));
return elem;
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/MexService.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/MexService.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/MexService.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/MexService.java Mon Jan 30 17:50:58 2017
@@ -22,10 +22,9 @@ import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
-import javax.xml.stream.XMLStreamException;
-
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axis2.AxisFault;
import org.apache.axis2.mex.MexConstants;
import org.apache.axis2.mex.om.Metadata;
@@ -56,12 +55,10 @@ public class MexService {
File file = new File("sample06/mex_policy.xml");
System.out.println(file.getAbsolutePath());
- StAXOMBuilder builder = new StAXOMBuilder(new FileInputStream(file));
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new FileInputStream(file));
return builder.getDocumentElement();
} catch (FileNotFoundException e) {
throw new AxisFault("Error reading the file",e);
- } catch (XMLStreamException e) {
- throw new AxisFault("Error parsing the file",e);
}
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/PWCBHandler.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/PWCBHandler.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/PWCBHandler.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample06/src/org/apache/rampart/samples/policy/sample06/PWCBHandler.java Mon Jan 30 17:50:58 2017
@@ -30,7 +30,7 @@ public class PWCBHandler implements Call
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
- String id = pwcb.getIdentifer();
+ String id = pwcb.getIdentifier();
if("client".equals(id)) {
pwcb.setPassword("apache");
} else if("service".equals(id)) {
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample07/src/org/apache/rampart/samples/policy/sample07/Client.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample07/src/org/apache/rampart/samples/policy/sample07/Client.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample07/src/org/apache/rampart/samples/policy/sample07/Client.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample07/src/org/apache/rampart/samples/policy/sample07/Client.java Mon Jan 30 17:50:58 2017
@@ -20,7 +20,8 @@ import org.apache.axiom.om.OMAbstractFac
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axis2.addressing.EndpointReference;
import org.apache.axis2.client.Options;
import org.apache.axis2.client.ServiceClient;
@@ -30,6 +31,8 @@ import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
import org.apache.rampart.RampartMessageData;
+import java.io.FileInputStream;
+
import javax.xml.namespace.QName;
public class Client {
@@ -59,7 +62,7 @@ public class Client {
}
private static Policy loadPolicy(String xmlPath) throws Exception {
- StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new FileInputStream(xmlPath));
return PolicyEngine.getPolicy(builder.getDocumentElement());
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample07/src/org/apache/rampart/samples/policy/sample07/PWCBHandler.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample07/src/org/apache/rampart/samples/policy/sample07/PWCBHandler.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample07/src/org/apache/rampart/samples/policy/sample07/PWCBHandler.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample07/src/org/apache/rampart/samples/policy/sample07/PWCBHandler.java Mon Jan 30 17:50:58 2017
@@ -30,7 +30,7 @@ public class PWCBHandler implements Call
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
- String id = pwcb.getIdentifer();
+ String id = pwcb.getIdentifier();
if("client".equals(id)) {
pwcb.setPassword("apache");
} else if("service".equals(id)) {
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/policy.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/policy.xml?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/policy.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/policy.xml Mon Jan 30 17:50:58 2017
@@ -35,7 +35,7 @@
<wsp:Policy>
<sp:IssuedToken sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
<Issuer xmlns="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
- <Address xmlns="http://www.w3.org/2005/08/addressing">http://localhost:8080/axis2/services/STS</Address>
+ <Address xmlns="http://www.w3.org/2005/08/addressing">http://localhost:@port@/axis2/services/STS</Address>
</Issuer>
<sp:RequestSecurityTokenTemplate>
<t:TokenType xmlns:t="http://schemas.xmlsoap.org/ws/2005/02/trust">http://docs.oasis-open.org/wss/oasis-wss-saml-token-profile-1.1#SAMLV2.0</t:TokenType>
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/Client.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/Client.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/Client.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/Client.java Mon Jan 30 17:50:58 2017
@@ -19,27 +19,21 @@ package org.apache.rampart.samples.polic
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
-import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.soap.SOAP12Constants;
-import org.apache.axis2.addressing.AddressingConstants;
-import org.apache.axis2.addressing.EndpointReference;
-import org.apache.axis2.client.Options;
-import org.apache.axis2.client.ServiceClient;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.neethi.Policy;
import org.apache.neethi.PolicyEngine;
import org.apache.rahas.RahasConstants;
import org.apache.rahas.Token;
-import org.apache.rahas.TokenStorage;
-import org.apache.rahas.TrustException;
import org.apache.rahas.TrustUtil;
import org.apache.rahas.client.STSClient;
-import org.apache.rampart.RampartMessageData;
import org.apache.ws.secpolicy.SP11Constants;
-import org.apache.ws.secpolicy.SPConstants;
-import org.opensaml.XML;
+import org.opensaml.common.xml.SAMLConstants;
+
+import java.io.FileInputStream;
+import java.net.URL;
import javax.xml.namespace.QName;
@@ -59,7 +53,7 @@ public class Client {
String action = TrustUtil.getActionValue(RahasConstants.VERSION_05_02, RahasConstants.RST_ACTION_ISSUE);
stsClient.setAction(action);
- Token responseToken = stsClient.requestSecurityToken(loadPolicy("sample08/policy.xml"), "http://localhost:8080/axis2/services/STS", loadPolicy("sample08/sts_policy.xml"), null);
+ Token responseToken = stsClient.requestSecurityToken(loadPolicy("sample08/policy.xml"), new URL(new URL(args[0]), "/axis2/services/STS").toString(), loadPolicy("sample08/sts_policy.xml"), null);
System.out.println("\n############################# Requested SAML 2.0 Token ###################################\n");
System.out.println(responseToken.getToken().toString());
@@ -69,7 +63,7 @@ public class Client {
}
private static Policy loadPolicy(String xmlPath) throws Exception {
- StAXOMBuilder builder = new StAXOMBuilder(xmlPath);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new FileInputStream(xmlPath));
return PolicyEngine.getPolicy(builder.getDocumentElement());
}
@@ -77,7 +71,7 @@ public class Client {
OMElement rst = resp.getFirstChildWithName(new QName(RahasConstants.WST_NS_05_02,
RahasConstants.IssuanceBindingLocalNames.
REQUESTED_SECURITY_TOKEN));
- OMElement elem = rst.getFirstChildWithName(new QName(XML.SAML_NS, "Assertion"));
+ OMElement elem = rst.getFirstChildWithName(new QName(SAMLConstants.SAML20_NS, "Assertion"));
return elem;
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/PWCBHandler.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/PWCBHandler.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/PWCBHandler.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-samples/policy/sample08/src/org/apache/rampart/samples/policy/sample08/PWCBHandler.java Mon Jan 30 17:50:58 2017
@@ -30,7 +30,7 @@ public class PWCBHandler implements Call
UnsupportedCallbackException {
for (int i = 0; i < callbacks.length; i++) {
WSPasswordCallback pwcb = (WSPasswordCallback)callbacks[i];
- String id = pwcb.getIdentifer();
+ String id = pwcb.getIdentifier();
if("client".equals(id)) {
pwcb.setPassword("apache");
} else if("service".equals(id)) {
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/pom.xml?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/pom.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/pom.xml Mon Jan 30 17:50:58 2017
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.rampart</groupId>
<artifactId>rampart-project</artifactId>
- <version>1.7.0-SNAPSHOT</version>
+ <version>1.8.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
@@ -48,11 +48,9 @@
</testResources>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
+ <artifactId>maven-deploy-plugin</artifactId>
<configuration>
- <source>1.5</source>
- <target>1.5</target>
+ <skip>true</skip>
</configuration>
</plugin>
</plugins>
@@ -82,20 +80,10 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
</dependencies>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>2.0-beta-5</version>
- <configuration>
- <templateDirectory>${basedir}</templateDirectory>
- <menu ref="parent" />
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-
</project>
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rahas/SimpleTokenStoreTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rahas/SimpleTokenStoreTest.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rahas/SimpleTokenStoreTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rahas/SimpleTokenStoreTest.java Mon Jan 30 17:50:58 2017
@@ -20,13 +20,11 @@ import org.apache.axiom.om.OMAbstractFac
import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMNamespace;
-import org.apache.axiom.om.impl.dom.DOOMAbstractFactory;
import junit.framework.TestCase;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.Date;
@@ -145,7 +143,7 @@ public class SimpleTokenStoreTest extend
private Token getTestToken(String tokenId, Date expiry)
throws TrustException {
- OMFactory factory = DOOMAbstractFactory.getOMFactory();
+ OMFactory factory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getOMFactory();
OMElement tokenEle = factory.createOMElement("testToken", "", "");
Token token = new Token(tokenId, tokenEle, new Date(), expiry);
token.setAttachedReference(tokenEle);
@@ -157,7 +155,6 @@ public class SimpleTokenStoreTest extend
public void testSerialize()
throws Exception {
- String fileName = "test.ser";
OMFactory factory = OMAbstractFactory.getOMFactory();
OMNamespace ns1 = factory.createOMNamespace("bar", "x");
@@ -168,30 +165,13 @@ public class SimpleTokenStoreTest extend
SimpleTokenStore store = new SimpleTokenStore();
store.add(t);
- FileOutputStream fos = null;
- ObjectOutputStream out = null;
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ ObjectOutputStream out = new ObjectOutputStream(baos);
- try {
- fos = new FileOutputStream(fileName);
- out = new ObjectOutputStream(fos);
- out.writeObject(store);
- } finally {
- out.close();
- }
-
- SimpleTokenStore store2 = null;
- FileInputStream fis = null;
- ObjectInputStream in = null;
- try {
- fis = new FileInputStream(fileName);
- in = new ObjectInputStream(fis);
- store2 = (SimpleTokenStore)in.readObject();
- in.close();
- } catch (IOException ex) {
- ex.printStackTrace();
- } catch (ClassNotFoundException ex) {
- ex.printStackTrace();
- }
+ out.writeObject(store);
+
+ ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray()));
+ SimpleTokenStore store2 = (SimpleTokenStore)in.readObject();
assertEquals(store.getToken("#1232122").getId(), store2.getToken("#1232122").getId());
assertEquals(store.getToken("#1232122").getCreated(), store2.getToken("#1232122").getCreated());
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/AsymmetricBindingBuilderTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/AsymmetricBindingBuilderTest.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/AsymmetricBindingBuilderTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/AsymmetricBindingBuilderTest.java Mon Jan 30 17:50:58 2017
@@ -38,7 +38,7 @@ public class AsymmetricBindingBuilderTes
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.WSSE_NS, WSConstants.BINARY_TOKEN_LN));
@@ -59,7 +59,7 @@ public class AsymmetricBindingBuilderTes
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
@@ -79,7 +79,7 @@ public class AsymmetricBindingBuilderTes
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.WSSE_NS, WSConstants.BINARY_TOKEN_LN));
@@ -102,7 +102,7 @@ public class AsymmetricBindingBuilderTes
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.WSSE_NS, WSConstants.BINARY_TOKEN_LN));
@@ -124,7 +124,7 @@ public class AsymmetricBindingBuilderTes
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
@@ -148,7 +148,7 @@ public class AsymmetricBindingBuilderTes
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
@@ -170,7 +170,7 @@ public class AsymmetricBindingBuilderTes
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
@@ -191,7 +191,7 @@ public class AsymmetricBindingBuilderTes
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.WSSE_NS,WSConstants.BINARY_TOKEN_LN));
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/MessageBuilderTestBase.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/MessageBuilderTestBase.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/MessageBuilderTestBase.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/MessageBuilderTestBase.java Mon Jan 30 17:50:58 2017
@@ -20,8 +20,6 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMXMLBuilderFactory;
import org.apache.axiom.om.OMXMLParserWrapper;
import org.apache.axiom.soap.SOAPEnvelope;
-import org.apache.axiom.soap.SOAP11Constants;
-import org.apache.axiom.soap.SOAP12Constants;
import org.apache.axis2.AxisFault;
import org.apache.axis2.client.Options;
import org.apache.axis2.context.ConfigurationContext;
@@ -74,7 +72,7 @@ public class MessageBuilderTestBase exte
* @throws AxisFault
*/
protected MessageContext getMsgCtx12() throws Exception {
- return initMsgCtxFromMessage("test-resources/policy/soapmessage.xml");
+ return initMsgCtxFromMessage("test-resources/policy/soapmessage12.xml");
}
/**
@@ -116,7 +114,7 @@ public class MessageBuilderTestBase exte
return PolicyEngine.getPolicy(builder.getDocumentElement());
}
- protected void verifySecHeader(Iterator qnameList, SOAPEnvelope env) {
+ protected void verifySecHeader(Iterator<QName> qnameList, SOAPEnvelope env) {
Iterator secHeaderChildren =
env.getHeader().
getFirstChildWithName(new QName(WSConstants.WSSE_NS,
@@ -139,16 +137,4 @@ public class MessageBuilderTestBase exte
"next expected element" + qnameList.next().toString());
}
}
-
- public String getContentTypeForEnvelope(SOAPEnvelope env) {
- String contentType = SOAP11Constants.SOAP_11_CONTENT_TYPE; //default
- if (SOAP11Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(env.getNamespace().getNamespaceURI())) {
- contentType = SOAP11Constants.SOAP_11_CONTENT_TYPE;
- }
- else if (SOAP12Constants.SOAP_ENVELOPE_NAMESPACE_URI.equals(env.getNamespace().getNamespaceURI())) {
- contentType = SOAP12Constants.SOAP_12_CONTENT_TYPE;
- }
- return contentType;
- }
-
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/PolicyAssertionsTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/PolicyAssertionsTest.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/PolicyAssertionsTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/PolicyAssertionsTest.java Mon Jan 30 17:50:58 2017
@@ -16,7 +16,9 @@ package org.apache.rampart;
import org.apache.axiom.soap.SOAPEnvelope;
import org.apache.axis2.builder.SOAPBuilder;
import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisService;
import org.apache.neethi.Policy;
+import org.apache.ws.security.handler.WSHandlerConstants;
import java.io.ByteArrayInputStream;
@@ -78,6 +80,82 @@ public class PolicyAssertionsTest extend
} catch (RampartException expected) {
// Ignore intentionally as the test is supposed to throw an exception
}
+
+ }
+
+ public void testHashedPasswordRequiredValid() throws Exception {
+
+ MessageContext ctx = getMsgCtx();
+
+ String policyXml = "test-resources/policy/rampart-hashed-password.xml";
+ Policy policy = loadPolicy(policyXml);
+
+ ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
+
+ ctx.getOptions().setUserName( "Ron" );
+ ctx.getOptions().setPassword( "noR" );
+
+ MessageBuilder builder = new MessageBuilder();
+ builder.build(ctx);
+
+ // Building the SOAP envelope from the OMElement
+ SOAPBuilder soapBuilder = new SOAPBuilder();
+ SOAPEnvelope env = ctx.getEnvelope();
+ ByteArrayInputStream inStream = new ByteArrayInputStream(env.toString().getBytes());
+ env = (SOAPEnvelope) soapBuilder.processDocument(inStream, "text/xml", ctx);
+ ctx.setEnvelope(env);
+
+ ctx.setServerSide(true);
+ AxisService axisService = ctx.getAxisService();
+ axisService.removeParameter(axisService.getParameter(RampartMessageData.PARAM_CLIENT_SIDE));
+
+ ctx.setProperty(WSHandlerConstants.PW_CALLBACK_REF, new TestCBHandler());
+
+ RampartEngine engine = new RampartEngine();
+ engine.process(ctx);
+
+ }
+
+ public void testHashedPasswordRequiredInvalid() throws Exception {
+
+ MessageContext ctx = getMsgCtx();
+
+ String policyXml = "test-resources/policy/rampart-plaintext-password.xml";
+ Policy policy = loadPolicy(policyXml);
+
+ ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
+
+ ctx.getOptions().setUserName( "Ron" );
+ ctx.getOptions().setPassword( "noR" );
+
+ MessageBuilder builder = new MessageBuilder();
+ builder.build(ctx);
+
+ // Building the SOAP envelope from the OMElement
+ SOAPBuilder soapBuilder = new SOAPBuilder();
+ SOAPEnvelope env = ctx.getEnvelope();
+ ByteArrayInputStream inStream = new ByteArrayInputStream(env.toString().getBytes());
+ env = (SOAPEnvelope) soapBuilder.processDocument(inStream, "text/xml", ctx);
+ ctx.setEnvelope(env);
+
+ ctx.setServerSide(true);
+ AxisService axisService = ctx.getAxisService();
+ axisService.removeParameter(axisService.getParameter(RampartMessageData.PARAM_CLIENT_SIDE));
+
+ policyXml = "test-resources/policy/rampart-hashed-password.xml";
+ policy = loadPolicy(policyXml);
+
+ ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
+ ctx.setProperty(WSHandlerConstants.PW_CALLBACK_REF, new TestCBHandler());
+
+ RampartEngine engine = new RampartEngine();
+
+ try {
+ engine.process(ctx);
+ fail(" This should have thrown RampartException: Invalid UsernameToken Type.");
+ } catch (RampartException expected) {
+ // Ignore intentionally as the test is supposed to throw an exception
+ }
}
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/RampartEngineTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/RampartEngineTest.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/RampartEngineTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/RampartEngineTest.java Mon Jan 30 17:50:58 2017
@@ -26,74 +26,41 @@ import org.apache.axis2.context.MessageC
import org.apache.neethi.Policy;
import org.apache.ws.security.WSConstants;
import org.apache.ws.security.WSSecurityEngineResult;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+@RunWith(JUnit4.class)
public class RampartEngineTest extends MessageBuilderTestBase {
-
- public RampartEngineTest(String name) {
- super(name);
- }
-
+ /**
+ * Tests that Rampart complains about missing security header in request.
+ *
+ * @throws Exception
+ */
+ @Test(expected=RampartException.class)
public void testEmptySOAPMessage() throws Exception {
-
- try {
- MessageContext ctx = getMsgCtx();
-
- String policyXml = "test-resources/policy/rampart-asymm-binding-6-3des-r15.xml";
- Policy policy = this.loadPolicy(policyXml);
-
- ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
-
- RampartEngine engine = new RampartEngine();
- engine.process(ctx);
- }
- catch (RampartException e) {
- assertEquals("Expected rampart to complain about missing security header",
- "Missing wsse:Security header in request", e.getMessage());
- }
- }
-
- public void testValidSOAPMessage() throws Exception {
-
MessageContext ctx = getMsgCtx();
String policyXml = "test-resources/policy/rampart-asymm-binding-6-3des-r15.xml";
- Policy policy = loadPolicy(policyXml);
+ Policy policy = this.loadPolicy(policyXml);
ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
- MessageBuilder builder = new MessageBuilder();
- builder.build(ctx);
-
- // Building the SOAP envelope from the OMElement
- buildSOAPEnvelope(ctx);
-
RampartEngine engine = new RampartEngine();
- List<WSSecurityEngineResult> results = engine.process(ctx);
+ engine.process(ctx);
+ }
- /*
- The principle purpose of the test case is to verify that the above processes
- without throwing an exception. However, perform a minimal amount of validation on the
- results.
- */
- assertNotNull("RampartEngine returned null result", results);
- //verify cert was stored
- X509Certificate usedCert = null;
- for (WSSecurityEngineResult result : results) {
- Integer action = (Integer) result.get(WSSecurityEngineResult.TAG_ACTION);
- if (action == WSConstants.SIGN) {
- //the result is for the signature, which contains the used certificate
- usedCert = (X509Certificate) result.get(WSSecurityEngineResult.TAG_X509_CERTIFICATE);
- break;
- }
- }
- assertNotNull("Result of processing did not include a certificate", usedCert);
+ @Test
+ public void testValidSOAPMessage() throws Exception {
+ runRampartEngine(getMsgCtx(), "test-resources/policy/rampart-asymm-binding-6-3des-r15.xml");
}
+ @Test
public void testValidSOAP12Message() throws Exception {
+ runRampartEngine(getMsgCtx12(), "test-resources/policy/rampart-asymm-binding-6-3des-r15.xml");
+ }
- MessageContext ctx = getMsgCtx12();
-
- String policyXml = "test-resources/policy/rampart-asymm-binding-6-3des-r15.xml";
+ private void runRampartEngine(MessageContext ctx, String policyXml) throws Exception {
Policy policy = loadPolicy(policyXml);
ctx.setProperty(RampartMessageData.KEY_RAMPART_POLICY, policy);
@@ -130,7 +97,7 @@ public class RampartEngineTest extends M
SOAPBuilder soapBuilder = new SOAPBuilder();
SOAPEnvelope env = ctx.getEnvelope();
ByteArrayInputStream inStream = new ByteArrayInputStream(env.toString().getBytes());
- env = (SOAPEnvelope) soapBuilder.processDocument(inStream, getContentTypeForEnvelope(env), ctx);
+ env = (SOAPEnvelope) soapBuilder.processDocument(inStream, env.getVersion().getMediaType().toString(), ctx);
ctx.setEnvelope(env);
}
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/SymmetricBindingBuilderTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/SymmetricBindingBuilderTest.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/SymmetricBindingBuilderTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/SymmetricBindingBuilderTest.java Mon Jan 30 17:50:58 2017
@@ -17,7 +17,6 @@
package org.apache.rampart;
import java.util.ArrayList;
-import java.util.Vector;
import javax.xml.namespace.QName;
@@ -40,7 +39,7 @@ public class SymmetricBindingBuilderTest
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
@@ -89,7 +88,7 @@ public class SymmetricBindingBuilderTest
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
@@ -113,7 +112,7 @@ public class SymmetricBindingBuilderTest
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
@@ -137,7 +136,7 @@ public class SymmetricBindingBuilderTest
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
@@ -159,7 +158,7 @@ public class SymmetricBindingBuilderTest
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- ArrayList list = new ArrayList();
+ ArrayList<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/TransportBindingBuilderTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/TransportBindingBuilderTest.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/TransportBindingBuilderTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/rampart/TransportBindingBuilderTest.java Mon Jan 30 17:50:58 2017
@@ -38,7 +38,7 @@ public class TransportBindingBuilderTest
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- List list = new ArrayList();
+ List<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.WSSE_NS, WSConstants.USERNAME_TOKEN_LN));
list.add(new QName(WSConstants.WSSE_NS, WSConstants.BINARY_TOKEN_LN));
@@ -57,7 +57,7 @@ public class TransportBindingBuilderTest
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- List list = new ArrayList();
+ List<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.WSSE_NS, WSConstants.USERNAME_TOKEN_LN));
list.add(new QName(WSConstants.SIG_NS, WSConstants.SIG_LN));
@@ -75,7 +75,7 @@ public class TransportBindingBuilderTest
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- List list = new ArrayList();
+ List<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
list.add(new QName(WSConstants.WSSE_NS, WSConstants.USERNAME_TOKEN_LN));
list.add(new QName(WSConstants.ENC_NS, WSConstants.ENC_KEY_LN));
@@ -97,7 +97,7 @@ public class TransportBindingBuilderTest
MessageBuilder builder = new MessageBuilder();
builder.build(ctx);
- List list = new ArrayList();
+ List<QName> list = new ArrayList<QName>();
list.add(new QName(WSConstants.WSU_NS, WSConstants.TIMESTAMP_TOKEN_LN));
this.verifySecHeader(list.iterator(), ctx.getEnvelope());
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/ws/secpolicy/model/SecpolicyModelTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/ws/secpolicy/model/SecpolicyModelTest.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/ws/secpolicy/model/SecpolicyModelTest.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/src/test/java/org/apache/ws/secpolicy/model/SecpolicyModelTest.java Mon Jan 30 17:50:58 2017
@@ -35,12 +35,12 @@ public class SecpolicyModelTest extends
public void testSymmBinding() throws Exception {
Policy p = this.getPolicy("test-resources/policy-symm-binding.xml");
- List assertions = (List)p.getAlternatives().next();
+ List<Assertion> assertions = (List<Assertion>)p.getAlternatives().next();
boolean symmBindingFound = false;
- for (Iterator iter = assertions.iterator(); iter.hasNext();) {
- Assertion assertion = (Assertion) iter.next();
+ for (Iterator<Assertion> iter = assertions.iterator(); iter.hasNext();) {
+ Assertion assertion = iter.next();
if(assertion instanceof SymmetricBinding) {
symmBindingFound = true;
SymmetricBinding binding = (SymmetricBinding)assertion;
@@ -67,11 +67,22 @@ public class SecpolicyModelTest extends
public void testAsymmBinding() throws Exception {
this.getPolicy("test-resources/policy-asymm-binding.xml");
}
-
+
public void testTransportBinding() throws Exception {
this.getPolicy("test-resources/policy-transport-binding.xml");
}
+ public void testSymmBindingWithBothProtectionTokenAndEncryptionToken() throws Exception {
+ boolean exceptionThrown = false;
+ try {
+ this.getPolicy("test-resources/policy-symm-binding-fault1.xml");
+ } catch (IllegalArgumentException e) {
+ exceptionThrown = true;
+ }
+ assertTrue("Policy cannot contain both ProtectionToken and EncryptionToken",
+ exceptionThrown);
+ }
+
private Policy getPolicy(String filePath) throws Exception {
OMXMLParserWrapper builder = OMXMLBuilderFactory.createOMBuilder(new FileInputStream(filePath));
OMElement elem = builder.getDocumentElement();
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/test-resources/axis2.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/test-resources/axis2.xml?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/test-resources/axis2.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-tests/test-resources/axis2.xml Mon Jan 30 17:50:58 2017
@@ -2,6 +2,16 @@
<parameter name="hotdeployment" locked="false">true</parameter>
<parameter name="hotupdate" locked="false">true</parameter>
+ <!-- ================================================= -->
+ <!-- Deployers -->
+ <!-- ================================================= -->
+
+ <!--Service deployer , this will alow users to deploy AAR or exploded AAR as axis2 services-->
+ <deployer extension=".aar" directory="services" class="org.apache.axis2.deployment.ServiceDeployer">
+ <serviceBuilderExtension name ="jwsbuilderExt" class="org.apache.axis2.jaxws.framework.JAXWSServiceBuilderExtension"/>
+ <serviceBuilderExtension name ="wsdlbuilderExt" class="org.apache.axis2.deployment.WSDLServiceBuilderExtension"/>
+ </deployer>
+
<messageReceiver mep="INOUT" class="org.apache.axis2.receivers.RawXMLINOutMessageReceiver"/>
@@ -10,7 +20,7 @@
<parameter name="passwordCallbackClass" locked="false">
org.apache.axis2.security.PWCallback</parameter>
- <transportSender name="http" class="org.apache.axis2.transport.http.CommonsHTTPTransportSender">
+ <transportSender name="http" class="org.apache.axis2.transport.http.impl.httpclient4.HTTPClient4TransportSender">
<parameter name="PROTOCOL" locked="false">HTTP/1.0</parameter>
</transportSender>
Propchange: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust-mar/
------------------------------------------------------------------------------
--- svn:ignore (original)
+++ svn:ignore Mon Jan 30 17:50:58 2017
@@ -1,3 +1,4 @@
.settings
target
.project
+.classpath
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust-mar/module.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust-mar/module.xml?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust-mar/module.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust-mar/module.xml Mon Jan 30 17:50:58 2017
@@ -5,7 +5,7 @@
<supported-policy-namespaces namespaces="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy, http://docs.oasis-open.org/ws-sx/ws-securitypolicy/200702
"/>
- <operation name="RequestSecurityToken" mep="http://www.w3.org/2006/01/wsdl/in-out">
+ <operation name="RequestSecurityToken" mep="http://www.w3.org/ns/wsdl/in-out">
<messageReceiver class="org.apache.rahas.STSMessageReceiver"/>
<!-- Action mapping to accept SCT requests. For submissive version. -->
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust-mar/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust-mar/pom.xml?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust-mar/pom.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust-mar/pom.xml Mon Jan 30 17:50:58 2017
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.rampart</groupId>
<artifactId>rampart-project</artifactId>
- <version>1.7.0-SNAPSHOT</version>
+ <version>1.8.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
@@ -35,30 +35,9 @@
<packaging>mar</packaging>
<name>Rampart - Trust-Mar</name>
- <scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/axis/axis2/java/rampart/trunk</connection>
- <developerConnection>
- scm:svn:https://svn.apache.org/repos/asf/axis/axis2/java/rampart/trunk</developerConnection>
- <url>http://svn.apache.org/viewvc/axis/axis2/java/rampart/trunk</url>
- </scm>
-
<build>
- <sourceDirectory>src/main/java</sourceDirectory>
- <resources>
- <resource>
- <directory>src/main/java</directory>
- </resource>
- </resources>
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
<groupId>org.apache.axis2</groupId>
<artifactId>axis2-mar-maven-plugin</artifactId>
<extensions>true</extensions>
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/pom.xml?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/pom.xml (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/pom.xml Mon Jan 30 17:50:58 2017
@@ -25,7 +25,7 @@
<parent>
<groupId>org.apache.rampart</groupId>
<artifactId>rampart-project</artifactId>
- <version>1.7.0-SNAPSHOT</version>
+ <version>1.8.0-SNAPSHOT</version>
<relativePath>../../pom.xml</relativePath>
</parent>
@@ -35,37 +35,14 @@
<name>Rampart - Trust</name>
<build>
- <sourceDirectory>src/main/java</sourceDirectory>
- <resources>
- <resource>
- <directory>src/main/java</directory>
- <excludes>
- <exclude>**/*.java</exclude>
- </excludes>
- </resource>
- </resources>
- <testResources>
- <testResource>
- <directory>${project.basedir}/src/test/resources</directory>
- </testResource>
- </testResources>
-
<plugins>
<plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.5</source>
- <target>1.5</target>
- </configuration>
- </plugin>
- <plugin>
<artifactId>maven-surefire-plugin</artifactId>
- <!--configuration>
- <includes>
- <include>**/*Test.java</include>
- </includes>
- </configuration-->
+ <!--configuration>
+ <includes>
+ <include>**/*Test.java</include>
+ </includes>
+ </configuration-->
</plugin>
</plugins>
</build>
@@ -79,21 +56,39 @@
<dependency>
<groupId>org.apache.ws.commons.axiom</groupId>
<artifactId>axiom-dom</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.ws.security</groupId>
+ <artifactId>wss4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.bouncycastle</groupId>
+ <artifactId>bcprov-jdk15on</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.opensaml</groupId>
+ <artifactId>opensaml</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <scope>runtime</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ <scope>test</scope>
</dependency>
</dependencies>
-
- <reporting>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-site-plugin</artifactId>
- <version>2.0-beta-5</version>
- <configuration>
- <templateDirectory>${basedir}</templateDirectory>
- <menu ref="parent" />
- </configuration>
- </plugin>
- </plugins>
- </reporting>
-
</project>
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/Rahas.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/Rahas.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/Rahas.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/Rahas.java Mon Jan 30 17:50:58 2017
@@ -25,9 +25,6 @@ import org.apache.axis2.description.Axis
import org.apache.axis2.modules.Module;
import org.apache.neethi.Assertion;
import org.apache.neethi.Policy;
-import org.apache.rahas.impl.util.AxiomParserPool;
-import org.opensaml.Configuration;
-import org.opensaml.DefaultBootstrap;
import org.opensaml.xml.ConfigurationException;
public class Rahas implements Module {
@@ -39,6 +36,9 @@ public class Rahas implements Module {
try {
RampartSAMLBootstrap.bootstrap();
+
+ // Initialize XML security
+ org.apache.xml.security.Init.init();
} catch (ConfigurationException ex) {
throw new AxisFault("Failed to bootstrap OpenSAML", ex);
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/RahasConstants.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/RahasConstants.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/RahasConstants.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/RahasConstants.java Mon Jan 30 17:50:58 2017
@@ -143,4 +143,6 @@ public class RahasConstants {
public static final String SAML20_SUBJECT_CONFIRMATION_BEARER = "urn:oasis:names:tc:SAML:2.0:cm:bearer";
public static final String SAML_NS = "urn:oasis:names:tc:SAML:1.0:assertion";
+
+ public static final String AUTHENTICATION_METHOD_PASSWORD = "urn:oasis:names:tc:SAML:1.0:am:password";
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/RahasData.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/RahasData.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/RahasData.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/RahasData.java Mon Jan 30 17:50:58 2017
@@ -16,10 +16,10 @@
package org.apache.rahas;
+import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
-import org.apache.axiom.om.impl.dom.factory.OMDOMFactory;
-import org.apache.axiom.om.util.Base64;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.util.base64.Base64Utils;
import org.apache.axis2.addressing.AddressingConstants;
import org.apache.axis2.context.MessageContext;
import org.apache.ws.security.WSConstants;
@@ -35,6 +35,7 @@ import javax.xml.namespace.QName;
import java.security.Principal;
import java.security.cert.X509Certificate;
+import java.util.Date;
import java.util.List;
/**
@@ -56,7 +57,7 @@ public class RahasData {
private String tokenId;
- private int keysize = -1;
+ private int keySize = -1;
private String computedKeyAlgo;
@@ -85,6 +86,11 @@ public class RahasData {
private String claimDialect;
private Assertion assertion;
+
+ private Date assertionCreatedDate;
+
+ private Date assertionExpiringDate;
+
/**
* Create a new RahasData instance and populate it with the information from
* the request.
@@ -138,6 +144,10 @@ public class RahasData {
}
+ public RahasData() {
+
+ }
+
/**
* Processes the authenticated user information from the WSS4J security
* results.
@@ -284,17 +294,17 @@ public class RahasData {
if (text != null && !"".equals(text.trim())) {
try {
//Set key size
- this.keysize = Integer.parseInt(text.trim());
+ this.keySize = Integer.parseInt(text.trim());
//Create an empty array to hold the key
- this.ephmeralKey = new byte[this.keysize/8];
+ this.ephmeralKey = new byte[this.keySize/8];
} catch (NumberFormatException e) {
throw new TrustException(TrustException.INVALID_REQUEST,
new String[]{"invalid wst:Keysize value"}, e);
}
}
}
- this.keysize = -1;
+ this.keySize = -1;
}
/**
@@ -324,8 +334,9 @@ public class RahasData {
OMElement strElem = validateTargetElem.getFirstChildWithName(new QName(WSConstants.WSSE_NS,
"SecurityTokenReference"));
- Element elem = (Element)(new StAXOMBuilder(new OMDOMFactory(),
- strElem.getXMLStreamReader()).getDocumentElement());
+ Element elem = (Element)OMXMLBuilderFactory.createStAXOMBuilder(
+ OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getOMFactory(),
+ strElem.getXMLStreamReader()).getDocumentElement();
try {
SecurityTokenReference str = new SecurityTokenReference((Element)elem);
@@ -350,8 +361,9 @@ public class RahasData {
OMElement strElem = renewTargetElem.getFirstChildWithName(new QName(WSConstants.WSSE_NS,
"SecurityTokenReference"));
- Element elem = (Element)(new StAXOMBuilder(new OMDOMFactory(),
- strElem.getXMLStreamReader()).getDocumentElement());
+ Element elem = (Element)OMXMLBuilderFactory.createStAXOMBuilder(
+ OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM).getOMFactory(),
+ strElem.getXMLStreamReader()).getDocumentElement();
try {
SecurityTokenReference str = new SecurityTokenReference((Element)elem);
@@ -377,13 +389,13 @@ public class RahasData {
private void processEntropy() throws TrustException {
OMElement entropyElem = this.rstElement
.getFirstChildWithName(new QName(this.wstNs,
- RahasConstants.IssuanceBindingLocalNames.ENTROPY));
+ RahasConstants.IssuanceBindingLocalNames.ENTROPY));
if (entropyElem != null) {
OMElement binSecElem = entropyElem.getFirstElement();
if (binSecElem != null && binSecElem.getText() != null
&& !"".equals(binSecElem.getText())) {
- this.requestEntropy = Base64.decode(binSecElem.getText());
+ this.requestEntropy = Base64Utils.decode(binSecElem.getText());
} else {
throw new TrustException("malformedEntropyElement",
new String[]{entropyElem.toString()});
@@ -428,13 +440,39 @@ public class RahasData {
}
/**
+ * Sets the given message context as in message context.
+ * @param context The message context.
+ */
+ public void setInMessageContext(MessageContext context) {
+ this.inMessageContext = context;
+ }
+
+ /**
+ * @deprecated As of Rampart 1.7. Use {@code getKeySize}.
* @return Returns the keysize.
*/
+ @Deprecated
public int getKeysize() {
- return keysize;
+ return keySize;
+ }
+
+ /**
+ * @return Returns the keySize.
+ */
+ public int getKeySize() {
+ return keySize;
+ }
+
+ /**
+ * Sets the key size.
+ * @param size Size of the key.
+ */
+ public void setKeySize(int size) {
+ this.keySize = size;
}
/**
+ * // TODO changes this keytype to an enumeration
* @return Returns the keyType.
*/
public String getKeyType() {
@@ -544,5 +582,19 @@ public class RahasData {
return appliesToEpr;
}
+ public Date getAssertionCreatedDate() {
+ return assertionCreatedDate;
+ }
+
+ public void setAssertionCreatedDate(Date assertionCreatedDate) {
+ this.assertionCreatedDate = assertionCreatedDate;
+ }
+ public Date getAssertionExpiringDate() {
+ return assertionExpiringDate;
+ }
+
+ public void setAssertionExpiringDate(Date assertionExpiringDate) {
+ this.assertionExpiringDate = assertionExpiringDate;
+ }
}
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/STSMessageReceiver.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/STSMessageReceiver.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/STSMessageReceiver.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/STSMessageReceiver.java Mon Jan 30 17:50:58 2017
@@ -39,7 +39,7 @@ public class STSMessageReceiver extends
.getParameter(TokenRequestDispatcherConfig.CONFIG_PARAM_KEY);
Parameter paramFile = inMessage
.getParameter(TokenRequestDispatcherConfig.CONFIG_FILE_KEY);
- TokenRequestDispatcher dispatcher = null;
+ TokenRequestDispatcher dispatcher;
if (param != null) {
dispatcher = new TokenRequestDispatcher(param
.getParameterElement().getFirstChildWithName(
@@ -53,12 +53,8 @@ public class STSMessageReceiver extends
.getProperty(TokenRequestDispatcherConfig.CONFIG_PARAM_KEY));
}
- if(dispatcher != null) {
- SOAPEnvelope responseEnv = dispatcher.handle(inMessage, outMessage);
- outMessage.setEnvelope(responseEnv);
- } else {
- throw new TrustException("missingDispatcherConfiguration");
- }
+ SOAPEnvelope responseEnv = dispatcher.handle(inMessage, outMessage);
+ outMessage.setEnvelope(responseEnv);
} catch (TrustException e) {
e.printStackTrace();
//Log the exception
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/SimpleTokenStore.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/SimpleTokenStore.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/SimpleTokenStore.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/SimpleTokenStore.java Mon Jan 30 17:50:58 2017
@@ -23,7 +23,11 @@ import org.apache.ws.security.message.to
import javax.xml.namespace.QName;
import java.io.Serializable;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
Modified: axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/Token.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/Token.java?rev=1780953&r1=1780952&r2=1780953&view=diff
==============================================================================
--- axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/Token.java (original)
+++ axis/axis2/java/rampart/branches/RAMPART-289/modules/rampart-trust/src/main/java/org/apache/rahas/Token.java Mon Jan 30 17:50:58 2017
@@ -37,7 +37,9 @@ import org.apache.axiom.om.OMElement;
import org.apache.axiom.om.OMException;
import org.apache.axiom.om.OMFactory;
import org.apache.axiom.om.OMMetaFactory;
-import org.apache.axiom.om.impl.builder.StAXOMBuilder;
+import org.apache.axiom.om.OMXMLBuilderFactory;
+import org.apache.axiom.om.OMXMLParserWrapper;
+import org.apache.axiom.om.OMXMLStreamReaderConfiguration;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.ws.security.WSConstants;
@@ -143,10 +145,10 @@ public class Token implements Externaliz
throws TrustException {
this.id = id;
OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
- StAXOMBuilder stAXOMBuilder =
- new StAXOMBuilder(metaFactory.getOMFactory(), tokenElem.getXMLStreamReader());
- stAXOMBuilder.setNamespaceURIInterning(true);
- this.token = stAXOMBuilder.getDocumentElement();
+ OMXMLStreamReaderConfiguration configuration = new OMXMLStreamReaderConfiguration();
+ configuration.setNamespaceURIInterning(true);
+ this.token = OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(),
+ tokenElem.getXMLStreamReader(true, configuration)).getDocumentElement();
this.created = created;
this.expires = expires;
}
@@ -155,10 +157,10 @@ public class Token implements Externaliz
throws TrustException {
this.id = id;
OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
- StAXOMBuilder stAXOMBuilder =
- new StAXOMBuilder(metaFactory.getOMFactory(), tokenElem.getXMLStreamReader());
- stAXOMBuilder.setNamespaceURIInterning(true);
- this.token = stAXOMBuilder.getDocumentElement();
+ OMXMLStreamReaderConfiguration configuration = new OMXMLStreamReaderConfiguration();
+ configuration.setNamespaceURIInterning(true);
+ this.token = OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(),
+ tokenElem.getXMLStreamReader(true, configuration)).getDocumentElement();
this.processLifeTime(lifetimeElem);
}
@@ -259,8 +261,8 @@ public class Token implements Externaliz
*/
public void setPreviousToken(OMElement presivousToken) {
OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
- this.previousToken = new StAXOMBuilder(metaFactory.getOMFactory(), presivousToken.getXMLStreamReader())
- .getDocumentElement();
+ this.previousToken = OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(),
+ presivousToken.getXMLStreamReader()).getDocumentElement();
}
/**
@@ -291,8 +293,8 @@ public class Token implements Externaliz
if (attachedReference != null) {
OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
this.attachedReference =
- new StAXOMBuilder(metaFactory.getOMFactory(), attachedReference.getXMLStreamReader())
- .getDocumentElement();
+ OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(),
+ attachedReference.getXMLStreamReader()).getDocumentElement();
}
}
@@ -310,8 +312,8 @@ public class Token implements Externaliz
if (unattachedReference != null) {
OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
this.unattachedReference =
- new StAXOMBuilder(metaFactory.getOMFactory(), unattachedReference.getXMLStreamReader())
- .getDocumentElement();
+ OMXMLBuilderFactory.createStAXOMBuilder(metaFactory.getOMFactory(),
+ unattachedReference.getXMLStreamReader()).getDocumentElement();
}
}
@@ -473,13 +475,13 @@ public class Token implements Externaliz
try {
Reader in = new StringReader(stringElement);
XMLStreamReader parser = XMLInputFactory.newInstance().createXMLStreamReader(in);
- StAXOMBuilder builder = new StAXOMBuilder(parser);
+ OMXMLParserWrapper builder = OMXMLBuilderFactory.createStAXOMBuilder(parser);
OMElement documentElement = builder.getDocumentElement();
XMLStreamReader llomReader = documentElement.getXMLStreamReader();
OMMetaFactory metaFactory = OMAbstractFactory.getMetaFactory(OMAbstractFactory.FEATURE_DOM);
OMFactory doomFactory = metaFactory.getOMFactory();
- StAXOMBuilder doomBuilder = new StAXOMBuilder(doomFactory, llomReader);
+ OMXMLParserWrapper doomBuilder = OMXMLBuilderFactory.createStAXOMBuilder(doomFactory, llomReader);
return doomBuilder.getDocumentElement();
} catch (XMLStreamException e) {