Thursday, November 21, 2013

Invoking Secure Service (UT enabled) Via Non Secure Client -Part 1

When client would require to invoke Secure Services via Non secure services, one possible solution is to enable encrypt the basic headers and them to the Authorization header in transport scope then to invoke the given service


<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="NonSecureProxy"
       transports="https,http"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <log level="full">
            <property name="INNNNN" value="***********INNNN sequence proxy2***********"/>
         </log>
         <property name="Authorization"
                   expression="fn:concat('Basic ', base64Encode('dushan:dushan'))"
                   scope="transport"/>
         <send>
            <endpoint>
               <address uri="https://localhost:8243/services/SecureService/getQuote"
                        format="pox"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <description/>
</proxy>


<proxy xmlns="http://ws.apache.org/ns/synapse"
       name="SecureService"
       transports="https"
       statistics="disable"
       trace="disable"
       startOnLoad="true">
   <target>
      <inSequence>
         <send>
            <endpoint>
               <address uri="http://localhost:9000/services/SimpleStockQuoteService"/>
            </endpoint>
         </send>
      </inSequence>
      <outSequence>
         <send/>
      </outSequence>
   </target>
   <enableSec/>
   <policy key="conf:/repository/axis2/service-groups/SecureService/services/SecureService/policies/UTOverTransport"/>
   <description/>
</proxy>



[2013-11-21 14:12:30,620] DEBUG - wire >> "[\r][\n]"
[2013-11-21 14:12:30,636] DEBUG - wire << "POST /services/SimpleStockQuoteService/getQuote HTTP/1.1[\r][\n]"
[2013-11-21 14:12:30,637] DEBUG - wire << "Authorization: Basic ZHVzaGFuOmR1c2hhbg==[\r][\n]"
[2013-11-21 14:12:30,637] DEBUG - wire << "Accept-Encoding: gzip,deflate[\r][\n]"
[2013-11-21 14:12:30,638] DEBUG - wire << "Content-Type: application/xml[\r][\n]"
[2013-11-21 14:12:30,638] DEBUG - wire << "SOAPAction: urn:getQuote[\r][\n]"
[2013-11-21 14:12:30,638] DEBUG - wire << "Transfer-Encoding: chunked[\r][\n]"
[2013-11-21 14:12:30,638] DEBUG - wire << "Host: localhost:9000[\r][\n]"
[2013-11-21 14:12:30,639] DEBUG - wire << "Connection: Keep-Alive[\r][\n]"
[2013-11-21 14:12:30,639] DEBUG - wire << "User-Agent: Synapse-PT-HttpComponents-NIO[\r][\n]"
[2013-11-21 14:12:30,639] DEBUG - wire << "[\r][\n]"
[2013-11-21 14:12:30,639] DEBUG - wire << "fe[\r][\n]"
[2013-11-21 14:12:30,639] DEBUG - wire << "<ser:getQuote xmlns:ser="http://services.samples">[\n]"
[2013-11-21 14:12:30,639] DEBUG - wire << "         <!--Optional:-->[\n]"
[2013-11-21 14:12:30,639] DEBUG - wire << "         <ser:request>[\n]"
[2013-11-21 14:12:30,640] DEBUG - wire << "            <!--Optional:-->[\n]"
[2013-11-21 14:12:30,640] DEBUG - wire << "            <xsd:symbol xmlns:xsd="http://services.samples/xsd">11</xsd:symbol>[\n]"
[2013-11-21 14:12:30,640] DEBUG - wire << "         </ser:request>[\n]"
[2013-11-21 14:12:30,640] DEBUG - wire << "      </ser:getQuote>[\r][\n]"
[2013-11-21 14:12:30,640] DEBUG - wire << "0[\r][\n]"
[2013-11-21 14:12:30,640] DEBUG - wire << "[\r][\n]"
[2013-11-21 14:12:30,644] DEBUG - wire >> "HTTP/1.1 200 OK[\r][\n]"
[2013-11-21 14:12:30,644] DEBUG - wire >> "Content-Type: application/xml; charset=UTF-8[\r][\n]"
[2013-11-21 14:12:30,645] DEBUG - wire >> "Date: Thu, 21 Nov 2013 08:42:30 GMT[\r][\n]"
[2013-11-21 14:12:30,645] DEBUG - wire >> "Transfer-Encoding: chunked[\r][\n]"
[2013-11-21 14:12:30,645] DEBUG - wire >> "Connection: Keep-Alive[\r][\n]"
[2013-11-21 14:12:30,645] DEBUG - wire >> "[\r][\n]"
[2013-11-21 14:12:30,647] DEBUG - wire >> "368[\r][\n]"
[2013-11-21 14:12:30,647] DEBUG - wire >> "<ns:getQuoteResponse xmlns:ns="http://services.samples"><ns:return xmlns:ax21="http://services.samples/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="ax21:GetQuoteResponse"><ax21:change>4.423747490453758</ax21:change><ax21:earnings>13.080465575691782</ax21:earnings><ax21:high>183.72455511877618</ax21:high><ax21:last>177.25933516401494</ax21:last><ax21:lastTradeTimestamp>Thu Nov 21 14:12:30 IST 2013</ax21:lastTradeTimestamp><ax21:low>-176.6775010130566</ax21:low><ax21:marketCap>1797692.482250683</ax21:marketCap><ax21:name>11 Company</ax21:name><ax21:open>183.25648908841202</ax21:open><ax21:peRatio>-17.898897366819455</ax21:peRatio><ax21:percentageChange>-2.6156190500725063</ax21:percentageChange><ax21:prevClose>-169.12812629695176</ax21:prevClose><ax21:symbol>11</ax21:symbol><ax21:volume>5447</ax21:volume></ns:return></ns:getQuoteResponse>[\r][\n]"
[2013-11-21 14:12:30,648] DEBUG - wire >> "0[\r][\n]"
[2013-11-21 14:12:30,648] DEBUG - wire >> "[\r][\n]"
[2013-11-21 14:12:30,655] DEBUG - wire << "HTTP/1.1 200 OK[\r][\n]"
[2013-11-21 14:12:30,655] DEBUG - wire << "Content-Type: application/xml[\r][\n]"
[2013-11-21 14:12:30,656] DEBUG - wire << "Date: Thu, 21 Nov 2013 08:42:30 GMT[\r][\n]"
[2013-11-21 14:12:30,656] DEBUG - wire << "Server: WSO2-PassThrough-HTTP[\r][\n]"
[2013

No comments:

Post a Comment