0

i'm following this tutorial in wso2 website, but there's no information where to put java Handler to make Authorization.

Is anyone know where to put that ? and how to make it working with API Resource ?

Community
  • 1
  • 1
Lyan Dwi Pangestu
  • 463
  • 1
  • 7
  • 23

3 Answers3

0

You can put this in handlers tag under the API, please check the tutorial sample code. This handler will apply to all resources.

<api xmlns="http://ws.apache.org/ns/synapse"
         name="TestGoogle"
         context="/search">
       <resource methods="GET">
          <inSequence>
             <log level="full">
               <property name="STATUS" value="***** REQUEST HITS IN SEQUENCE *****"/>
             </log>
             <send>
                <endpoint>
                   <http method="get" uri-template="https://www.google.lk/search?q=wso2"/>
                </endpoint>
             </send>
          </inSequence>
       </resource>
       <handlers>
           <handler class="org.wso2.handler.SimpleOAuthHandler"/>
       </handlers>
    </api>
zizifn
  • 395
  • 1
  • 2
  • 14
0

You can add the handler before the closing tag of the API, after saving it, API may not show the handler, but if you check the source view then you can see the handler assigned to the API. (Main -> Source View)

krishan
  • 579
  • 3
  • 9
0

You have to copy the jar containing the handler to [ESB_HOME]/repository/component/lib and restart the server. The handler is added to the API configuration as a child to <api> as

<handlers>
   <handler class="org.wso2.rest.BasicAuthHandler"/>
</handlers>
maheeka
  • 1,983
  • 1
  • 17
  • 25
  • I've placed the jar file, restart the server many times, but it's still not loaded – Lyan Dwi Pangestu Oct 29 '16 at 03:30
  • Do you see any errors in the console during server start up? – maheeka Oct 29 '16 at 03:43
  • yes, it's just says org.wso2.rest.BasicAuthHandler cannot be found by synapse-core_2.1.7.wso2v7 – Lyan Dwi Pangestu Oct 29 '16 at 03:46
  • This means that it is looking for the BasicAuthHandler in synapse-core because it is not able to find the java component that you have deployed. Can you restart the server to see if there are any errors/warnings on your java component being deployed – maheeka Oct 29 '16 at 03:48
  • there's no error about java component, it's just says that xml error because the class is not found :( – Lyan Dwi Pangestu Oct 29 '16 at 04:08
  • Try with the sample BasicAuthHandler project from https://github.com/wso2/product-esb/tree/v5.0.0/modules/samples/integration-scenarios/starbucks_sample/BasicAuth-handler/ – maheeka Oct 29 '16 at 22:26