use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.
the class MAPAggregatorImpl method setupNamespace.
private void setupNamespace(AddressingProperties maps, Message message) {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
if (null == aim) {
String ns = (String) message.getContextualProperty(MAPAggregator.ADDRESSING_NAMESPACE);
if (ns != null) {
maps.exposeAs(ns);
}
return;
}
Collection<AssertionInfo> aic = aim.getAssertionInfo(MetadataConstants.USING_ADDRESSING_2004_QNAME);
if (aic != null && !aic.isEmpty()) {
maps.exposeAs(Names200408.WSA_NAMESPACE_NAME);
}
}
use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.
the class MAPAggregatorImpl method assertAddressing.
/**
* If the isRequestor(message) == true and isAddressRequired() == false
* Assert all the wsa related assertion to true
*
* @param message the current message
*/
private void assertAddressing(Message message) {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
if (null == aim) {
return;
}
QName[] types = new QName[] { MetadataConstants.ADDRESSING_ASSERTION_QNAME, MetadataConstants.USING_ADDRESSING_2004_QNAME, MetadataConstants.USING_ADDRESSING_2005_QNAME, MetadataConstants.USING_ADDRESSING_2006_QNAME };
for (QName type : types) {
assertAssertion(aim, type);
// ADDRESSING_ASSERTION is normalized, so check only the default namespace
if (type.equals(MetadataConstants.ADDRESSING_ASSERTION_QNAME)) {
assertAssertion(aim, MetadataConstants.ANON_RESPONSES_ASSERTION_QNAME);
assertAssertion(aim, MetadataConstants.NON_ANON_RESPONSES_ASSERTION_QNAME);
}
}
}
use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.
the class AbstractPolicySecurityTest method runOutInterceptorAndValidate.
protected Document runOutInterceptorAndValidate(Document document, Policy policy, List<QName> assertedOutAssertions, List<QName> notAssertedOutAssertions) throws Exception {
AssertionInfoMap aim = new AssertionInfoMap(policy);
final SoapMessage msg = this.getOutSoapMessageForDom(document, aim);
return this.runOutInterceptorAndValidate(msg, policy, aim, assertedOutAssertions, notAssertedOutAssertions);
}
use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.
the class AbstractPolicySecurityTest method runOutInterceptorAndValidateSamlTokenAttached.
protected void runOutInterceptorAndValidateSamlTokenAttached(String policyDoc) throws Exception {
// create the request message
final Document document = this.readDocument("wsse-request-clean.xml");
final Element outPolicyElement = this.readDocument(policyDoc).getDocumentElement();
final Policy policy = this.policyBuilder.getPolicy(outPolicyElement);
AssertionInfoMap aim = new AssertionInfoMap(policy);
SoapMessage msg = this.getOutSoapMessageForDom(document, aim);
// add an "issued" assertion into the message exchange
Element issuedAssertion = this.readDocument("example-sts-issued-saml-assertion.xml").getDocumentElement();
Properties cryptoProps = new Properties();
URL url = ClassLoader.getSystemResource("outsecurity.properties");
cryptoProps.load(url.openStream());
Crypto crypto = CryptoFactory.getInstance(cryptoProps);
// Sign the "issued" assertion
SamlAssertionWrapper assertionWrapper = new SamlAssertionWrapper(issuedAssertion);
assertionWrapper.signAssertion("myalias", "myAliasPassword", crypto, false);
Document doc = DOMUtils.newDocument();
issuedAssertion = OpenSAMLUtil.toDom(assertionWrapper.getSaml1(), doc);
String assertionId = issuedAssertion.getAttributeNodeNS(null, "AssertionID").getNodeValue();
SecurityToken issuedToken = new SecurityToken(assertionId, issuedAssertion, null);
String alias = cryptoProps.getProperty("org.apache.ws.security.crypto.merlin.keystore.alias");
CryptoType cryptoType = new CryptoType(CryptoType.TYPE.ALIAS);
cryptoType.setAlias(alias);
issuedToken.setX509Certificate(crypto.getX509Certificates(cryptoType)[0], crypto);
msg.getExchange().getEndpoint().put(SecurityConstants.TOKEN_ID, issuedToken.getId());
msg.getExchange().put(SecurityConstants.TOKEN_ID, issuedToken.getId());
TokenStore tokenStore = new MemoryTokenStore();
msg.getExchange().getEndpoint().getEndpointInfo().setProperty(TokenStore.class.getName(), tokenStore);
tokenStore.add(issuedToken);
// fire the interceptor and verify results
final Document signedDoc = this.runOutInterceptorAndValidate(msg, policy, aim, null, null);
this.runInInterceptorAndValidate(signedDoc, policy, Collections.singletonList(SP12Constants.ISSUED_TOKEN), null, Collections.singletonList(CoverageType.SIGNED));
}
use of org.apache.cxf.ws.policy.AssertionInfoMap in project cxf by apache.
the class AbstractRMInterceptor method assertReliability.
/**
* Asserts all RMAssertion assertions for the current message, regardless their attributes
* (if there is more than one we have ensured that they are all supported by considering
* e.g. the minimum acknowledgment interval).
* @param message the current message
*/
void assertReliability(Message message) {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
Collection<AssertionInfo> ais = RMPolicyUtilities.collectRMAssertions(aim);
for (AssertionInfo ai : ais) {
ai.setAsserted(true);
}
}
Aggregations