use of org.apache.cxf.ws.policy.AssertionInfo in project tesb-rt-se by Talend.
the class CompressionOutInterceptor method handleMessage.
public void handleMessage(Message message) throws Fault {
try {
// Load threshold value from policy assertion
AssertionInfo ai = CompressionPolicyBuilder.getAssertion(message);
if (ai != null) {
Assertion a = ai.getAssertion();
if (a instanceof CompressionAssertion) {
this.setThreshold(((CompressionAssertion) a).getThreshold());
}
}
wrapOriginalOutputStream(message);
// Confirm policy processing
if (ai != null) {
ai.setAsserted(true);
}
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new Fault(e);
}
}
use of org.apache.cxf.ws.policy.AssertionInfo in project cxf by apache.
the class AbstractTokenInterceptor method policyNotAsserted.
protected void policyNotAsserted(AbstractToken assertion, String reason, SoapMessage message) {
if (assertion == null) {
return;
}
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
Collection<AssertionInfo> ais = aim.get(assertion.getName());
if (ais != null) {
for (AssertionInfo ai : ais) {
if (ai.getAssertion() == assertion) {
ai.setNotAsserted(reason);
}
}
}
if (!assertion.isOptional()) {
throw new PolicyException(new Message(reason, LOG));
}
}
use of org.apache.cxf.ws.policy.AssertionInfo in project cxf by apache.
the class AbstractTokenInterceptor method assertTokens.
protected AbstractToken assertTokens(SoapMessage message, String localname, boolean signed) {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
Collection<AssertionInfo> ais = PolicyUtils.getAllAssertionsByLocalname(aim, localname);
AbstractToken tok = null;
for (AssertionInfo ai : ais) {
tok = (AbstractToken) ai.getAssertion();
ai.setAsserted(true);
}
PolicyUtils.assertPolicy(aim, SPConstants.SUPPORTING_TOKENS);
if (signed || isTLSInUse(message)) {
PolicyUtils.assertPolicy(aim, SPConstants.SIGNED_SUPPORTING_TOKENS);
}
return tok;
}
use of org.apache.cxf.ws.policy.AssertionInfo in project cxf by apache.
the class AlgorithmSuiteTranslater method translateAlgorithmSuites.
public void translateAlgorithmSuites(AssertionInfoMap aim, RequestData data) throws WSSecurityException {
if (aim == null) {
return;
}
List<org.apache.wss4j.policy.model.AlgorithmSuite> algorithmSuites = getAlgorithmSuites(getBindings(aim));
if (!algorithmSuites.isEmpty()) {
// Translate into WSS4J's AlgorithmSuite class
AlgorithmSuite algorithmSuite = translateAlgorithmSuites(algorithmSuites);
data.setAlgorithmSuite(algorithmSuite);
}
// Now look for an AlgorithmSuite for a SAML Assertion
Collection<AssertionInfo> ais = PolicyUtils.getAllAssertionsByLocalname(aim, SPConstants.SAML_TOKEN);
if (!ais.isEmpty()) {
List<org.apache.wss4j.policy.model.AlgorithmSuite> samlAlgorithmSuites = new ArrayList<>();
for (AssertionInfo ai : ais) {
SamlToken samlToken = (SamlToken) ai.getAssertion();
AbstractSecurityAssertion parentAssertion = samlToken.getParentAssertion();
if (parentAssertion instanceof SupportingTokens && ((SupportingTokens) parentAssertion).getAlgorithmSuite() != null) {
samlAlgorithmSuites.add(((SupportingTokens) parentAssertion).getAlgorithmSuite());
}
}
if (!samlAlgorithmSuites.isEmpty()) {
data.setSamlAlgorithmSuite(translateAlgorithmSuites(samlAlgorithmSuites));
}
}
}
use of org.apache.cxf.ws.policy.AssertionInfo in project cxf by apache.
the class AlgorithmSuiteTranslater method getBindings.
/**
* Get all of the WS-SecurityPolicy Bindings that are in operation
*/
private List<AbstractBinding> getBindings(AssertionInfoMap aim) {
List<AbstractBinding> bindings = new ArrayList<>();
Collection<AssertionInfo> ais = PolicyUtils.getAllAssertionsByLocalname(aim, SPConstants.TRANSPORT_BINDING);
if (!ais.isEmpty()) {
for (AssertionInfo ai : ais) {
bindings.add((AbstractBinding) ai.getAssertion());
}
}
ais = PolicyUtils.getAllAssertionsByLocalname(aim, SPConstants.ASYMMETRIC_BINDING);
if (!ais.isEmpty()) {
for (AssertionInfo ai : ais) {
bindings.add((AbstractBinding) ai.getAssertion());
}
}
ais = PolicyUtils.getAllAssertionsByLocalname(aim, SPConstants.SYMMETRIC_BINDING);
if (!ais.isEmpty()) {
for (AssertionInfo ai : ais) {
bindings.add((AbstractBinding) ai.getAssertion());
}
}
return bindings;
}
Aggregations