use of org.apache.axis2.databinding.types.soapencoding.Integer in project wso2-synapse by wso2.
the class ServerConnFactoryBuilder method parseSSL.
public ServerConnFactoryBuilder parseSSL() throws AxisFault {
Parameter keyParam = transportIn.getParameter("keystore");
Parameter trustParam = transportIn.getParameter("truststore");
Parameter clientAuthParam = transportIn.getParameter("SSLVerifyClient");
Parameter httpsProtocolsParam = transportIn.getParameter("HttpsProtocols");
final Parameter sslpParameter = transportIn.getParameter("SSLProtocol");
Parameter preferredCiphersParam = transportIn.getParameter(NhttpConstants.PREFERRED_CIPHERS);
final String sslProtocol = sslpParameter != null ? sslpParameter.getValue().toString() : "TLS";
OMElement keyStoreEl = keyParam != null ? keyParam.getParameterElement().getFirstElement() : null;
OMElement trustStoreEl = trustParam != null ? trustParam.getParameterElement().getFirstElement() : null;
OMElement clientAuthEl = clientAuthParam != null ? clientAuthParam.getParameterElement() : null;
OMElement httpsProtocolsEl = httpsProtocolsParam != null ? httpsProtocolsParam.getParameterElement() : null;
OMElement preferredCiphersEl = preferredCiphersParam != null ? preferredCiphersParam.getParameterElement() : null;
final Parameter cvp = transportIn.getParameter("CertificateRevocationVerifier");
final String cvEnable = cvp != null ? cvp.getParameterElement().getAttribute(new QName("enable")).getAttributeValue() : null;
RevocationVerificationManager revocationVerifier = null;
if ("true".equalsIgnoreCase(cvEnable)) {
String cacheSizeString = cvp.getParameterElement().getFirstChildWithName(new QName("CacheSize")).getText();
String cacheDelayString = cvp.getParameterElement().getFirstChildWithName(new QName("CacheDelay")).getText();
Integer cacheSize = null;
Integer cacheDelay = null;
try {
cacheSize = new Integer(cacheSizeString);
cacheDelay = new Integer(cacheDelayString);
} catch (NumberFormatException e) {
}
revocationVerifier = new RevocationVerificationManager(cacheSize, cacheDelay);
}
ssl = createSSLContext(keyStoreEl, trustStoreEl, clientAuthEl, httpsProtocolsEl, preferredCiphersEl, revocationVerifier, sslProtocol);
return this;
}
use of org.apache.axis2.databinding.types.soapencoding.Integer in project wso2-synapse by wso2.
the class FieldOrderingTest method testRepeatingGroupOrdering.
public void testRepeatingGroupOrdering() throws IOException {
int[] order = new int[] { Symbol.FIELD, SecurityID.FIELD, SecurityIDSource.FIELD, Product.FIELD, QuoteType.FIELD, OrderQty.FIELD, SettlDate.FIELD, QuotePriceType.FIELD, ValidUntilTime.FIELD, ExpireTime.FIELD };
Message message = new QuoteRequest(new QuoteReqID("20101110-2"));
Group group = new Group(NoRelatedSym.FIELD, Symbol.FIELD, order);
group.setField(new Symbol("TestSymbol"));
group.setField(new SecurityID("SecurityID"));
group.setField(new SecurityIDSource("SecurityIDSource"));
group.setField(new Product(11));
group.setField(new QuoteType(1));
group.setField(new OrderQty(500));
group.setField(new SettlDate("20151116"));
group.setField(new QuotePriceType(1));
group.setField(new ValidUntilTime(new Date()));
group.setField(new ExpireTime(new Date()));
message.addGroup(group);
System.out.println("Original Message: " + message);
MessageContext msgCtx = new MessageContext();
FIXUtils.getInstance().setSOAPEnvelope(message, 1, "TestSession", msgCtx);
OMElement msgElt = msgCtx.getEnvelope().getBody().getFirstElement();
OMElement groupsElt = msgElt.getFirstChildWithName(new QName(FIXConstants.FIX_BODY)).getFirstChildWithName(new QName(FIXConstants.FIX_GROUPS));
int groupId = Integer.parseInt(groupsElt.getAttributeValue(new QName(FIXConstants.FIX_FIELD_ID)));
assertEquals(groupId, group.getFieldTag());
// Test whether the fileds in the SOAP infoset are in the correct order
Iterator fields = groupsElt.getFirstElement().getChildrenWithName(new QName(FIXConstants.FIX_FIELD));
List<Integer> fieldList = new ArrayList<Integer>();
while (fields.hasNext()) {
OMElement fieldElt = (OMElement) fields.next();
fieldList.add(Integer.parseInt(fieldElt.getAttributeValue(new QName(FIXConstants.FIX_FIELD_ID))));
}
assertEquals(order.length, fieldList.size());
for (int i = 0; i < order.length; i++) {
assertEquals(order[i], (int) fieldList.get(i));
}
// Test whether the reconstructed message preserves the group field order
Message copy = FIXUtils.getInstance().createFIXMessage(msgCtx);
System.out.println("Reconstructed Message: " + copy);
List<Group> groups = copy.getGroups(NoRelatedSym.FIELD);
assertEquals(1, groups.size());
int[] copyOrder = groups.get(0).getFieldOrder();
assertEquals(order.length, copyOrder.length);
for (int i = 0; i < order.length; i++) {
assertEquals(order[i], copyOrder[i]);
}
assertEquals(message.toString(), copy.toString());
}
use of org.apache.axis2.databinding.types.soapencoding.Integer in project wso2-synapse by wso2.
the class SampleAxis2ServerManager method configurePort.
private void configurePort(ConfigurationContext configCtx) {
TransportInDescription trsIn = configCtx.getAxisConfiguration().getTransportsIn().get("http");
if (trsIn != null) {
String port = System.getProperty("http_port");
if (port != null) {
try {
new Integer(port);
trsIn.getParameter("port").setValue(port);
} catch (NumberFormatException e) {
log.error("Given port is not a valid integer. Using 9000 for port.");
trsIn.getParameter("port").setValue("9000");
}
} else {
trsIn.getParameter("port").setValue("9000");
}
}
TransportInDescription httpsTrsIn = configCtx.getAxisConfiguration().getTransportsIn().get("https");
if (httpsTrsIn != null) {
String port = System.getProperty("https_port");
if (port != null) {
try {
new Integer(port);
httpsTrsIn.getParameter("port").setValue(port);
} catch (NumberFormatException e) {
log.error("Given port is not a valid integer. Using 9000 for port.");
httpsTrsIn.getParameter("port").setValue("9002");
}
} else {
httpsTrsIn.getParameter("port").setValue("9002");
}
}
}
use of org.apache.axis2.databinding.types.soapencoding.Integer in project wso2-synapse by wso2.
the class ProxyServiceMessageReceiver method receive.
public void receive(org.apache.axis2.context.MessageContext mc) throws AxisFault {
boolean traceOn = proxy.getAspectConfiguration().isTracingEnabled();
boolean traceOrDebugOn = traceOn || log.isDebugEnabled();
CustomLogSetter.getInstance().setLogAppender(proxy.getArtifactContainerName());
String remoteAddr = (String) mc.getProperty(org.apache.axis2.context.MessageContext.REMOTE_ADDR);
if (traceOrDebugOn) {
traceOrDebug(traceOn, "Proxy Service " + name + " received a new message" + (remoteAddr != null ? " from : " + remoteAddr : "..."));
traceOrDebug(traceOn, ("Message To: " + (mc.getTo() != null ? mc.getTo().getAddress() : "null")));
traceOrDebug(traceOn, ("SOAPAction: " + (mc.getSoapAction() != null ? mc.getSoapAction() : "null")));
traceOrDebug(traceOn, ("WSA-Action: " + (mc.getWSAAction() != null ? mc.getWSAAction() : "null")));
if (traceOn && trace.isTraceEnabled()) {
String[] cids = null;
try {
cids = mc.getAttachmentMap().getAllContentIDs();
} catch (Exception ex) {
// partially read stream could lead to corrupted attachment map and hence this exception
// corrupted attachment map leads to inconsistent runtime exceptions and behavior
// discard the attachment map for the fault handler invocation
// ensure the successful completion for fault handler flow
mc.setAttachmentMap(null);
log.error("Synapse encountered an exception when reading attachments from bytes stream. " + "Hence Attachments map is dropped from the message context.", ex);
}
if (cids != null && cids.length > 0) {
for (String cid : cids) {
trace.trace("With attachment content ID : " + cid);
}
}
trace.trace("Envelope : " + mc.getEnvelope());
}
}
MessageContext synCtx = MessageContextCreatorForAxis2.getSynapseMessageContext(mc);
Integer statisticReportingIndex = null;
// Statistic reporting
boolean isStatisticsEnabled = RuntimeStatisticCollector.isStatisticsEnabled();
if (isStatisticsEnabled) {
statisticReportingIndex = OpenEventCollector.reportEntryEvent(synCtx, this.name, proxy.getAspectConfiguration(), ComponentType.PROXYSERVICE);
}
Object inboundServiceParam = proxy.getParameterMap().get(SynapseConstants.INBOUND_PROXY_SERVICE_PARAM);
Object inboundMsgCtxParam = mc.getProperty(SynapseConstants.IS_INBOUND);
// check whether the message is from Inbound EP
if (inboundMsgCtxParam == null || !(boolean) inboundMsgCtxParam) {
// check whether service parameter is set to true or null, then block this request
if (inboundServiceParam != null && (Boolean.valueOf((String) inboundServiceParam))) {
/*
return because same proxy is exposed via InboundEP and service parameter(inbound.only) is set to
true, which disable normal http transport proxy
*/
if (!synCtx.getFaultStack().isEmpty()) {
if (log.isDebugEnabled()) {
log.debug("Executing fault handler - message discarded due to the proxy is allowed only via InboundEP");
}
(synCtx.getFaultStack().pop()).handleFault(synCtx, new Exception("Proxy Service " + name + " message discarded due to the proxy is allowed only via InboundEP"));
} else {
if (log.isDebugEnabled()) {
log.debug("Proxy Service " + name + " message discarded due to the proxy is " + "allowed only via InboundEP");
}
}
return;
}
}
TenantInfoConfigurator configurator = synCtx.getEnvironment().getTenantInfoConfigurator();
if (configurator != null) {
configurator.extractTenantInfo(synCtx);
}
TransportInDescription trpInDesc = mc.getTransportIn();
if (trpInDesc != null) {
synCtx.setProperty(SynapseConstants.TRANSPORT_IN_NAME, trpInDesc.getName());
}
// get service log for this message and attach to the message context also set proxy name
Log serviceLog = LogFactory.getLog(SynapseConstants.SERVICE_LOGGER_PREFIX + name);
((Axis2MessageContext) synCtx).setServiceLog(serviceLog);
synCtx.setProperty(SynapseConstants.PROXY_SERVICE, name);
// synCtx.setTracingState(proxy.getTraceState());
synCtx.setProperty(SynapseConstants.IS_CLIENT_DOING_REST, mc.isDoingREST());
synCtx.setProperty(SynapseConstants.IS_CLIENT_DOING_SOAP11, mc.isSOAP11());
try {
if (synCtx.getEnvironment().isDebuggerEnabled()) {
SynapseDebugManager debugManager = synCtx.getEnvironment().getSynapseDebugManager();
debugManager.acquireMediationFlowLock();
debugManager.advertiseMediationFlowStartPoint(synCtx);
if (!synCtx.isResponse()) {
SynapseWireLogHolder wireLogHolder = (SynapseWireLogHolder) ((Axis2MessageContext) synCtx).getAxis2MessageContext().getProperty(SynapseDebugInfoHolder.SYNAPSE_WIRE_LOG_HOLDER_PROPERTY);
if (wireLogHolder == null) {
wireLogHolder = new SynapseWireLogHolder();
}
if (synCtx.getProperty(SynapseConstants.PROXY_SERVICE) != null && !synCtx.getProperty(SynapseConstants.PROXY_SERVICE).toString().isEmpty()) {
wireLogHolder.setProxyName(synCtx.getProperty(SynapseConstants.PROXY_SERVICE).toString());
}
((Axis2MessageContext) synCtx).getAxis2MessageContext().setProperty(SynapseDebugInfoHolder.SYNAPSE_WIRE_LOG_HOLDER_PROPERTY, wireLogHolder);
}
}
synCtx.setProperty(SynapseConstants.RESPONSE_STATE, new ResponseState());
List handlers = synCtx.getEnvironment().getSynapseHandlers();
Iterator<SynapseHandler> iterator = handlers.iterator();
while (iterator.hasNext()) {
SynapseHandler handler = iterator.next();
if (!handler.handleRequestInFlow(synCtx)) {
return;
}
}
Mediator mandatorySeq = synCtx.getConfiguration().getMandatorySequence();
if (mandatorySeq != null) {
if (log.isDebugEnabled()) {
log.debug("Start mediating the message in the " + "pre-mediate state using the mandatory sequence");
}
if (!mandatorySeq.mediate(synCtx)) {
if (log.isDebugEnabled()) {
log.debug("Request message for the proxy service " + name + " dropped in " + "the pre-mediation state by the mandatory sequence : \n" + synCtx);
}
return;
}
}
// setup fault sequence - i.e. what happens when something goes wrong with this message
proxy.registerFaultHandler(synCtx);
boolean inSequenceResult = true;
// Using inSequence for the incoming message mediation
if (proxy.getTargetInSequence() != null) {
Mediator inSequence = synCtx.getSequence(proxy.getTargetInSequence());
if (inSequence != null) {
traceOrDebug(traceOn, "Using sequence named : " + proxy.getTargetInSequence() + " for incoming message mediation");
inSequenceResult = inSequence.mediate(synCtx);
} else {
handleException("Unable to find in-sequence : " + proxy.getTargetInSequence(), synCtx);
}
} else if (proxy.getTargetInLineInSequence() != null) {
traceOrDebug(traceOn, "Using the anonymous " + "in-sequence of the proxy service for mediation");
inSequenceResult = proxy.getTargetInLineInSequence().mediate(synCtx);
}
// if inSequence returns true, forward message to endpoint
if (inSequenceResult) {
if (proxy.getTargetEndpoint() != null) {
Endpoint endpoint = synCtx.getEndpoint(proxy.getTargetEndpoint());
if (endpoint != null) {
traceOrDebug(traceOn, "Forwarding message to the endpoint : " + proxy.getTargetEndpoint());
endpoint.send(synCtx);
} else {
handleException("Unable to find the endpoint specified : " + proxy.getTargetEndpoint(), synCtx);
}
} else if (proxy.getTargetInLineEndpoint() != null) {
traceOrDebug(traceOn, "Forwarding the message to the anonymous " + "endpoint of the proxy service");
proxy.getTargetInLineEndpoint().send(synCtx);
}
}
} catch (SynapseException syne) {
if (!synCtx.getFaultStack().isEmpty()) {
warn(traceOn, "Executing fault handler due to exception encountered", synCtx);
((FaultHandler) synCtx.getFaultStack().pop()).handleFault(synCtx, syne);
} else {
warn(traceOn, "Exception encountered but no fault handler found - " + "message dropped", synCtx);
}
} finally {
// Statistic reporting
if (isStatisticsEnabled) {
CloseEventCollector.tryEndFlow(synCtx, this.name, ComponentType.PROXYSERVICE, statisticReportingIndex, true);
}
if (synCtx.getEnvironment().isDebuggerEnabled()) {
SynapseDebugManager debugManager = synCtx.getEnvironment().getSynapseDebugManager();
debugManager.advertiseMediationFlowTerminatePoint(synCtx);
debugManager.releaseMediationFlowLock();
}
doPostInjectUpdates(synCtx);
}
}
use of org.apache.axis2.databinding.types.soapencoding.Integer in project wso2-synapse by wso2.
the class FIXOutgoingMessageHandler method sendQueuedMessages.
/**
* Sends any messages in the queues. Maintains the order of the messages.
*
* @param expectedValue expected counter value
* @param session source FIX session
*
* @throws SessionNotFound on error
*/
private void sendQueuedMessages(int expectedValue, String session) throws SessionNotFound {
Map<Integer, Object[]> messages = messagesMap.get(session);
Object[] obj = messages.get(expectedValue);
while (obj != null) {
Message message = (Message) obj[0];
SessionID sessionID = (SessionID) obj[1];
MessageContext msgCtx = null;
String targetEPR = null;
if (obj[2] != null) {
msgCtx = (MessageContext) obj[2];
targetEPR = (String) obj[3];
}
if (log.isDebugEnabled()) {
log.debug("Source session: " + session + " - Sending the previously queued message " + "with the sequence number: " + expectedValue);
}
sendToTarget(msgCtx, targetEPR, message, sessionID);
messages.remove(expectedValue);
if (FIXConstants.DEFAULT_COUNTER_UPPER_LIMIT == expectedValue) {
if (log.isDebugEnabled()) {
log.debug("Outgoing request counter rolled over for the session: " + session + " (from " + expectedValue + ")");
}
expectedValue = 1;
}
obj = messages.get(++expectedValue);
}
messagesMap.put(session, messages);
countersMap.put(session, expectedValue);
}
Aggregations