String fileName="security/EndorsingSupportingToken.xml";
Policy policy = unmarshalPolicy(fileName);
Iterator <AssertionSet> itr = policy.iterator();
if(itr.hasNext()) {
AssertionSet as = itr.next();
for(PolicyAssertion assertion : as) {
assertEquals("Invalid assertion", "EndorsingSupportingTokens",assertion.getName().getLocalPart());
EndorsingSupportingTokens est = (EndorsingSupportingTokens)assertion;
AlgorithmSuite aSuite = (AlgorithmSuite) est.getAlgorithmSuite();
assertEquals("Unmatched Algorithm",aSuite.getEncryptionAlgorithm(), AlgorithmSuiteValue.TripleDesRsa15.getEncAlgorithm());
Iterator itrest = est.getTokens();
if(itrest.hasNext()) {
assertTrue(X509Token.WSSX509V3TOKEN10.equals(((X509Token)itrest.next()).getTokenType()));
}
Iterator itrTkn = est.getSignedParts();
if(itrTkn.hasNext()) {
SignedParts sp = ((SignedParts)itrTkn.next());
assertEquals("Body should be present",true,sp.hasBody());
assertTrue(isHeaderPresent(new QName("http://schemas.xmlsoap.org/ws/2004/08/addressing","To"),sp.getHeaders()));
assertTrue(isHeaderPresent(new QName("http://schemas.xmlsoap.org/ws/2004/08/addressing","From"),sp.getHeaders()));
assertTrue(isHeaderPresent(new QName("http://schemas.xmlsoap.org/ws/2004/08/addressing","FaultTo"),sp.getHeaders()));
assertTrue(isHeaderPresent(new QName("http://schemas.xmlsoap.org/ws/2004/08/addressing","ReplyTo"),sp.getHeaders()));
assertTrue(isHeaderPresent(new QName("http://schemas.xmlsoap.org/ws/2004/08/addressing","MessageID"),sp.getHeaders()));
assertTrue(isHeaderPresent(new QName("http://schemas.xmlsoap.org/ws/2004/08/addressing","RelatesTo"),sp.getHeaders()));
assertTrue(isHeaderPresent(new QName("http://schemas.xmlsoap.org/ws/2004/08/addressing","Action"),sp.getHeaders()));
}
}
}