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())); } } } }
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!"); } }
public void process() throws PolicyException { collectPolicies(); PolicyAssertion binding = (PolicyAssertion) getBinding(); policyBinding = (Binding) binding; if (binding == null) { // log error. // logger.log(Level.SEVERE,LogStringsMessages.SP_0105_ERROR_BINDING_ASSR_NOT_PRESENT()); // throw new PolicyException(LogStringsMessages.SP_0105_ERROR_BINDING_ASSR_NOT_PRESENT()); // We handle this now NilBindingProcessor nbp = new NilBindingProcessor(isServer, isIncoming, _policyContainer); nbp.process(); processNonBindingAssertions(nbp); return; } if (PolicyUtil.isTransportBinding(binding, spVersion)) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "TransportBinding was configured in the policy"); } TransportBindingProcessor tbp = new TransportBindingProcessor( (TransportBinding) binding, isServer, isIncoming, _policyContainer); tbp.process(); processNonBindingAssertions(tbp); transportBinding = true; } else { iAP = new IntegrityAssertionProcessor(_binding.getAlgorithmSuite(), _binding.isSignContent()); eAP = new EncryptionAssertionProcessor(_binding.getAlgorithmSuite(), false); _policyContainer.setPolicyContainerMode(_binding.getLayout()); if (PolicyUtil.isSymmetricBinding(binding.getName(), spVersion)) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "SymmetricBinding was configured in the policy"); } SymmetricBindingProcessor sbp = new SymmetricBindingProcessor( (SymmetricBinding) _binding, _policyContainer, isServer, isIncoming, signedParts, encryptedParts, signedElements, encryptedElements, spVersion); if (wssAssertion != null && PolicyUtil.isWSS11(wssAssertion, spVersion)) { sbp.setWSS11((WSSAssertion) wssAssertion); } sbp.process(); processNonBindingAssertions(sbp); sbp.close(); } else if (PolicyUtil.isAsymmetricBinding(binding.getName(), spVersion)) { if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "AsymmetricBinding was configured in the policy"); } AsymmetricBindingProcessor abp = new AsymmetricBindingProcessor( (AsymmetricBinding) _binding, _policyContainer, isServer, isIncoming, signedParts, encryptedParts, signedElements, encryptedElements, spVersion); if (wssAssertion != null && PolicyUtil.isWSS11(wssAssertion, spVersion)) { abp.setWSS11((WSSAssertion) wssAssertion); } abp.process(); processNonBindingAssertions(abp); abp.close(); } } }