Methods Summary |
---|
private java.io.Reader | getResourceReader(java.lang.String resourceName)
return new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName));
|
protected void | setUp()
|
public static junit.framework.Test | suite()
TestSuite suite = new TestSuite(AsymmetricBindingTest.class);
return suite;
|
protected void | tearDown()
|
public void | testAsymmerticBinding1()
String fileName="security/AsymmetricBindingAssertion1.xml";
Policy policy = unmarshalPolicy(fileName);
Iterator <AssertionSet> itr = policy.iterator();
if(itr.hasNext()) {
AssertionSet as = itr.next();
for(PolicyAssertion assertion : as) {
assertEquals("Invalid assertion", "AsymmetricBinding",assertion.getName().getLocalPart());
AsymmetricBinding asb = (AsymmetricBinding)assertion;
X509Token tkn1 = (X509Token)asb.getInitiatorToken();
assertTrue(tkn1.getTokenType().equals(com.sun.xml.ws.security.impl.policy.X509Token.WSSX509V1TOKEN10));
X509Token tkn2 = (X509Token)asb.getRecipientToken();
assertTrue(tkn2.getTokenType().equals(com.sun.xml.ws.security.impl.policy.X509Token.WSSX509V3TOKEN11));
assertFalse("Tokens are Protected", asb.getTokenProtection());
AlgorithmSuite aSuite = asb.getAlgorithmSuite();
assertEquals("Unmatched Algorithm",aSuite.getEncryptionAlgorithm(), AlgorithmSuiteValue.TripleDesRsa15.getEncAlgorithm());
assertTrue(asb.isIncludeTimeStamp());
assertFalse("Signature is Encrypted", asb.getSignatureProtection());
assertFalse(asb.isSignContent());
}
}
|
public void | testAsymmerticBinding2()
String fileName="security/AsymmetricBindingAssertion2.xml";
Policy policy = unmarshalPolicy(fileName);
Iterator <AssertionSet> itr = policy.iterator();
if(itr.hasNext()) {
AssertionSet as = itr.next();
for(PolicyAssertion assertion : as) {
assertEquals("Invalid assertion", "AsymmetricBinding",assertion.getName().getLocalPart());
AsymmetricBinding asb = (AsymmetricBinding)assertion;
X509Token tkn1 = (X509Token)asb.getInitiatorToken();
assertTrue(tkn1.getTokenType().equals(com.sun.xml.ws.security.impl.policy.X509Token.WSSX509V1TOKEN10));
X509Token tkn2 = (X509Token)asb.getRecipientToken();
assertTrue(tkn2.getTokenType().equals(com.sun.xml.ws.security.impl.policy.X509Token.WSSX509V3TOKEN11));
AlgorithmSuite aSuite = asb.getAlgorithmSuite();
assertEquals("Unmatched Algorithm",aSuite.getEncryptionAlgorithm(), AlgorithmSuiteValue.TripleDesRsa15.getEncAlgorithm());
assertTrue(asb.isIncludeTimeStamp());
assertTrue("Signature is not Encrypted", asb.getSignatureProtection());
assertTrue("Tokens are not protected", asb.getTokenProtection());
assertEquals("SIGN_ENCRYPT is the protection order",com.sun.xml.ws.security.impl.policy.AsymmetricBinding.ENCRYPT_SIGN,asb.getProtectionOrder());
}
}
|
public void | testAsymmerticCR6420594()
String fileName="security/AsymmetricCR.xml";
Policy policy = unmarshalPolicy(fileName);
Iterator <AssertionSet> itr = policy.iterator();
if(itr.hasNext()) {
AssertionSet as = itr.next();
for(PolicyAssertion assertion : as) {
assertEquals("Invalid assertion", "AsymmetricBinding",assertion.getName().getLocalPart());
AsymmetricBinding asb = (AsymmetricBinding)assertion;
X509Token tkn1 = (X509Token)asb.getInitiatorToken();
assertTrue(tkn1.getIncludeToken().equals(Token.INCLUDE_ALWAYS));
assertTrue(tkn1.getTokenType().equals(com.sun.xml.ws.security.impl.policy.X509Token.WSSX509V3TOKEN10));
X509Token tkn2 = (X509Token)asb.getRecipientToken();
assertTrue(tkn2.getIncludeToken().equals(Token.INCLUDE_ALWAYS));
assertTrue(tkn2.getTokenType().equals(com.sun.xml.ws.security.impl.policy.X509Token.WSSX509V3TOKEN10));
}
}
|
public com.sun.xml.ws.policy.Policy | unmarshalPolicy(java.lang.String xmlFile)
PolicySourceModel model = unmarshalPolicyResource(
xmlFile);
Policy mbp = PolicyModelTranslator.getTranslator().translate(model);
return mbp;
|
private com.sun.xml.ws.policy.sourcemodel.PolicySourceModel | unmarshalPolicyResource(java.lang.String resource)
Reader reader = getResourceReader(resource);
PolicySourceModel model = PolicyModelUnmarshaller.getXmlUnmarshaller().unmarshalModel(reader);
reader.close();
return model;
|