Source:
public boolean handleRequest(MessageContext messageContext) { org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) messageContext).getAxis2MessageContext(); Object headers = axis2MessageContext.getProperty( org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); if (!isInitialized) { this.initialize(messageContext); isInitialized = true; } String authHeader = null; if (headers != null && headers instanceof Map) { Map headersMap = (Map) headers; if (headersMap.get(HTTPConstants.HEADER_AUTHORIZATION) != null) { authHeader = (String) headersMap.get(HTTPConstants.HEADER_AUTHORIZATION); } } if (authHeader == null) { headersMap.clear(); axis2MessageContext.setProperty(BasicAuthConstants.HTTP_STATUS_CODE, BasicAuthConstants.SC_UNAUTHORIZED); headersMap.put(BasicAuthConstants.WWW_AUTHENTICATE, BasicAuthConstants.WWW_AUTH_METHOD); axis2MessageContext.setProperty(BasicAuthConstants.NO_ENTITY_BODY, true); messageContext.setProperty(BasicAuthConstants.RESPONSE, BasicAuthConstants.TRUE); messageContext.setTo(null); Axis2Sender.sendBack(messageContext); return false; } else { if (authHeader.startsWith("Basic ") { String credentials = authHeader.substring(6).trim(); if (processSecurity(credentials, messageContext.getProperty("REST_API_CONTEXT").toString())) { return true; } } headersMap.clear(); axis2MessageContext.setProperty(BasicAuthConstants.HTTP_STATUS_CODE, BasicAuthConstants.SC_FORBIDDEN); axis2MessageContext.setProperty(BasicAuthConstants.NO_ENTITY_BODY, true); messageContext.setProperty(BasicAuthConstants.RESPONSE, BasicAuthConstants.TRUE); messageContext.setTo(null); Axis2Sender.sendBack(messageContext); return false; } }

Target:
public boolean handleRequest(MessageContext messageContext) { org.apache.axis2.context.MessageContext axis2MessageContext = ((Axis2MessageContext) messageContext).getAxis2MessageContext(); Object headers = axis2MessageContext.getProperty( org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS); if (!isInitialized) { this.initialize(messageContext); isInitialized = true; } Map headersMap = null; String authHeader = null; if (headers != null && headers instanceof Map) { headersMap = (Map) headers; if (headersMap.get(HTTPConstants.HEADER_AUTHORIZATION) != null) { authHeader = (String) headersMap.get(HTTPConstants.HEADER_AUTHORIZATION); } } if (headersMap == null || authHeader == null) { if (headersMap == null) { headersMap = new HashMap<String,String>(); axis2MessageContext.setProperty( org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS, headersMap); } else { headersMap.clear(); } headersMap.put(BasicAuthConstants.WWW_AUTHENTICATE, BasicAuthConstants.WWW_AUTH_METHOD); axis2MessageContext.setProperty(BasicAuthConstants.HTTP_STATUS_CODE, BasicAuthConstants.SC_UNAUTHORIZED); axis2MessageContext.setProperty(BasicAuthConstants.NO_ENTITY_BODY, true); messageContext.setProperty(BasicAuthConstants.RESPONSE, BasicAuthConstants.TRUE); messageContext.setTo(null); Axis2Sender.sendBack(messageContext); } else { if (authHeader.startsWith("Basic ")) { String credentials = authHeader.substring(6).trim(); if (processSecurity(credentials, messageContext.getProperty("REST_API_CONTEXT").toString())) { return true; } } headersMap.clear(); axis2MessageContext.setProperty(BasicAuthConstants.HTTP_STATUS_CODE, BasicAuthConstants.SC_FORBIDDEN); axis2MessageContext.setProperty(BasicAuthConstants.NO_ENTITY_BODY, true); messageContext.setProperty(BasicAuthConstants.RESPONSE, BasicAuthConstants.TRUE); messageContext.setTo(null); Axis2Sender.sendBack(messageContext); } return false; }