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 [25/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-dom/src/test/java/org/apache/wss4j/dom/misc/PrincipalTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/PrincipalTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/PrincipalTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/PrincipalTest.java Tue Dec 15 16:40:37 2015
@@ -61,16 +61,16 @@ import org.w3c.dom.Document;
* Test various principal objects after processing a security token.
*/
public class PrincipalTest extends org.junit.Assert {
- private static final org.slf4j.Logger LOG =
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(PrincipalTest.class);
-
+
private CallbackHandler callbackHandler = new UsernamePasswordCallbackHandler();
@org.junit.AfterClass
public static void cleanup() throws Exception {
SecurityTestUtil.cleanup();
}
-
+
/**
* Test the principal that is created after processing a Username Token
*/
@@ -84,13 +84,13 @@ public class PrincipalTest extends org.j
Document signedDoc = builder.build(doc, secHeader);
if (LOG.isDebugEnabled()) {
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(signedDoc);
LOG.debug(outputString);
}
WSHandlerResult results = verify(signedDoc, null);
-
- Principal principal =
+
+ Principal principal =
(Principal)results.getResults().get(0).get(WSSecurityEngineResult.TAG_PRINCIPAL);
assertTrue(principal instanceof UsernameTokenPrincipal);
assertTrue("wernerd".equals(principal.getName()));
@@ -101,7 +101,7 @@ public class PrincipalTest extends org.j
assertTrue(userPrincipal.isPasswordDigest());
assertTrue(WSConstants.PASSWORD_DIGEST.equals(userPrincipal.getPasswordType()));
}
-
+
/**
* Test the principal that is created after processing a Username Token, which has been
* transformed into a SAML Assertion.
@@ -116,20 +116,20 @@ public class PrincipalTest extends org.j
Document signedDoc = builder.build(doc, secHeader);
if (LOG.isDebugEnabled()) {
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(signedDoc);
LOG.debug(outputString);
}
- WSHandlerResult results =
+ WSHandlerResult results =
verify(signedDoc, new DummyValidator(), WSConstants.USERNAME_TOKEN, null);
-
- Principal principal =
+
+ Principal principal =
(Principal)results.getResults().get(0).get(WSSecurityEngineResult.TAG_PRINCIPAL);
assertTrue(principal instanceof SAMLTokenPrincipal);
assertTrue(principal.getName().contains("uid=joe"));
assertTrue(((SAMLTokenPrincipal)principal).getToken() != null);
}
-
+
/**
* Test the principal that is created after processing a SAML Token
*/
@@ -138,7 +138,7 @@ public class PrincipalTest extends org.j
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
@@ -148,31 +148,31 @@ public class PrincipalTest extends org.j
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
LOG.debug(outputString);
}
-
+
WSHandlerResult results = verify(unsignedDoc, null);
-
- List<WSSecurityEngineResult> samlResults =
+
+ List<WSSecurityEngineResult> samlResults =
results.getActionResults().get(WSConstants.ST_UNSIGNED);
WSSecurityEngineResult actionResult = samlResults.get(0);
SamlAssertionWrapper receivedSamlAssertion =
(SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
assertTrue(receivedSamlAssertion != null);
-
+
Principal principal = (Principal)actionResult.get(WSSecurityEngineResult.TAG_PRINCIPAL);
assertTrue(principal instanceof SAMLTokenPrincipal);
assertTrue(principal.getName().contains("uid=joe"));
assertTrue(((SAMLTokenPrincipal)principal).getToken() != null);
}
-
+
/**
* Test the principal that is created after processing a SAML2 Token
*/
@@ -181,7 +181,7 @@ public class PrincipalTest extends org.j
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
@@ -191,31 +191,31 @@ public class PrincipalTest extends org.j
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
LOG.debug(outputString);
}
-
+
WSHandlerResult results = verify(unsignedDoc, null);
-
- List<WSSecurityEngineResult> samlResults =
+
+ List<WSSecurityEngineResult> samlResults =
results.getActionResults().get(WSConstants.ST_UNSIGNED);
WSSecurityEngineResult actionResult = samlResults.get(0);
-
+
SamlAssertionWrapper receivedSamlAssertion =
(SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
assertTrue(receivedSamlAssertion != null);
-
+
Principal principal = (Principal)actionResult.get(WSSecurityEngineResult.TAG_PRINCIPAL);
assertTrue(principal instanceof SAMLTokenPrincipal);
assertTrue(principal.getName().contains("uid=joe"));
assertTrue(((SAMLTokenPrincipal)principal).getToken() != null);
}
-
+
/**
* Test the principal that is created after processing a SAML Token, which has been
* transformed into another SAML Token.
@@ -225,42 +225,42 @@ public class PrincipalTest extends org.j
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-
+
WSSecSAMLToken wsSign = new WSSecSAMLToken();
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
LOG.debug(outputString);
}
-
- WSHandlerResult results =
+
+ WSHandlerResult results =
verify(unsignedDoc, new DummyValidator(), WSConstants.SAML_TOKEN, null);
-
- List<WSSecurityEngineResult> samlResults =
+
+ List<WSSecurityEngineResult> samlResults =
results.getActionResults().get(WSConstants.ST_UNSIGNED);
WSSecurityEngineResult actionResult = samlResults.get(0);
SamlAssertionWrapper receivedSamlAssertion =
(SamlAssertionWrapper) actionResult.get(WSSecurityEngineResult.TAG_SAML_ASSERTION);
assertTrue(receivedSamlAssertion != null);
-
+
Principal principal = (Principal)actionResult.get(WSSecurityEngineResult.TAG_PRINCIPAL);
assertTrue(principal instanceof SAMLTokenPrincipal);
assertTrue(principal.getName().contains("uid=joe"));
assertTrue(((SAMLTokenPrincipal)principal).getToken() != null);
}
-
+
/**
* Test the principal that is created after processing (and explicitly validating)
* a BinarySecurityToken.
@@ -271,39 +271,39 @@ public class PrincipalTest extends org.j
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
X509Security bst = new X509Security(doc);
CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
cryptoType.setAlias("wss40");
Crypto crypto = CryptoFactory.getInstance("wss40.properties");
X509Certificate[] certs = crypto.getX509Certificates(cryptoType);
bst.setX509Certificate(certs[0]);
-
+
WSSecurityUtil.prependChildElement(secHeader.getSecurityHeader(), bst.getElement());
-
+
if (LOG.isDebugEnabled()) {
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(doc);
LOG.debug(outputString);
}
-
- WSHandlerResult results =
+
+ WSHandlerResult results =
verify(doc, new DummyValidator(), WSConstants.BINARY_TOKEN, crypto);
-
- List<WSSecurityEngineResult> bstResults =
+
+ List<WSSecurityEngineResult> bstResults =
results.getActionResults().get(WSConstants.BST);
WSSecurityEngineResult actionResult = bstResults.get(0);
BinarySecurity token =
(BinarySecurity)actionResult.get(WSSecurityEngineResult.TAG_BINARY_SECURITY_TOKEN);
assertNotNull(token);
-
+
Principal principal = (Principal)actionResult.get(WSSecurityEngineResult.TAG_PRINCIPAL);
assertTrue(principal instanceof SAMLTokenPrincipal);
assertTrue(principal.getName().contains("uid=joe"));
assertTrue(((SAMLTokenPrincipal)principal).getToken() != null);
}
-
+
/**
* Verifies the soap envelope
*/
@@ -313,12 +313,12 @@ public class PrincipalTest extends org.j
) throws Exception {
return verify(doc, null, null, crypto);
}
-
+
/**
* Verifies the soap envelope
*/
private WSHandlerResult verify(
- Document doc,
+ Document doc,
Validator validator,
QName validatorName,
Crypto crypto
@@ -328,17 +328,17 @@ public class PrincipalTest extends org.j
requestData.setDecCrypto(crypto);
requestData.setSigVerCrypto(crypto);
requestData.setValidateSamlSubjectConfirmation(false);
-
+
WSSecurityEngine secEngine = new WSSecurityEngine();
WSSConfig config = WSSConfig.getNewInstance();
secEngine.setWssConfig(config);
-
+
if (validator != null && validatorName != null) {
config.setValidator(validatorName, validator);
}
return secEngine.processSecurityHeader(doc, requestData);
}
-
+
/**
* A Dummy Validator instance that just creates a new SAML Assertion, ignoring the
* credential it has been passed.
@@ -350,17 +350,17 @@ public class PrincipalTest extends org.j
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-
+
credential.setTransformedToken(samlAssertion);
return credential;
} catch (Exception ex) {
throw new WSSecurityException(WSSecurityException.ErrorCode.FAILURE);
}
}
-
+
}
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/SecurityHeaderTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/SecurityHeaderTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/SecurityHeaderTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/misc/SecurityHeaderTest.java Tue Dec 15 16:40:37 2015
@@ -29,8 +29,8 @@ import org.w3c.dom.Document;
* This tests how security headers are parsed and processed.
*/
public class SecurityHeaderTest extends org.junit.Assert {
- private static final String DUPLICATE_NULL_ACTOR_MSG =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ private static final String DUPLICATE_NULL_ACTOR_MSG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
@@ -42,12 +42,12 @@ public class SecurityHeaderTest extends
+ "xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">"
+ "</wsse:Security>"
+ "</SOAP-ENV:Header>"
- + "<SOAP-ENV:Body>"
- + "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">"
- + "<value xmlns=\"\">15</value>" + "</add>"
+ + "<SOAP-ENV:Body>"
+ + "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">"
+ + "<value xmlns=\"\">15</value>" + "</add>"
+ "</SOAP-ENV:Body>\r\n \r\n" + "</SOAP-ENV:Envelope>";
- private static final String DUPLICATE_ACTOR_MSG =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ private static final String DUPLICATE_ACTOR_MSG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
@@ -59,12 +59,12 @@ public class SecurityHeaderTest extends
+ "xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">"
+ "</wsse:Security>"
+ "</SOAP-ENV:Header>"
- + "<SOAP-ENV:Body>"
- + "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">"
- + "<value xmlns=\"\">15</value>" + "</add>"
+ + "<SOAP-ENV:Body>"
+ + "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">"
+ + "<value xmlns=\"\">15</value>" + "</add>"
+ "</SOAP-ENV:Body>\r\n \r\n" + "</SOAP-ENV:Envelope>";
- private static final String TWO_ACTOR_MSG =
- "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ private static final String TWO_ACTOR_MSG =
+ "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
+ "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\" "
+ "xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" "
+ "xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
@@ -76,18 +76,18 @@ public class SecurityHeaderTest extends
+ "xmlns:wsse=\"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd\">"
+ "</wsse:Security>"
+ "</SOAP-ENV:Header>"
- + "<SOAP-ENV:Body>"
- + "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">"
- + "<value xmlns=\"\">15</value>" + "</add>"
+ + "<SOAP-ENV:Body>"
+ + "<add xmlns=\"http://ws.apache.org/counter/counter_port_type\">"
+ + "<value xmlns=\"\">15</value>" + "</add>"
+ "</SOAP-ENV:Body>\r\n \r\n" + "</SOAP-ENV:Envelope>";
-
+
private WSSecurityEngine secEngine = new WSSecurityEngine();
@org.junit.AfterClass
public static void cleanup() throws Exception {
SecurityTestUtil.cleanup();
}
-
+
/**
* Test for processing multiple security headers with the same (null) actor
*/
@@ -98,10 +98,10 @@ public class SecurityHeaderTest extends
secEngine.processSecurityHeader(doc, null, null, null);
fail("Failure expected on a null actor");
} catch (WSSecurityException ex) {
- assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
+ assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
}
}
-
+
/**
* Test for processing multiple security headers with the same actor
*/
@@ -112,10 +112,10 @@ public class SecurityHeaderTest extends
secEngine.processSecurityHeader(doc, "user", null, null);
fail("Failure expected on a duplicate actor");
} catch (WSSecurityException ex) {
- assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
+ assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
}
}
-
+
/**
* Test for processing multiple security headers with different actors
*/
@@ -123,7 +123,7 @@ public class SecurityHeaderTest extends
public void testTwoActors() throws Exception {
Document doc = SOAPUtil.toSOAPPart(TWO_ACTOR_MSG);
secEngine.processSecurityHeader(doc, null, null, null);
-
+
secEngine.processSecurityHeader(doc, "user", null, null);
}
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/EncryptedKeyDataRefTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/EncryptedKeyDataRefTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/EncryptedKeyDataRefTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/EncryptedKeyDataRefTest.java Tue Dec 15 16:40:37 2015
@@ -41,39 +41,39 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
- * Test that checks for correct WSDataRef which should be returned by
- * <code>org.apache.wss4j.dom.processor.EncryptedKeyProcessor</code>
- *
+ * Test that checks for correct WSDataRef which should be returned by
+ * <code>org.apache.wss4j.dom.processor.EncryptedKeyProcessor</code>
+ *
* This test uses the RSA_15 algorithm to transport (wrap) the symmetric key.
* The test case creates a ReferenceList element that references EncryptedData
- * elements. The ReferencesList element is put into the EncryptedKey. The
- * EncryptedData elements contain a KeyInfo that references the EncryptedKey via
+ * elements. The ReferencesList element is put into the EncryptedKey. The
+ * EncryptedData elements contain a KeyInfo that references the EncryptedKey via
* a STR/Reference structure.
- *
- * WSDataRef object must contain the correct QName of the decrypted element.
- *
+ *
+ * WSDataRef object must contain the correct QName of the decrypted element.
+ *
*/
public class EncryptedKeyDataRefTest extends org.junit.Assert {
- private static final org.slf4j.Logger LOG =
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(EncryptedKeyDataRefTest.class);
private WSSecurityEngine secEngine = new WSSecurityEngine();
private CallbackHandler callbackHandler = new KeystoreCallbackHandler();
private Crypto crypto = null;
-
+
@org.junit.AfterClass
public static void cleanup() throws Exception {
SecurityTestUtil.cleanup();
}
-
+
public EncryptedKeyDataRefTest() throws Exception {
crypto = CryptoFactory.getInstance("wss40.properties");
WSSConfig.init();
}
/**
- * Test that check for correct WSDataRef object from EncryptedKey Processor
- *
- *
+ * Test that check for correct WSDataRef object from EncryptedKey Processor
+ *
+ *
* @throws Exception
* Thrown when there is an error in encryption or decryption
*/
@@ -96,7 +96,7 @@ public class EncryptedKeyDataRefTest ext
/*
* Set up the parts structure to encrypt the body
*/
- WSEncryptionPart encP =
+ WSEncryptionPart encP =
new WSEncryptionPart(
"add", "http://ws.apache.org/counter/counter_port_type", "Element"
);
@@ -108,9 +108,9 @@ public class EncryptedKeyDataRefTest ext
* itself as a child.
*/
Element refs = builder.encrypt();
-
+
/*
- * We use this method because we want the reference list to be inside the
+ * We use this method because we want the reference list to be inside the
* EncryptedKey element
*/
builder.addInternalRefElement(refs);
@@ -131,35 +131,35 @@ public class EncryptedKeyDataRefTest ext
/**
* Verifies the soap envelope <p/>
- *
+ *
* @param envelope
* @throws Exception
* Thrown when there is a problem in verification
*/
@SuppressWarnings("unchecked")
private void checkDataRef(Document doc) throws Exception {
-
- // Retrieve the wsResults List
- WSHandlerResult wsResults =
+
+ // Retrieve the wsResults List
+ WSHandlerResult wsResults =
secEngine.processSecurityHeader(doc, null, callbackHandler, crypto);
boolean found = false;
-
+
for (int i = 0; i < wsResults.getResults().size(); i++) {
WSSecurityEngineResult wsSecEngineResult = wsResults.getResults().get(i);
int action = (Integer)
wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION);
-
+
// We want to filter only encryption results
if (action != WSConstants.ENCR) {
continue;
}
List<WSDataRef> dataRefs = (List<WSDataRef>)wsSecEngineResult
.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
-
- //We want check only the DATA_REF_URIS
+
+ //We want check only the DATA_REF_URIS
if (dataRefs != null && dataRefs.size() > 0) {
for (int j = 0; j < dataRefs.size(); j++) {
- Object obj = dataRefs.get(i);
+ Object obj = dataRefs.get(i);
// ReferenceList Processor must Return a WSDataRef objects
assertTrue(obj instanceof WSDataRef);
@@ -169,13 +169,13 @@ public class EncryptedKeyDataRefTest ext
// Check whether QName is correctly set
assertEquals("add", dataRef.getName().getLocalPart());
assertEquals(
- "http://ws.apache.org/counter/counter_port_type",
+ "http://ws.apache.org/counter/counter_port_type",
dataRef.getName().getNamespaceURI()
);
// Check whether wsu:Id is set
assertNotNull(dataRef.getWsuId());
-
+
// Check the encryption algorithm was set
assertEquals(WSConstants.TRIPLE_DES, dataRef.getAlgorithm());
@@ -185,10 +185,10 @@ public class EncryptedKeyDataRefTest ext
}
}
}
-
+
// Make sure the element is actually found in the decrypted elements
assertTrue(found);
-
+
}
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/ReferenceListDataRefTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/ReferenceListDataRefTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/ReferenceListDataRefTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/processor/ReferenceListDataRefTest.java Tue Dec 15 16:40:37 2015
@@ -41,39 +41,39 @@ import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
- * Test that checks for correct WSDataRef which should be returned by
- * <code>org.apache.wss4j.dom.processor.ReferenceListProcessor</code>
- *
+ * Test that checks for correct WSDataRef which should be returned by
+ * <code>org.apache.wss4j.dom.processor.ReferenceListProcessor</code>
+ *
* This test uses the RSA_15 algorithm to transport (wrap) the symmetric key.
* The test case creates a ReferenceList element that references EncryptedData
* elements. The ReferencesList element is put into the Security header, not
* as child of the EncryptedKey. The EncryptedData elements contain a KeyInfo
* that references the EncryptedKey via a STR/Reference structure.
- *
- * WSDataRef object must contain the correct QName of the decrypted element.
- *
+ *
+ * WSDataRef object must contain the correct QName of the decrypted element.
+ *
*/
public class ReferenceListDataRefTest extends org.junit.Assert {
- private static final org.slf4j.Logger LOG =
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(ReferenceListDataRefTest.class);
private WSSecurityEngine secEngine = new WSSecurityEngine();
private CallbackHandler callbackHandler = new KeystoreCallbackHandler();
private Crypto crypto = null;
-
+
@org.junit.AfterClass
public static void cleanup() throws Exception {
SecurityTestUtil.cleanup();
}
-
+
public ReferenceListDataRefTest() throws Exception {
crypto = CryptoFactory.getInstance("wss40.properties");
WSSConfig.init();
}
/**
- * Test that check for correct WSDataRef object from ReferenceList Processor
- *
- *
+ * Test that check for correct WSDataRef object from ReferenceList Processor
+ *
+ *
* @throws Exception
* Thrown when there is an error in encryption or decryption
*/
@@ -96,7 +96,7 @@ public class ReferenceListDataRefTest ex
/*
* Set up the parts structure to encrypt the body
*/
- WSEncryptionPart encP =
+ WSEncryptionPart encP =
new WSEncryptionPart(
"add", "http://ws.apache.org/counter/counter_port_type", "Element"
);
@@ -127,35 +127,35 @@ public class ReferenceListDataRefTest ex
/**
* Verifies the soap envelope <p/>
- *
+ *
* @param envelope
* @throws Exception
* Thrown when there is a problem in verification
*/
@SuppressWarnings("unchecked")
private void checkDataRef(Document doc) throws Exception {
-
- // Retrieve the wsResults List
- WSHandlerResult wsResults =
+
+ // Retrieve the wsResults List
+ WSHandlerResult wsResults =
secEngine.processSecurityHeader(doc, null, callbackHandler, crypto);
boolean found = false;
-
+
for (int i = 0; i < wsResults.getResults().size(); i++) {
WSSecurityEngineResult wsSecEngineResult = wsResults.getResults().get(i);
int action = (Integer)
wsSecEngineResult.get(WSSecurityEngineResult.TAG_ACTION);
-
+
// We want to filter only encryption results
if (action != WSConstants.ENCR) {
continue;
}
- List<WSDataRef> dataRefs =
+ List<WSDataRef> dataRefs =
(List<WSDataRef>)wsSecEngineResult.get(WSSecurityEngineResult.TAG_DATA_REF_URIS);
-
- //We want check only the DATA_REF_URIS
+
+ //We want check only the DATA_REF_URIS
if (dataRefs != null && dataRefs.size() > 0) {
for (int j = 0; j < dataRefs.size(); j++) {
- Object obj = dataRefs.get(i);
+ Object obj = dataRefs.get(i);
// ReferenceList Processor must Return a WSDataRef objects
assertTrue(obj instanceof WSDataRef);
@@ -165,13 +165,13 @@ public class ReferenceListDataRefTest ex
// Check whether QName is correctly set
assertEquals("add", dataRef.getName().getLocalPart());
assertEquals(
- "http://ws.apache.org/counter/counter_port_type",
+ "http://ws.apache.org/counter/counter_port_type",
dataRef.getName().getNamespaceURI()
);
// Check whether wsu:Id is set
assertNotNull(dataRef.getWsuId());
-
+
// Check the encryption algorithm was set
assertEquals(WSConstants.TRIPLE_DES, dataRef.getAlgorithm());
@@ -181,10 +181,10 @@ public class ReferenceListDataRefTest ex
}
}
}
-
+
// Make sure the element is actually found in the decrypted elements
assertTrue(found);
-
+
}
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAlgorithmSuiteTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAlgorithmSuiteTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAlgorithmSuiteTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAlgorithmSuiteTest.java Tue Dec 15 16:40:37 2015
@@ -47,15 +47,15 @@ import org.apache.wss4j.dom.util.WSSecur
* SAML (HOK) assertion when specifying an AlgorithmSuite policy.
*/
public class SamlAlgorithmSuiteTest extends org.junit.Assert {
- private static final org.slf4j.Logger LOG =
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(SamlAlgorithmSuiteTest.class);
private Crypto crypto = null;
-
+
@org.junit.AfterClass
public static void cleanup() throws Exception {
SecurityTestUtil.cleanup();
}
-
+
public SamlAlgorithmSuiteTest() throws Exception {
WSSConfig.init();
crypto = CryptoFactory.getInstance("crypto.properties");
@@ -67,11 +67,11 @@ public class SamlAlgorithmSuiteTest exte
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY);
callbackHandler.setIssuer("www.example.com");
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-
+
samlAssertion.signAssertion("16c73ab6-b892-458f-abf5-2f875f74882e", "security", crypto, false);
WSSecSAMLToken wsSign = new WSSecSAMLToken();
@@ -79,43 +79,43 @@ public class SamlAlgorithmSuiteTest exte
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(signedDoc);
LOG.debug(outputString);
}
-
+
Element securityHeader = WSSecurityUtil.getSecurityHeader(signedDoc, null);
AlgorithmSuite algorithmSuite = createAlgorithmSuite();
-
+
verify(securityHeader, algorithmSuite, crypto);
-
+
algorithmSuite.setMinimumAsymmetricKeyLength(1024);
-
+
try {
verify(securityHeader, algorithmSuite, crypto);
fail("Expected failure as 512-bit keys are not allowed");
} catch (WSSecurityException ex) {
- assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
+ assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
}
}
-
+
@org.junit.Test
public void testDSASignedSAML11Assertion() throws Exception {
Crypto dsaCrypto = CryptoFactory.getInstance("wss40.properties");
-
+
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY);
callbackHandler.setIssuer("www.example.com");
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-
+
samlAssertion.signAssertion("wss40DSA", "security", dsaCrypto, false);
WSSecSAMLToken wsSign = new WSSecSAMLToken();
@@ -123,40 +123,40 @@ public class SamlAlgorithmSuiteTest exte
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(signedDoc);
LOG.debug(outputString);
}
-
+
Element securityHeader = WSSecurityUtil.getSecurityHeader(signedDoc, null);
AlgorithmSuite algorithmSuite = createAlgorithmSuite();
-
+
try {
verify(securityHeader, algorithmSuite, dsaCrypto);
fail("Expected failure as DSA is not allowed");
} catch (WSSecurityException ex) {
- assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
+ assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
}
-
+
algorithmSuite.addSignatureMethod(WSConstants.DSA);
verify(securityHeader, algorithmSuite, dsaCrypto);
}
-
+
@org.junit.Test
public void testC14nMethod() throws Exception {
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setConfirmationMethod(SAML1Constants.CONF_HOLDER_KEY);
callbackHandler.setIssuer("www.example.com");
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-
+
samlAssertion.signAssertion(
"16c73ab6-b892-458f-abf5-2f875f74882e", "security", crypto, false,
WSConstants.C14N_EXCL_WITH_COMMENTS, WSConstants.RSA_SHA1);
@@ -166,25 +166,25 @@ public class SamlAlgorithmSuiteTest exte
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document signedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(signedDoc);
LOG.debug(outputString);
}
-
+
Element securityHeader = WSSecurityUtil.getSecurityHeader(signedDoc, null);
AlgorithmSuite algorithmSuite = createAlgorithmSuite();
-
+
try {
verify(securityHeader, algorithmSuite, crypto);
fail("Expected failure as C14n algorithm is not allowed");
} catch (WSSecurityException ex) {
- assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
+ assertTrue(ex.getErrorCode() == WSSecurityException.ErrorCode.INVALID_SECURITY);
}
-
+
algorithmSuite.addC14nAlgorithm(WSConstants.C14N_EXCL_WITH_COMMENTS);
verify(securityHeader, algorithmSuite, crypto);
}
@@ -195,7 +195,7 @@ public class SamlAlgorithmSuiteTest exte
algorithmSuite.setMinimumAsymmetricKeyLength(512);
algorithmSuite.addC14nAlgorithm(WSConstants.C14N_EXCL_OMIT_COMMENTS);
algorithmSuite.addDigestAlgorithm(WSConstants.SHA1);
-
+
return algorithmSuite;
}
@@ -207,7 +207,7 @@ public class SamlAlgorithmSuiteTest exte
data.setSigVerCrypto(sigVerCrypto);
data.setSamlAlgorithmSuite(algorithmSuite);
data.setValidateSamlSubjectConfirmation(false);
-
+
return secEngine.processSecurityHeader(securityHeader, data);
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAuthnTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAuthnTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAuthnTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlAuthnTest.java Tue Dec 15 16:40:37 2015
@@ -45,10 +45,10 @@ import org.w3c.dom.Document;
* Some tests for SAML Authentication Assertions
*/
public class SamlAuthnTest extends org.junit.Assert {
- private static final org.slf4j.Logger LOG =
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(SamlAuthnTest.class);
private WSSecurityEngine secEngine = new WSSecurityEngine();
-
+
@org.junit.AfterClass
public static void cleanup() throws Exception {
SecurityTestUtil.cleanup();
@@ -60,102 +60,102 @@ public class SamlAuthnTest extends org.j
config.setValidator(WSConstants.SAML2_TOKEN, new CustomSamlAssertionValidator());
secEngine.setWssConfig(config);
}
-
+
@org.junit.Test
public void testSAML1AuthnAssertion() throws Exception {
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
createAndVerifyMessage(callbackHandler, true);
}
-
+
@org.junit.Test
public void testSAML2AuthnAssertion() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
createAndVerifyMessage(callbackHandler, true);
}
-
+
@org.junit.Test
public void testSAML1FutureAuthnInstant() throws Exception {
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
callbackHandler.setAuthenticationInstant(new DateTime().plusMinutes(70));
-
+
createAndVerifyMessage(callbackHandler, false);
}
-
+
@org.junit.Test
public void testSAML2FutureAuthnInstant() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
callbackHandler.setAuthenticationInstant(new DateTime().plusMinutes(70));
-
+
createAndVerifyMessage(callbackHandler, false);
}
-
+
@org.junit.Test
public void testSAML2StaleSessionNotOnOrAfter() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
callbackHandler.setSessionNotOnOrAfter(new DateTime().minusMinutes(70));
-
+
createAndVerifyMessage(callbackHandler, false);
}
-
+
@org.junit.Test
public void testSAML1ValidSubjectLocality() throws Exception {
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
callbackHandler.setSubjectLocality("127.0.0.1", "xyz.ws.apache.org"); //NOPMD
-
+
createAndVerifyMessage(callbackHandler, true);
}
-
+
@org.junit.Test
public void testSAML2ValidSubjectLocality() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
callbackHandler.setSubjectLocality("127.0.0.1", "xyz.ws.apache.org"); //NOPMD
-
+
createAndVerifyMessage(callbackHandler, true);
}
-
+
@org.junit.Test
public void testSAML1InvalidSubjectLocality() throws Exception {
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
callbackHandler.setSubjectLocality("xyz.ws.apache.org", "xyz.ws.apache.org");
-
+
createAndVerifyMessage(callbackHandler, false);
}
-
+
@org.junit.Test
public void testSAML2InalidSubjectLocality() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
callbackHandler.setSubjectLocality("xyz.ws.apache.org", "xyz.ws.apache.org");
-
+
createAndVerifyMessage(callbackHandler, false);
}
-
+
private void createAndVerifyMessage(
CallbackHandler samlCallbackHandler, boolean success
) throws Exception {
@@ -168,15 +168,15 @@ public class SamlAuthnTest extends org.j
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
LOG.debug(outputString);
}
-
+
try {
verify(unsignedDoc);
if (!success) {
@@ -187,23 +187,23 @@ public class SamlAuthnTest extends org.j
assertTrue(ex.getMessage().contains("SAML token security failure"));
}
}
-
+
/**
* Verifies the soap envelope
* <p/>
- *
- * @param envelope
+ *
+ * @param envelope
* @throws Exception Thrown when there is a problem in verification
*/
private WSHandlerResult verify(Document doc) throws Exception {
RequestData requestData = new RequestData();
requestData.setValidateSamlSubjectConfirmation(false);
-
+
WSHandlerResult results = secEngine.processSecurityHeader(doc, requestData);
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(doc);
assertTrue(outputString.indexOf("counter_port_type") > 0 ? true : false);
return results;
}
-
+
}
Modified: webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlConditionsTest.java
URL: http://svn.apache.org/viewvc/webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlConditionsTest.java?rev=1720192&r1=1720191&r2=1720192&view=diff
==============================================================================
--- webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlConditionsTest.java (original)
+++ webservices/wss4j/trunk/ws-security-dom/src/test/java/org/apache/wss4j/dom/saml/SamlConditionsTest.java Tue Dec 15 16:40:37 2015
@@ -55,10 +55,10 @@ import org.w3c.dom.Document;
* Test-case for sending and processing an a SAML Token with a custom Conditions element.
*/
public class SamlConditionsTest extends org.junit.Assert {
- private static final org.slf4j.Logger LOG =
+ private static final org.slf4j.Logger LOG =
org.slf4j.LoggerFactory.getLogger(SamlConditionsTest.class);
private WSSecurityEngine secEngine = new WSSecurityEngine();
-
+
@org.junit.AfterClass
public static void cleanup() throws Exception {
SecurityTestUtil.cleanup();
@@ -70,7 +70,7 @@ public class SamlConditionsTest extends
config.setValidator(WSConstants.SAML2_TOKEN, new CustomSamlAssertionValidator());
secEngine.setWssConfig(config);
}
-
+
/**
* Test that creates, sends and processes an unsigned SAML 1.1 authentication assertion
* with a custom Conditions statement.
@@ -80,16 +80,16 @@ public class SamlConditionsTest extends
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
DateTime notBefore = new DateTime();
conditions.setNotBefore(notBefore);
conditions.setNotAfter(notBefore.plusMinutes(20));
callbackHandler.setConditions(conditions);
-
+
createAndVerifyMessage(callbackHandler, true);
}
-
+
/**
* Test that creates, sends and processes an unsigned SAML 2 authentication assertion
* with an (invalid) custom Conditions statement.
@@ -99,56 +99,56 @@ public class SamlConditionsTest extends
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
DateTime notBefore = new DateTime();
conditions.setNotBefore(notBefore.minusMinutes(5));
conditions.setNotAfter(notBefore.minusMinutes(3));
callbackHandler.setConditions(conditions);
-
+
createAndVerifyMessage(callbackHandler, false);
}
-
+
@org.junit.Test
public void testSAML2StaleNotOnOrAfter() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
DateTime notBefore = new DateTime();
conditions.setNotAfter(notBefore.minusMinutes(60));
conditions.setNotBefore(notBefore.minusMinutes(70));
callbackHandler.setConditions(conditions);
-
+
createAndVerifyMessage(callbackHandler, false);
}
-
+
@org.junit.Test
public void testSAML2FutureNotBefore() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
DateTime notBefore = new DateTime();
conditions.setNotAfter(new DateTime().plusMinutes(70));
conditions.setNotBefore(notBefore.plusMinutes(60));
callbackHandler.setConditions(conditions);
-
+
createAndVerifyMessage(callbackHandler, false);
}
-
+
@org.junit.Test
public void testSAML2FutureIssueInstant() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-
+
DateTime issueInstant = new DateTime();
issueInstant = issueInstant.plusMinutes(60);
samlAssertion.getSaml2().setIssueInstant(issueInstant);
@@ -158,16 +158,16 @@ public class SamlConditionsTest extends
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
LOG.debug("SAML 2 Authn Assertion (sender vouches):");
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
LOG.debug(outputString);
}
-
+
try {
verify(unsignedDoc);
fail("Failure expected in processing the SAML Conditions element");
@@ -175,17 +175,17 @@ public class SamlConditionsTest extends
assertTrue(ex.getMessage().contains("SAML token security failure"));
}
}
-
+
@org.junit.Test
public void testSAML2StaleIssueInstant() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-
+
DateTime issueInstant = new DateTime();
issueInstant = issueInstant.minusMinutes(31);
samlAssertion.getSaml2().setIssueInstant(issueInstant);
@@ -196,16 +196,16 @@ public class SamlConditionsTest extends
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
LOG.debug("SAML 2 Authn Assertion (sender vouches):");
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
LOG.debug(outputString);
}
-
+
try {
verify(unsignedDoc);
fail("Failure expected in processing a stale SAML Assertion");
@@ -213,21 +213,21 @@ public class SamlConditionsTest extends
assertTrue(ex.getMessage().contains("SAML token security failure"));
}
}
-
+
@org.junit.Test
public void testSAML2StaleIssueInstantButWithNotOnOrAfter() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-
+
ConditionsBean conditions = new ConditionsBean();
conditions.setNotBefore(new DateTime());
conditions.setNotAfter(new DateTime().plusMinutes(35));
-
+
DateTime issueInstant = new DateTime();
issueInstant = issueInstant.minusMinutes(31);
samlAssertion.getSaml2().setIssueInstant(issueInstant);
@@ -237,29 +237,29 @@ public class SamlConditionsTest extends
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
LOG.debug("SAML 2 Authn Assertion (sender vouches):");
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
LOG.debug(outputString);
}
-
+
verify(unsignedDoc);
}
-
+
@org.junit.Test
public void testSAML1StaleIssueInstant() throws Exception {
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
-
+
DateTime issueInstant = new DateTime();
issueInstant = issueInstant.minusMinutes(31);
samlAssertion.getSaml1().setIssueInstant(issueInstant);
@@ -270,16 +270,16 @@ public class SamlConditionsTest extends
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
LOG.debug("SAML 1 Authn Assertion (sender vouches):");
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
LOG.debug(outputString);
}
-
+
try {
verify(unsignedDoc);
fail("Failure expected in processing a stale SAML Assertion");
@@ -287,7 +287,7 @@ public class SamlConditionsTest extends
assertTrue(ex.getMessage().contains("SAML token security failure"));
}
}
-
+
/**
* Test that creates, sends and processes an unsigned SAML 2 authentication assertion
* with an (invalid) custom Conditions statement.
@@ -297,16 +297,16 @@ public class SamlConditionsTest extends
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
DateTime notBefore = new DateTime();
conditions.setNotBefore(notBefore.plusMinutes(2));
conditions.setNotAfter(notBefore.plusMinutes(5));
callbackHandler.setConditions(conditions);
-
+
createAndVerifyMessage(callbackHandler, false);
}
-
+
/**
* Test that creates, sends and processes an unsigned SAML 2 authentication assertion
* with a Conditions statement that has a NotBefore "in the future".
@@ -316,16 +316,16 @@ public class SamlConditionsTest extends
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
DateTime notBefore = new DateTime();
conditions.setNotBefore(notBefore.plusSeconds(30));
conditions.setNotAfter(notBefore.plusMinutes(5));
callbackHandler.setConditions(conditions);
-
+
createAndVerifyMessage(callbackHandler, true);
}
-
+
/**
* Test that creates, sends and processes an unsigned SAML 2 authentication assertion
* with a OneTimeUse Element
@@ -335,13 +335,13 @@ public class SamlConditionsTest extends
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
conditions.setTokenPeriodMinutes(5);
conditions.setOneTimeUse(true);
-
+
callbackHandler.setConditions(conditions);
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
@@ -351,19 +351,19 @@ public class SamlConditionsTest extends
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
assertTrue(outputString.contains("OneTimeUse"));
if (LOG.isDebugEnabled()) {
LOG.debug(outputString);
}
-
+
verify(unsignedDoc);
}
-
+
/**
* Test that creates, sends and processes an unsigned SAML 2 authentication assertion
* with a ProxyRestriction Element
@@ -373,7 +373,7 @@ public class SamlConditionsTest extends
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
conditions.setTokenPeriodMinutes(5);
ProxyRestrictionBean proxyRestriction = new ProxyRestrictionBean();
@@ -383,9 +383,9 @@ public class SamlConditionsTest extends
proxyRestriction.getAudienceURIs().addAll(audiences);
proxyRestriction.setCount(5);
conditions.setProxyRestriction(proxyRestriction);
-
+
callbackHandler.setConditions(conditions);
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
@@ -395,19 +395,19 @@ public class SamlConditionsTest extends
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
assertTrue(outputString.contains("ProxyRestriction"));
if (LOG.isDebugEnabled()) {
LOG.debug(outputString);
}
-
+
verify(unsignedDoc);
}
-
+
/**
* Test that creates, sends and processes an unsigned SAML 2 authentication assertion
* with an AudienceRestriction Element
@@ -417,7 +417,7 @@ public class SamlConditionsTest extends
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
conditions.setTokenPeriodMinutes(5);
List<String> audiences = new ArrayList<>();
@@ -426,9 +426,9 @@ public class SamlConditionsTest extends
AudienceRestrictionBean audienceRestrictionBean = new AudienceRestrictionBean();
audienceRestrictionBean.setAudienceURIs(audiences);
conditions.setAudienceRestrictions(Collections.singletonList(audienceRestrictionBean));
-
+
callbackHandler.setConditions(conditions);
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
@@ -438,26 +438,26 @@ public class SamlConditionsTest extends
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
assertTrue(outputString.contains("AudienceRestriction"));
if (LOG.isDebugEnabled()) {
LOG.debug(outputString);
}
-
+
verify(unsignedDoc);
}
-
+
// Now test AudienceRestrictions with supplied restrictions
@org.junit.Test
public void testSAML2AudienceRestrictionVerification() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
conditions.setTokenPeriodMinutes(5);
List<String> audiences = new ArrayList<>();
@@ -466,9 +466,9 @@ public class SamlConditionsTest extends
AudienceRestrictionBean audienceRestrictionBean = new AudienceRestrictionBean();
audienceRestrictionBean.setAudienceURIs(audiences);
conditions.setAudienceRestrictions(Collections.singletonList(audienceRestrictionBean));
-
+
callbackHandler.setConditions(conditions);
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
@@ -478,46 +478,46 @@ public class SamlConditionsTest extends
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
assertTrue(outputString.contains("AudienceRestriction"));
if (LOG.isDebugEnabled()) {
LOG.debug(outputString);
}
-
+
// This should fail as the expected audience isn't in the assertion
audiences.clear();
audiences.add("http://apache.org/three");
-
+
WSSecurityEngine newEngine = new WSSecurityEngine();
RequestData data = new RequestData();
data.setAudienceRestrictions(audiences);
data.setValidateSamlSubjectConfirmation(false);
-
+
try {
newEngine.processSecurityHeader(doc, data);
fail("Failure expected on a bad audience restriction");
} catch (WSSecurityException ex) {
assertTrue(ex.getMessage().contains("SAML token security failure"));
}
-
+
// Now add the correct audience back in...
audiences.add("http://apache.org/one");
data.setAudienceRestrictions(audiences);
-
+
newEngine.processSecurityHeader(doc, data);
}
-
+
// Now test AudienceRestrictions with supplied restrictions
@org.junit.Test
public void testSAML1AudienceRestrictionVerification() throws Exception {
SAML1CallbackHandler callbackHandler = new SAML1CallbackHandler();
callbackHandler.setStatement(SAML1CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
conditions.setTokenPeriodMinutes(5);
List<String> audiences = new ArrayList<>();
@@ -526,9 +526,9 @@ public class SamlConditionsTest extends
AudienceRestrictionBean audienceRestrictionBean = new AudienceRestrictionBean();
audienceRestrictionBean.setAudienceURIs(audiences);
conditions.setAudienceRestrictions(Collections.singletonList(audienceRestrictionBean));
-
+
callbackHandler.setConditions(conditions);
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
@@ -538,39 +538,39 @@ public class SamlConditionsTest extends
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
assertTrue(outputString.contains("AudienceRestriction"));
if (LOG.isDebugEnabled()) {
LOG.debug(outputString);
}
-
+
// This should fail as the expected audience isn't in the assertion
audiences.clear();
audiences.add("http://apache.org/three");
-
+
WSSecurityEngine newEngine = new WSSecurityEngine();
RequestData data = new RequestData();
data.setAudienceRestrictions(audiences);
data.setValidateSamlSubjectConfirmation(false);
-
+
try {
newEngine.processSecurityHeader(doc, data);
fail("Failure expected on a bad audience restriction");
} catch (WSSecurityException ex) {
assertTrue(ex.getMessage().contains("SAML token security failure"));
}
-
+
// Now add the correct audience back in...
audiences.add("http://apache.org/one");
data.setAudienceRestrictions(audiences);
-
+
newEngine.processSecurityHeader(doc, data);
}
-
+
/**
* Test that creates, sends and processes an unsigned SAML 2 authentication assertion
* with two AudienceRestriction Elements
@@ -580,23 +580,23 @@ public class SamlConditionsTest extends
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
conditions.setTokenPeriodMinutes(5);
-
+
List<AudienceRestrictionBean> audiencesRestrictions = new ArrayList<>();
AudienceRestrictionBean audienceRestrictionBean = new AudienceRestrictionBean();
audienceRestrictionBean.setAudienceURIs(Collections.singletonList("http://apache.org/one"));
audiencesRestrictions.add(audienceRestrictionBean);
-
+
audienceRestrictionBean = new AudienceRestrictionBean();
audienceRestrictionBean.setAudienceURIs(Collections.singletonList("http://apache.org/two"));
audiencesRestrictions.add(audienceRestrictionBean);
-
+
conditions.setAudienceRestrictions(audiencesRestrictions);
-
+
callbackHandler.setConditions(conditions);
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
@@ -606,42 +606,42 @@ public class SamlConditionsTest extends
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
assertTrue(outputString.contains("AudienceRestriction"));
if (LOG.isDebugEnabled()) {
LOG.debug(outputString);
}
-
+
verify(unsignedDoc);
}
-
+
// Now test AudienceRestrictions with supplied restrictions
@org.junit.Test
public void testSAML2AudienceRestrictionSeparateRestrictionsValidation() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
conditions.setTokenPeriodMinutes(5);
-
+
List<AudienceRestrictionBean> audiencesRestrictions = new ArrayList<>();
AudienceRestrictionBean audienceRestrictionBean = new AudienceRestrictionBean();
audienceRestrictionBean.setAudienceURIs(Collections.singletonList("http://apache.org/one"));
audiencesRestrictions.add(audienceRestrictionBean);
-
+
audienceRestrictionBean = new AudienceRestrictionBean();
audienceRestrictionBean.setAudienceURIs(Collections.singletonList("http://apache.org/two"));
audiencesRestrictions.add(audienceRestrictionBean);
-
+
conditions.setAudienceRestrictions(audiencesRestrictions);
-
+
callbackHandler.setConditions(conditions);
-
+
SAMLCallback samlCallback = new SAMLCallback();
SAMLUtil.doSAMLCallback(callbackHandler, samlCallback);
SamlAssertionWrapper samlAssertion = new SamlAssertionWrapper(samlCallback);
@@ -651,66 +651,66 @@ public class SamlConditionsTest extends
Document doc = SOAPUtil.toSOAPPart(SOAPUtil.SAMPLE_SOAP_MSG);
WSSecHeader secHeader = new WSSecHeader(doc);
secHeader.insertSecurityHeader();
-
+
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
assertTrue(outputString.contains("AudienceRestriction"));
if (LOG.isDebugEnabled()) {
LOG.debug(outputString);
}
-
+
// This should fail as the expected audience isn't in the assertion
List<String> audiences = new ArrayList<>();
audiences.add("http://apache.org/three");
-
+
WSSecurityEngine newEngine = new WSSecurityEngine();
RequestData data = new RequestData();
data.setAudienceRestrictions(audiences);
data.setValidateSamlSubjectConfirmation(false);
-
+
try {
newEngine.processSecurityHeader(doc, data);
fail("Failure expected on a bad audience restriction");
} catch (WSSecurityException ex) {
assertTrue(ex.getMessage().contains("SAML token security failure"));
}
-
+
// Now add the correct audience back in...
audiences.add("http://apache.org/one");
data.setAudienceRestrictions(audiences);
-
+
newEngine.processSecurityHeader(doc, data);
}
-
+
@org.junit.Test
public void testSAML2Delegate() throws Exception {
SAML2CallbackHandler callbackHandler = new SAML2CallbackHandler();
callbackHandler.setStatement(SAML2CallbackHandler.Statement.AUTHN);
callbackHandler.setIssuer("www.example.com");
-
+
ConditionsBean conditions = new ConditionsBean();
DateTime notBefore = new DateTime();
conditions.setNotBefore(notBefore);
conditions.setNotAfter(notBefore.plusMinutes(20));
-
+
DelegateBean delegate = new DelegateBean();
delegate.setDelegationInstant(DateTime.now());
delegate.setConfirmationMethod(SAML2Constants.CONF_BEARER);
-
+
NameIDBean nameID = new NameIDBean();
nameID.setNameValue("bob");
nameID.setNameQualifier("www.example.com");
delegate.setNameIDBean(nameID);
-
+
conditions.setDelegates(Collections.singletonList(delegate));
-
+
callbackHandler.setConditions(conditions);
-
+
createAndVerifyMessage(callbackHandler, true);
}
-
+
private void createAndVerifyMessage(
CallbackHandler samlCallbackHandler, boolean success
) throws Exception {
@@ -727,7 +727,7 @@ public class SamlConditionsTest extends
Document unsignedDoc = wsSign.build(doc, samlAssertion, secHeader);
if (LOG.isDebugEnabled()) {
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(unsignedDoc);
LOG.debug(outputString);
}
@@ -742,23 +742,23 @@ public class SamlConditionsTest extends
assertTrue(ex.getMessage().contains("SAML token security failure"));
}
}
-
+
/**
* Verifies the soap envelope
* <p/>
- *
- * @param envelope
+ *
+ * @param envelope
* @throws Exception Thrown when there is a problem in verification
*/
private WSHandlerResult verify(Document doc) throws Exception {
RequestData requestData = new RequestData();
requestData.setValidateSamlSubjectConfirmation(false);
-
+
WSHandlerResult results = secEngine.processSecurityHeader(doc, requestData);
- String outputString =
+ String outputString =
XMLUtils.PrettyDocumentToString(doc);
assertTrue(outputString.indexOf("counter_port_type") > 0 ? true : false);
return results;
}
-
+
}