Wednesday, October 28, 2015

Creating databases and testing the connection of a IBM Informix DB


This blog post will be mainly focused on how to start / stop the informix server. Create a database and table etc.


Login from informix user and run the server instance


Login with the informix windows user that was created during the installation and simply search for informix under start and you will find a server instance similar to "ol_informix1210". Run the server instance as Administrator.


Basic commands to get started with informix


Run the below commands in the cmd that was open.
  • Start informix server - oninit -ivy
  • Shut down informix server - onmode -ky
  • Check server status   - onstat -g dis

Create Informix DB



Use the command "dbaccess" cmd to navigate to db creation section. You will be getting the following options.




Navigate to Database  - > Create

Provide a suitable name for the database which needs to be created.



Select a DB space

After selecting a DB space select  "Create-new-database" and click enter. This will create the new database.




Create a table


Select the DB that was created and go to tables section the select "Create" and provide a table name.



Add columns as your requirement refer below pic to get an idea.



Once you are done select "Build-new-table" this will create the table.


Connect and test the informix DB created


You can use a client like DBeaver to connect to the database you created. You have to provide the host, Port, server,database/Schema, username and password in order to connect to the server.

NOTE - Informix by default binds a ipv6 for the port. So to connect to the db follow the below sample.

* You can use a simple tool such as cports to view the ports and the address that it is bind to or you can use the command

netstat -a | findstr 'Port number' 


jdbc connection URL looks like this, which needs for the connection.

jdbc:informix-sqli://{hostip}:{port}/{DBName}:INFORMIXSERVER={InformixServerName}

jdbc:informix-sqli://fe80::f16e:99a8:22ca:682:9088/test:INFORMIXSERVER=ol_informix1210



Now you can view the table that was created via dbeaver client



Binding the Port to a IP V4  


After the installation you will be able to see a separate option called the 'IBM informix' in the start menu. You can create any number of server instances from the 'Server Instance Manager' tool under that option the Start Menu.




In informix you have the possibility to create a server with a IP V4 or IP V6. We can create a IP V4 from the 'Server Instance Manager'.

From there you will be asked to set a 'service name' and a 'port number'  while proceeding.  Set the desired values for these fields, So they can be referred lately.









Wednesday, October 21, 2015

How to apply security (QOS) to a proxy in WSO2 ESB 4.9.0 using WSO2 Developer Studio


From WSO2 ESB 4.9.0 on-wards applying security for a proxy / service should be done via WSO2 Developer Studio. This post will be a simple guide on how to create a proxy and apply basic qos to it. I will be using User Name token authentication to apply qos.

Find the links below to download the latest releases of the two  products.

  1. WSO2 ESB 4.9.0
  2. WSO2 Developer Studio 3.8.0

Step 1 Extract and run the two products


After you download the two products extract them to a preferred location. And start WSO2 ESB by navigating to <ESB_HOME>/bin and run wso2server.sh if you are on linux or  wso2server.bat if your are on windows. Go to <DEVSTUDIO_HOME> and launch by double clicking eclipse icon.


Step 2 Create a registry project


Lets start first by creating a registry project - Open Developer studio dash board and select "Registry Resource" project

Dev studio dashboard



Now lets create a registry resource file. Right click on the project created then search for "Registry Resource" and click next and follow the below 3 steps to create the registry resource file.

Step 1 - Select registry resource

Step 2 - Select From existing template

Step 3 - Select Template and registry project

Select the Template as WS - Policy and Select the registry project name ( by default it will be selected) and click on Finish.


Step 3 Select user token security policy and grant permission


Double click on the registry resource file that was created which will lead show the scenarios that are available as the below pic shows.





Select "UsernameToken" and click on "User Roles" and a window will be opened as below. Now point to the esb instance URL and provide user name and password as admin/admin. Now click on Get Roles. This will fetch all the user roles that is available in ESB. Lets select admin and click on ok.



Now  click on the source view and the source will be shown as below. Note that the user role admin can be seen in the source. Refer below pic.






Step 4 Create the proxy project


Select "Proxy Service" project from the dev studio dashboard. In the window that popups provide any name for the proxy, leave the  proxy type as Pass Through Proxy and click on "Create a new ESB project" and create a project. Finally provide the endpoint url for this I have used the default echo service that is been shipped in ESB.







After creating the proxy select and double click on the proxy file which resides in proxy- services(refer below pic)



Now in the graphical view select the proxy as the below picture shows.



Now set "Security Enabled" to true and click on Service policies which will open a window as shown in below pic where you can select the policy key





Browse to the eclipse project by selecting work-space.



Select the registry resource file from the works pace as shown in below pic and save the changes.



Click on source view then you will see that the security policy is been added.





Step 4 Create a Car file


To deploy the proxy and the registry file we need to bundle it in a Composite Application Project and then export it which will create a .car extension file which can be then uploaded to ESB. Lets see how it is done.


Select the Composite Application Project from dashboard and then select the two projects that were created. Refer below pic.




Remember to change the server role to Enterprise Service Bus in the registry project.




Now right click on the project created and click on "Export Composite Application Project" This will create the .car file.



Step 5 Deploy the project in WSO2 ESB



Now that we created the car file its just a matter of deploying it in ESB to secure the echo service. To do that go to ESB home and navigate to Carbon Applications section and browse to the car file created and upload the car file. If it is successfully deployed the ESB log will be as below.

[2015-10-18 12:04:52,063]  INFO - ApplicationManager Deploying Carbon Application : QOS_Composite_Proj_1.0.0.car...
[2015-10-18 12:04:53,100]  INFO - ProxyService Building Axis service for Proxy service : QOS_PROXY_PROJECT
[2015-10-18 12:04:53,111]  INFO - ProxyService Adding service QOS_PROXY_PROJECT to the Axis2 configuration
[2015-10-18 12:04:53,112]  INFO - DeploymentInterceptor Deploying Axis2 service: QOS_PROXY_PROJECT {super-tenant}
[2015-10-18 12:04:53,115]  INFO - ProxyService WS-Security is enabled for service : QOS_PROXY_PROJECT
[2015-10-18 12:04:53,116]  INFO - ProxyService Successfully created the Axis2 service for Proxy service : QOS_PROXY_PROJECT
[2015-10-18 12:04:53,116]  INFO - ProxyServiceDeployer ProxyService named 'QOS_PROXY_PROJECT' has been deployed from file : /home/jasons/Products/ESB/QOS/wso2esb-4.9.0-RC4-SNAPSHOT/tmp/carbonapps/-1234/1445150092064QOS_Composite_Proj_1.0.0.car/QOS_PROXY_PROJECT_1.0.0/QOS_PROXY_PROJECT-1.0.0.xml
[2015-10-18 12:04:53,116]  INFO - ApplicationManager Successfully Deployed Carbon Application : QOS_Composite_Proj_1.0.0 {super-tenant}



To verify whether the proxy is been secured go to Services -> List section verify that the secured symbol is available as shown in below pic.




Step 6 Test the service


Now lets verify that the service is secured. For this I will be using SOPA UI. Create  a SOAP project and give the wsdl of the proxy created. Then copy the https endpoint and set it as the url. Set the user name and the password. Now invoke the web-service to echo a string and you will be able to see the result. Try it with false credentials and you will not be able to echo the message.









Wednesday, October 7, 2015

How to enable Email as the user name in WSO2 Products


Let us see how to enable email to be used as the user name in WSO2 Products. This feature by default is disabled which can be enabled with ease. For this example I will be using WSO2 Message Broker.


Step 1 - Download and extract the WSO2 MB product


Step 2 - Change configuration in carbon.xml


Open the carbon.xml which can be found under <WSO2MBHOME>/repository/conf/carbon.xml. Un-comment the below section,

<!--EnableEmailUserName>true</EnableEmailUserName-->


Step 3 -  Change configuration in user-mgt.xml


Replace,
 <Property name="UsernameJavaRegEx">^[^~!#$;%^*+={}\\|\\\\&lt;&gt;,\'\"]{3,30}$</Property>
with - 
 <Property name="UsernameJavaRegEx">[a-zA-Z0-9@._-|//]{3,30}$</Property>

Now lets set up the admin account with a email address,

                 <AdminUser>
                     <UserName>jason@yopmail.com</UserName>
                     <Password>123123</Password>
                </AdminUser>

Step 4 - Login to management console


Start message broker by issuing the command <WSO2MBHOME>/bin/wso2server.sh start  if you are using linux distro or <PRODUCT_HOME>\bin\wso2server.bat if you are on windows and navigate to https://localhost:9443/carbon. Now you can login to console with the above credentials.