Methods Summary |
---|
private java.io.Reader | getResourceReader(java.lang.String resourceName)
ClassLoader cl = Thread.currentThread().getContextClassLoader();
if(cl==null) {
return new InputStreamReader(ClassLoader.getSystemResourceAsStream(resourceName));
} else {
return new InputStreamReader(cl.getResourceAsStream(resourceName));
}
|
protected void | setUp()
|
public static junit.framework.Test | suite()
TestSuite suite = new TestSuite(SymmetricBindingTest.class);
return suite;
|
protected void | tearDown()
|
public void | testSymmerticBinding1()
String fileName="security/SymmetricBindingAssertion1.xml";
Policy policy = unmarshalPolicy(fileName);
Iterator <AssertionSet> itr = policy.iterator();
if(itr.hasNext()) {
AssertionSet as = itr.next();
for(PolicyAssertion assertion : as) {
assertEquals("Invalid assertion", "SymmetricBinding",assertion.getName().getLocalPart());
SymmetricBinding sb = (SymmetricBinding)assertion;
// System.out.println((sb.getProtectionToken().getIncludeToken()));
assertTrue(sb.getTokenProtection());
AlgorithmSuite aSuite = sb.getAlgorithmSuite();
assertEquals("Unmatched Algorithm",aSuite.getEncryptionAlgorithm(), AlgorithmSuiteValue.Basic128.getEncAlgorithm());
assertTrue(sb.isIncludeTimeStamp());
assertFalse("Signature is Encrypted", sb.getSignatureProtection());
assertFalse(sb.isSignContent());
}
}
|
public void | testSymmerticBinding2()
String fileName="security/SymmetricBindingAssertion2.xml";
Policy policy = unmarshalPolicy(fileName);
Iterator <AssertionSet> itr = policy.iterator();
if(itr.hasNext()) {
AssertionSet as = itr.next();
for(PolicyAssertion assertion : as) {
assertEquals("Invalid assertion", "SymmetricBinding",assertion.getName().getLocalPart());
SymmetricBinding sb = (SymmetricBinding)assertion;
X509Token tkn1 = (X509Token)sb.getSignatureToken();
assertTrue(tkn1.getTokenType().equals(com.sun.xml.ws.security.impl.policy.X509Token.WSSX509V1TOKEN10));
X509Token tkn2 = (X509Token)sb.getEncryptionToken();
assertTrue(tkn2.getTokenType().equals(com.sun.xml.ws.security.impl.policy.X509Token.WSSX509V3TOKEN10));
AlgorithmSuite aSuite = sb.getAlgorithmSuite();
assertEquals("Unmatched Algorithm",aSuite.getEncryptionAlgorithm(), AlgorithmSuiteValue.TripleDesRsa15.getEncAlgorithm());
assertTrue(sb.isIncludeTimeStamp());
assertTrue("Signature is not Encypted", sb.getSignatureProtection());
assertFalse("Tokens are protected", sb.getTokenProtection());
}
}
|
public void | testSymmetricIssuedTokenCR6419493()
String fileName="security/IssuedTokenCR.xml";
Policy policy = unmarshalPolicy(fileName);
Iterator <AssertionSet> itr = policy.iterator();
if(itr.hasNext()) {
AssertionSet as = itr.next();
for(PolicyAssertion assertion : as) {
assertEquals("Invalid assertion", "SymmetricBinding",assertion.getName().getLocalPart());
SymmetricBinding sb = (SymmetricBinding)assertion;
IssuedToken tkn1 = (IssuedToken)sb.getProtectionToken();
assertTrue(tkn1.getIncludeToken().equals(Token.INCLUDE_ALWAYS));
}
}
|
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;
|