Sunday, April 30, 2017

Invoke a Secured Backend ( Non-Repudiation ) using WSO2 ESB 5.0.0

This article explains how we can invoke a backend service, which is secured by Non-Repudiation through WSO2 ESB 5.0.0. Here I'm using the class mediator which is written for this purpose by Asela in [1]. The reason behind this class mediator option is clearly mentioned in [2].

[1] https://svn.wso2.org/repos/wso2/people/asela/ws-security/secure-callback/
[2] http://xacmlinfo.org/2014/09/26/improved-callback-for-calling-backend-services-from-wso2esb/

In this sample, I'm using the below flow:

SOAP UI Client -> EBS 5.0.0 Proxy service with secured endpoint with policy -> Backend ( ESB proxy secured with Non-Repudiation )

For the backend, we can use ESB4.8.1 functionality of securing using Non-Repudiation, in which way we can easily secure it using the management console.

1) Created a keystore to use to sign the outgoing request.

 keytool -genkeypair -alias partner2 -keyalg RSA -keysize 4096 -keystore partner2_keystore.jks -dname "C=LK,ST=WP,L=Colombo,O=WSO2,OU=Carbon,CN=partner2.com" -storepass partner2 -keypass partner2 -ext ku:c=dig,keyEncipherment,nR,dataEncipherment  


2) As our sample flow is like: Client (SOAP UI) -> ESB 5.0.0 ( Endpoint Secured Proxy ) -> Backend ( ESB Proxy secured with non repudiation policy )

We need to load the wso2carbon certificate to our newly created keystore ( partner2_keystore.jks ).

 keytool -export -keystore wso2carbon.jks -alias wso2carbon -file wso2carbon.cer  
   
 keytool -import -trustcacerts -alias wso2carbon -file wso2carbon.cer -keystore partner2_keystore.jks -storepass partner2  

3) Now if we check our newly created keystore we will see:

 keytool -v -list -keystore partner2_keystore.jks  

 Keystore type: JKS  
 Keystore provider: SUN  
   
 Your keystore contains 2 entries  
   
 Alias name: wso2carbon  
 Creation date: Apr 27, 2017  
 Entry type: trustedCertEntry  
   
 Owner: CN=localhost, O=WSO2, L=Mountain View, ST=CA, C=US  
 Issuer: CN=localhost, O=WSO2, L=Mountain View, ST=CA, C=US  
 Serial number: 4b7e3782  
 Valid from: Fri Feb 19 12:32:26 IST 2010 until: Tue Feb 13 12:32:26 IST 2035  
 Certificate fingerprints:  
       MD5: 02:FB:AA:5F:20:64:49:4A:27:29:55:71:83:F7:46:CD  
       SHA1: 6B:F8:E1:36:EB:36:D4:A5:6E:A0:5C:7A:E4:B9:A4:5B:63:BF:97:5D  
       SHA256: 1D:72:9F:B8:C4:68:EA:D8:20:A2:A0:BE:4A:DB:8F:BA:BE:D9:AB:1B:A1:26:C9:D2:14:66:C5:70:6E:8E:4D:30  
       Signature algorithm name: SHA1withRSA  
       Version: 3  
   
 Extensions:   
   
 #1: ObjectId: 2.5.29.15 Criticality=true  
 KeyUsage [  
  DigitalSignature  
  Non_repudiation  
  Key_Encipherment  
  Data_Encipherment  
 ]  
   
   
   
 *******************************************  
 *******************************************  
   
   
 Alias name: partner2  
 Creation date: Apr 27, 2017  
 Entry type: PrivateKeyEntry  
 Certificate chain length: 1  
 Certificate[1]:  
 Owner: C=LK, ST=WP, L=Colombo, O=WSO2, OU=Carbon, CN=partner2.com  
 Issuer: C=LK, ST=WP, L=Colombo, O=WSO2, OU=Carbon, CN=partner2.com  
 Serial number: 5e0d9a7b  
 Valid from: Thu Apr 27 12:38:49 IST 2017 until: Wed Jul 26 12:38:49 IST 2017  
 Certificate fingerprints:  
       MD5: 05:1F:15:7F:D1:56:6E:FA:BA:5F:FA:85:57:75:83:A8  
       SHA1: 29:60:F3:5E:F1:06:DF:78:C4:74:89:A3:CE:C4:13:9E:04:16:98:E7  
       SHA256: 59:1B:AE:34:9C:14:EC:EA:5C:35:07:01:16:CE:B9:73:98:A4:86:2B:D8:22:3C:5E:58:B9:FF:F4:08:FB:0D:33  
       Signature algorithm name: SHA256withRSA  
       Version: 3  
   
 Extensions:   
   
 #1: ObjectId: 2.5.29.15 Criticality=true  
 KeyUsage [  
  DigitalSignature  
  Non_repudiation  
  Key_Encipherment  
  Data_Encipherment  
 ]  
   
 #2: ObjectId: 2.5.29.14 Criticality=false  
 SubjectKeyIdentifier [  
 KeyIdentifier [  
 0000: 2E D6 37 7F DF A2 F1 39  5E 28 1D 43 2A 45 B7 60 ..7....9^(.C*E.`  
 0010: F8 8E 37 D7                    ..7.  
 ]  
 ]  
   
   
   
 *******************************************  
 *******************************************  

4) Now we need to load the certificate of our client to the backend Server's keystore.

 keytool -export -keystore partner2_keystore.jks -alias partner2 -file partner2.cer  
   
 keytool -import -trustcacerts -alias partner2 -file partner2.cer -keystore wso2carbon.jks -storepass wso2carbon  

5) Now we are done with certificate configurations.

6) Then download and copy the org.soasecurity.wssecurity.secure.callback-1.0.0.jar from [1] to ESB_HOME/repository/components/dropins.

7) Restart the ESB and load the partner2_keystore.jks to Keystores in management console.



8) Now create a policy which do the signing and send the message to backend and load it to the registry.

 <wsp:Policy wsu:Id="SigOnly"  
   xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">  
   <wsp:ExactlyOne>  
     <wsp:All>  
       <sp:AsymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">  
         <wsp:Policy>  
           <sp:InitiatorToken>  
             <wsp:Policy>  
               <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/AlwaysToRecipient">  
                 <wsp:Policy>  
                   <sp:RequireIssuerSerialReference/>  
                   <sp:WssX509V3Token10/>  
                 </wsp:Policy>  
               </sp:X509Token>  
             </wsp:Policy>  
           </sp:InitiatorToken>  
           <sp:RecipientToken>  
             <wsp:Policy>  
               <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">  
                 <wsp:Policy>  
                   <sp:RequireIssuerSerialReference/>  
                   <sp:WssX509V3Token10/>  
                 </wsp:Policy>  
               </sp:X509Token>  
             </wsp:Policy>  
           </sp:RecipientToken>  
           <sp:AlgorithmSuite>  
             <wsp:Policy>  
               <sp:Basic256/>  
             </wsp:Policy>  
           </sp:AlgorithmSuite>  
           <sp:Layout>  
             <wsp:Policy>  
               <sp:Strict/>  
             </wsp:Policy>  
           </sp:Layout>  
           <sp:IncludeTimestamp/>  
           <sp:OnlySignEntireHeadersAndBody/>  
         </wsp:Policy>  
       </sp:AsymmetricBinding>  
       <sp:Wss10 xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">  
         <wsp:Policy>  
           <sp:MustSupportRefKeyIdentifier/>  
           <sp:MustSupportRefIssuerSerial/>  
         </wsp:Policy>  
       </sp:Wss10>  
       <sp:SignedParts xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">  
         <sp:Body/>  
       </sp:SignedParts>  
     </wsp:All>  
   </wsp:ExactlyOne>  
   <rampart:RampartConfig xmlns:rampart="http://ws.apache.org/rampart/policy">  
        <rampart:rampartConfigCallbackClass>org.soasecurity.wssecurity.secure.callback.handler.ESBConfigCallbackHandler</rampart:rampartConfigCallbackClass>  
   </rampart:RampartConfig>  
 </wsp:Policy>  

9) Create a proxy as below:

Here:
privateKeyAlias - Alias name of the key inside the partner2_keystore.jks.
keyStore - The keystore we are going to use for the signing.
encryptionKeyAlias - This is the public certificate of the backend. Here I'm using wso2carbon as that's the backend i used in this sample.
http://ajanthan-ThinkPad-T440p:8280/services/NonRepudiationBackEND - This is the mock backend we created using the ESB's non-repudiation feature.

 <?xml version="1.0" encoding="UTF-8"?>  
 <proxy xmlns="http://ws.apache.org/ns/synapse"  
     name="TestRampartLoadProxy"  
     startOnLoad="true"  
     statistics="disable"  
     trace="disable"  
     transports="https,http">  
   <target>  
    <inSequence>  
      <log level="custom">  
       <property name="STATUS:"  
            value="-----------------TestRampartLoadProxy Invoked------------------"/>  
      </log>  
      <class name="org.soasecurity.wssecurity.secure.callback.mediator.ESBCallbackMediator">  
       <property name="privateKeyAlias" value="partner2"/>  
       <property name="keyStore" value="partner2_keystore.jks"/>  
       <property name="encryptionKeyAlias" value="wso2carbon"/>  
       <property name="userName" value=""/>  
      </class>  
      <send>  
       <endpoint>  
         <address uri="http://ajanthan-ThinkPad-T440p:8280/services/NonRepudiationBackEND">  
          <enableSec policy="conf:/policy/endpointsignpolicy.xml"/>  
         </address>  
       </endpoint>  
      </send>  
      <log level="custom">  
       <property name="STATUS:"  
            value="-----------------TestRampartLoadProxy Invoked: After Send------------------"/>  
      </log>  
    </inSequence>  
    <outSequence>  
      <log level="custom">  
       <property name="STATUS:"  
            value="-----------------TestRampartLoadProxy OUT Invoked ------------------"/>  
      </log>  
      <log level="full"/>  
      <send/>  
    </outSequence>  
   </target>  
   <description/>  
 </proxy>  

10) The Backend Proxy configuration as below:

 <?xml version="1.0" encoding="UTF-8"?>  
 <proxy xmlns="http://ws.apache.org/ns/synapse"  
     name="NonRepudiationBackEND"  
     transports="https,http,local"  
     statistics="disable"  
     trace="disable"  
     startOnLoad="true">  
   <target>  
    <inSequence>  
      <log level="custom">  
       <property name="STATUS"  
            value="-----------------NonRepudiationBackEND IN Invoked--------------------"/>  
      </log>  
      <log level="full"/>  
      <respond/>  
    </inSequence>  
   </target>  
   <parameter name="disableREST">true</parameter>  
   <parameter name="ScenarioID">scenario2</parameter>  
   <enableSec/>  
   <policy key="conf:/repository/axis2/service-groups/NonRepudiationBackEND/services/NonRepudiationBackEND/policies/SigOnly"/>  
   <description/>  
 </proxy>     

11) For testing send a message as below:

 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org">  
   <soapenv:Header/>  
   <soapenv:Body>  
    <echo:echoString>  
      <in>Test</in>  
    </echo:echoString>  
   </soapenv:Body>  
 </soapenv:Envelope>  

12) If we checked the wire logs, we can confirm that the message got signed during it goes out from fron end ESB and successfully invoked the backend and another signed message will come as out from the backend and when goes out from front ESB to the SOAP client it will remove the sign part and sent to SOAP client. This is because our front proxy is not secured for response signing only the back invocation is secured.
 [2017-04-27 14:42:41,072] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "POST /services/TestRampartLoadProxy HTTP/1.1[\r][\n]"  
 [2017-04-27 14:42:41,072] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "Accept-Encoding: gzip,deflate[\r][\n]"  
 [2017-04-27 14:42:41,073] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "Content-Type: text/xml;charset=UTF-8[\r][\n]"  
 [2017-04-27 14:42:41,073] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "SOAPAction: "urn:echoString"[\r][\n]"  
 [2017-04-27 14:42:41,073] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "Content-Length: 281[\r][\n]"  
 [2017-04-27 14:42:41,073] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "ProxySignOnlyHost: ajanthan-ThinkPad-T440p:8282[\r][\n]"  
 [2017-04-27 14:42:41,073] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "Connection: Keep-Alive[\r][\n]"  
 [2017-04-27 14:42:41,073] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]"  
 [2017-04-27 14:42:41,074] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "[\r][\n]"  
 [2017-04-27 14:42:41,074] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org">[\n]"  
 [2017-04-27 14:42:41,074] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "  <soapenv:Header/>[\n]"  
 [2017-04-27 14:42:41,074] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "  <soapenv:Body>[\n]"  
 [2017-04-27 14:42:41,074] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "   <echo:echoString>[\n]"  
 [2017-04-27 14:42:41,075] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "     <in>Test</in>[\n]"  
 [2017-04-27 14:42:41,075] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "   </echo:echoString>[\n]"  
 [2017-04-27 14:42:41,075] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "  </soapenv:Body>[\n]"  
 [2017-04-27 14:42:41,075] DEBUG - wire HTTP-Listener I/O dispatcher-3 >> "</soapenv:Envelope>"  
 [2017-04-27 14:42:41,077] INFO - LogMediator STATUS: = -----------------TestRampartLoadProxy Invoked------------------  
 [2017-04-27 14:42:41,159] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "POST /services/NonRepudiationBackEND HTTP/1.1[\r][\n]"  
 [2017-04-27 14:42:41,159] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Accept-Encoding: gzip,deflate[\r][\n]"  
 [2017-04-27 14:42:41,160] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Content-Type: text/xml;charset=UTF-8[\r][\n]"  
 [2017-04-27 14:42:41,160] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "SOAPAction: "urn:echoString"[\r][\n]"  
 [2017-04-27 14:42:41,160] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Transfer-Encoding: chunked[\r][\n]"  
 [2017-04-27 14:42:41,160] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Host: ajanthan-ThinkPad-T440p:8280[\r][\n]"  
 [2017-04-27 14:42:41,160] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "Connection: Keep-Alive[\r][\n]"  
 [2017-04-27 14:42:41,160] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"  
 [2017-04-27 14:42:41,161] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "[\r][\n]"  
 [2017-04-27 14:42:41,161] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "1413[\r][\n]"  
 [2017-04-27 14:42:41,161] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org"><soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-5"><wsu:Created>2017-04-27T09:12:41.080Z</wsu:Created><wsu:Expires>2017-04-27T09:17:41.080Z</wsu:Expires></wsu:Timestamp><wsse:BinarySecurityToken xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" wsu:Id="CertId-82A538C385C5F453B614932843610897">MIIFdTCCA12gAwIBAgIEXg2aezANBgkqhkiG9w0BAQsFADBjMRUwEwYDVQQDEwxwYXJ0bmVyMi5jb20xDzANBgNVBAsTBkNhcmJvbjENMAsGA1UEChMEV1NPMjEQMA4GA1UEBxMHQ29sb21ibzELMAkGA1UECBMCV1AxCzAJBgNVBAYTAkxLMB4XDTE3MDQyNzA3MDg0OVoXDTE3MDcyNjA3MDg0OVowYzEVMBMGA1UEAxMMcGFydG5lcjIuY29tMQ8wDQYDVQQLEwZDYXJib24xDTALBgNVBAoTBFdTTzIxEDAOBgNVBAcTB0NvbG9tYm8xCzAJBgNVBAgTAldQMQswCQYDVQQGEwJMSzCCAiIwDQYJKoZIhvcNAQEBBQADggIPADCCAgoCggIBAIUeFnqDGnzcoLEUrUCcRjKAKvgWDFDgSS8fQV8pf5wYoccArkXSbttS+PbBXVhB1L5mzNOBiGYONLg0uLYMQEtVv5GRcqcmNQa4rDTbHykqUjgZfWcaoBmlGqobXkO9yGg7JBDvKqg37jsJ2S9CptV8WYQlxnM2WJWFLxvJHFdoTSd6aAmE0KdG0GYggcrAnV/8OVcCzQ/7ZRExTKBRu+TfWSPVP/dCOrwYPMZzos2+j/KH3nfLtHjJdgOPzL/z6/+ycp87YQh2aSd6LLAK5GBkCAyuYEl7rJ+KDyj0jO3DTRF6PQcCXN5ESvjKqViSVl4myo1WcOcoL9KoyKVQcykPNR2+f7F/jtFp4nIPz2nEGqji6ULt0550Xybwsuflrs8PgST8BsyA1i8pKsdK4sy7EzmxOlE2yG/unURGCstmO8ddXo1ybHQPoz65z2IVO+7hCjRXGZCQtnFNcQSnOwr5sPux03nkW+M8SKVtqQfpUQZ9QbI9xsGKcuqmIGK/12tX5lfIut7oPy30/y0VnHe+6DzYwDkbJCinmU1qeldGYWmpJ522botqZXEDfTBlDRrkEA+Mqv6kjzrlU1AWxB3lCg67wgwEg18oOT6Q1vjaQAtWc27ypsJxLSBcUnk8jzJnynF7A84dOR/TjoR9Xp9H0k/AYaWIofyB9V9FAarfAgMBAAGjMTAvMA4GA1UdDwEB/wQEAwIE8DAdBgNVHQ4EFgQULtY3f9+i8TleKB1DKkW3YPiON9cwDQYJKoZIhvcNAQELBQADggIBAARiUPwci4bi4BKloW/QiQK2A+NCAe8phgMf3d54GM8OW2i2CNGrd5W8qjCIMTP+8PaFFG94zcTZWn+KOz2cru3NZktYiTo25SjdRzSxXadMK6qnWuybgHET55zwmAvju8yCiBVLqBF++3cV2h1EZWThjRYrsWJURFC7p6MNCKLdLfEJUlX5N3cdcyf6k+CenD0it1ktkddKujIkQlyNBpCM8nG6oJi13O5oO4kn9jSngWgcE+6hNv7X/dl9Y4NmrzXld5CMRamh/Mjm5p05dvuagesvZl64kQNZV6U0PF3f5L7PI9j5crm5te0A59jg8zaxv83DstovjcRFAzDqBCo5HTBUkE/L6oiIl1BNbaQalN14LfLqPY4K8ABR6SKa1dUODv3wN5pDkdhdMSyCR06Gt4uclI9haCUEpEndOiSyDoe9lq6+4FTCnDhMjpRm2Fy+MUjKG9ase9DH/71E0i2UQ0pP0ikEtIHUYU6MccobNfYjCBNMh4z6kdvcTXrmKlrtaeAPmnXoDs2pc20cAR80Aa9g6lyAkV1lQLO/axjfTruwmGxIbW0jq5bYKGs0+O/OcY16iENS2wmfSXNVi502CvDIIlIt/f0j4omdz4CCwraj04TGER9/xaK35j8Gkzk/UhcrDb3fDQKXiK1IOcMT+oj8N2tD8teOqZ8CSReo</wsse:BinarySecurityToken><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-6">[\n]"  
 [2017-04-27 14:42:41,161] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:SignedInfo>[\n]"  
 [2017-04-27 14:42:41,162] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>[\n]"  
 [2017-04-27 14:42:41,162] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>[\n]"  
 [2017-04-27 14:42:41,162] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:Reference URI="#Id-666433853">[\n]"  
 [2017-04-27 14:42:41,162] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:Transforms>[\n]"  
 [2017-04-27 14:42:41,162] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>[\n]"  
 [2017-04-27 14:42:41,162] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "</ds:Transforms>[\n]"  
 [2017-04-27 14:42:41,163] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>[\n]"  
 [2017-04-27 14:42:41,163] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:DigestValue>cZzOvBs4Xoea7pl71Jqb8sWcMOE=</ds:DigestValue>[\n]"  
 [2017-04-27 14:42:41,163] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "</ds:Reference>[\n]"  
 [2017-04-27 14:42:41,163] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:Reference URI="#Timestamp-5">[\n]"  
 [2017-04-27 14:42:41,164] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:Transforms>[\n]"  
 [2017-04-27 14:42:41,164] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>[\n]"  
 [2017-04-27 14:42:41,166] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "</ds:Transforms>[\n]"  
 [2017-04-27 14:42:41,166] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>[\n]"  
 [2017-04-27 14:42:41,167] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:DigestValue>ZRSs0tPK6yxqHCUv/J0jGSzHnYw=</ds:DigestValue>[\n]"  
 [2017-04-27 14:42:41,167] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "</ds:Reference>[\n]"  
 [2017-04-27 14:42:41,167] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "</ds:SignedInfo>[\n]"  
 [2017-04-27 14:42:41,167] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:SignatureValue>[\n]"  
 [2017-04-27 14:42:41,167] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "CYCLRYfVOaZfVfXVUbxPdDfDT5fjh070Ii9OgIwvW+lQE9MN+yyOuMb7HUY1RU2oNfPUu8XzsWAe[\n]"  
 [2017-04-27 14:42:41,167] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "EV9SfHKKDXK+3MRX0SKIk/ZzHG2UxgvPLZQUeyvLkaCeKh6G1ubXMFDr3HeWtZjYyKQnYDt0Rpfv[\n]"  
 [2017-04-27 14:42:41,168] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "k1PQ7Dufnn1OKu15RHMKvAMHIIxlblJmjGi4JkV3X3OiWiWudKtaUR8mq7qepspVqU66Pm54GdQR[\n]"  
 [2017-04-27 14:42:41,168] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "UuWY2UH3GzbNsNnKwWGwm/39sJJXD78Ehuv4LQP0cKq/jrc3U897OX4ZmlDkVr2BUCicIwJ+uybz[\n]"  
 [2017-04-27 14:42:41,168] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "e2bh07yp0TL7MDLLWc+sR4DaylZDFJxUSApaPgxTKBl/4kMDVdVXiOzMAOCVPtnT1dkzmWgTGjWS[\n]"  
 [2017-04-27 14:42:41,168] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "j37xKu8SkT6rwHnP9hCsJOhszQ+Ua0Tg6dOMFEsNAjZ4dCyF+tfgLAK+wPzphJOn/yEm261fLIDB[\n]"  
 [2017-04-27 14:42:41,168] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "wgYM7WI4tZM4VBVEBdNa2PNfG0CqY6eNFEOwlTh5SpByh7cwnHQX0NqX1SwYrEVFanKNnmJccbqr[\n]"  
 [2017-04-27 14:42:41,168] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "FAh50E8gJkEXk6frs2Hkd7AR/RPWdigZtPMRy9O1F74POH9r5toq47ZU9cIWNCl5TPbne4rdzFXU[\n]"  
 [2017-04-27 14:42:41,168] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "TUy00XeaNQl/92NGHtRi3+ZsD3u5g57mPnHd2y3Cvoxm5EAjHEFx726/DzosdLkiDXaC64jS4oU=[\n]"  
 [2017-04-27 14:42:41,168] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "</ds:SignatureValue>[\n]"  
 [2017-04-27 14:42:41,168] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<ds:KeyInfo Id="KeyId-82A538C385C5F453B614932843610898">[\n]"  
 [2017-04-27 14:42:41,169] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "<wsse:SecurityTokenReference xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="STRId-82A538C385C5F453B614932843610899"><wsse:Reference URI="#CertId-82A538C385C5F453B614932843610897" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3"/></wsse:SecurityTokenReference>[\n]"  
 [2017-04-27 14:42:41,169] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "</ds:KeyInfo>[\n]"  
 [2017-04-27 14:42:41,169] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "</ds:Signature></wsse:Security></soapenv:Header><soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-666433853">[\n]"  
 [2017-04-27 14:42:41,169] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "   <echo:echoString>[\n]"  
 [2017-04-27 14:42:41,169] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "     <in>Test</in>[\n]"  
 [2017-04-27 14:42:41,169] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "   </echo:echoString>[\n]"  
 [2017-04-27 14:42:41,169] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "  </soapenv:Body></soapenv:Envelope>[\r][\n]"  
 [2017-04-27 14:42:41,169] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "0[\r][\n]"  
 [2017-04-27 14:42:41,169] DEBUG - wire HTTP-Sender I/O dispatcher-3 << "[\r][\n]"  
 [2017-04-27 14:42:41,183] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "HTTP/1.1 200 OK[\r][\n]"  
 [2017-04-27 14:42:41,183] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "Host: ajanthan-ThinkPad-T440p:8280[\r][\n]"  
 [2017-04-27 14:42:41,183] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "SOAPAction: "urn:echoString"[\r][\n]"  
 [2017-04-27 14:42:41,183] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "Accept-Encoding: gzip,deflate[\r][\n]"  
 [2017-04-27 14:42:41,183] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "Content-Type: text/xml;charset=UTF-8[\r][\n]"  
 [2017-04-27 14:42:41,183] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "Date: Thu, 27 Apr 2017 09:12:41 GMT[\r][\n]"  
 [2017-04-27 14:42:41,183] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "Server: WSO2-PassThrough-HTTP[\r][\n]"  
 [2017-04-27 14:42:41,184] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "Transfer-Encoding: chunked[\r][\n]"  
 [2017-04-27 14:42:41,184] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "Connection: Keep-Alive[\r][\n]"  
 [2017-04-27 14:42:41,184] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "[\r][\n]"  
 [2017-04-27 14:42:41,184] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "a08[\r][\n]"  
 [2017-04-27 14:42:41,184] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org"><soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-5"><wsu:Created>2017-04-27T09:12:41.174Z</wsu:Created><wsu:Expires>2017-04-27T09:17:41.174Z</wsu:Expires></wsu:Timestamp><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-6">[\n]"  
 [2017-04-27 14:42:41,184] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:SignedInfo>[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:CanonicalizationMethod>[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"></ds:SignatureMethod>[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:Reference URI="#Id-666433853">[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:Transforms>[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:Transform>[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "</ds:Transforms>[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod>[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:DigestValue>cZzOvBs4Xoea7pl71Jqb8sWcMOE=</ds:DigestValue>[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "</ds:Reference>[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:Reference URI="#Timestamp-5">[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:Transforms>[\n]"  
 [2017-04-27 14:42:41,185] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"></ds:Transform>[\n]"  
 [2017-04-27 14:42:41,186] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "</ds:Transforms>[\n]"  
 [2017-04-27 14:42:41,186] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"></ds:DigestMethod>[\n]"  
 [2017-04-27 14:42:41,186] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:DigestValue>R1RdAeLnHkyi8cHBp8aoPLUF5EY=</ds:DigestValue>[\n]"  
 [2017-04-27 14:42:41,186] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "</ds:Reference>[\n]"  
 [2017-04-27 14:42:41,186] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "</ds:SignedInfo>[\n]"  
 [2017-04-27 14:42:41,186] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:SignatureValue>[\n]"  
 [2017-04-27 14:42:41,186] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "KneVvSOq/l5roCjtIYtoMDjgjUm4QYAWVO9tMmVxWYNairpLeE4QyKfpVL6D6y6PZ6PBB34m/PP2[\n]"  
 [2017-04-27 14:42:41,186] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "tWAyObh22PzlAZZBM/ikbMf7Whsc5mL44tBlKPIUz9PTErLQNTq1QswPeMSCw0uo5mqynYns8LCW[\n]"  
 [2017-04-27 14:42:41,186] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "BJG9PHDv4zU8rcSkj3A=[\n]"  
 [2017-04-27 14:42:41,187] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "</ds:SignatureValue>[\n]"  
 [2017-04-27 14:42:41,187] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<ds:KeyInfo Id="KeyId-E822D37D00541EA0F514932843611758">[\n]"  
 [2017-04-27 14:42:41,187] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "<wsse:SecurityTokenReference xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="STRId-E822D37D00541EA0F514932843611759"><wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1">a/jhNus21KVuoFx65LmkW2O/l10=</wsse:KeyIdentifier></wsse:SecurityTokenReference>[\n]"  
 [2017-04-27 14:42:41,187] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "</ds:KeyInfo>[\n]"  
 [2017-04-27 14:42:41,187] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "</ds:Signature></wsse:Security></soapenv:Header><soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-666433853">[\n]"  
 [2017-04-27 14:42:41,187] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "   <echo:echoString>[\n]"  
 [2017-04-27 14:42:41,188] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "     <in>Test</in>[\n]"  
 [2017-04-27 14:42:41,188] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "   </echo:echoString>[\n]"  
 [2017-04-27 14:42:41,188] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "  </soapenv:Body></soapenv:Envelope>[\r][\n]"  
 [2017-04-27 14:42:41,188] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "0[\r][\n]"  
 [2017-04-27 14:42:41,188] DEBUG - wire HTTP-Sender I/O dispatcher-3 >> "[\r][\n]"  
 [2017-04-27 14:42:41,194] INFO - LogMediator STATUS: = -----------------TestRampartLoadProxy OUT Invoked ------------------  
 [2017-04-27 14:42:41,195] INFO - LogMediator To: http://www.w3.org/2005/08/addressing/anonymous, WSAction: , SOAPAction: , MessageID: urn:uuid:061fde37-7eac-4170-86f6-97ecea67839e, Direction: response, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org"><soapenv:Header><wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" soapenv:mustUnderstand="1"><wsu:Timestamp xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Timestamp-5"><wsu:Created>2017-04-27T09:12:41.174Z</wsu:Created><wsu:Expires>2017-04-27T09:17:41.174Z</wsu:Expires></wsu:Timestamp><ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#" Id="Signature-6">  
 <ds:SignedInfo>  
 <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>  
 <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>  
 <ds:Reference URI="#Id-666433853">  
 <ds:Transforms>  
 <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>  
 </ds:Transforms>  
 <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>  
 <ds:DigestValue>cZzOvBs4Xoea7pl71Jqb8sWcMOE=</ds:DigestValue>  
 </ds:Reference>  
 <ds:Reference URI="#Timestamp-5">  
 <ds:Transforms>  
 <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#"/>  
 </ds:Transforms>  
 <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>  
 <ds:DigestValue>R1RdAeLnHkyi8cHBp8aoPLUF5EY=</ds:DigestValue>  
 </ds:Reference>  
 </ds:SignedInfo>  
 <ds:SignatureValue>  
 KneVvSOq/l5roCjtIYtoMDjgjUm4QYAWVO9tMmVxWYNairpLeE4QyKfpVL6D6y6PZ6PBB34m/PP2  
 tWAyObh22PzlAZZBM/ikbMf7Whsc5mL44tBlKPIUz9PTErLQNTq1QswPeMSCw0uo5mqynYns8LCW  
 BJG9PHDv4zU8rcSkj3A=  
 </ds:SignatureValue>  
 <ds:KeyInfo Id="KeyId-E822D37D00541EA0F514932843611758">  
 <wsse:SecurityTokenReference xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="STRId-E822D37D00541EA0F514932843611759"><wsse:KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/oasis-wss-soap-message-security-1.1#ThumbprintSHA1">a/jhNus21KVuoFx65LmkW2O/l10=</wsse:KeyIdentifier></wsse:SecurityTokenReference>  
 </ds:KeyInfo>  
 </ds:Signature></wsse:Security></soapenv:Header><soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-666433853">  
    <echo:echoString>  
      <in>Test</in>  
    </echo:echoString>  
   </soapenv:Body></soapenv:Envelope>  
 [2017-04-27 14:42:41,197] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "HTTP/1.1 200 OK[\r][\n]"  
 [2017-04-27 14:42:41,203] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "Host: ajanthan-ThinkPad-T440p:8280[\r][\n]"  
 [2017-04-27 14:42:41,203] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "SOAPAction: "urn:echoString"[\r][\n]"  
 [2017-04-27 14:42:41,203] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "Accept-Encoding: gzip,deflate[\r][\n]"  
 [2017-04-27 14:42:41,203] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "Content-Type: text/xml;charset=UTF-8[\r][\n]"  
 [2017-04-27 14:42:41,204] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "Date: Thu, 27 Apr 2017 09:12:41 GMT[\r][\n]"  
 [2017-04-27 14:42:41,204] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "Transfer-Encoding: chunked[\r][\n]"  
 [2017-04-27 14:42:41,204] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "Connection: Keep-Alive[\r][\n]"  
 [2017-04-27 14:42:41,205] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "[\r][\n]"  
 [2017-04-27 14:42:41,205] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "19a[\r][\n]"  
 [2017-04-27 14:42:41,205] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org"><soapenv:Body xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd" wsu:Id="Id-666433853">[\n]"  
 [2017-04-27 14:42:41,205] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "   <echo:echoString>[\n]"  
 [2017-04-27 14:42:41,205] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "     <in>Test</in>[\n]"  
 [2017-04-27 14:42:41,205] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "   </echo:echoString>[\n]"  
 [2017-04-27 14:42:41,206] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "  </soapenv:Body></soapenv:Envelope>[\r][\n]"  
 [2017-04-27 14:42:41,206] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "0[\r][\n]"  
 [2017-04-27 14:42:41,206] DEBUG - wire HTTP-Listener I/O dispatcher-3 << "[\r][\n]"  
   


References


[1] https://svn.wso2.org/repos/wso2/people/asela/ws-security/secure-callback/
[2] http://xacmlinfo.org/2014/09/26/improved-callback-for-calling-backend-services-from-wso2esb/

Saturday, April 22, 2017

Sending Single character < in a message which goes through a XSLT transformation WSO2 ESB 4.9.0

When we try to send a message which holds single character &lt; we will encounter a problem as explained in [1].

[1] http://ajanthane.blogspot.com/2017/04/reason-behind-comctcwstxexcwstxunexpect.html

Take the below request:
 <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org">  
   <soapenv:Header/>  
   <soapenv:Body>  
    <Description>Test for escaping &lt; &gt; characters</Description>  
   </soapenv:Body>  
 </soapenv:Envelope>  

Which goes through a sample proxy as below:
 <?xml version="1.0" encoding="UTF-8"?>  
 <proxy xmlns="http://ws.apache.org/ns/synapse"  
     name="CheckXSLTEscapeCharacters"  
     transports="https,http"  
     statistics="disable"  
     trace="disable"  
     startOnLoad="true">  
   <target>  
    <inSequence>  
      <log level="custom">  
       <property name="STATUS"  
            value="--------------------CheckXSLTEscapeCharacters Invoked--------------------"/>  
      </log>  
      <log level="full"/>  
      <log level="custom">  
       <property name="STATUS"  
            value="--------------------CheckXSLTEscapeCharacters After Log full Invoked--------------------"/>  
      </log>  
      <xslt key="conf:TransformationXSLT.xslt"/>  
      <log level="custom">  
       <property name="STATUS"  
            value="--------------------CheckXSLTEscapeCharacters Invoked After XSLT Transformation--------------------"/>  
      </log>  
      <respond/>  
    </inSequence>  
   </target>  
   <description/>  
 </proxy>  

The XSLT used here is as below:
 <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="2.0">  
   <xsl:output method="xml" indent="yes" cdata-section-elements="Description"/>  
   <xsl:preserve-space elements="*" />  
   <xsl:template match="Description">  
     <Description>  
      <xsl:value-of select="." disable-output-escaping="yes" />  
     </Description>  
   </xsl:template>  
   <xsl:template match="@*|node()">  
     <xsl:copy>  
       <xsl:apply-templates select="@*|node()"/>  
     </xsl:copy>  
   </xsl:template>  
 </xsl:stylesheet>  

During this will get an error as below:
 [2017-04-21 21:15:23,882] DEBUG - wire >> "POST /services/CheckXSLTEscapeCharacters HTTP/1.1[\r][\n]"  
 [2017-04-21 21:15:23,883] DEBUG - wire >> "Accept-Encoding: gzip,deflate[\r][\n]"  
 [2017-04-21 21:15:23,883] DEBUG - wire >> "Content-Type: text/xml;charset=UTF-8[\r][\n]"  
 [2017-04-21 21:15:23,883] DEBUG - wire >> "SOAPAction: "urn:echoString"[\r][\n]"  
 [2017-04-21 21:15:23,883] DEBUG - wire >> "Content-Length: 281[\r][\n]"  
 [2017-04-21 21:15:23,883] DEBUG - wire >> "Host: ajanthan-ThinkPad-T440p:8280[\r][\n]"  
 [2017-04-21 21:15:23,884] DEBUG - wire >> "Connection: Keep-Alive[\r][\n]"  
 [2017-04-21 21:15:23,884] DEBUG - wire >> "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]"  
 [2017-04-21 21:15:23,884] DEBUG - wire >> "[\r][\n]"  
 [2017-04-21 21:15:23,884] DEBUG - wire >> "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org">[\n]"  
 [2017-04-21 21:15:23,884] DEBUG - wire >> "  <soapenv:Header/>[\n]"  
 [2017-04-21 21:15:23,885] DEBUG - wire >> "  <soapenv:Body>[\n]"  
 [2017-04-21 21:15:23,885] DEBUG - wire >> "   <Description>Test for escaping &lt; &gt; characters</Description>[\n]"  
 [2017-04-21 21:15:23,885] DEBUG - wire >> "  </soapenv:Body>[\n]"  
 [2017-04-21 21:15:23,885] DEBUG - wire >> "</soapenv:Envelope>"  
 [2017-04-21 21:15:23,917] INFO - LogMediator STATUS = --------------------CheckXSLTEscapeCharacters Invoked--------------------  
 [2017-04-21 21:15:23,917] INFO - LogMediator To: /services/CheckXSLTEscapeCharacters, WSAction: urn:echoString, SOAPAction: urn:echoString, MessageID: urn:uuid:4e549a72-8b19-494f-84a9-351509a2b184, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org"><soapenv:Body>  
    <Description>Test for escaping &lt; > characters</Description>  
   </soapenv:Body></soapenv:Envelope>  
 [2017-04-21 21:15:23,917] INFO - LogMediator STATUS = --------------------CheckXSLTEscapeCharacters After Log full Invoked--------------------  
 [2017-04-21 21:15:31,664] ERROR - XSLTMediator Unable to perform XSLT transformation using : Value {name ='null', keyValue ='conf:TransformationXSLT.xslt'} against source XPath : s11:Body/child::*[position()=1] | s12:Body/child::*[position()=1] reason : com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ' ' (code 32) in content after '<' (malformed start element?).  
  at [row,col {unknown-source}]: [2,33]  
 org.apache.axiom.om.OMException: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ' ' (code 32) in content after '<' (malformed start element?).  
  at [row,col {unknown-source}]: [2,33]  
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:296)  
      at org.apache.axiom.om.impl.llom.OMSerializableImpl.build(OMSerializableImpl.java:78)  
      at org.apache.axiom.om.impl.llom.OMElementImpl.build(OMElementImpl.java:722)  
      at org.apache.axiom.om.impl.llom.OMElementImpl.detach(OMElementImpl.java:700)  
      at org.apache.axiom.om.impl.llom.OMNodeImpl.setParent(OMNodeImpl.java:105)  
      at org.apache.axiom.om.impl.llom.OMNodeImpl.insertSiblingAfter(OMNodeImpl.java:203)  
      at org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:360)  
      at org.apache.synapse.mediators.transform.XSLTMediator.mediate(XSLTMediator.java:196)  
      at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:81)  
      at org.apache.synapse.mediators.AbstractListMediator.mediate(AbstractListMediator.java:48)  
      at org.apache.synapse.mediators.base.SequenceMediator.mediate(SequenceMediator.java:149)  
      at org.apache.synapse.core.axis2.ProxyServiceMessageReceiver.receive(ProxyServiceMessageReceiver.java:185)  
      at org.apache.axis2.engine.AxisEngine.receive(AxisEngine.java:180)  
      at org.apache.synapse.transport.passthru.ServerWorker.processEntityEnclosingRequest(ServerWorker.java:395)  
      at org.apache.synapse.transport.passthru.ServerWorker.run(ServerWorker.java:142)  
      at org.apache.axis2.transport.base.threads.NativeWorkerPool$1.run(NativeWorkerPool.java:172)  
      at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)  
      at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)  
      at java.lang.Thread.run(Thread.java:745)  
 Caused by: com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ' ' (code 32) in content after '<' (malformed start element?).  
  at [row,col {unknown-source}]: [2,33]  
      at com.ctc.wstx.sr.StreamScanner.throwUnexpectedChar(StreamScanner.java:639)  
      at com.ctc.wstx.sr.BasicStreamReader.nextFromTree(BasicStreamReader.java:2843)  
      at com.ctc.wstx.sr.BasicStreamReader.next(BasicStreamReader.java:1072)  
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.parserNext(StAXOMBuilder.java:681)  
      at org.apache.axiom.om.impl.builder.StAXOMBuilder.next(StAXOMBuilder.java:214)  
      at org.apache.axiom.om.impl.llom.OMElementImpl.buildNext(OMElementImpl.java:653)  
      at org.apache.axiom.om.impl.llom.OMNodeImpl.getNextOMSibling(OMNodeImpl.java:122)  
      at org.apache.axiom.om.impl.traverse.OMChildrenIterator.getNextNode(OMChildrenIterator.java:36)  
      at org.apache.axiom.om.impl.traverse.OMAbstractIterator.hasNext(OMAbstractIterator.java:58)  
      at org.apache.axiom.om.impl.util.OMSerializerUtil.serializeChildren(OMSerializerUtil.java:554)  
      at org.apache.axiom.om.impl.llom.OMElementImpl.internalSerialize(OMElementImpl.java:875)  
      at org.apache.axiom.om.impl.llom.OMSerializableImpl.serialize(OMSerializableImpl.java:125)  
      at org.apache.axiom.om.impl.llom.OMSerializableImpl.serialize(OMSerializableImpl.java:113)  
      at org.apache.axiom.om.impl.llom.OMElementImpl.toString(OMElementImpl.java:988)  
      at org.apache.synapse.mediators.transform.XSLTMediator.performXSLT(XSLTMediator.java:310)  
      ... 12 more  
 [2017-04-21 21:15:31,671] INFO - LogMediator To: /services/CheckXSLTEscapeCharacters, WSAction: urn:echoString, SOAPAction: urn:echoString, MessageID: urn:uuid:4e549a72-8b19-494f-84a9-351509a2b184, Direction: request, MESSAGE = Executing default 'fault' sequence, ERROR_CODE = 0, ERROR_MESSAGE = Unable to perform XSLT transformation using : Value {name ='null', keyValue ='conf:TransformationXSLT.xslt'} against source XPath : s11:Body/child::*[position()=1] | s12:Body/child::*[position()=1] reason : com.ctc.wstx.exc.WstxUnexpectedCharException: Unexpected character ' ' (code 32) in content after '<' (malformed start element?)., Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org"><soapenv:Body>  
    <Description>Test for escaping &lt; > characters</Description>  
   </soapenv:Body></soapenv:Envelope>  
 [2017-04-21 21:15:31,672] DEBUG - wire << "HTTP/1.1 202 Accepted[\r][\n]"  
 [2017-04-21 21:15:31,673] DEBUG - wire << "Date: Fri, 21 Apr 2017 15:45:31 GMT[\r][\n]"  
 [2017-04-21 21:15:31,673] DEBUG - wire << "Transfer-Encoding: chunked[\r][\n]"  
 [2017-04-21 21:15:31,673] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"  
 [2017-04-21 21:15:31,674] DEBUG - wire << "[\r][\n]"  
 [2017-04-21 21:15:31,674] DEBUG - wire << "0[\r][\n]"  
 [2017-04-21 21:15:31,674] DEBUG - wire << "[\r][\n]"  

To overcome this we need to follow the below steps.

1) Create a file named XMLInputFactory.properties inside ESB_HOME folder.

2) Add the below content to it.
javax.xml.stream.isCoalescing=false

3) Make sure to enable cdata-section-elements in the XSLT file. I have already enabled it in the above sample and provided the Description tag, which is the one holds the data which needs to be passed as CDATA segment.

Also make sure that disable-output-escaping="no" in the XSLT stylesheet.

4) Now send the same request. Will get the below log which indicates that we successfully sent the message.
 [2017-04-21 21:28:06,529] DEBUG - wire >> "POST /services/CheckXSLTEscapeCharacters HTTP/1.1[\r][\n]"  
 [2017-04-21 21:28:06,531] DEBUG - wire >> "Accept-Encoding: gzip,deflate[\r][\n]"  
 [2017-04-21 21:28:06,531] DEBUG - wire >> "Content-Type: text/xml;charset=UTF-8[\r][\n]"  
 [2017-04-21 21:28:06,532] DEBUG - wire >> "SOAPAction: "urn:echoString"[\r][\n]"  
 [2017-04-21 21:28:06,532] DEBUG - wire >> "Content-Length: 281[\r][\n]"  
 [2017-04-21 21:28:06,532] DEBUG - wire >> "Host: ajanthan-ThinkPad-T440p:8280[\r][\n]"  
 [2017-04-21 21:28:06,532] DEBUG - wire >> "Connection: Keep-Alive[\r][\n]"  
 [2017-04-21 21:28:06,532] DEBUG - wire >> "User-Agent: Apache-HttpClient/4.1.1 (java 1.5)[\r][\n]"  
 [2017-04-21 21:28:06,532] DEBUG - wire >> "[\r][\n]"  
 [2017-04-21 21:28:06,532] DEBUG - wire >> "<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org">[\n]"  
 [2017-04-21 21:28:06,532] DEBUG - wire >> "  <soapenv:Header/>[\n]"  
 [2017-04-21 21:28:06,533] DEBUG - wire >> "  <soapenv:Body>[\n]"  
 [2017-04-21 21:28:06,533] DEBUG - wire >> "   <Description>Test for escaping &lt; &gt; characters</Description>[\n]"  
 [2017-04-21 21:28:06,533] DEBUG - wire >> "  </soapenv:Body>[\n]"  
 [2017-04-21 21:28:06,533] DEBUG - wire >> "</soapenv:Envelope>"  
 [2017-04-21 21:28:06,535] INFO - LogMediator STATUS = --------------------CheckXSLTEscapeCharacters Invoked--------------------  
 [2017-04-21 21:28:06,536] INFO - LogMediator To: /services/CheckXSLTEscapeCharacters, WSAction: urn:echoString, SOAPAction: urn:echoString, MessageID: urn:uuid:9813658e-ea39-48aa-9da4-d88e91ac087f, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org"><soapenv:Body>  
    <Description>Test for escaping &lt; > characters</Description>  
   </soapenv:Body></soapenv:Envelope>  
 [2017-04-21 21:28:06,537] INFO - LogMediator STATUS = --------------------CheckXSLTEscapeCharacters After Log full Invoked--------------------  
 [2017-04-21 21:28:06,543] INFO - LogMediator STATUS = --------------------CheckXSLTEscapeCharacters Invoked After XSLT Transformation--------------------  
 [2017-04-21 21:28:06,554] DEBUG - wire << "HTTP/1.1 200 OK[\r][\n]"  
 [2017-04-21 21:28:06,558] DEBUG - wire << "Host: ajanthan-ThinkPad-T440p:8280[\r][\n]"  
 [2017-04-21 21:28:06,559] DEBUG - wire << "SOAPAction: "urn:echoString"[\r][\n]"  
 [2017-04-21 21:28:06,559] DEBUG - wire << "Accept-Encoding: gzip,deflate[\r][\n]"  
 [2017-04-21 21:28:06,560] DEBUG - wire << "Content-Type: text/xml;charset=UTF-8; charset=UTF-8[\r][\n]"  
 [2017-04-21 21:28:06,560] DEBUG - wire << "Date: Fri, 21 Apr 2017 15:58:06 GMT[\r][\n]"  
 [2017-04-21 21:28:06,560] DEBUG - wire << "Transfer-Encoding: chunked[\r][\n]"  
 [2017-04-21 21:28:06,560] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"  
 [2017-04-21 21:28:06,560] DEBUG - wire << "[\r][\n]"  
 [2017-04-21 21:28:06,560] DEBUG - wire << "145[\r][\n]"  
 [2017-04-21 21:28:06,561] DEBUG - wire << "<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:echo="http://echo.services.core.carbon.wso2.org">[\n]"  
 [2017-04-21 21:28:06,561] DEBUG - wire << "  <soapenv:Header/>[\n]"  
 [2017-04-21 21:28:06,561] DEBUG - wire << "  <soapenv:Body>[\n]"  
 [2017-04-21 21:28:06,561] DEBUG - wire << "   <Description><![CDATA[Test for escaping < > characters]]></Description>[\n]"  
 [2017-04-21 21:28:06,561] DEBUG - wire << "  </soapenv:Body>[\n]"  
 [2017-04-21 21:28:06,561] DEBUG - wire << "</soapenv:Envelope>[\r][\n]"  
 [2017-04-21 21:28:06,561] DEBUG - wire << "0[\r][\n]"  
 [2017-04-21 21:28:06,562] DEBUG - wire << "[\r][\n]"  


Wednesday, March 22, 2017

Splitting Large files using Ubuntu Linux Command

Sometimes when we analyze large log files, we need to split them to analyze. Use the below linux command to split a large file into 1GB files.

split -b 1G -d <large_file_path> <file_name_for_parts>


Saturday, March 18, 2017

Integrating WSO2 ESB 5.0.0 with Oracle Advanced Queue ( AQ ) ( PART2 )

This is continuation of blog Integrating WSO2 ESB 5.0.0 with Oracle Advanced Queue ( AQ )  ( PART1 )

Now we need to do the configuration for the hierarchy, which we saw earlier. To do that modify the below ldif and upload it through the administrative context created above.

Below is the content of the load_config.ldif file. Right click on the created Administrative Context partition and load the ldif file.
dn: uid=ajanthan,ou=DevOpsTeam,o=wso2,c=lk
objectClass: organizationalPerson
objectClass: person
objectClass: inetOrgPerson
objectClass: top
cn: admin
sn: admin
uid: ajanthan
userPassword:: batticaloa

dn: cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk
objectClass: top
objectClass: javaContainer
cn: OracleContext

dn: cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk
objectClass: top
objectClass: orclContainer
cn: XE

dn: cn=OracleDBQueues,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk
objectClass: top
objectClass: orclContainer
cn: OracleDBQueues

dn: cn=ESBAQADMIN.MESSAGE_QUEUE,cn=OracleDBQueues,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk
orcldbaqpointerattr: cn=ESBAQADMIN.ESB_QUEUE_MESSAGE_TABLE,cn=OracleDBQueuesTables,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk
javaClassName: oracle.jms.AQjmsDestination
orcldbaqobjname: MESSAGE_QUEUE
javaFactory: oracle.jms.AQjmsDestinationFactory
objectClass: top
objectClass: javaContainer
objectClass: javaObject
objectClass: javaNamingReference
objectClass: orclDBAQObject
orcldbaqobjtype: Queue
cn: ESBAQADMIN.MESSAGE_QUEUE
orcldbaqgeneric: maxretries=3
orcldbaqobjowner: ESBAQADMIN

dn: cn=OracleDBQueuesTables,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk
objectClass: top
objectClass: orclContainer
cn: OracleDBQueuesTables

dn: cn=ESBAQADMIN.ESB_QUEUE_MESSAGE_TABLE,cn=OracleDBQueuesTables,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk
orcldbaqobjname: ESB_QUEUE_MESSAGE_TABLE
orcldbaqobjtype: QueueTable
objectClass: top
objectClass: javaContainer
objectClass: javaObject
objectClass: javaNamingReference
objectClass: orclDBAQObject
javaClassName: oracle.AQ.AQOracleQueueTable
javaFactory: oracle.AQ.AQOracleQueueTableFactory
orcldbaqobjowner: ESBAQADMIN
orcldbaqgeneric: PayloadType=SYS.AQ$_JMS_TEXT_MESSAGE
cn: ESBAQADMIN.ESB_QUEUE_MESSAGE_TABLE

dn: cn=oracledbconnections,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk
objectClass: top
objectClass: orclContainer
cn: oracledbconnections

dn: cn=ESBAQADMIN,cn=oracledbconnections,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk
objectClass: top
objectClass: javaContainer
objectClass: javaObject
objectClass: javaNamingReference
objectClass: orclDBAQConnection
javaFactory: oracle.jms.AQjmsConnectionFactory
javaClassName: oracle.jms.AQjmsQueueConnectionFactory
cn: ESBAQADMIN
orcldbaqgeneric: JDBC_connect_string=jdbc:oracle:thin:@localhost:1521:xe
orcldbaqgeneric: Username=ESBAQADMIN
orcldbaqgeneric: Password=ESBAQADMIN





After the successful load you will get the below screen.


Now we have successfully made the connection between LDAP Server and Oracle AQ Queue.


4) Configuring WSO2 ESB 5.0.0 

1) First we need to enable the JMS transport sender and listener. Add the below to the axis2.xml.

<transportReceiver name="jms" class="org.apache.axis2.transport.jms.JMSListener">  
  <parameter name="myQueueConnectionFactory" locked="false">  
   <parameter name="java.naming.factory.initial" locked="false">com.sun.jndi.ldap.LdapCtxFactory</parameter>  
   <parameter name="java.naming.provider.url" locked="false">ldap://localhost:10389</parameter>  
   <parameter name="server_dn" locked="false">cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk</parameter>  
   <parameter name="java.naming.security.principal" locked="false">uid=ajanthan,ou=DevOpsTeam,o=wso2,c=lk</parameter>  
   <parameter name="java.naming.security.credentials" locked="false">batticaloa</parameter>  
   <parameter name="java.naming.security.authentication" locked="false">simple</parameter>  
   <parameter name="transport.jms.UserName" locked="false">esbaqadmin</parameter>  
   <parameter name="transport.jms.Password" locked="false">esbaqadmin</parameter>                 
   <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">cn=ESBAQADMIN,cn=oracledbconnections,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk</parameter>  
   <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>  
  </parameter>  
  <parameter name="default" locked="false">  
   <parameter name="java.naming.factory.initial" locked="false">com.sun.jndi.ldap.LdapCtxFactory</parameter>  
   <parameter name="java.naming.provider.url" locked="false">ldap://localhost:10389</parameter>  
   <parameter name="server_dn" locked="false">cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk</parameter>  
   <parameter name="java.naming.security.principal" locked="false">uid=ajanthan,ou=DevOpsTeam,o=wso2,c=lk</parameter>  
   <parameter name="java.naming.security.credentials" locked="false">batticaloa</parameter>  
   <parameter name="java.naming.security.authentication" locked="false">simple</parameter>  
   <parameter name="transport.jms.UserName" locked="false">esbaqadmin</parameter>  
   <parameter name="transport.jms.Password" locked="false">esbaqadmin</parameter>  
   <parameter name="transport.jms.ConnectionFactoryJNDIName" locked="false">cn=ESBAQADMIN,cn=oracledbconnections,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk</parameter>  
   <parameter name="transport.jms.ConnectionFactoryType" locked="false">queue</parameter>  
  </parameter>   
 </transportReceiver> 

<transportSender name="jms" class="org.apache.axis2.transport.jms.JMSSender"/>

2) Need to copy the required JARS to ESB_HOME/repository/components/lib folder. You can find the JARS at below link.

https://drive.google.com/file/d/0B-VAIXmh-0yebnEzeVlJekNEeTQ/view?usp=sharing

3) Now start the ESB server. At that time If you get any error as below:

Caused by: javax.naming.AuthenticationException: [LDAP: error code 49 - INVALID_CREDENTIALS: Bind failed: ERR_229 Cannot authenticate user uid=ajanthan,ou=DevOpsTeam,o=wso2,c=lk]
 at com.sun.jndi.ldap.LdapCtx.mapErrorCode(LdapCtx.java:3136)
 at com.sun.jndi.ldap.LdapCtx.processReturnCode(LdapCtx.java:3082)

This is due to the password of the use we specified in the ldif file. We can reset the password using the ApacheDS below screens.





4) Now we are going create the Sender Proxy.

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="OracleAQMessageSender"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="http,https">
   <target>
      <inSequence>
         <log level="custom">
            <property name="STATUS"
                      value="----------------OracleAQMessageSender Invoked----------------"/>
         </log>
         <property name="OUT_ONLY" value="true"/>
         <property name="FORCE_SC_ACCEPTED" scope="axis2" value="true"/>
         <send>
            <endpoint>
               <address uri="jms:/cn=ESBAQADMIN.MESSAGE_QUEUE,cn=OracleDBQueues,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk?java.naming.factory.initial=com.sun.jndi.ldap.LdapCtxFactory&transport.jms.ConnectionFactoryJNDIName=cn=ESBAQADMIN,cn=oracledbconnections,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk&java.naming.provider.url=ldap://localhost:10389/& transport.jms.DestinationType=queue& server_dn=cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk& java.naming.security.principal=uid=ajanthan,ou=DevOpsTeam,o=wso2,c=lk&java.naming.security.credentials=batticaloa& java.naming.security.authentication=simple&transport.jms.UserName=esbaqadmin&transport.jms.Password=esbaqadmin"/>
            </endpoint>
         </send>
      </inSequence>
   </target>
   <description/>
</proxy>

5) Now send the message. The sample message sent from SOAP UI as below:


We can check whether the queue received the message using below Screen.


6) Now we will check the listener Proxy. Create a proxy as below:

<?xml version="1.0" encoding="UTF-8"?>
<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="OracleAQListenerProxy"
       startOnLoad="true"
       statistics="disable"
       trace="disable"
       transports="jms">
   <target>
      <inSequence>
         <log level="full"/>
         <drop/>
      </inSequence>
   </target>
   <parameter name="transport.jms.Destination">cn=ESBAQADMIN.MESSAGE_QUEUE,cn=OracleDBQueues,cn=XE,cn=OracleContext,ou=DevOpsTeam,o=wso2,c=lk</parameter>
   <parameter name="transport.jms.ContentType">
      <rules xmlns="">
         <jmsProperty>ContentType</jmsProperty>
         <default>text/plain</default>
      </rules>
   </parameter>
   <description/>
</proxy>

7) The carbon log will show the message read from the queue.

[2017-03-18 21:14:52,391]  INFO - LogMediator To: , WSAction: "urn:mediate", SOAPAction: "urn:mediate", MessageID: ID:4B042CCE936269E8E050007F01014B5F, Direction: request, Envelope: <?xml version='1.0' encoding='utf-8'?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><axis2ns4:text xmlns:axis2ns4="http://ws.apache.org/commons/ns/payload">ajanthan test AQ Sender 
</axis2ns4:text></soapenv:Body></soapenv:Envelope>

That's all. We have successfully configured WSO2 ESB with Oracle AQ through LDAP Server.



Saturday, March 11, 2017

Integrating WSO2 ESB 5.0.0 with Oracle Advanced Queue ( AQ ) ( PART1 )

This Article explains how we can configure WSO2 ESB 5.0.0 with Oracle Advanced Queue. The Flow we are going to integrate here is:


Contents Included:


1) What is Oracle AQ ( Advanced Queue )?
2) Setting up AQ in Oracle Database
3) Configuring LDAP Server
4) Configuring WSO2 ESB 5.0.0

1) What is Oracle AQ ( Advanced Queue )?


Oracle Advanced Queue is a message-oriented middleware, which provides database-integrated message queuing functionality. As this integrated with the database, the functional benefits of database can be obtained while using this.

Messages can be queried using standard SQL. This means that you can use SQL to access the message properties, the message history, and the payload. With SQL access you can also audit and track messages. All available SQL technology, such as indexes, can be used to optimize access to messages.

Above information extracted from [1] and for more information can refer [1] and [2].


2) Setting up Advanced Queue in Oracle Database


Queue Creation

1) First we need to create role, here we are going to create two roles, one is for administrator and other is for the users with the below privileges.


Execute the below commands to create the two roles:

sqlplus / as sysdba;

CREATE ROLE aqesb_adm_role;
GRANT CONNECT, RESOURCE, aq_administrator_role TO aqesb_adm_role; 


CREATE USER esbaqadmin IDENTIFIED BY esbaqadmin;

GRANT aqesb_adm_role TO esbaqadmin; 

ALTER user esbaqadmin quota 50m on system;


Now log in as our AQ Administrator and execute the below commands.

EXECUTE DBMS_AQADM.CREATE_QUEUE_TABLE (Queue_table => 'ESBAQADMIN.MESSAGE_QUEUE_TABLE', Queue_payload_type => 'SYS.AQ$_JMS_TEXT_MESSAGE');

EXECUTE DBMS_AQADM.CREATE_QUEUE (Queue_name => 'ESBAQADMIN.MESSAGE_QUEUE', Queue_table => 'ESBAQADMIN.MESSAGE_QUEUE_TABLE');

EXECUTE DBMS_AQADM.START_QUEUE (Queue_name => 'ESBAQADMIN.MESSAGE_QUEUE');


Below are some useful commands to drop the queue and queue table:


EXECUTE DBMS_AQADM.DROP_QUEUE_TABLE (queue_table => 'ESB_QUEUE_MESSAGE_TABLE');

EXECUTE DBMS_AQADM.DROP_QUEUE (Queue_name => 'MESSAGE_QUEUE');

Now our oracle queue is ready for use.

When you connect through Oracle SQL Developer using esbaqadmin account, you will get the below screen.



3) Configuring LDAP Server


Here I'm using ApacheDS [1] ldap server and the Apache Directory studio [2].


Installation details can be found at [3].

[3] https://technology.amis.nl/2014/10/22/getting-started-with-apacheds-ldap-server-and-directory-studio/

Follow the below screens to establish the connection between LDAP Server and Apache Directory Studio.

The default connection parameters ( username / password / port ) of ldap servers can be found at this link [4].

[4] https://directory.apache.org/studio/users-guide/ldap_browser/gettingstarted_create_connection.html




Here the default bind password is: secret





Creating own Partitions

In ApacheDS, partitions are used to organize directories into domains. More details on creating partitions can be found at http://directory.apache.org/apacheds/basic-ug/1.4.3-adding-partition.html

Before we start to create the partitions, first we need to load the needed object classes and schema of oracle.

To implement any open solution for Oracle LDAP, the Schema for Oracle Net Services must be imported into it.

Copy the below content to oracle_schema.ldif file.

# SCHEMA "ORACLE"
dn: cn=oracle, ou=schema
objectclass: metaSchema
objectclass: top
cn: oracle
m-dependencies: system
m-dependencies: core
m-dependencies: java

dn: ou=attributetypes, cn=oracle, ou=schema
objectclass: organizationalUnit
objectclass: top
ou: attributetypes

dn: m-oid=2.16.840.1.113894.2.1.100.1, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.2.1.100.1
m-name: orcldbaqgeneric
m-description: orcldbaqgeneric
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15

dn: m-oid=2.16.840.1.113894.2.1.100.2, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.2.1.100.2
m-name: orcldbaqobjname
m-description: orcldbaqobjname
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.2.1.100.3, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.2.1.100.3
m-name: orcldbaqobjowner
m-description: orcldbaqobjowner
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.2.1.100.4, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.2.1.100.4
m-name: orcldbaqobjtype
m-description: orcldbaqobjtype
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.2.1.100.5, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.2.1.100.5
m-name: orcldbaqpointerattr
m-description: orcldbaqpointerattr
m-equality: DistinguishedNameMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.12
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.7.1.1, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.7.1.1
m-name: orclVersion
m-description: orclVersion
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.7.1.4, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.7.1.4
m-name: orclServiceType
m-description: orclServiceType
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.3.1.1, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.1
m-name: orclNetSourceRoute
m-description: orclNetSourceRoute
m-syntax: 1.3.6.1.4.1.1466.115.121.1.5
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.3.1.2, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.2
m-name: orclNetLoadBalance
m-description: orclNetLoadBalance
m-syntax: 1.3.6.1.4.1.1466.115.121.1.5
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.3.1.3, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.3
m-name: orclNetFailover
m-description: orclNetFailover
m-syntax: 1.3.6.1.4.1.1466.115.121.1.5
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.3.1.12, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.12
m-name: orclNetDescName
m-description: orclNetDescName
m-equality: DistinguishedNameMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.12
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.3.1.6, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.6
m-name: orclNetServiceName
m-description: orclNetServiceName
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.3.1.13, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.13
m-name: orclNetDescString
m-description: orclNetDescString
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.3.1.14, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.14
m-name: orclNetAddressString
m-description: orclNetAddressString
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.3.1.15, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.15
m-name: orclNetProtocol
m-description: orclNetProtocol
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.3.1.16, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.16
m-name: orclNetShared
m-description: orclNetShared
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15
m-singleValue: TRUE

dn: m-oid=2.16.840.1.113894.3.1.17, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.17
m-name: orclNetAddrList
m-description: orclNetAddrList
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15

dn: m-oid=2.16.840.1.113894.3.1.22, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.22
m-name: orclNetSendBufSize
m-description: orclNetSendBufSize
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15

dn: m-oid=2.16.840.1.113894.3.1.23, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.23
m-name: orclNetReceiveBufSize
m-description: orclNetReceiveBufSize
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15

dn: m-oid=2.16.840.1.113894.3.1.24, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.24
m-name: orclNetFailoverModeString
m-description: orclNetFailoverModeString
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15

dn: m-oid=2.16.840.1.113894.3.1.25, ou=attributetypes, cn=oracle, ou=schema
objectclass: metaAttributeType
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.1.25
m-name: orclNetInstanceRole
m-description: orclNetInstanceRole
m-equality: caseIgnoreMatch
m-syntax: 1.3.6.1.4.1.1466.115.121.1.15

dn: ou=comparators, cn=oracle, ou=schema
objectclass: organizationalUnit
objectclass: top
ou: comparators

dn: ou=ditcontentrules, cn=oracle, ou=schema
objectclass: organizationalUnit
objectclass: top
ou: ditcontentrules

dn: ou=ditstructurerules, cn=oracle, ou=schema
objectclass: organizationalUnit
objectclass: top
ou: ditstructurerules

dn: ou=matchingrules, cn=oracle, ou=schema
objectclass: organizationalUnit
objectclass: top
ou: matchingrules

dn: ou=matchingruleuse, cn=oracle, ou=schema
objectclass: organizationalUnit
objectclass: top
ou: matchingruleuse

dn: ou=nameforms, cn=oracle, ou=schema
objectclass: organizationalUnit
objectclass: top
ou: nameforms

dn: ou=normalizers, cn=oracle, ou=schema
objectclass: organizationalUnit
objectclass: top
ou: normalizers

dn: ou=objectclasses, cn=oracle, ou=schema
objectclass: organizationalUnit
objectclass: top
ou: objectClasses

dn: m-oid=2.16.840.1.113894.2.2.100.2, ou=objectclasses, cn=oracle, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.2.2.100.2
m-name: orclDBAQConnection
m-supObjectClass: javaContainer
m-must: cn
m-may: orcldbaqgeneric
m-may: orclVersion

dn: m-oid=2.16.840.1.113894.2.2.100.3, ou=objectclasses, cn=oracle, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.2.2.100.3
m-name: orclDBAQObject
m-supObjectClass: javaContainer
m-must: cn
m-must: orcldbaqobjtype
m-may: orcldbaqobjowner
m-may: orcldbaqobjname
m-may: orcldbaqpointerattr
m-may: orcldbaqgeneric
m-may: orclVersion

dn: m-oid=2.16.840.1.113894.3.2.1, ou=objectclasses, cn=oracle, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.2.1
m-name: orclNetAddress
m-supObjectClass: top
m-must: cn
m-may: orclNetAddressString
m-may: orclNetProtocol
m-may: orclNetShared
m-may: orclVersion
m-may: description

dn: m-oid=2.16.840.1.113894.3.2.2, ou=objectclasses, cn=oracle, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.2.2
m-name: orclNetAddressList
m-supObjectClass: top
m-must: cn
m-may: orclNetAddrList
m-may: orclNetSourceRoute
m-may: orclNetLoadBalance
m-may: orclNetFailover
m-may: orclNetShared
m-may: orclVersion
m-may: description

dn: m-oid=2.16.840.1.113894.3.2.3, ou=objectclasses, cn=oracle, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.2.3
m-name: orclNetDescription
m-supObjectClass: top
m-must: cn
m-may: orclNetServiceName
m-may: orclVersion
m-may: orclNetFailover
m-may: orclNetAddrList
m-may: orclNetShared
m-may: orclNetLoadBalance

dn: m-oid=2.16.840.1.113894.3.2.5, ou=objectclasses, cn=oracle, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.2.5
m-name: orclNetService
m-supObjectClass: top
m-must: cn
m-may: orclNetDescName
m-may: orclNetDescString
m-may: orclVersion

dn: m-oid=2.16.840.1.113894.3.2.6, ou=objectclasses, cn=oracle, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.2.6
m-name: orclNetServiceAlias
m-supObjectClass: alias
m-must: cn

dn: m-oid=2.16.840.1.113894.3.2.7, ou=objectclasses, cn=oracle, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.3.2.7
m-name: orclNetDescriptionAux1
m-supObjectClass: top
m-typeObjectClass: AUXILIARY
m-may: orclNetSendBufSize
m-may: orclNetReceiveBufSize
m-may: orclNetFailoverModeString
m-may: orclNetInstanceRole

dn: m-oid=2.16.840.1.113894.7.2.2, ou=objectclasses, cn=oracle, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.7.2.2
m-name: orclContainer
m-supObjectClass: top
m-must: cn
m-may: orclServiceType
m-may: orclVersion

dn: m-oid=2.16.840.1.113894.7.2.3, ou=objectclasses, cn=oracle, ou=schema
objectclass: metaObjectClass
objectclass: metaTop
objectclass: top
m-oid: 2.16.840.1.113894.7.2.3
m-name: orclContext
m-supObjectClass: top
m-must: cn

dn: ou=syntaxcheckers, cn=oracle, ou=schema
objectclass: organizationalUnit
objectclass: top
ou: syntaxcheckers

dn: ou=syntaxes, cn=oracle, ou=schema
objectclass: organizationalUnit
objectclass: top
ou: syntaxes


Now we need to load this to the ou=schema. To do that right click on it and follow the screens.






Now we have loaded the required classes. Now we can go ahead and create the partition.


Follow the below screens to create partition.

   Go to partitions tab and create the new partition.



   Save the configuration now, and restart the server.

oracle@ajanthan-ThinkPad-T440p:~/Pictures$ sudo /etc/init.d/apacheds-2.0.0-M23-default restart
Stopping ApacheDS - default...
Waiting for ApacheDS - default to exit...
Stopped ApacheDS - default.
Starting ApacheDS - default...
oracle@ajanthan-ThinkPad-T440p:~/Pictures$ 





Now we need to create the structure. Below is the Structure of Oracle Streams AQ Entries in LDAP Server.



Please refer my next blog of PART2 for the continuation...

http://ajanthane.blogspot.com/2017/03/integrating-wso2-esb-500-with-oracle_18.html