Pages

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