Use the following class mediator inside a proxy service.
When the proxy service is invoked with the SSL Client you will see the ssl.client.auth.cert.X509 object id will be logged.
Debug through it so that you can find the SSL properties in the message context.
Code:
package org.wso2.carbon.mediator;
import org.apache.synapse.MessageContext;
import org.apache.synapse.core.axis2.Axis2MessageContext;
import org.apache.synapse.mediators.AbstractMediator;
public class SynapseMessageContextMediator extends AbstractMediator {
public boolean mediate(MessageContext msgCtx) {
org.apache.axis2.context.MessageContext axis2MessageCtx =
((Axis2MessageContext) msgCtx).getAxis2MessageContext();
if (axis2MessageCtx.getMessageID() != null) {
log.info("Cert: " + axis2MessageCtx.getProperty("ssl.client.auth.cert.X509"));
}
return true;
}
}
The IntelliJ IDEA project for this class mediator can be found here.
https://svn.wso2.org/repos/wso2/people/chamaraa/SynapseMessageContextMediator
A sample proxy service that uses this class mediator will be like;
<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="echoProxy"
transports="https http"
startOnLoad="true"
trace="disable">
<description/>
<target>
<endpoint>
<address uri="http://192.168.71.1:8280/services/echo/"/>
</endpoint>
<inSequence>
<class name="org.wso2.carbon.mediator.SynapseMessageContextMediator"/>
</inSequence>
<outSequence>
<send/>
</outSequence>
</target>
</proxy>
To invoke the proxy service you have to use a Mutual SSL java client.
How can i return a String value in my custom class mediator? For example i am performing add function and i want to return the result obtained after addition. How to do this?
ReplyDelete