use of org.apache.neethi.Assertion in project tesb-rt-se by Talend.
the class SamEnablingInterceptorProviderTest method createSamlAssertion.
public List<Assertion> createSamlAssertion(String appliesTo) throws Exception {
List<Assertion> assertions = new ArrayList<Assertion>();
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = dbf.newDocumentBuilder();
Document doc = builder.newDocument();
Element element = doc.createElement("root");
doc.appendChild(element);
element.setAttribute("appliesTo", appliesTo);
assertions.add(new SamEnablingPolicy(element));
return assertions;
}
use of org.apache.neethi.Assertion 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.neethi.Assertion in project tesb-rt-se by Talend.
the class CompressionPolicyBuilderTest method testCompressionPolicyBuilder.
@Test
public void testCompressionPolicyBuilder() {
Collection<Assertion> c = new ArrayList<Assertion>();
AssertionInfoMap aim = new AssertionInfoMap(c);
Message m = CompressionCommonTest.getMessageStub(aim, null);
try {
assertNull(CompressionPolicyBuilder.getAssertion(m));
} catch (SAXException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} catch (ParserConfigurationException e) {
e.printStackTrace();
}
}
use of org.apache.neethi.Assertion in project cxf by apache.
the class HTTPClientAssertionBuilderTest method testBuildAssertion.
@Test
public void testBuildAssertion() throws Exception {
HTTPClientAssertionBuilder ab = new HTTPClientAssertionBuilder();
Assertion a = ab.buildAssertion();
assertTrue(a instanceof JaxbAssertion);
assertTrue(a instanceof HTTPClientAssertionBuilder.HTTPClientPolicyAssertion);
assertEquals(new ClientPolicyCalculator().getDataClassName(), a.getName());
assertFalse(a.isOptional());
}
use of org.apache.neethi.Assertion in project cxf by apache.
the class SpnegoContextTokenInInterceptor method handleMessage.
public void handleMessage(SoapMessage message) throws Fault {
AssertionInfoMap aim = message.get(AssertionInfoMap.class);
// extract Assertion information
if (aim != null) {
Collection<AssertionInfo> ais = PolicyUtils.getAllAssertionsByLocalname(aim, SPConstants.SPNEGO_CONTEXT_TOKEN);
if (ais.isEmpty()) {
return;
}
if (isRequestor(message)) {
// client side should be checked on the way out
for (AssertionInfo ai : ais) {
ai.setAsserted(true);
}
return;
}
String s = (String) message.get(SoapBindingConstants.SOAP_ACTION);
if (s == null) {
s = SoapActionInInterceptor.getSoapAction(message);
}
AddressingProperties inProps = (AddressingProperties) message.getContextualProperty(JAXWSAConstants.ADDRESSING_PROPERTIES_INBOUND);
if (inProps != null && s == null) {
// MS/WCF doesn't put a soap action out for this, must check the headers
s = inProps.getAction().getValue();
}
if (s != null && s.contains("/RST/Issue") && (s.startsWith(STSUtils.WST_NS_05_02) || s.startsWith(STSUtils.WST_NS_05_12))) {
Policy p = new Policy();
ExactlyOne ea = new ExactlyOne();
p.addPolicyComponent(ea);
All all = new All();
Assertion ass = NegotiationUtils.getAddressingPolicy(aim, false);
all.addPolicyComponent(ass);
ea.addPolicyComponent(all);
// setup endpoint and forward to it.
unmapSecurityProps(message);
String ns = STSUtils.WST_NS_05_12;
if (s.startsWith(STSUtils.WST_NS_05_02)) {
ns = STSUtils.WST_NS_05_02;
}
NegotiationUtils.recalcEffectivePolicy(message, ns, p, new SpnegoSTSInvoker(), false);
} else {
message.getInterceptorChain().add(SpnegoContextTokenFinderInterceptor.INSTANCE);
}
}
}
Aggregations