Java Code Examples for org.apache.synapse.core.axis2.Axis2MessageContext#getAxis2MessageContext()

The following examples show how to use org.apache.synapse.core.axis2.Axis2MessageContext#getAxis2MessageContext() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: InboundHttpServerWorker.java    From micro-integrator with Apache License 2.0 5 votes vote down vote up
/**
 * Sends the respond back to the client.
 *
 * @param synCtx the MessageContext
 * @param result the result of API Call
 */
private void respond(org.apache.synapse.MessageContext synCtx, boolean result) {
    synCtx.setTo(null);
    synCtx.setResponse(true);
    Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
    org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext();
    axis2MessageCtx.getOperationContext().setProperty(Constants.RESPONSE_WRITTEN, "SKIP");
    if (!result) {
        if (axis2MessageCtx.getProperty(PassThroughConstants.HTTP_SC) == null) {
            axis2MessageCtx.setProperty(PassThroughConstants.HTTP_SC, "404");
        }
    }
    Axis2Sender.sendBack(synCtx);
}
 
Example 2
Source File: TenantAwareLoadBalanceEndpoint.java    From attic-stratos with Apache License 2.0 5 votes vote down vote up
/**
 * Adding the X-Forwarded-For/X-Originating-IP headers to the outgoing message.
 *
 * @param synCtx Current message context
 */
protected void setupTransportHeaders(MessageContext synCtx) {
    Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
    org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext();
    Object headers = axis2MessageCtx.getProperty(org.apache.axis2.context.MessageContext.TRANSPORT_HEADERS);
    if (headers != null && headers instanceof Map) {
        Map headersMap = (Map) headers;
        String xForwardFor = (String) headersMap.get(NhttpConstants.HEADER_X_FORWARDED_FOR);
        String remoteHost = (String) axis2MessageCtx.getProperty(org.apache.axis2.context.MessageContext.REMOTE_ADDR);

        if (xForwardFor != null && !"".equals(xForwardFor)) {
            StringBuilder xForwardedForString = new StringBuilder();
            xForwardedForString.append(xForwardFor);
            if (remoteHost != null && !"".equals(remoteHost)) {
                xForwardedForString.append(",").append(remoteHost);
            }
            headersMap.put(NhttpConstants.HEADER_X_FORWARDED_FOR, xForwardedForString.toString());
        } else {
            headersMap.put(NhttpConstants.HEADER_X_FORWARDED_FOR, remoteHost);
        }

        //Extracting information of X-Originating-IP
        if (headersMap.get(NhttpConstants.HEADER_X_ORIGINATING_IP_FORM_1) != null) {
            headersMap.put(NhttpConstants.HEADER_X_ORIGINATING_IP_FORM_1, headersMap.get(NhttpConstants.HEADER_X_ORIGINATING_IP_FORM_1));
        } else if (headersMap.get(NhttpConstants.HEADER_X_ORIGINATING_IP_FORM_2) != null) {
            headersMap.put(NhttpConstants.HEADER_X_ORIGINATING_IP_FORM_2, headersMap.get(NhttpConstants.HEADER_X_ORIGINATING_IP_FORM_2));
        }

    }
}
 
Example 3
Source File: SAMLEntitlementCallbackHandler.java    From micro-integrator with Apache License 2.0 4 votes vote down vote up
public String getUserName(MessageContext synCtx) {
    org.apache.axis2.context.MessageContext msgContext;
    Axis2MessageContext axis2Msgcontext = (Axis2MessageContext) synCtx;
    msgContext = axis2Msgcontext.getAxis2MessageContext();
    return (String) msgContext.getProperty("saml.subject.id");
}
 
Example 4
Source File: APIThrottleHandler.java    From carbon-apimgt with Apache License 2.0 4 votes vote down vote up
protected org.apache.axis2.context.MessageContext getAxis2MessageContext(Axis2MessageContext messageContext) {
    return messageContext.
            getAxis2MessageContext();
}
 
Example 5
Source File: TenantAwareLoadBalanceEndpoint.java    From attic-stratos with Apache License 2.0 2 votes vote down vote up
/**
 * Extract incoming request URL from message context.
 *
 * @param synCtx
 * @return
 */
private String extractUrl(MessageContext synCtx) {
    Axis2MessageContext axis2smc = (Axis2MessageContext) synCtx;
    org.apache.axis2.context.MessageContext axis2MessageCtx = axis2smc.getAxis2MessageContext();
    return (String) axis2MessageCtx.getProperty(LoadBalancerConstants.AXIS2_MSG_CTX_TRANSPORT_IN_URL);
}