Pages

Monday, March 2, 2015

Create API and Publish using WSO2 API Manager

WSO2 API Manager is a complete solution for designing and publishing APIs, creating and managing a developer community, and for scalable routing API traffic. It leverages proven, production-ready integration, security, and governance components from the WSO2 Enterprise Service Bus, WSO2 Identity Server, and WSO2 Governance Registry. In addition, it leverages the WSO2 Business Activity Monitor for Big Data analytics, giving you instant insight into APIs behavior.

This article explains how to create and publish API in WSO2 API Manager. Here we are using http://www.webservicex.net/country.asmx web service and publish it as an API.

Prerequisite
WSO2 API Manager 1.5 or above

Steps
1. Download and unzip WSO2 API Manager
2. Start WSO2 API Manager.

3. Goto http://localhost:9763/publisher and login to publisher portal. (Default credentials user name : admin, password : admin)

4. Click Add and enter values as follows.

















Once complete entering above value click Implement.


5. Enter values in next screen as follows and click manage. Enter correct service endpoint under Production Endpoint.













6. Enter values in next screen as follows and click Save & Publish

















After completing above steps, you have an API published.

7. Go to https://localhost:9443/store/ and login to store portal.

8. Go to My Subscriptions and Click on the API created on the left hand list. Click Subscribe and Click Go to My Subscription from popup window.

Note. Copy Production and Sandbox URL under overview for later use.


















9. Click Generate button under Keys-Production to generate access token.

















10. Go to Tools - >RESTClient and invoke API. Make sure to use correct entries for access token and URL. Following image illustrate required information.




Wednesday, January 28, 2015

WSO2Con EU 2015

WSO2Con brings together architects, directors, and CxOs who desire to gain insights into creating a connected business. The WSO2Con EU 2015 agenda will showcase and share technology developments, architecture guidelines and best practices to compete in a connected world using the WSO2 enterprise middleware platform.










You can find more information from here

Monday, January 26, 2015

Install XACML Engine in WSO2 API

This article explains how to install XACML engine in WSO2 API Manager.

Prerequisite
WSO2 API Manager 1.5 or above

Steps
1. Download and unzip WSO2 API Manager
2. Start WSO2 API Manager.
3. Install XACML feature in API Manager.

Goto http://localhost:9443/carbon and login to management console. Once inside the admin console, select the ‘configure’ tab from the tabs available on the left-hand side. Inside the ‘configure’ menu you would find the features icon as shown below.










Inside the features page, select the repository management tab and click on the ‘add repository’ icon











Add the following repository details in the ‘Add Repository’ page.
Name – Turing
Once the repository is added, click on the ‘Available Features’ tab. Select the newly added repository and un-tick the ‘Group features by category option’ and click on ‘Find features’ button.

Select following two XACML features from the search list and install

Follow the installation flow and install the XACML features. After the installation is completed restart WSO2 API Manager.

Sunday, January 11, 2015

Remote debug in Tomcat

As developers we always need to debug the application, Please see below the simple steps to enable remote debug in apache tomcat. Here I am using Mac OS X. You can use same steps in Linux environment.

1. Open Terminal window and Set CATALINA_OPTS environment variable. Execute following command.

export CATALINA_OPTS="-agentlib:jdwp=transport=dt_socket,address=1043,server=y,suspend=n"


2. Goto <Tomcat_home>/bin and execute below command.

./catalina.sh run

3. Open required project from IntelliJ IDEA. (You can use other IDE such as Eclipse)

4. Go to Run->Edit Configurations


4. Add Remote debug by Clicking + and Remote


5. Change debug port to 1043 and click Apply and Debug


Thats all, you can add required breakpoint and debug the application.

Cheers. Hope this will help you all.



Troubleshoot WSO2 products

Troubleshooting is something key thing software products should have both in production and development stage. All WSO2 product has debug log facility to help developers to understand the exact problem.

Steps to enable debug log

1. Edit log4j.properties file which located in <IS_HOME>/repository/conf directory.

2. Add following entry to enable debug logs for all component in the product.

log4j.logger.org.wso2=DEBUG

3. Sometime you want to enable debug log in specific component, then you can the entry as follows.

log4j.logger.org.wso2.carbon.user.core=DEBUG

This will enable all logs related to user core component.

4. Restart the product.


Hope this will help you.

Wednesday, November 26, 2014

Resolve "ORA-01882: timezone region not found" when start WSO2 Product with Oracle Database

When datasource point to Oracle DB following error occurred when start any WSO2 product.

Caused by: java.sql.SQLException: ORA-00604: error occurred at recursive SQL level 1
ORA-01882: timezone region  not found

at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:440)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:389)
at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:382)
at oracle.jdbc.driver.T4CTTIfun.processError(T4CTTIfun.java:573)
at oracle.jdbc.driver.T4CTTIoauthenticate.processError(T4CTTIoauthenticate.java:431)
at oracle.jdbc.driver.T4CTTIfun.receive(T4CTTIfun.java:445)
at oracle.jdbc.driver.T4CTTIfun.doRPC(T4CTTIfun.java:191)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:366)
at oracle.jdbc.driver.T4CTTIoauthenticate.doOAUTH(T4CTTIoauthenticate.java:752)
at oracle.jdbc.driver.T4CConnection.logon(T4CConnection.java:366)
at oracle.jdbc.driver.PhysicalConnection.<init>(PhysicalConnection.java:536)
at oracle.jdbc.driver.T4CConnection.<init>(T4CConnection.java:228)
at oracle.jdbc.driver.T4CDriverExtension.getConnection(T4CDriverExtension.java:32)
at oracle.jdbc.driver.OracleDriver.connect(OracleDriver.java:521)
at org.apache.tomcat.jdbc.pool.PooledConnection.connectUsingDriver(PooledConnection.java:278)
at org.apache.tomcat.jdbc.pool.PooledConnection.connect(PooledConnection.java:182)
at org.apache.tomcat.jdbc.pool.ConnectionPool.createConnection(ConnectionPool.java:701)
at org.apache.tomcat.jdbc.pool.ConnectionPool.borrowConnection(ConnectionPool.java:635)
at org.apache.tomcat.jdbc.pool.ConnectionPool.getConnection(ConnectionPool.java:188)
at org.apache.tomcat.jdbc.pool.DataSourceProxy.getConnection(DataSourceProxy.java:127)
at org.wso2.carbon.user.core.claim.dao.ClaimDAO.getDialectCount(ClaimDAO.java:158)

... 22 more

Solution

Add following entry to <WSO2_PRODUCT>/bin/wso2server.sh 

-Duser.timezone="+05:30" \

Please see below a sample wso2server.sh with after modification with highlight. 



Monday, November 24, 2014

How to enable H2 database browser in WSO2 Products

Follow below steps to enable H2 Database browser in WSO2 Products. Here I am using WSO2 Identity Server . 

1. Download Identity Server (http://wso2.com/products/identity-server/)
2. Unzip downloaded pack (Ex. unzip wso2is-5.0.0.zip on Linux or Mac)
3. Edit <IS_HOME>/repository/conf/carbon.xml and uncomment H2DatabaseConfiguration section.
4. Remove all the tags after <property name="webAllowOthers" /> 

Please see below the relevant section in the carbon.xml after modification.

<H2DatabaseConfiguration>
        <property name="web" />
        <property name="webPort">8082</property>
        <property name="webAllowOthers" />
</H2DatabaseConfiguration>

5. Start server sh <IS_HOME>/bin/wso2server.sh

7. You will see following window


8. Enter required JDBC URL, User Name and Password which you can them in <IS_HOME>/repository/conf/datasources/master-datasources.xml

Please see below the required data have highlighted in a sample master-datasources.xml

<datasource>
            <name>WSO2_CARBON_DB</name>
            <description>The datasource used for registry and user manager</description>
            <jndiConfig>
                <name>jdbc/WSO2CarbonDB</name>
            </jndiConfig>
            <definition type="RDBMS">
                <configuration>
                    <url>jdbc:h2:repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE;LOCK_TIMEOUT=60000</url>
                    <username>wso2carbon</username>
                    <password>wso2carbon</password>
                    <driverClassName>org.h2.Driver</driverClassName>
                    <maxActive>50</maxActive>
                    <maxWait>60000</maxWait>
                    <testOnBorrow>true</testOnBorrow>
                    <validationQuery>SELECT 1</validationQuery>
                    <validationInterval>30000</validationInterval>
                </configuration>
            </definition>
        </datasource>

9. Click Connect.





Tuesday, March 27, 2012

Please join me to congratulate Susantha Senevirathne on his new Job at anotherinnovation Ltd as a Senior Software Engineer

Thursday, January 12, 2012

Tuesday, January 10, 2012

Mediator Design Pattern

When an application use many objects and those objects are sharing their references on each other. These kind of situation is so hard to maintain. 

This is the object sharing complexity.
In such a situation we can use the Design patter called Mediator. Using this design pattern it keep a Mediator class (Controller class) and it has reference to all above classes (Object1, Object2....), and All above object has reference to Mediator. Using that we can maintain Complex Object sharing scenarios.

This is after applying Mediator design pattern

Smartcard Unique Identifier

Card that has Mifare contain a unique identifier in Mifare block 0. To read the that Mifare Unique identifier we have two ways
1. Using Applet we can read the Mifare Block 0 using Mifare API.
2. You can send command FFCA000000
This is a purely Mifare command and this will not work in the contact interface.

You can get the unique identifier of the card using the command 80CA9F7F00. This command giving you lot of information of the card.

Following is the Example output and the information of a card.
9F 7F 2A 47 90 50 37 16 71 92 59 48 04 10 46 95 00 07 54 71 49 47 92 02 17 16 73 92 64 16 74 12 91 00 00 00 74 00 00 00 00 00 00 00 00 90 00

  IC Fabricator                      : 4790
  IC Type                          
  : 5037
  Operating System ID                : 1671
  Operating System release date      : 9259 (16.9.2009)
  Operating System release level     : 4804
  IC Fabrication Date                : 1046 (15.2.2001)
  IC Serial Number                   : 95000754
  IC Batch Identifier                : 7149
  IC Module Fabricator               : 4792
  IC Module Packaging Date           : 0217 (4.8.2000)
  ICC Manufacturer                   : 1673
  IC Embedding Date                  : 9264 (21.9.2009)
  IC Pre-Personalizer              
: 1674
  IC Pre-Perso. Equipment Date       : 1291 (18.10.2001)
  IC Pre-Perso. Equipment ID         : 00000074
  IC Personalizer                  
: 0000
  IC Personalization Date            : 0000
  IC Perso. Equipment ID             : 00000000 

If you are using jcop tools you can execute the command get-cplc and get above information.

APDU Structure

When we are doing smartcard programming we should properly know the structure of the APDU.
APDUs has two categories, Command APDU and Response APDU (C-APDU and R-APDU)

Command APDU
Field
Length(byte)
Comment
CLA
1
indicates the type of command
INS
1
indicates the specific command Ex: Get Data
P1
1
Instruction parameter 1  for the command
P2
1
Instruction parameter 2  for the command
Lc
N
Number of bytes in the data field
Data
Nc
Contain the data
Le
N
The maximum number of bytes expected in the data field in the response APDU

Response APDU
Field
Length(byte)
Comment
Response Data
N
Response Data
SW1-SW2
2
Status of the command processing Ex: Success : 90 00

Example to select the applet.

C-APDU : 00 A4 04 00 08 A0 00 00 00 03 00 00 00
R-APDU : 6F 10 84 08 A0 00 00 00 03 00 00 00 A5 04 9F 65 01 FF 90 00

Getting start android

android SDK can configured in both NetBean and Eclipse. But according to my experience eclipse will be much better (I am not blaming NetBean :) )

This is a very good  video to setup the development environment for android.



Boost to starting Java Card

I also faced to lot of difficulties to really start to work with javacard programming. Hope this will be a boost to who starting to learn javacard programming. Here I am not going to give any introduction or theoretical overall about javacard since you can Google and find many resources on the web.

Download jpcsc.jar library from http://www.linuxnet.com/


Context cardContext = new Context();
cardContext.EstablishContext(PCSC.SCOPE_SYSTEM, null, null);
String[] sa = cardContext.ListReaders();
if (sa.length == 0) {
  // there is no reader detected.
} 

try {
    Card card = cardContext.Connect(sa[0], PCSC.SHARE_EXCLUSIVE, PCSC.PROTOCOL_T0);
    System.out.println("Card Get connected");
          // Here After You can transmit APDU commands to card using card.Transmit
    } catch (Exception ex) {
       ex.printStackTrace();
    }