1 package com.freemindcafe.apache.cxf.wsdl.sample3;
6 import javax.xml.namespace.QName;
8 import org.
apache.cxf.binding.soap.SoapMessage;
12 import org.
apache.cxf.ws.security.wss4j.WSS4JInInterceptor;
22 public class WSSecurityInterceptor
extends WSS4JInInterceptor{
24 protected Logger log = Logger.getLogger(WSSecurityInterceptor.class);
26 public WSSecurityInterceptor() {
30 public WSSecurityInterceptor(Map<String, Object> properties) {
36 public void handleMessage(SoapMessage message)
throws Fault {
38 System.out.println(
"WSSecurityInterceptor-----------------");
39 boolean securityHeaderExists =
false;
40 List<Header> headers = message.getHeaders();
41 for(Header head : headers){
42 if( head.getName().getLocalPart().equals(
"Security")){
43 securityHeaderExists =
true;
49 if( !securityHeaderExists){
53 super.handleMessage(message);
56 f.setMessage(
"Authentication failed");
57 f.setFaultCode(
new QName(
"Client"));
60 }
catch (Exception ex) {
61 Fault fault =
new Fault(
new Exception(
"Authentication failed"));
62 fault.setFaultCode(
new QName(
"Client"));
68 public void handleFault(SoapMessage message) {
72 super.handleFault(message);