Saturday, June 24, 2017
Networking jargon's
Tuesday, February 10, 2015
Smart Card Communication-APDU Format
Applets are applications that reside on the smart card. The host application and the smart cards communicate in a specific sequence. The host application sends commands to the applets and the applets sends back a response.
This communication takes place with the help of Application Protocol Data Unit or APDU. The APDU is basically divided into two parts namely:
- Command APDU: Sent by the host application to the Java Card. The structure of the same is displayed below:
Mandatory Header Optional Body CLA INS P1 P2 Lc Data Field Le - Response APDU: Response sent by the Java Card applet to the host application. The structure of the same is displayed below:
Optional Body Mandatory Trailer Data Field SW1 SW2
Monday, February 9, 2015
Using oracle.sql.ARRAY with Spring JdbcTemplate
We have two master tables namely:
EMP (employee master) and PROJECTS (employee's projects). The structure of the same is as follows:
| EMP_ID | EMP_NAME |
|---|---|
| 1 | Jack |
| 2 | Jim |
| PRJ_ID | PRJ_NAME |
|---|---|
| I001 | Inventory |
| B0021 | BFSI |
As you can see the relation between EMP and Projects is many to many. So we have one more table namely EMP_PROJECTS. The structure of the same is as follows:
| EMP_ID | PRJ_ID |
|---|---|
| 1 | I001 |
| 1 | B0021 |
To insert multiple bulk values in the EMP_PROJECTS table, we might consider using oracle.sql.ARRAY. So we declare a test array object as follows:
CREATE OR REPLACE TYPE TEST_ARR AS TABLE OF VARCHAR2(1000);
Now we have a stored procedure that uses the above mentioned type to insert data into the EMP_PROJECTS table as follows:
CREATE OR REPLACE PROCEDURE PRC_INS_EMP_PRJ(EMP_ID IN VARCHAR2, PRJ_ARR IN TEST_ARR)
AS
BEGIN
INSERT INTO EMP_PROJECTS (EMP_ID, PRJ_ID) VALUES (SELECT EMP_ID, COLUMN_VALUE FROM FROM TABLE (PRJ_ARR));
END;
In the above procedure, we can insert multiple project id's against a single employee id. To call the above procedure using Spring JdbcTemplate, we first need to set the SQL parameters as follows:
SqlParameter inEmpId = new SqlParameter(Types.VARCHAR);
SqlParameter inPProjectIdArray = new SqlParameter(Types.ARRAY);
List<SqlParameter> sqlParameterList = new ArrayList<SqlParameter>();
sqlParameterList.add(inEmpId);
sqlParameterList.add(inPProjectIdArray);
List<String> projectIdList = new ArrayList<String>();
projectIdList.add("1001");
projectIdList.add("B0021");
@Override
public CallableStatement createCallableStatement(Connection connection)
throws SQLException {
ArrayDescriptor arrayDescriptor = ArrayDescriptor.createDescriptor(TEST_ARR, connection);
ARRAY inputArray = new ARRAY(arrayDescriptor, connection, projectIdList.toArray());
CallableStatement cs = connection.prepareCall(sqlQuery);
cs.setString(1, empId);
cs.setString(2, inputArray);
return cs;
}
}, sqlParameterList);
Saturday, February 13, 2010
Basics of Smart Cards
A Smart Card also known as an Integrated Circuit Card (ICC) consists of an embedded microprocessor. Smart cards are generally made of plastic with a small gold plate which is visible on one side. The microprocessor is embedded under this gold plate. A smart card differs from normal Magnetic Stripe cards where in it processes the inputs received and then produces the output respectively. The other advantage is that smart cards are more secure as compared to Magnetic Stripe cards where in the data stored on the magnetic card can be read easily whereas smart cards provide extra security features.
Typical smart card specifications available in the market today are as follows:
- RAM: 4Kb to 8Kb
- EEPROM: 32Kb to 64Kb
- Microprocessor: 8-bit
Smart Cards are mainly used in applications that need high confidentiality of information. Smart cards are more reliable than Magnetic Stripe Cards and can store plenty of information.
The communication with smart cards takes place with a hardware device known as Smart Card Reader. There are basically two modes in which a smart card can communicate with the reader namely:
-
Contact-based:
In this method, the smart card is inserted into the reader and the gold plate makes contact with the interpreter device inside the reader. The card is removed from the reader once the user has finished his/her operations. -
Contact-less:
In this method, the reader and the card communicate with the help of an antenna. You need to get the card closer to the reader and the card will start communicating with the reader.
Cards with dual mode of operations are available wherein you can use the same card with contact-based readers as well as contact less readers.