You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ws.apache.org by co...@apache.org on 2015/12/15 17:40:42 UTC
svn commit: r1720192 [32/33] - in /webservices/wss4j/trunk:
bindings/src/main/java/org/apache/wss4j/binding/wss10/
bindings/src/main/java/org/apache/wss4j/binding/wss11/
bindings/src/main/java/org/apache/wss4j/binding/wssc13/
bindings/src/main/java/org...
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AttachmentTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AttachmentTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AttachmentTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/AttachmentTest.java Tue Dec 15 16:40:37 2015
@@ -117,7 +117,7 @@ public class AttachmentTest extends Abst
securityProperties.addSignaturePart(new SecurePart("cid:Attachments", SecurePart.Modifier.Content));
securityProperties.setCallbackHandler(new CallbackHandlerImpl());
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Collections.singletonList(attachment));
securityProperties.setAttachmentCallbackHandler(attachmentCallbackHandler);
@@ -129,7 +129,7 @@ public class AttachmentTest extends Abst
}
//done signature; now test sig-verification:
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Collections.singletonList(attachment));
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -145,7 +145,7 @@ public class AttachmentTest extends Abst
}
Assert.assertFalse(attachmentCallbackHandler.getResponseAttachments().isEmpty());
Attachment responseAttachment = attachmentCallbackHandler.getResponseAttachments().get(0);
-
+
byte[] attachmentBytes = readInputStream(responseAttachment.getSourceStream());
Assert.assertTrue(Arrays.equals(attachmentBytes, SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
Assert.assertEquals("text/xml", responseAttachment.getMimeType());
@@ -173,7 +173,7 @@ public class AttachmentTest extends Abst
securityProperties.addSignaturePart(new SecurePart("cid:Attachments", SecurePart.Modifier.Content));
securityProperties.setCallbackHandler(new CallbackHandlerImpl());
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Collections.singletonList(attachment));
securityProperties.setAttachmentCallbackHandler(attachmentCallbackHandler);
@@ -241,7 +241,7 @@ public class AttachmentTest extends Abst
securityProperties.addSignaturePart(new SecurePart("cid:Attachments", SecurePart.Modifier.Element));
securityProperties.setCallbackHandler(new CallbackHandlerImpl());
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Collections.singletonList(attachment));
securityProperties.setAttachmentCallbackHandler(attachmentCallbackHandler);
@@ -253,7 +253,7 @@ public class AttachmentTest extends Abst
}
//done signature; now test sig-verification:
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Collections.singletonList(attachment));
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -270,7 +270,7 @@ public class AttachmentTest extends Abst
Assert.assertFalse(attachmentCallbackHandler.getResponseAttachments().isEmpty());
Attachment responseAttachment = attachmentCallbackHandler.getResponseAttachments().get(0);
-
+
byte[] attachmentBytes = readInputStream(responseAttachment.getSourceStream());
Assert.assertTrue(Arrays.equals(attachmentBytes, SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
Assert.assertEquals("text/xml", responseAttachment.getMimeType());
@@ -298,7 +298,7 @@ public class AttachmentTest extends Abst
securityProperties.addSignaturePart(new SecurePart("cid:Attachments", SecurePart.Modifier.Element));
securityProperties.setCallbackHandler(new CallbackHandlerImpl());
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Collections.singletonList(attachment));
securityProperties.setAttachmentCallbackHandler(attachmentCallbackHandler);
@@ -374,7 +374,7 @@ public class AttachmentTest extends Abst
securityProperties.addSignaturePart(new SecurePart("cid:Attachments", SecurePart.Modifier.Element));
securityProperties.setCallbackHandler(new CallbackHandlerImpl());
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Arrays.asList(attachment));
securityProperties.setAttachmentCallbackHandler(attachmentCallbackHandler);
@@ -386,7 +386,7 @@ public class AttachmentTest extends Abst
}
//done signature; now test sig-verification:
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Arrays.asList(attachment));
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -403,7 +403,7 @@ public class AttachmentTest extends Abst
Assert.assertFalse(attachmentCallbackHandler.getResponseAttachments().isEmpty());
Attachment responseAttachment = attachmentCallbackHandler.getResponseAttachments().get(0);
-
+
byte[] attachmentBytes = readInputStream(responseAttachment.getSourceStream());
Assert.assertTrue(Arrays.equals(attachmentBytes, SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
Assert.assertEquals("text/xml", responseAttachment.getMimeType());
@@ -418,7 +418,7 @@ public class AttachmentTest extends Abst
attachment.addHeaders(getHeaders(attachmentId));
attachment.setId(attachmentId);
attachment.setSourceStream(new ByteArrayInputStream(SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Collections.singletonList(attachment));
List<Attachment> encryptedAttachments = attachmentCallbackHandler.getResponseAttachments();
@@ -471,7 +471,7 @@ public class AttachmentTest extends Abst
Assert.assertFalse(attachmentCallbackHandler.getResponseAttachments().isEmpty());
Attachment responseAttachment = attachmentCallbackHandler.getResponseAttachments().get(0);
-
+
byte[] attachmentBytes = readInputStream(responseAttachment.getSourceStream());
Assert.assertTrue(Arrays.equals(attachmentBytes, SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
Assert.assertEquals("text/xml", responseAttachment.getMimeType());
@@ -488,7 +488,7 @@ public class AttachmentTest extends Abst
attachment.addHeaders(getHeaders(attachmentId));
attachment.setId(attachmentId);
attachment.setSourceStream(new ByteArrayInputStream(SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Collections.singletonList(attachment));
List<Attachment> encryptedAttachments = attachmentCallbackHandler.getResponseAttachments();
@@ -526,7 +526,7 @@ public class AttachmentTest extends Abst
Assert.assertEquals(childs.item(0).getLocalName(), "EncryptedKey");
Assert.assertEquals(childs.item(1).getLocalName(), "EncryptedData");
}
-
+
final PushbackInputStream pis = new PushbackInputStream(encryptedAttachments.get(0).getSourceStream(), 1);
pis.unread('K');
encryptedAttachments.get(0).setSourceStream(pis);
@@ -536,7 +536,7 @@ public class AttachmentTest extends Abst
securityProperties.loadDecryptionKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
securityProperties.setCallbackHandler(new CallbackHandlerImpl());
securityProperties.setAttachmentCallbackHandler(attachmentCallbackHandler);
-
+
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
@@ -544,13 +544,13 @@ public class AttachmentTest extends Abst
Assert.assertFalse(attachmentCallbackHandler.getResponseAttachments().isEmpty());
Attachment responseAttachment = attachmentCallbackHandler.getResponseAttachments().get(0);
-
+
// Different behaviour here for different JDKs...
try {
byte[] attachmentBytes = readInputStream(responseAttachment.getSourceStream());
Assert.assertFalse(Arrays.equals(attachmentBytes, SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
Assert.assertEquals("text/xml", responseAttachment.getMimeType());
-
+
Map<String, String> attHeaders = responseAttachment.getHeaders();
Assert.assertEquals(6, attHeaders.size());
} catch (IOException ex) {
@@ -578,7 +578,7 @@ public class AttachmentTest extends Abst
attachment.addHeaders(getHeaders(attachmentId));
attachment.setId(attachmentId);
attachment.setSourceStream(new ByteArrayInputStream(SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Collections.singletonList(attachment));
List<Attachment> encryptedAttachments = attachmentCallbackHandler.getResponseAttachments();
@@ -640,8 +640,8 @@ public class AttachmentTest extends Abst
attachment.addHeaders(getHeaders(attachmentId));
attachment.setId(attachmentId);
attachment.setSourceStream(new ByteArrayInputStream(SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
-
- AttachmentCallbackHandler attachmentCallbackHandler =
+
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Collections.singletonList(attachment));
List<Attachment> encryptedAttachments = attachmentCallbackHandler.getResponseAttachments();
@@ -714,10 +714,10 @@ public class AttachmentTest extends Abst
attachment.setId(attachmentId);
attachment.setSourceStream(new ByteArrayInputStream(SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
- AttachmentCallbackHandler attachmentCallbackHandler =
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Collections.singletonList(attachment));
List<Attachment> encryptedAttachments = attachmentCallbackHandler.getResponseAttachments();
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -729,7 +729,7 @@ public class AttachmentTest extends Abst
securityProperties.addEncryptionPart(new SecurePart(new QName("http://schemas.xmlsoap.org/soap/envelope/", "Body"), SecurePart.Modifier.Content));
securityProperties.addEncryptionPart(new SecurePart("cid:Attachments", SecurePart.Modifier.Element));
securityProperties.setAttachmentCallbackHandler(attachmentCallbackHandler);
-
+
OutboundWSSec wsSecOut = WSSec.getOutboundWSSec(securityProperties);
XMLStreamWriter xmlStreamWriter = wsSecOut.processOutMessage(baos, StandardCharsets.UTF_8.name(), new ArrayList<SecurityEvent>());
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml"));
@@ -764,7 +764,7 @@ public class AttachmentTest extends Abst
securityProperties.loadDecryptionKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
securityProperties.setCallbackHandler(new CallbackHandlerImpl());
securityProperties.setAttachmentCallbackHandler(attachmentCallbackHandler);
-
+
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
try {
@@ -774,7 +774,7 @@ public class AttachmentTest extends Abst
// Assert.assertEquals(e.getCause().getMessage(), "The signature or decryption was invalid");
return;
}
-
+
Assert.assertFalse(attachmentCallbackHandler.getResponseAttachments().isEmpty());
Attachment responseAttachment = attachmentCallbackHandler.getResponseAttachments().get(0);
byte[] attachmentBytes = readInputStream(responseAttachment.getSourceStream());
@@ -801,8 +801,8 @@ public class AttachmentTest extends Abst
attachment[1].addHeaders(getHeaders(attachment2Id));
attachment[1].setId(attachment2Id);
attachment[1].setSourceStream(new ByteArrayInputStream(SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
-
- AttachmentCallbackHandler attachmentCallbackHandler =
+
+ AttachmentCallbackHandler attachmentCallbackHandler =
new AttachmentCallbackHandler(Arrays.asList(attachment));
List<Attachment> encryptedAttachments = attachmentCallbackHandler.getResponseAttachments();
@@ -839,7 +839,7 @@ public class AttachmentTest extends Abst
Assert.assertFalse(attachmentCallbackHandler.getResponseAttachments().isEmpty());
Attachment responseAttachment = attachmentCallbackHandler.getResponseAttachments().get(0);
-
+
byte[] attachment1Bytes = readInputStream(responseAttachment.getSourceStream());
Assert.assertTrue(Arrays.equals(attachment1Bytes, SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
Assert.assertEquals("text/xml", responseAttachment.getMimeType());
@@ -847,7 +847,7 @@ public class AttachmentTest extends Abst
Assert.assertEquals(6, att1Headers.size());
responseAttachment = attachmentCallbackHandler.getResponseAttachments().get(1);
-
+
byte[] attachment2Bytes = readInputStream(responseAttachment.getSourceStream());
Assert.assertTrue(Arrays.equals(attachment2Bytes, SOAPUtil.SAMPLE_SOAP_MSG.getBytes(StandardCharsets.UTF_8)));
Assert.assertEquals("text/plain", responseAttachment.getMimeType());
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ConfigurationConverterTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ConfigurationConverterTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ConfigurationConverterTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ConfigurationConverterTest.java Tue Dec 15 16:40:37 2015
@@ -46,7 +46,7 @@ public class ConfigurationConverterTest
config.put(ConfigurationConstants.PASSWORD_TYPE, "PasswordText");
config.put(ConfigurationConstants.ADD_USERNAMETOKEN_NONCE, "true");
config.put(ConfigurationConstants.ADD_USERNAMETOKEN_CREATED, "false");
-
+
WSSSecurityProperties properties = ConfigurationConverter.convert(config);
Assert.assertEquals(properties.getTokenUser(), "testuser");
Assert.assertEquals(properties.getActions().size(), 1);
@@ -56,10 +56,10 @@ public class ConfigurationConverterTest
UsernameTokenPasswordType.PASSWORD_TEXT);
Assert.assertTrue(properties.isAddUsernameTokenNonce());
Assert.assertFalse(properties.isAddUsernameTokenCreated());
-
+
WSSec.validateAndApplyDefaultsToOutboundSecurityProperties(properties);
}
-
+
@Test
public void testOutboundSignatureConfiguration() throws Exception {
Map<String, Object> config = new HashMap<String, Object>();
@@ -71,30 +71,30 @@ public class ConfigurationConverterTest
config.put(ConfigurationConstants.SIG_KEY_ID, "Thumbprint");
config.put(ConfigurationConstants.ADD_INCLUSIVE_PREFIXES, "false");
config.put(ConfigurationConstants.SIG_PROP_FILE, "transmitter-crypto.properties");
- config.put(ConfigurationConstants.SIGNATURE_PARTS,
+ config.put(ConfigurationConstants.SIGNATURE_PARTS,
"{}{http://schemas.xmlsoap.org/soap/envelope/}Body;");
-
+
WSSSecurityProperties properties = ConfigurationConverter.convert(config);
-
+
Assert.assertEquals(properties.getSignatureUser(), "transmitter");
Assert.assertEquals(properties.getActions().size(), 1);
Assert.assertEquals(properties.getActions().get(0), WSSConstants.SIGNATURE);
Assert.assertTrue(properties.getCallbackHandler() instanceof CallbackHandlerImpl);
Assert.assertEquals(properties.getSignatureAlgorithm(), sigAlgo);
- Assert.assertEquals(properties.getSignatureKeyIdentifier(),
+ Assert.assertEquals(properties.getSignatureKeyIdentifier(),
WSSecurityTokenConstants.KeyIdentifier_ThumbprintIdentifier);
Assert.assertFalse(properties.isAddExcC14NInclusivePrefixes());
Assert.assertNotNull(properties.getSignatureCrypto());
Assert.assertTrue(properties.getSignatureSecureParts() != null);
Assert.assertEquals(properties.getSignatureSecureParts().size(), 1);
- Assert.assertEquals(properties.getSignatureSecureParts().get(0).getName().getLocalPart(),
+ Assert.assertEquals(properties.getSignatureSecureParts().get(0).getName().getLocalPart(),
"Body");
- Assert.assertEquals(properties.getSignatureSecureParts().get(0).getName().getNamespaceURI(),
+ Assert.assertEquals(properties.getSignatureSecureParts().get(0).getName().getNamespaceURI(),
"http://schemas.xmlsoap.org/soap/envelope/");
-
+
WSSec.validateAndApplyDefaultsToOutboundSecurityProperties(properties);
}
-
+
@Test
public void testInboundSignatureConfiguration() throws Exception {
Map<String, Object> config = new HashMap<String, Object>();
@@ -104,19 +104,19 @@ public class ConfigurationConverterTest
config.put(ConfigurationConstants.SIG_VER_PROP_FILE, "transmitter-crypto.properties");
config.put(ConfigurationConstants.IS_BSP_COMPLIANT, "false");
config.put(ConfigurationConstants.ENABLE_REVOCATION, "true");
-
+
WSSSecurityProperties properties = ConfigurationConverter.convert(config);
-
+
Assert.assertEquals(properties.getActions().size(), 1);
Assert.assertEquals(properties.getActions().get(0), WSSConstants.SIGNATURE);
Assert.assertTrue(properties.getCallbackHandler() instanceof CallbackHandlerImpl);
Assert.assertTrue(properties.isDisableBSPEnforcement());
Assert.assertTrue(properties.isEnableRevocation());
Assert.assertNotNull(properties.getSignatureVerificationCrypto());
-
+
WSSec.validateAndApplyDefaultsToInboundSecurityProperties(properties);
}
-
+
@Test
public void testOutboundEncryptionConfiguration() throws Exception {
Map<String, Object> config = new HashMap<String, Object>();
@@ -126,30 +126,30 @@ public class ConfigurationConverterTest
config.put(ConfigurationConstants.ENC_KEY_TRANSPORT, WSSConstants.NS_XENC_RSA15);
config.put(ConfigurationConstants.ENC_KEY_ID, "EncryptedKeySHA1");
config.put(ConfigurationConstants.ENC_PROP_FILE, "receiver-crypto.properties");
- config.put(ConfigurationConstants.ENCRYPTION_PARTS,
+ config.put(ConfigurationConstants.ENCRYPTION_PARTS,
"{}{http://schemas.xmlsoap.org/soap/envelope/}Body;");
-
+
WSSSecurityProperties properties = ConfigurationConverter.convert(config);
-
+
Assert.assertEquals(properties.getEncryptionUser(), "transmitter");
Assert.assertEquals(properties.getActions().size(), 1);
Assert.assertEquals(properties.getActions().get(0), WSSConstants.ENCRYPT);
Assert.assertTrue(properties.getCallbackHandler() instanceof CallbackHandlerImpl);
- Assert.assertEquals(properties.getEncryptionKeyTransportAlgorithm(),
+ Assert.assertEquals(properties.getEncryptionKeyTransportAlgorithm(),
WSSConstants.NS_XENC_RSA15);
Assert.assertEquals(properties.getEncryptionKeyIdentifier(),
WSSecurityTokenConstants.KeyIdentifier_EncryptedKeySha1Identifier);
Assert.assertNotNull(properties.getEncryptionCrypto());
Assert.assertTrue(properties.getEncryptionSecureParts() != null);
Assert.assertEquals(properties.getEncryptionSecureParts().size(), 1);
- Assert.assertEquals(properties.getEncryptionSecureParts().get(0).getName().getLocalPart(),
+ Assert.assertEquals(properties.getEncryptionSecureParts().get(0).getName().getLocalPart(),
"Body");
- Assert.assertEquals(properties.getEncryptionSecureParts().get(0).getName().getNamespaceURI(),
+ Assert.assertEquals(properties.getEncryptionSecureParts().get(0).getName().getNamespaceURI(),
"http://schemas.xmlsoap.org/soap/envelope/");
-
+
WSSec.validateAndApplyDefaultsToOutboundSecurityProperties(properties);
}
-
+
@Test
public void testInboundEncryptionConfiguration() throws Exception {
Map<String, Object> config = new HashMap<String, Object>();
@@ -157,54 +157,54 @@ public class ConfigurationConverterTest
config.put(ConfigurationConstants.PW_CALLBACK_REF, new CallbackHandlerImpl());
config.put(ConfigurationConstants.DEC_PROP_FILE, "receiver-crypto.properties");
config.put(ConfigurationConstants.ALLOW_RSA15_KEY_TRANSPORT_ALGORITHM, "true");
-
+
WSSSecurityProperties properties = ConfigurationConverter.convert(config);
-
+
Assert.assertEquals(properties.getActions().size(), 1);
Assert.assertEquals(properties.getActions().get(0), WSSConstants.ENCRYPT);
Assert.assertTrue(properties.getCallbackHandler() instanceof CallbackHandlerImpl);
Assert.assertNotNull(properties.getDecryptionCrypto());
-
+
WSSec.validateAndApplyDefaultsToInboundSecurityProperties(properties);
}
-
+
@Test
public void testSAMLConfiguration() throws Exception {
Map<String, Object> config = new HashMap<String, Object>();
config.put(ConfigurationConstants.ACTION, ConfigurationConstants.SAML_TOKEN_UNSIGNED);
config.put(ConfigurationConstants.SAML_CALLBACK_REF, new SAMLCallbackHandlerImpl());
-
+
WSSSecurityProperties properties = ConfigurationConverter.convert(config);
Assert.assertEquals(properties.getActions().size(), 1);
Assert.assertEquals(properties.getActions().get(0), WSSConstants.SAML_TOKEN_UNSIGNED);
Assert.assertTrue(properties.getSamlCallbackHandler() instanceof SAMLCallbackHandlerImpl);
-
+
WSSec.validateAndApplyDefaultsToOutboundSecurityProperties(properties);
}
-
+
@Test
public void testTimestampConfiguration() throws Exception {
// Outbound
Map<String, Object> config = new HashMap<String, Object>();
config.put(ConfigurationConstants.ACTION, ConfigurationConstants.TIMESTAMP);
config.put(ConfigurationConstants.TTL_TIMESTAMP, "180");
-
+
WSSSecurityProperties properties = ConfigurationConverter.convert(config);
Assert.assertEquals(properties.getActions().size(), 1);
Assert.assertEquals(properties.getActions().get(0), WSSConstants.TIMESTAMP);
Assert.assertEquals(properties.getTimestampTTL(), Integer.valueOf(180));
-
+
WSSec.validateAndApplyDefaultsToOutboundSecurityProperties(properties);
-
+
// Inbound
config.put(ConfigurationConstants.TTL_FUTURE_TIMESTAMP, "120");
config.put(ConfigurationConstants.TIMESTAMP_STRICT, "false");
-
+
properties = ConfigurationConverter.convert(config);
Assert.assertEquals(properties.getTimeStampFutureTTL(), Integer.valueOf(120));
Assert.assertFalse(properties.isStrictTimestampCheck());
-
+
WSSec.validateAndApplyDefaultsToInboundSecurityProperties(properties);
}
-
+
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/DerivedKeyTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/DerivedKeyTokenTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/DerivedKeyTokenTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/DerivedKeyTokenTest.java Tue Dec 15 16:40:37 2015
@@ -74,9 +74,9 @@ import org.w3c.dom.NodeList;
@RunWith(value = org.junit.runners.Parameterized.class)
public class DerivedKeyTokenTest extends AbstractTestBase {
-
+
final int version;
-
+
public DerivedKeyTokenTest(int version) {
this.version = version;
}
@@ -88,7 +88,7 @@ public class DerivedKeyTokenTest extends
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
-
+
return Arrays.asList(new Object[][] {{ConversationConstants.VERSION_05_02},
{ConversationConstants.VERSION_05_12}
});
@@ -217,7 +217,7 @@ public class DerivedKeyTokenTest extends
org.junit.Assert.assertEquals(securityEventListener.getReceivedSecurityEvents().size(), operationSecurityEvents.size() + encryptedPartSecurityEvents.size());
}
}
-
+
@Test
public void testEncryptionDecryptionTRIPLEDESInboundAction() throws Exception {
@@ -225,14 +225,14 @@ public class DerivedKeyTokenTest extends
{
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
String action = WSHandlerConstants.ENCRYPT_DERIVED;
-
+
Properties properties = new Properties();
properties.put(WSHandlerConstants.DERIVED_TOKEN_REFERENCE, "EncryptedKey");
if (version == ConversationConstants.VERSION_05_02) {
properties.put(WSHandlerConstants.USE_2005_12_NAMESPACE, "false");
}
properties.put(WSHandlerConstants.USER, "receiver");
- properties.put(WSHandlerConstants.ENC_SYM_ALGO,
+ properties.put(WSHandlerConstants.ENC_SYM_ALGO,
"http://www.w3.org/2001/04/xmlenc#tripledes-cbc");
Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties);
@@ -243,7 +243,7 @@ public class DerivedKeyTokenTest extends
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
}
-
+
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
securityProperties.loadDecryptionKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
@@ -380,7 +380,7 @@ public class DerivedKeyTokenTest extends
Assert.assertEquals(nodeList.getLength(), 0);
}
}
-
+
@Test
public void testEncryptionDecryptionAES128InboundAction() throws Exception {
@@ -388,17 +388,17 @@ public class DerivedKeyTokenTest extends
{
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
String action = WSHandlerConstants.ENCRYPT_DERIVED;
-
+
Properties properties = new Properties();
properties.put(WSHandlerConstants.DERIVED_TOKEN_REFERENCE, "EncryptedKey");
if (version == ConversationConstants.VERSION_05_02) {
properties.put(WSHandlerConstants.USE_2005_12_NAMESPACE, "false");
}
properties.put(WSHandlerConstants.USER, "receiver");
- properties.put(WSHandlerConstants.ENC_SYM_ALGO,
+ properties.put(WSHandlerConstants.ENC_SYM_ALGO,
"http://www.w3.org/2001/04/xmlenc#aes128-cbc");
Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties);
-
+
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedData.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedData.getLocalPart());
Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_soap11_Body.getLocalPart());
@@ -406,7 +406,7 @@ public class DerivedKeyTokenTest extends
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
}
-
+
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
securityProperties.loadDecryptionKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
@@ -501,12 +501,12 @@ public class DerivedKeyTokenTest extends
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
-
+
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
Assert.assertEquals(nodeList.getLength(), 1);
}
}
-
+
@Test
public void testSignatureInboundAction() throws Exception {
@@ -514,7 +514,7 @@ public class DerivedKeyTokenTest extends
{
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
String action = WSHandlerConstants.SIGNATURE_DERIVED;
-
+
Properties properties = new Properties();
properties.put(WSHandlerConstants.DERIVED_TOKEN_REFERENCE, "EncryptedKey");
if (version == ConversationConstants.VERSION_05_02) {
@@ -530,7 +530,7 @@ public class DerivedKeyTokenTest extends
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
}
-
+
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
securityProperties.loadSignatureVerificationKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
@@ -540,7 +540,7 @@ public class DerivedKeyTokenTest extends
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
-
+
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
Assert.assertEquals(nodeList.getLength(), 1);
}
@@ -637,8 +637,8 @@ public class DerivedKeyTokenTest extends
Assert.assertEquals(nodeList.getLength(), 1);
}
}
-
-
+
+
@Test
public void testSignatureThumbprintSHA1InboundAction() throws Exception {
@@ -646,7 +646,7 @@ public class DerivedKeyTokenTest extends
{
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
String action = WSHandlerConstants.SIGNATURE_DERIVED;
-
+
Properties properties = new Properties();
properties.put(WSHandlerConstants.DERIVED_TOKEN_REFERENCE, "DirectReference");
if (version == ConversationConstants.VERSION_05_02) {
@@ -661,7 +661,7 @@ public class DerivedKeyTokenTest extends
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
}
-
+
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
securityProperties.loadSignatureVerificationKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
@@ -768,7 +768,7 @@ public class DerivedKeyTokenTest extends
Assert.assertEquals(nodeList.getLength(), 1);
}
}
-
+
@Test
public void testSignatureSKIInboundAction() throws Exception {
@@ -776,7 +776,7 @@ public class DerivedKeyTokenTest extends
{
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
String action = WSHandlerConstants.SIGNATURE_DERIVED;
-
+
Properties properties = new Properties();
properties.put(WSHandlerConstants.DERIVED_TOKEN_REFERENCE, "DirectReference");
properties.put(WSHandlerConstants.DERIVED_TOKEN_KEY_ID, "SKIKeyIdentifier");
@@ -792,7 +792,7 @@ public class DerivedKeyTokenTest extends
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
}
-
+
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
securityProperties.loadSignatureVerificationKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
@@ -1040,7 +1040,7 @@ public class DerivedKeyTokenTest extends
Assert.assertEquals(nodeList.getLength(), 0);
}
}
-
+
@Test
public void testEncryptSignatureInboundAction() throws Exception {
@@ -1049,14 +1049,14 @@ public class DerivedKeyTokenTest extends
{
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
String action = WSHandlerConstants.SIGNATURE_DERIVED + " " + WSHandlerConstants.ENCRYPT_DERIVED;
-
+
Properties properties = new Properties();
properties.put(WSHandlerConstants.DERIVED_TOKEN_REFERENCE, "EncryptedKey");
if (version == ConversationConstants.VERSION_05_02) {
properties.put(WSHandlerConstants.USE_2005_12_NAMESPACE, "false");
}
properties.put(WSHandlerConstants.USER, "receiver");
- properties.put(WSHandlerConstants.SIG_ALGO,
+ properties.put(WSHandlerConstants.SIG_ALGO,
"http://www.w3.org/2000/09/xmldsig#hmac-sha1");
Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties);
@@ -1067,7 +1067,7 @@ public class DerivedKeyTokenTest extends
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
}
-
+
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
securityProperties.loadSignatureVerificationKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncDecryptionTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncDecryptionTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncDecryptionTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncDecryptionTest.java Tue Dec 15 16:40:37 2015
@@ -230,7 +230,7 @@ public class EncDecryptionTest extends A
operationSecurityEvents.size() + encryptedPartSecurityEvents.size());
}
}
-
+
@Test
public void testEncDecryptionCryptoPropertiesOutbound() throws Exception {
@@ -240,7 +240,7 @@ public class EncDecryptionTest extends A
List<WSSConstants.Action> actions = new ArrayList<WSSConstants.Action>();
actions.add(WSSConstants.ENCRYPT);
securityProperties.setActions(actions);
- Properties properties =
+ Properties properties =
CryptoFactory.getProperties("transmitter-crypto.properties", this.getClass().getClassLoader());
securityProperties.setEncryptionCryptoProperties(properties);
securityProperties.setEncryptionUser("receiver");
@@ -308,7 +308,7 @@ public class EncDecryptionTest extends A
//test streaming decryption
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
- Properties properties =
+ Properties properties =
CryptoFactory.getProperties("receiver-crypto.properties", this.getClass().getClassLoader());
securityProperties.setDecryptionCryptoProperties(properties);
securityProperties.setCallbackHandler(new CallbackHandlerImpl());
@@ -1840,28 +1840,28 @@ public class EncDecryptionTest extends A
securityProperties.setEncryptionUser("receiver");
securityProperties.setEncryptionSymAlgorithm("http://www.w3.org/2009/xmlenc11#aes128-gcm");
securityProperties.setEncryptionKeyTransportAlgorithm("http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p");
-
+
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
baos = doOutboundSecurity(securityProperties, sourceDocument);
-
+
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedKey.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedKey.getLocalPart());
Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_wsse_Security.getLocalPart());
-
+
XPathExpression xPathExpression = getXPath("/soap:Envelope/soap:Header/wsse:Security/xenc:EncryptedKey/xenc:EncryptionMethod[@Algorithm='http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p']");
Node node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
Assert.assertNotNull(node);
-
+
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_DataReference.getNamespaceURI(), WSSConstants.TAG_xenc_DataReference.getLocalPart());
Assert.assertEquals(nodeList.getLength(), 1);
-
+
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedData.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedData.getLocalPart());
Assert.assertEquals(nodeList.getLength(), 1);
-
+
xPathExpression = getXPath("/soap:Envelope/soap:Body/xenc:EncryptedData/xenc:EncryptionMethod[@Algorithm='http://www.w3.org/2009/xmlenc11#aes128-gcm']");
node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
Assert.assertNotNull(node);
-
+
Assert.assertEquals(node.getParentNode().getParentNode().getLocalName(), "Body");
NodeList childNodes = node.getParentNode().getParentNode().getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
@@ -1875,7 +1875,7 @@ public class EncDecryptionTest extends A
}
}
}
-
+
//done encryption; now test decryption:
{
String action = WSHandlerConstants.ENCRYPT;
@@ -1947,32 +1947,32 @@ public class EncDecryptionTest extends A
securityProperties.setEncryptionSymAlgorithm("http://www.w3.org/2009/xmlenc11#aes192-gcm");
securityProperties.setEncryptionKeyTransportAlgorithm("http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p");
securityProperties.setEncryptionKeyTransportDigestAlgorithm("http://www.w3.org/2001/04/xmlenc#sha256");
-
+
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
baos = doOutboundSecurity(securityProperties, sourceDocument);
-
+
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedKey.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedKey.getLocalPart());
Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_wsse_Security.getLocalPart());
-
+
XPathExpression xPathExpression = getXPath("/soap:Envelope/soap:Header/wsse:Security/xenc:EncryptedKey/xenc:EncryptionMethod[@Algorithm='http://www.w3.org/2001/04/xmlenc#rsa-oaep-mgf1p']");
Node node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
Assert.assertNotNull(node);
-
+
xPathExpression = getXPath("/soap:Envelope/soap:Header/wsse:Security/xenc:EncryptedKey/xenc:EncryptionMethod/dsig:DigestMethod[@Algorithm='http://www.w3.org/2001/04/xmlenc#sha256']");
node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
Assert.assertNotNull(node);
-
+
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_DataReference.getNamespaceURI(), WSSConstants.TAG_xenc_DataReference.getLocalPart());
Assert.assertEquals(nodeList.getLength(), 1);
-
+
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedData.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedData.getLocalPart());
Assert.assertEquals(nodeList.getLength(), 1);
-
+
xPathExpression = getXPath("/soap:Envelope/soap:Body/xenc:EncryptedData/xenc:EncryptionMethod[@Algorithm='http://www.w3.org/2009/xmlenc11#aes192-gcm']");
node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
Assert.assertNotNull(node);
-
+
Assert.assertEquals(node.getParentNode().getParentNode().getLocalName(), "Body");
NodeList childNodes = node.getParentNode().getParentNode().getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
@@ -2190,40 +2190,40 @@ public class EncDecryptionTest extends A
securityProperties.setEncryptionKeyTransportDigestAlgorithm("http://www.w3.org/2001/04/xmldsig-more#sha384");
securityProperties.setEncryptionKeyTransportMGFAlgorithm("http://www.w3.org/2009/xmlenc11#mgf1sha384");
securityProperties.setEncryptionKeyTransportOAEPParams(Base64.decode("ZHVtbXkxMjM=".getBytes(StandardCharsets.UTF_8)));
-
+
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
baos = doOutboundSecurity(securityProperties, sourceDocument);
-
+
Document document = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedKey.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedKey.getLocalPart());
Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_wsse_Security.getLocalPart());
-
+
XPathExpression xPathExpression = getXPath("/soap:Envelope/soap:Header/wsse:Security/xenc:EncryptedKey/xenc:EncryptionMethod[@Algorithm='http://www.w3.org/2009/xmlenc11#rsa-oaep']");
Node node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
Assert.assertNotNull(node);
-
+
xPathExpression = getXPath("/soap:Envelope/soap:Header/wsse:Security/xenc:EncryptedKey/xenc:EncryptionMethod/xenc:OAEPparams");
node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
Assert.assertNotNull(node);
-
+
xPathExpression = getXPath("/soap:Envelope/soap:Header/wsse:Security/xenc:EncryptedKey/xenc:EncryptionMethod/dsig:DigestMethod[@Algorithm='http://www.w3.org/2001/04/xmldsig-more#sha384']");
node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
Assert.assertNotNull(node);
-
+
xPathExpression = getXPath("/soap:Envelope/soap:Header/wsse:Security/xenc:EncryptedKey/xenc:EncryptionMethod/xenc11:MGF[@Algorithm='http://www.w3.org/2009/xmlenc11#mgf1sha384']");
node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
Assert.assertNotNull(node);
-
+
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_DataReference.getNamespaceURI(), WSSConstants.TAG_xenc_DataReference.getLocalPart());
Assert.assertEquals(nodeList.getLength(), 1);
-
+
nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_xenc_EncryptedData.getNamespaceURI(), WSSConstants.TAG_xenc_EncryptedData.getLocalPart());
Assert.assertEquals(nodeList.getLength(), 1);
-
+
xPathExpression = getXPath("/soap:Envelope/soap:Body/xenc:EncryptedData/xenc:EncryptionMethod[@Algorithm='http://www.w3.org/2009/xmlenc11#aes192-gcm']");
node = (Node) xPathExpression.evaluate(document, XPathConstants.NODE);
Assert.assertNotNull(node);
-
+
Assert.assertEquals(node.getParentNode().getParentNode().getLocalName(), "Body");
NodeList childNodes = node.getParentNode().getParentNode().getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
@@ -2308,7 +2308,7 @@ public class EncDecryptionTest extends A
Assert.assertEquals(nodeList.getLength(), 0);
}
}
-
+
@Test
public void testInboundRequiredAlgorithms() throws Exception {
@@ -2366,7 +2366,7 @@ public class EncDecryptionTest extends A
}
}
}
-
+
@Test
public void testEncDecryptionPropertiesOutbound() throws Exception {
@@ -2455,10 +2455,10 @@ public class EncDecryptionTest extends A
WSSSecurityProperties securityProperties = ConfigurationConverter.convert(config);
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
- XMLStreamReader outXmlStreamReader =
+ XMLStreamReader outXmlStreamReader =
wsSecIn.processInMessage(
- xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())),
- new ArrayList<SecurityEvent>(),
+ xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())),
+ new ArrayList<SecurityEvent>(),
securityEventListener);
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), outXmlStreamReader);
@@ -2517,7 +2517,7 @@ public class EncDecryptionTest extends A
@Test
public void testElementoEncryptNotFound() throws Exception {
-
+
ByteArrayOutputStream baos = new ByteArrayOutputStream();
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncryptionCRLTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncryptionCRLTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncryptionCRLTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/EncryptionCRLTest.java Tue Dec 15 16:40:37 2015
@@ -37,8 +37,8 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
/**
- * This is a test for Certificate Revocation List checking before encryption.
- *
+ * This is a test for Certificate Revocation List checking before encryption.
+ *
* This test reuses the revoked certificate from SignatureCRLTest
*/
public class EncryptionCRLTest extends AbstractTestBase {
@@ -91,7 +91,7 @@ public class EncryptionCRLTest extends A
}
}
}
-
+
/**
* TODO Re-enable once CRL issue fixed
*/
@@ -110,7 +110,7 @@ public class EncryptionCRLTest extends A
securityProperties.loadCRLCertStore(this.getClass().getClassLoader().getResource("wss40CACRL.pem"));
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
-
+
try {
doOutboundSecurity(securityProperties, sourceDocument);
Assert.fail("Expected failure on a revocation check");
@@ -119,5 +119,5 @@ public class EncryptionCRLTest extends A
}
}
}
-
+
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/FaultTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/FaultTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/FaultTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/FaultTest.java Tue Dec 15 16:40:37 2015
@@ -69,7 +69,7 @@ public class FaultTest extends AbstractT
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
}
}
-
+
@Test
public void testEncryptedFaultInbound() throws Exception {
@@ -94,7 +94,7 @@ public class FaultTest extends AbstractT
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
}
}
-
+
@Test
public void testUnsecuredFaultInbound() throws Exception {
@@ -120,5 +120,5 @@ public class FaultTest extends AbstractT
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
}
}
-
+
}
\ No newline at end of file
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InteroperabilityTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InteroperabilityTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InteroperabilityTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/InteroperabilityTest.java Tue Dec 15 16:40:37 2015
@@ -811,24 +811,24 @@ public class InteroperabilityTest extend
securityProperties.addSignaturePart(new SecurePart(new QName("http://www.w3.org/1999/XMLSchema", "complexType"), SecurePart.Modifier.Element));
securityProperties.setSignatureCanonicalizationAlgorithm("http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments");
securityProperties.setCallbackHandler(new CallbackHandlerImpl());
-
+
OutboundWSSec wsSecOut = WSSec.getOutboundWSSec(securityProperties);
XMLStreamWriter xmlStreamWriter = wsSecOut.processOutMessage(baos, StandardCharsets.UTF_8.name(), new ArrayList<SecurityEvent>());
XMLStreamReader xmlStreamReader = xmlInputFactory.createXMLStreamReader(this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml"));
XmlReaderToWriter.writeAll(xmlStreamReader, xmlStreamWriter);
xmlStreamWriter.close();
-
+
securedDocument = documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray()));
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_wsse_Security.getLocalPart());
}
-
+
{
String action = WSHandlerConstants.SIGNATURE + " " + WSHandlerConstants.ENCRYPT;
Properties properties = new Properties();
doInboundSecurityWithWSS4J_1(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action, properties, false);
}
-
+
//done signature; now test sig-verification:
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -839,7 +839,7 @@ public class InteroperabilityTest extend
securityProperties.addIgnoreBSPRule(BSPRule.R5423);
securityProperties.addIgnoreBSPRule(BSPRule.R5412);
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
-
+
WSSecurityEventConstants.Event[] expectedSecurityEvents = new WSSecurityEventConstants.Event[]{
WSSecurityEventConstants.AlgorithmSuite,
WSSecurityEventConstants.AlgorithmSuite,
@@ -929,14 +929,14 @@ public class InteroperabilityTest extend
final TestSecurityEventListener securityEventListener = new TestSecurityEventListener(expectedSecurityEvents);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(
xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())), null, securityEventListener);
-
+
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
-
+
//header element must still be there
NodeList nodeList = document.getElementsByTagNameNS(WSSConstants.TAG_dsig_Signature.getNamespaceURI(), WSSConstants.TAG_dsig_Signature.getLocalPart());
Assert.assertEquals(nodeList.getLength(), 1);
Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_wsse_Security.getLocalPart());
-
+
securityEventListener.compare();
}
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/MultipleActionTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/MultipleActionTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/MultipleActionTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/MultipleActionTest.java Tue Dec 15 16:40:37 2015
@@ -87,7 +87,7 @@ public class MultipleActionTest extends
Assert.assertEquals(((Element) nodeList.item(1)).getAttributeNS(null, WSSConstants.ATT_NULL_PrefixList.getLocalPart()), "");
}
}
-
+
@Test
@org.junit.Ignore
public void testTwoEncryptionActions() throws Exception {
@@ -110,7 +110,7 @@ public class MultipleActionTest extends
xmlStreamWriter.close();
}
}
-
+
@Test
public void testDuplicateActions() throws Exception {
WSSSecurityProperties properties = new WSSSecurityProperties();
@@ -120,14 +120,14 @@ public class MultipleActionTest extends
properties.setSignatureUser("transmitter");
properties.setCallbackHandler(new CallbackHandlerImpl());
properties.setActions(actions);
-
+
// Should work
WSSec.getOutboundWSSec(properties);
-
+
// Should throw an error on a duplicate Action
actions.add(XMLSecurityConstants.SIGNATURE);
properties.setActions(actions);
-
+
try {
WSSec.getOutboundWSSec(properties);
Assert.fail();
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordEncryptorTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordEncryptorTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordEncryptorTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordEncryptorTest.java Tue Dec 15 16:40:37 2015
@@ -63,9 +63,9 @@ public class PasswordEncryptorTest exten
List<WSSConstants.Action> actions = new ArrayList<WSSConstants.Action>();
actions.add(WSSConstants.SIGNATURE);
securityProperties.setActions(actions);
- Properties properties =
+ Properties properties =
CryptoFactory.getProperties("transmitter-crypto-enc.properties", this.getClass().getClassLoader());
- PasswordEncryptor passwordEncryptor =
+ PasswordEncryptor passwordEncryptor =
new JasyptPasswordEncryptor(new CallbackHandlerImpl());
securityProperties.setSignatureCryptoProperties(properties, passwordEncryptor);
securityProperties.setSignatureUser("transmitter");
@@ -101,7 +101,7 @@ public class PasswordEncryptorTest exten
doInboundSecurityWithWSS4J(documentBuilderFactory.newDocumentBuilder().parse(new ByteArrayInputStream(baos.toByteArray())), action);
}
}
-
+
@Test
public void testEncDecryptionCryptoPropertiesOutbound() throws Exception {
@@ -111,9 +111,9 @@ public class PasswordEncryptorTest exten
List<WSSConstants.Action> actions = new ArrayList<WSSConstants.Action>();
actions.add(WSSConstants.ENCRYPT);
securityProperties.setActions(actions);
- Properties properties =
+ Properties properties =
CryptoFactory.getProperties("transmitter-crypto-enc.properties", this.getClass().getClassLoader());
- PasswordEncryptor passwordEncryptor =
+ PasswordEncryptor passwordEncryptor =
new JasyptPasswordEncryptor(new CallbackHandlerImpl());
securityProperties.setEncryptionCryptoProperties(properties, passwordEncryptor);
securityProperties.setEncryptionUser("receiver");
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordTypeTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordTypeTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordTypeTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PasswordTypeTest.java Tue Dec 15 16:40:37 2015
@@ -44,7 +44,7 @@ import org.w3c.dom.NodeList;
/**
* This is a test for processing a Username Token to enforce either a plaintext or digest
- * password type.
+ * password type.
*/
public class PasswordTypeTest extends AbstractTestBase {
@@ -80,7 +80,7 @@ public class PasswordTypeTest extends Ab
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
}
-
+
// It should pass with null
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -92,7 +92,7 @@ public class PasswordTypeTest extends Ab
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
}
-
+
// It should fail with PASSWORD_TEXT
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -113,7 +113,7 @@ public class PasswordTypeTest extends Ab
}
}
}
-
+
@Test
public void testPasswordText() throws Exception {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
@@ -147,7 +147,7 @@ public class PasswordTypeTest extends Ab
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
}
-
+
// It should pass with null
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -159,7 +159,7 @@ public class PasswordTypeTest extends Ab
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
}
-
+
// It should fail with PASSWORD_DIGEST
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -181,5 +181,5 @@ public class PasswordTypeTest extends Ab
}
}
-
+
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PrincipalTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PrincipalTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PrincipalTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/PrincipalTest.java Tue Dec 15 16:40:37 2015
@@ -92,7 +92,7 @@ public class PrincipalTest extends Abstr
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
// Check principal
- UsernameTokenSecurityEvent event =
+ UsernameTokenSecurityEvent event =
(UsernameTokenSecurityEvent)securityEventListener.getSecurityEvent(WSSecurityEventConstants.UsernameToken);
Assert.assertNotNull(event);
UsernameSecurityToken usernameSecurityToken = event.getSecurityToken();
@@ -107,7 +107,7 @@ public class PrincipalTest extends Abstr
Assert.assertTrue(WSSConstants.NS_PASSWORD_DIGEST.equals(usernameTokenPrincipal.getPasswordType()));
}
}
-
+
@Test
public void testSAMLToken() throws Exception {
@@ -150,7 +150,7 @@ public class PrincipalTest extends Abstr
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
// Check principal
- SamlTokenSecurityEvent event =
+ SamlTokenSecurityEvent event =
(SamlTokenSecurityEvent)securityEventListener.getSecurityEvent(WSSecurityEventConstants.SamlToken);
Assert.assertNotNull(event);
SamlSecurityToken token = event.getSecurityToken();
@@ -193,7 +193,7 @@ public class PrincipalTest extends Abstr
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())), null, securityEventListener);
StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
-
+
// Check principal
X509TokenSecurityEvent event =
(X509TokenSecurityEvent)securityEventListener.getSecurityEvent(WSSecurityEventConstants.X509Token);
@@ -301,7 +301,7 @@ public class PrincipalTest extends Abstr
@Test
public void testECKeyValue() throws Exception {
-
+
//
// This test fails with the IBM JDK and with JDK 1.8
// TODO - Re-enable with JDK 1.8 when we fix Santuario
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ReplayTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ReplayTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ReplayTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/ReplayTest.java Tue Dec 15 16:40:37 2015
@@ -83,7 +83,7 @@ public class ReplayTest extends Abstract
Assert.assertEquals(nodeList.getLength(), 1);
Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_wsse_Security.getLocalPart());
}
-
+
//done signature; now test sig-verification:
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -101,7 +101,7 @@ public class ReplayTest extends Abstract
}
}
}
-
+
@Test
public void testUsernameToken() throws Exception {
@@ -115,7 +115,7 @@ public class ReplayTest extends Abstract
//some test that we can really sure we get what we want from WSS4J
NodeList nodeList = securedDocument.getElementsByTagNameNS(WSSConstants.TAG_wsse_UsernameToken.getNamespaceURI(), WSSConstants.TAG_wsse_UsernameToken.getLocalPart());
Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_wsse_Security.getLocalPart());
-
+
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
}
@@ -136,7 +136,7 @@ public class ReplayTest extends Abstract
Assert.assertEquals(nodeList.getLength(), 1);
Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_wsse_Security.getLocalPart());
}
-
+
//done UsernameToken; now test verification:
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
@@ -153,7 +153,7 @@ public class ReplayTest extends Abstract
}
}
}
-
+
/**
* Test that creates, sends and processes an unsigned SAML 2 authentication assertion. This
* is just a sanity test to make sure that it is possible to send the SAML token twice, as
@@ -188,12 +188,12 @@ public class ReplayTest extends Abstract
ReplayCache replayCache = null;
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
-
+
SamlTokenValidatorImpl validator = new SamlTokenValidatorImpl();
validator.setRequireBearerSignature(false);
securityProperties.addValidator(WSSConstants.TAG_saml2_Assertion, validator);
securityProperties.addValidator(WSSConstants.TAG_saml_Assertion, validator);
-
+
replayCache = securityProperties.getSamlOneTimeUseReplayCache();
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
@@ -201,16 +201,16 @@ public class ReplayTest extends Abstract
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.assertNotNull(document);
}
-
+
// now process SAML Token again
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
-
+
SamlTokenValidatorImpl validator = new SamlTokenValidatorImpl();
validator.setRequireBearerSignature(false);
securityProperties.addValidator(WSSConstants.TAG_saml2_Assertion, validator);
securityProperties.addValidator(WSSConstants.TAG_saml_Assertion, validator);
-
+
securityProperties.setSamlOneTimeUseReplayCache(replayCache);
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
@@ -219,7 +219,7 @@ public class ReplayTest extends Abstract
Assert.assertNotNull(document);
}
}
-
+
/**
* Test that creates, sends and processes an unsigned SAML 2 authentication assertion
* with a OneTimeUse Element
@@ -253,12 +253,12 @@ public class ReplayTest extends Abstract
ReplayCache replayCache = null;
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
-
+
SamlTokenValidatorImpl validator = new SamlTokenValidatorImpl();
validator.setRequireBearerSignature(false);
securityProperties.addValidator(WSSConstants.TAG_saml2_Assertion, validator);
securityProperties.addValidator(WSSConstants.TAG_saml_Assertion, validator);
-
+
replayCache = securityProperties.getSamlOneTimeUseReplayCache();
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
@@ -266,16 +266,16 @@ public class ReplayTest extends Abstract
Document document = StAX2DOM.readDoc(documentBuilderFactory.newDocumentBuilder(), xmlStreamReader);
Assert.assertNotNull(document);
}
-
+
// now process SAML Token again
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
-
+
SamlTokenValidatorImpl validator = new SamlTokenValidatorImpl();
validator.setRequireBearerSignature(false);
securityProperties.addValidator(WSSConstants.TAG_saml2_Assertion, validator);
securityProperties.addValidator(WSSConstants.TAG_saml_Assertion, validator);
-
+
securityProperties.setSamlOneTimeUseReplayCache(replayCache);
InboundWSSec wsSecIn = WSSec.getInboundWSSec(securityProperties);
XMLStreamReader xmlStreamReader = wsSecIn.processInMessage(xmlInputFactory.createXMLStreamReader(new ByteArrayInputStream(baos.toByteArray())));
@@ -288,5 +288,5 @@ public class ReplayTest extends Abstract
}
}
}
-
+
}
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SecurityContextTokenTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SecurityContextTokenTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SecurityContextTokenTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SecurityContextTokenTest.java Tue Dec 15 16:40:37 2015
@@ -74,19 +74,19 @@ import org.w3c.dom.NodeList;
public class SecurityContextTokenTest extends AbstractTestBase {
final int version;
-
+
public SecurityContextTokenTest(int version) {
this.version = version;
}
-
+
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
-
+
return Arrays.asList(new Object[][] {{ConversationConstants.VERSION_05_02},
{ConversationConstants.VERSION_05_12}
});
}
-
+
@BeforeClass
public static void setUp() throws Exception {
WSSConfig.init();
@@ -221,7 +221,7 @@ public class SecurityContextTokenTest ex
);
}
}
-
+
@Test
public void testSCTDKTEncryptInboundAction() throws Exception {
@@ -230,7 +230,7 @@ public class SecurityContextTokenTest ex
{
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
String action = WSHandlerConstants.ENCRYPT_DERIVED;
-
+
Properties properties = new Properties();
CallbackHandlerImpl callbackHandler = new CallbackHandlerImpl(tempSecret);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
@@ -239,7 +239,7 @@ public class SecurityContextTokenTest ex
properties.put(WSHandlerConstants.USE_2005_12_NAMESPACE, "false");
}
properties.put(WSHandlerConstants.USER, "receiver");
- properties.put(WSHandlerConstants.ENC_SYM_ALGO,
+ properties.put(WSHandlerConstants.ENC_SYM_ALGO,
"http://www.w3.org/2001/04/xmlenc#aes128-cbc");
Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties);
@@ -250,7 +250,7 @@ public class SecurityContextTokenTest ex
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
}
-
+
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
securityProperties.loadDecryptionKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
@@ -448,7 +448,7 @@ public class SecurityContextTokenTest ex
{
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
String action = WSHandlerConstants.SIGNATURE_DERIVED;
-
+
Properties properties = new Properties();
CallbackHandlerImpl callbackHandler = new CallbackHandlerImpl(tempSecret);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
@@ -457,7 +457,7 @@ public class SecurityContextTokenTest ex
properties.put(WSHandlerConstants.USE_2005_12_NAMESPACE, "false");
}
properties.put(WSHandlerConstants.USER, "transmitter");
- properties.put(WSHandlerConstants.ENC_SYM_ALGO,
+ properties.put(WSHandlerConstants.ENC_SYM_ALGO,
"http://www.w3.org/2001/04/xmlenc#aes128-cbc");
Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties);
@@ -468,7 +468,7 @@ public class SecurityContextTokenTest ex
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
}
-
+
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
securityProperties.loadSignatureVerificationKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
@@ -528,7 +528,7 @@ public class SecurityContextTokenTest ex
);
}
}
-
+
@Test
public void testSCTKDKTSignAbsoluteInbound() throws Exception {
@@ -622,7 +622,7 @@ public class SecurityContextTokenTest ex
encrBuilder.build(doc, secHeader);
sctBuilder.prependSCTElementToHeader(doc, secHeader);
-
+
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(doc), new StreamResult(baos));
}
@@ -699,7 +699,7 @@ public class SecurityContextTokenTest ex
);
}
}
-
+
@Test()
public void testSCTKDKTSignEncryptAction() throws Exception {
@@ -707,9 +707,9 @@ public class SecurityContextTokenTest ex
ByteArrayOutputStream baos = new ByteArrayOutputStream();
{
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
- String action =
+ String action =
WSHandlerConstants.SIGNATURE_DERIVED + " " + WSHandlerConstants.ENCRYPT_DERIVED;
-
+
Properties properties = new Properties();
CallbackHandlerImpl callbackHandler = new CallbackHandlerImpl(tempSecret);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
@@ -718,14 +718,14 @@ public class SecurityContextTokenTest ex
properties.put(WSHandlerConstants.USE_2005_12_NAMESPACE, "false");
}
properties.put(WSHandlerConstants.USER, "transmitter");
- properties.put(WSHandlerConstants.ENC_SYM_ALGO,
+ properties.put(WSHandlerConstants.ENC_SYM_ALGO,
"http://www.w3.org/2001/04/xmlenc#aes128-cbc");
Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties);
javax.xml.transform.Transformer transformer = TRANSFORMER_FACTORY.newTransformer();
transformer.transform(new DOMSource(securedDocument), new StreamResult(baos));
}
-
+
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();
securityProperties.loadDecryptionKeystore(this.getClass().getClassLoader().getResource("receiver.jks"), "default".toCharArray());
@@ -922,7 +922,7 @@ public class SecurityContextTokenTest ex
);
}
}
-
+
@Test
public void testSCTKDKTEncryptSignAction() throws Exception {
@@ -930,9 +930,9 @@ public class SecurityContextTokenTest ex
ByteArrayOutputStream baos = new ByteArrayOutputStream();
{
InputStream sourceDocument = this.getClass().getClassLoader().getResourceAsStream("testdata/plain-soap-1.1.xml");
- String action =
+ String action =
WSHandlerConstants.ENCRYPT_DERIVED + " " + WSHandlerConstants.SIGNATURE_DERIVED;
-
+
Properties properties = new Properties();
CallbackHandlerImpl callbackHandler = new CallbackHandlerImpl(tempSecret);
properties.put(WSHandlerConstants.PW_CALLBACK_REF, callbackHandler);
@@ -941,7 +941,7 @@ public class SecurityContextTokenTest ex
properties.put(WSHandlerConstants.USE_2005_12_NAMESPACE, "false");
}
properties.put(WSHandlerConstants.USER, "transmitter");
- properties.put(WSHandlerConstants.ENC_SYM_ALGO,
+ properties.put(WSHandlerConstants.ENC_SYM_ALGO,
"http://www.w3.org/2001/04/xmlenc#aes128-cbc");
Document securedDocument = doOutboundSecurityWithWSS4J(sourceDocument, action, properties);
Modified: webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SignatureCRLTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SignatureCRLTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SignatureCRLTest.java (original)
+++ webservices/wss4j/trunk/ws-security-stax/src/test/java/org/apache/wss4j/stax/test/SignatureCRLTest.java Tue Dec 15 16:40:37 2015
@@ -47,28 +47,28 @@ import org.w3c.dom.NodeList;
/**
* This is a test for Certificate Revocation List checking. A message is signed and sent to the
* receiver. If Certificate Revocation is enabled, then signature trust verification should
- * fail as the message has been signed by the private key corresponding to a revoked signature.
- *
+ * fail as the message has been signed by the private key corresponding to a revoked signature.
+ *
* Generate the client keypair, make a csr, sign it with the CA key
- *
- * keytool -genkey -validity 3650 -alias wss40rev -keyalg RSA -keystore wss40rev.jks
+ *
+ * keytool -genkey -validity 3650 -alias wss40rev -keyalg RSA -keystore wss40rev.jks
* -dname "CN=Colm,OU=WSS4J,O=Apache,L=Dublin,ST=Leinster,C=IE"
* keytool -certreq -alias wss40rev -keystore wss40rev.jks -file wss40rev.cer
- * openssl ca -config ca.config -policy policy_anything -days 3650 -out wss40rev.pem
+ * openssl ca -config ca.config -policy policy_anything -days 3650 -out wss40rev.pem
* -infiles wss40rev.cer
* openssl x509 -outform DER -in wss40rev.pem -out wss40rev.crt
- *
+ *
* Import the CA cert into wss40.jks and import the new signed certificate
- *
+ *
* keytool -import -file wss40CA.crt -alias wss40CA -keystore wss40rev.jks
* keytool -import -file wss40rev.crt -alias wss40rev -keystore wss40rev.jks
- *
+ *
* Generate a Revocation list
- *
- * openssl ca -gencrl -keyfile wss40CAKey.pem -cert wss40CA.pem -out wss40CACRL.pem
+ *
+ * openssl ca -gencrl -keyfile wss40CAKey.pem -cert wss40CA.pem -out wss40CACRL.pem
* -config ca.config -crldays 3650
* openssl ca -revoke wss40rev.pem -keyfile wss40CAKey.pem -cert wss40CA.pem -config ca.config
- * openssl ca -gencrl -keyfile wss40CAKey.pem -cert wss40CA.pem -out wss40CACRL.pem
+ * openssl ca -gencrl -keyfile wss40CAKey.pem -cert wss40CA.pem -out wss40CACRL.pem
* -config ca.config -crldays 3650
*/
public class SignatureCRLTest extends AbstractTestBase {
@@ -109,7 +109,7 @@ public class SignatureCRLTest extends Ab
Assert.assertEquals(nodeList.getLength(), 1);
Assert.assertEquals(nodeList.item(0).getParentNode().getLocalName(), WSSConstants.TAG_wsse_Security.getLocalPart());
}
-
+
//done signature; now test sig-verification: This should fail as revocation is enabled
{
WSSSecurityProperties securityProperties = new WSSSecurityProperties();