use of org.apache.axis2.description.TransportOutDescription in project carbon-apimgt by wso2.
the class CertificateMgtUtils method getSSLSenderProfilePath.
public static String getSSLSenderProfilePath() {
AxisConfiguration axisConfiguration = ServiceReferenceHolder.getContextService().getServerConfigContext().getAxisConfiguration();
TransportOutDescription transportOut = axisConfiguration.getTransportOut(APIConstants.HTTPS_PROTOCOL);
if (transportOut != null && transportOut.getParameter("dynamicSSLProfilesConfig") != null) {
OMElement dynamicSSLProfilesConfigElement = transportOut.getParameter("dynamicSSLProfilesConfig").getParameterElement();
if (dynamicSSLProfilesConfigElement != null) {
OMElement filePathElement = dynamicSSLProfilesConfigElement.getFirstChildWithName(new QName("filePath"));
if (filePathElement != null) {
String sslProfilePath = filePathElement.getText();
if (sslProfilePath.contains(".xml")) {
return getFullPath(sslProfilePath);
}
}
}
}
return null;
}
use of org.apache.axis2.description.TransportOutDescription in project carbon-apimgt by wso2.
the class APIUtil method isForgetPasswordConfigured.
public static boolean isForgetPasswordConfigured() {
AxisConfiguration axis2Config = ServiceReferenceHolder.getContextService().getServerConfigContext().getAxisConfiguration();
TransportOutDescription emailTransportSender = axis2Config.getTransportOut(APIConstants.EMAIL_TRANSPORT);
if (emailTransportSender != null) {
return true;
}
return false;
}
use of org.apache.axis2.description.TransportOutDescription in project wso2-axis2-transports by wso2.
the class XMPPSender method getConnectionDetailsFromAxisConfiguration.
/**
* Extract connection details from axis2.xml's transportsender section
* @param serverCredentials
* @param transportOut
*/
private void getConnectionDetailsFromAxisConfiguration(TransportOutDescription transportOut) {
if (transportOut != null) {
Parameter serverUrl = transportOut.getParameter(XMPPConstants.XMPP_SERVER_URL);
if (serverUrl != null) {
serverCredentials.setServerUrl(Utils.getParameterValue(serverUrl));
}
Parameter userName = transportOut.getParameter(XMPPConstants.XMPP_SERVER_USERNAME);
if (userName != null) {
serverCredentials.setAccountName(Utils.getParameterValue(userName));
}
Parameter password = transportOut.getParameter(XMPPConstants.XMPP_SERVER_PASSWORD);
if (password != null) {
serverCredentials.setPassword(Utils.getParameterValue(password));
}
Parameter serverType = transportOut.getParameter(XMPPConstants.XMPP_SERVER_TYPE);
if (serverType != null) {
serverCredentials.setServerType(Utils.getParameterValue(serverType));
}
Parameter domainName = transportOut.getParameter(XMPPConstants.XMPP_DOMAIN_NAME);
if (serverUrl != null) {
serverCredentials.setDomainName(Utils.getParameterValue(domainName));
}
}
}
use of org.apache.axis2.description.TransportOutDescription in project wso2-axis2-transports by wso2.
the class DefaultSMSMessageBuilderImpl method buildMessaage.
public MessageContext buildMessaage(SMSMessage msg, ConfigurationContext configurationContext) throws InvalidMessageFormatException {
String message = msg.getContent();
String sender = msg.getSender();
String receiver = msg.getReceiver();
String[] parts = message.split(":");
// may be can add feature to send message format for a request like ????
if (parts.length < 2) {
throw new InvalidMessageFormatException("format must be \"service_name \" : \"opration_name\" : " + "\"parm_1=val_1\" :..:\"param_n = val_n\"");
} else {
AxisConfiguration repo = configurationContext.getAxisConfiguration();
MessageContext messageContext = configurationContext.createMessageContext();
parts = trimSplited(parts);
try {
AxisService axisService = repo.getService(parts[0]);
if (axisService == null) {
throw new InvalidMessageFormatException("Service : " + parts[0] + "does not exsist");
} else {
messageContext.setAxisService(axisService);
AxisOperation axisOperation = axisService.getOperation(new QName(parts[1]));
if (axisOperation == null) {
throw new InvalidMessageFormatException("Operation: " + parts[1] + " does not exsist");
}
messageContext.setAxisOperation(axisOperation);
messageContext.setAxisMessage(axisOperation.getMessage(WSDLConstants.MESSAGE_LABEL_IN_VALUE));
Map params = getParams(parts, 2);
SOAPEnvelope soapEnvelope = createSoapEnvelope(messageContext, params);
messageContext.setServerSide(true);
messageContext.setEnvelope(soapEnvelope);
TransportInDescription in = configurationContext.getAxisConfiguration().getTransportIn("sms");
TransportOutDescription out = configurationContext.getAxisConfiguration().getTransportOut("sms");
messageContext.setIncomingTransportName("sms");
messageContext.setProperty(SMSTransportConstents.SEND_TO, sender);
messageContext.setProperty(SMSTransportConstents.DESTINATION, receiver);
messageContext.setTransportIn(in);
messageContext.setTransportOut(out);
handleSMSProperties(msg, messageContext);
return messageContext;
}
} catch (AxisFault axisFault) {
log.debug("[DefaultSMSMessageBuilderImpl] Error while extracting the axis2Service \n" + axisFault);
}
}
return null;
}
use of org.apache.axis2.description.TransportOutDescription in project wso2-axis2-transports by wso2.
the class JMSSenderTestCase method testGettingHyphenModeFromJMSConnectionFactory.
/**
* Test case for EI-2776.
* Test whether the transport.jms.MessagePropertyHyphens parameter is set to the message context.
* @throws Exception
*/
public void testGettingHyphenModeFromJMSConnectionFactory() throws Exception {
JMSSender jmsSender = PowerMockito.spy(new JMSSender());
JMSOutTransportInfo jmsOutTransportInfo = Mockito.mock(JMSOutTransportInfo.class);
JMSMessageSender jmsMessageSender = Mockito.mock(JMSMessageSender.class);
Session session = Mockito.mock(Session.class);
final String hyphenMode = "replace";
JMSConnectionFactory jmsConnectionFactory = Mockito.mock(JMSConnectionFactory.class);
Hashtable<String, String> paramTable = new Hashtable<>();
paramTable.put(JMSConstants.PARAM_JMS_HYPHEN_MODE, hyphenMode);
Mockito.when(jmsConnectionFactory.getParameters()).thenReturn(paramTable);
PowerMockito.whenNew(JMSMessageSender.class).withArguments(any(JMSConnectionFactory.class), any(String.class)).thenReturn(jmsMessageSender);
Mockito.doReturn(session).when(jmsMessageSender).getSession();
PowerMockito.whenNew(JMSOutTransportInfo.class).withArguments(any(String.class)).thenReturn(jmsOutTransportInfo);
Mockito.doReturn(jmsMessageSender).when(jmsOutTransportInfo).createJMSSender(any(MessageContext.class));
PowerMockito.doReturn(jmsConnectionFactory).when(jmsSender, "getJMSConnectionFactory", ArgumentMatchers.any());
PowerMockito.doReturn(new JMSReplyMessage()).when(jmsSender, "sendOverJMS", ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any(), ArgumentMatchers.any());
jmsSender.init(new ConfigurationContext(new AxisConfiguration()), new TransportOutDescription("jms"));
MessageContext messageContext = new MessageContext();
jmsSender.sendMessage(messageContext, "jms:/SimpleStockQuoteService", null);
Assert.assertEquals("Hyphen mode provided by the JMSConnectionFactory has not been set " + "to the message context", hyphenMode, messageContext.getProperty(JMSConstants.PARAM_JMS_HYPHEN_MODE));
}
Aggregations