コード例 #1
0
  public void testSignedSupportingToken() throws Exception {
    String fileName = "security/SignedSupportingTokenAssertion.xml";
    Policy policy = unmarshalPolicy(fileName);
    Iterator<AssertionSet> itr = policy.iterator();
    if (itr.hasNext()) {
      AssertionSet as = itr.next();
      for (PolicyAssertion assertion : as) {
        assertEquals(
            "Invalid assertion", "SignedSupportingTokens", assertion.getName().getLocalPart());
        SignedSupportingTokens sst = (SignedSupportingTokens) assertion;

        AlgorithmSuite aSuite = (AlgorithmSuite) sst.getAlgorithmSuite();
        assertEquals(
            "Unmatched Algorithm",
            aSuite.getEncryptionAlgorithm(),
            AlgorithmSuiteValue.TripleDesRsa15.getEncAlgorithm());

        Iterator itrTkn = sst.getTokens();
        if (itrTkn.hasNext()) {
          assertTrue(
              ((com.sun.xml.ws.security.policy.UserNameToken) itrTkn.next())
                  .getType()
                  .equals(com.sun.xml.ws.security.policy.UserNameToken.WSS_USERNAME_TOKEN_10));
        }
        Iterator itrSparts = sst.getSignedElements();
        if (itrSparts.hasNext()) {
          SignedElements se = (SignedElements) itrSparts.next();
          assertTrue(hasXPathTarget("//soapEnv:Body", se.getTargets()));
          assertTrue(hasXPathTarget("//addr:To", se.getTargets()));
          assertTrue(hasXPathTarget("//addr:From", se.getTargets()));
          assertTrue(hasXPathTarget("//addr:RealtesTo", se.getTargets()));
        }
      }
    }
  }
コード例 #2
0
 public void testSpnegoContextToken() throws Exception {
   String fileName = "security/SpnegoContextTokenAssertions.xml";
   Policy policy = unmarshalPolicy(fileName);
   Iterator<AssertionSet> itr = policy.iterator();
   if (itr.hasNext()) {
     AssertionSet as = itr.next();
     for (PolicyAssertion assertion : as) {
       assertEquals("Invalid assertion", "SpnegoContextToken", assertion.getName().getLocalPart());
       SpnegoContextToken sct = (SpnegoContextToken) assertion;
       assertTrue(sct.isRequireDerivedKeys());
     }
   } else {
     throw new Exception("No Assertions found!. Unmarshalling of " + fileName + " failed!");
   }
 }