Tuesday, February 28, 2017

Task1 - Exporting a given API from one environment and Importing to


Proposed solution :- 



Migrating the APIs to a Different Environment is one of the major functionalities that should be achieved through the tool.  When migrating an API manager from one server environment to another environment, it will be more effective if there’s a way to move all created API’s in the first environment to the other environment since no need to create the API’s again in the new environment. The tool is developed focusing on the API management systems that consuming RESTful APIs to retrieve API’s data from data sources.
When user sends a request to export an API the Oauth token which was generated in the OAuth2 authentication process will be appended as a header in the relevant http call to secure the functionality. After user sends the request all the information required for the requested API will be retrieve through REST API invocations from the data sources. After executing the relevant command it will generates a portable .zip file which includes all the entities bundled together and which can be downloaded. In the .zip file the Meta information which contains all the basic information required for an API to be imported in another environment and the API swagger definition, documents which contains the summary of all the documents available for the API, thumbnail image of the API, WSDL file of the API and the sequences available for the API will be available.
The same zip archive which was created in the export functionality can be used for importing the API into the API Manager. It is required to call rest APIs to import an API, the request includes the data to be sent on the request as the payload and also includes Oauth token as the header for each REST call to ensure the security. If the request is successful the response with 200 will be returned. Unzip of the archive will be done by configuring the basic token key and OAuth2 access token which were created in the authentication process to provide a more secure service. After that the API will be created in the imported environment.






Up and Running with WSO2 API Manager


WSO2 API Manager is a free and open source API managing tool that facilitate creating, publishing, life cycle management and monetization of APIs in a secure and affordable manner. Installing and running the product is obvious. But prior to installing the product API Manager, there are few application that recommended to be install in order to run the API manager. Let's looking to them one by one:

Oracle javaSE Development Kit(jdk)

jdk is nessassary since program is launch, build and run on top of java. follow the following steps to download and install jdk in to your machine.

visit http://java.sun.com/javase/downloads/index.jsp and choose the right tar.gz and download

For the installation you need sudo privileges, for that type sudo su and enter.





Create a directory for jdk installation.
mkdir /opt/jdk

Extract the tar.gz file into created directory.
tar -zxf jdk-8u5-linux-x64.tar.gz -C /opt/jdk

To install java and javac type the following commands and enter.
update-alternatives --install /usr/bin/java java /opt/jdk/jdk1.8.0_05/bin/java
update-alternatives --install /usr/bin/javac javac /opt/jdk/jdk1.8.0_05/bin/javac

Next we have to set the JAVA_HOME variable. Following tutorial will explain the steps to set the JAVA_HOME and PATH variables permanently.


Apache maven

Apache maven is required to build the product from the source code.

visit http://maven.apache.org and select tar.gz of a version 3.0.0 or above and download.

create a directory for maven installation.
mkdir /opt/maven

Extract the tar.gz file into created directory.
tar -zvxf apache-maven-3.3.9-bin.tar.gz -C /opt/maven

open the bashrc file and add the bin directory of the created directory apache-maven-3.3.9 to the PATH environment variable












To confirm the maven installation open up a new terminal and type mvn -v and enter. If installed correctly result look similar to following.




 
Apache Ant

Apache ant is required to compile and run the product

visit http://ant.apache.org and select tar.gz of a version 1.7.0 or above and download.

create a directory for ant installation.
mkdir /opt/ant

Extract the tar.gz file into created directory.
tar -zvxf apache-ant-1.9.7-bin.tar.gz -C /opt/ant

open the .bashrc file and add the bin directory of the created directory apache-ant-1.9.7 to the PATH environment variable as did in installing apache maven.

To confirm the maven installation open up a new terminal and type ant-version and enter. Result will look as follows if installed correctly.






Installing and running WSO2 API Manager.

After fulfilling above prerequisites it is possible to install and run the product. Visit the site http://wso2.com/api-management/ and download the latest version of WSO2 API Manager.
Extract the archive in to a seperate directory
product can be run by executing one of the given commands
  • Windows: <APIM_HOME>/bin/wso2server.bat --run
  • Linux: sh <APIM_HOME>/bin/wso2server.sh





Task 2 - API Creation / Publishing


Solution Proposed:-


                For the api creation found that there are endpoint that will require api.json which contains all the basic information required for an API to be imported in another environment as payload with an Auth2 key that was generated in the key generation phase as header info.Basically the endpoint invocation is required to handle the api creation through the cli tool. If the API creation is successful it invocation returns a response with code 201. Depending on the response recieved, if succeed ,then going to upload the swagger.json ,docs.json , api thumbnail, wsdl and any other component of the imported API by calling relavent REST APIs with corresponding payloads.

               Mainly thought to make this process an efficient one with less no of Rest call's to hit the endpoint for the creation for now thought to have a http client pool to handle the http requests.






Monday, February 27, 2017

Task 4 - Key generation


Solution Proposed:-


          When a user first call a command from the cli tool it will directly redirect to the main class and will redirect to the endpoint which handle the basic authentication.With the key that return it will redirect again to the endpoint that handles the OAuth2 authentication and will generate a  OAuth2  key  which give access to the other endpoints afterwords.

Why OAuth2 :-


      When going through the WSO2 API Manager product saw that using OAuth2  protocol as the token generator in the product.

Advantages of OAuth 2 other than OpenID connect:-


 the most important feature of OAuth is the access token which provides a long lasting method of  making additional requests.
 Unlike OpenID, OAuth does not end with authentication but provides an access token to gain access  to
 additional resources provided by the same third-party service. However, since OAuth does not  support discovery,
 it requires pre-selecting and hard-coding the providers you decide to use. A user visiting your site  cannot use
 any identifier, only those pre-selected by you. Also, OAuth does not have a concept of identity so  using it for
 login means either adding a custom parameter (as done by Twitter) or making another API call to get  the currently "logged in" user.