use of org.apache.cxf.interceptor.Fault in project tesb-rt-se by Talend.
the class CompressionInInterceptor method handleMessage.
public void handleMessage(Message message) throws Fault {
try {
// Perform compression
decompressMessage(message);
// Confirm policy processing
confirmPolicyProcessing(message);
} catch (RuntimeException e) {
throw e;
} catch (Exception e) {
throw new Fault(e);
}
}
use of org.apache.cxf.interceptor.Fault 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.interceptor.Fault in project fuse-karaf by jboss-fuse.
the class EnableCORSInterceptor method handleMessage.
@Override
public void handleMessage(Message message) throws Fault {
Map<String, List<String>> headers = Headers.getSetProtocolHeaders(message);
try {
// Access-Control-Allow-Origin:* Access-Control-Allow-Methods:POST,GET
headers.put("Access-Control-Allow-Origin", Arrays.asList("*"));
headers.put("Access-Control-Allow-Methods", Arrays.asList("POST", "GET"));
} catch (Exception ce) {
throw new Fault(ce);
}
}
use of org.apache.cxf.interceptor.Fault in project jbossws-cxf by jbossws.
the class GracefulShutdownInterceptor method createFault.
private Fault createFault() {
Fault f = new Fault(new org.apache.cxf.common.i18n.Message("Server is suspended", LOG));
f.setStatusCode(503);
return f;
}
use of org.apache.cxf.interceptor.Fault in project testcases by coheigea.
the class SyncopeBasicAuthInterceptor method handleMessage.
public void handleMessage(Message message) throws Fault {
AuthorizationPolicy policy = message.get(AuthorizationPolicy.class);
if (policy == null || policy.getUserName() == null || policy.getPassword() == null) {
String name = null;
if (policy != null) {
name = policy.getUserName();
}
String error = "No user credentials are available";
LOG.warning(error + " " + "for name: " + name);
throw new SecurityException(error);
}
try {
UsernameToken token = convertPolicyToToken(policy);
Credential credential = new Credential();
credential.setUsernametoken(token);
RequestData data = new RequestData();
data.setMsgContext(message);
credential = validator.validate(credential, data);
// Create a Principal/SecurityContext
Principal p = null;
if (credential != null && credential.getPrincipal() != null) {
p = credential.getPrincipal();
} else {
p = new WSUsernameTokenPrincipalImpl(policy.getUserName(), false);
((WSUsernameTokenPrincipalImpl) p).setPassword(policy.getPassword());
}
message.put(SecurityContext.class, createSecurityContext(p));
} catch (Exception ex) {
throw new Fault(ex);
}
}
Aggregations