FileDocCategorySizeDatePackage
SecureConversationTokenTest.javaAPI DocExample7081Tue May 29 16:57:42 BST 2007com.sun.xml.ws.security.impl.policy

SecureConversationTokenTest

public class SecureConversationTokenTest extends TestCase
author
Mayank.Mishra@SUN.com

Fields Summary
Constructors Summary
public SecureConversationTokenTest(String testName)

        super(testName);
    
Methods Summary
private java.io.ReadergetResourceReader(java.lang.String resourceName)

        return new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(resourceName));
    
protected voidsetUp()

    
public static junit.framework.Testsuite()

        TestSuite suite = new TestSuite(SecureConversationTokenTest.class);
        
        return suite;
    
protected voidtearDown()

    
public voidtestSecureConversationToken1()

        String fileName = "security/SecureConversationTokenAssertions1.xml";
        Policy policy = unmarshalPolicy(fileName);
        Iterator <AssertionSet> itr = policy.iterator();
        if(itr.hasNext()) {
            AssertionSet as = itr.next();
            for(PolicyAssertion assertion : as) {
                assertEquals("Invalid assertion","SecureConversationToken",assertion.getName().getLocalPart());
                SecureConversationToken sct = (SecureConversationToken)assertion;
                assertTrue(sct.isRequireDerivedKeys());
            }
        } else {
            throw new Exception("No Assertions found!. Unmarshalling of "+fileName+" failed!");
        }
    
public voidtestSecureConversationToken2()

        String fileName = "security/SecureConversationTokenAssertions2.xml";
        Policy policy = unmarshalPolicy(fileName);
        Iterator <AssertionSet> itr = policy.iterator();
        if(itr.hasNext()) {
            AssertionSet as = itr.next();
            for(PolicyAssertion assertion : as) {
                assertEquals("Invalid assertion","SecureConversationToken",assertion.getName().getLocalPart());
                SecureConversationToken sct = (SecureConversationToken)assertion;
                assertTrue(sct.getTokenRefernceTypes().contains(com.sun.xml.ws.security.impl.policy.SecureConversationToken.REQUIRE_EXTERNAL_URI_REFERENCE));
            }
        } else {
            throw new Exception("No Assertions found!. Unmarshalling of "+fileName+" failed!");
        }
    
public voidtestSecureConversationToken3()

        String fileName = "security/SecureConversationTokenAssertions3.xml";
        Policy policy = unmarshalPolicy(fileName);
        Iterator <AssertionSet> itr = policy.iterator();
        if(itr.hasNext()) {
            AssertionSet as = itr.next();
            for(PolicyAssertion assertion : as) {
                assertEquals("Invalid assertion","SecureConversationToken",assertion.getName().getLocalPart());
                SecureConversationToken sct = (SecureConversationToken)assertion;
                assertTrue(sct.getTokenType().equals(com.sun.xml.ws.security.impl.policy.SecureConversationToken.SC10_SECURITYCONTEXT_TOKEN));
            }
        } else {
            throw new Exception("No Assertions found!. Unmarshalling of "+fileName+" failed!");
        }
    
public com.sun.xml.ws.policy.PolicyunmarshalPolicy(java.lang.String xmlFile)

        PolicySourceModel model =  unmarshalPolicyResource(
                xmlFile);
        Policy mbp = PolicyModelTranslator.getTranslator().translate(model);
        return mbp;
        
    
private com.sun.xml.ws.policy.sourcemodel.PolicySourceModelunmarshalPolicyResource(java.lang.String resource)

        Reader reader = getResourceReader(resource);
        PolicySourceModel model = PolicyModelUnmarshaller.getXmlUnmarshaller().unmarshalModel(reader);
        reader.close();
        return model;