ffang commented on code in PR #1660:
URL: https://github.com/apache/cxf/pull/1660#discussion_r1480553067
##########
rt/ws/security/src/main/java/org/apache/cxf/ws/security/policy/custom/DefaultAlgorithmSuiteLoader.java:
##########
@@ -140,9 +164,116 @@ protected void parseCustomAssertion(Assertion assertion) {
} else if ("Basic256GCM".equals(assertionName)) {
setAlgorithmSuiteType(ALGORITHM_SUITE_TYPES.get("Basic256GCM"));
getAlgorithmSuiteType().setNamespace(assertionNamespace);
+ } else if ("CustomizedAlgorithmSuite".equals(assertionName)) {
+
setAlgorithmSuiteType(ALGORITHM_SUITE_TYPES.get("CustomizedAlgorithmSuite"));
+ getAlgorithmSuiteType().setNamespace(assertionNamespace);
}
}
}
+ public static AlgorithmSuite.AlgorithmSuiteType
customize(AlgorithmSuite.AlgorithmSuiteType suiteType,
+ Message message)
{
+
+ Map<String, Object> values = message.getContextualPropertyKeys()
+ .stream()
+ .filter(k ->
k.startsWith(SecurityConstants.CUSTOM_ALG_SUITE_PREFIX))
+ .collect(Collectors.toMap(Function.identity(), k ->
message.getContextualProperty(k)));
+
+ return customize(suiteType, values);
+
+ }
+
+ public static AlgorithmSuite.AlgorithmSuiteType
customize(AlgorithmSuite.AlgorithmSuiteType suiteType,
+ Map<String,
Object> values) {
+
+ //customization happens only for CustomizedAlgorithmSuite
+ if (suiteType != null &&
!"CustomizedAlgorithmSuite".equals(suiteType.getName())) {
+ return suiteType;
+ }
+
+
+ AlgorithmSuite.AlgorithmSuiteType retVal = suiteType != null ?
suiteType
+ : new AlgorithmSuite.AlgorithmSuiteType(null, null, null, null,
+ null, null, null,
Review Comment:
Hi @JiriOndrusek ,
I believe here the AlgorithmSuiteType name shouldn't be null anyway.
Actually I think if the original suiteType is null, we shouldn't create a
new one and customize it, we should just skip the customization.
Freeman
##########
systests/ws-security/src/test/resources/wsdl_systest_wssec/wssec10/WsSecurity10_policy_customizedAlgorithmSuite.wsdl:
##########
@@ -0,0 +1,178 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsam="http://www.w3.org/2007/05/addressing/metadata"
xmlns:tns="http://apache.cxf.org/"
xmlns:wsa="http://schemas.xmlsoap.org/ws/2004/08/addressing"
xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy"
xmlns:wssec10test="http://WSSec/wssec10"
xmlns:wsap="http://schemas.xmlsoap.org/ws/2004/08/addressing/policy"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:wsaw="http://www.w3.org/2006/05/addressing/wsdl"
xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:wsa10="http://www.w3.org/2005/08/addressing"
xmlns:wsx="http://schemas.xmlsoap.org/ws/2004/09/mex"
targetNamespace="http://apache.cxf.org/">
+ <wsp:Policy wsu:Id="Customizable10SignEncrypt01_IPingService_policy">
+ <wsp:ExactlyOne>
+ <wsp:All>
+ <sp:AsymmetricBinding
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
+ <wsp:Policy>
+ <sp:InitiatorToken>
+ <wsp:Policy>
+ <sp:X509Token
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:InitiatorToken>
+ <sp:RecipientToken>
+ <wsp:Policy>
+ <sp:X509Token
sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
+ <wsp:Policy>
+ <sp:WssX509V3Token10/>
+ </wsp:Policy>
+ </sp:X509Token>
+ </wsp:Policy>
+ </sp:RecipientToken>
+ <sp:AlgorithmSuite>
+ <wsp:Policy>
+ <sp:CustomizedAlgorithmSuite/>
Review Comment:
Hi @JiriOndrusek ,
Though I believe technically it's doable, like in the
org.apache.cxf.ws.security.policy.custom.AlgorithmSuiteBuilder constructor you
can get nestedPolicyElement which is a DOM element
```
final Element nestedPolicyElement =
SPUtils.getFirstPolicyChildElement(element);
```
So you can get all child element from this point actually.
However, I'm hesitant to do it because this behaviour isn't aligned with
current properties implementations used in WSS4J and CXF. You can find more
discussion in
https://issues.apache.org/jira/browse/CXF-8971
Best Regards
Freeman
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]