Search in sources :

Example 36 with TransportOutDescription

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;
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) QName(javax.xml.namespace.QName) OMElement(org.apache.axiom.om.OMElement) TransportOutDescription(org.apache.axis2.description.TransportOutDescription)

Example 37 with TransportOutDescription

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;
}
Also used : AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) TransportOutDescription(org.apache.axis2.description.TransportOutDescription)

Example 38 with TransportOutDescription

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));
        }
    }
}
Also used : Parameter(org.apache.axis2.description.Parameter)

Example 39 with TransportOutDescription

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;
}
Also used : AxisFault(org.apache.axis2.AxisFault) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) QName(javax.xml.namespace.QName) SOAPEnvelope(org.apache.axiom.soap.SOAPEnvelope) MessageContext(org.apache.axis2.context.MessageContext) HashMap(java.util.HashMap) Map(java.util.Map)

Example 40 with TransportOutDescription

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));
}
Also used : ConfigurationContext(org.apache.axis2.context.ConfigurationContext) AxisConfiguration(org.apache.axis2.engine.AxisConfiguration) Hashtable(java.util.Hashtable) MessageContext(org.apache.axis2.context.MessageContext) Session(javax.jms.Session) TransportOutDescription(org.apache.axis2.description.TransportOutDescription)

Aggregations

TransportOutDescription (org.apache.axis2.description.TransportOutDescription)28 AxisConfiguration (org.apache.axis2.engine.AxisConfiguration)20 Parameter (org.apache.axis2.description.Parameter)17 ConfigurationContext (org.apache.axis2.context.ConfigurationContext)16 MessageContext (org.apache.axis2.context.MessageContext)11 AxisFault (org.apache.axis2.AxisFault)9 QName (javax.xml.namespace.QName)7 OMElement (org.apache.axiom.om.OMElement)6 AxisService (org.apache.axis2.description.AxisService)6 TransportInDescription (org.apache.axis2.description.TransportInDescription)6 IOException (java.io.IOException)4 Map (java.util.Map)4 ServiceContext (org.apache.axis2.context.ServiceContext)4 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 HashMap (java.util.HashMap)3 OperationContext (org.apache.axis2.context.OperationContext)3 InOutAxisOperation (org.apache.axis2.description.InOutAxisOperation)3 OutTransportInfo (org.apache.axis2.transport.OutTransportInfo)3 VFSOutTransportInfo (org.apache.synapse.commons.vfs.VFSOutTransportInfo)3