Java intelligent card foundation

zhaozj2021-02-08  382

From this article, we will continue to publish a series of articles that will be issued in Java on a smart card.

Let's make a basic introduction to you by this. Just have a smart card, a read card

Machines and a set of software that can communicate with smart cards, you can start using practical applications.

developed. Introduction of this article includes: compliance with ISO7816 standard smart card management software;

Use the GemPlus reader and Gemplus smart card from the smart card; a profit

The application program of the memory function of the card can be used. The subsequent article will introduce the smart cards produced by the factory.

And will also involve the standard of the smart card.

As a special series, this article will make a pavement work for the next discussion. here,

We will discuss a new standard called OpenCard.

The subsequent article will be involved in the peacekeeping card and electric wallet. At the end, we will introduce you to your smart card.

Basic frame structure of the pieces.

Non-theory is in the Javaone meeting in April (speaking to four tests related to this technique), it is still huge

The network is new to the station or CNN, and the smart card has a big wave. In this article, we will use real intelligence.

Capacity card instance shows you the true intelligent card. This skill will allow you to open a smart card Java application

The order.

Our discussion focus is on the two smart cards: save smart cards, it can be seen

There are small-class readable and writable magnetic disks available eliminated.

The handler card, it can be seen with a mini-type computer with an input port. After the article

Will be more introduced to the instrument card.

The exquisite situation in this article is in that we will create a simple prototype for reading and writing smart cards. We want to discuss

A medical department card, which will keep all the drugs in all the drugs, check the insurance, the prescription, etc.

Information. And we will spread around the square card. In this series of articles, you will pay attention to

A common topic of the card, that is, an all-time issue. The security mentioned here is the main thing to prevent the abuse of the card.

Insert or ActiveX Components and other means of non-acquisition data. For this purpose, this paper is related to the data of the read and write smart card.

The model will give you a safe, a storing storage.

What is the smart card?

You can make a smart card as a credit card with a brain. Its brain

It is a small embedded meter coefficient. This kind of core can be

The program has a task or a storage of some data, but it should be successful:

The core is only small, its processing can be more than your desktop

Machine.

Before the purpose, the smart card is only used for telegraphs, transport, banks and health care, but I am grateful to many developers. In the near future, I will come.

It will be seen that the smart card should be used in the internet application. Smart card has been in the day

This and European Guangguang is applicable, and it has been welcomed in the United States. In fact, in the United States

The intelligent card industry has recently born three more meaningful events:

PC / SC

Microsoft jointly launched a few company to be called PC / SC

Smart card application standard, personal computer and smart card for Win32 platform

Real now intervals. PC / SC does not support non-Win32 system platform, or Xu

Microsoft will never do it. I will discuss this after I will discuss this.

The OpenCard frame OpenCard is an open-plated standard, which supports a smart card

Application is on the platform of the network meter, POS, desktop, and lap.

Reality interoperability. OpenCard Xuke provides a 100% pure Java's smart card application program. through

The usual intelligence card should be used to help the pure Java, because they must

External inter-communication or a program library on the guest household. ( of course not

OpenCard, I can still use 100% pure Java, but it is necessary to the development of the smart card.

Customize an interface from the head. OpenCard also provided an interface to PC / SC,

Get the developer to make the device on the existing Win32 platform.

Javacard

Javacard is the first to Schlumberger, and it has been determined by JavaSoft to be

A standard. Schlumberger is only available in the market in the city. Java intelligence

Card, and the company is the first manufacturer of Javacard. As a pole

The potential to occupy the intelligent card standard of the intensive place, Javacard includes the standard class

Library and API, make Java small should be directly connected to the intelligence of ISO7816 standard

Can card. Javacard is provided with different application procedures to be safe and related to the core.

Operation environment.

Note:

Although this article is intelligent card main question, but more important is that you should never be in this kind.

The device is above. From my perspective, I am more preferred to produce Dallassemiconductor

Pinch Button® device. It is like a small portable credit card, but it is more easy.

why ? Because you no longer need to take the wallet from a few cards to choose it.

One, iButton is in your hand. Yes, it is a ring. Do not touch

Type smart card (herein, see below), I think ibutton this like beads

The product of the treasure ornament will be able to make a graph. Please see the reference information for details, please refer to Ibutton.

Let's talk about it, in August, the Java Internet Business Expo (Jibe) exhibition in New York,

Java CommerceTeam show 揓 avary defeat? / P>

What is the use of a smart card?

What is the good place to use a smart card? Ok, answer this next

Problem:

1. The smart card is more reliable than the magnetic card

2. Smart cards can save a hundred times more than the data of the magnetic card

3. Smart card is more difficult to be broken than magnetic cards

4. Smart card can be processed or returned

5. Smart cards can be widely used in industrial applications and provide multiple functions

can

6. The smart card is compatible with the portable electronical equipment, such as calls, PCs or

Personal Number Assistant (PDA)

7. The smart card is unbroken (Bi, there is a piece of calculation)

Machine chip)

Type of smart card

As mentioned earlier, this article will focus on two types of smart cards:

Storage and handling. But it is a total of five types of intelligence.

card:

Storage smart card

Processing smart card

electronic wallet

Security card

Javacard

The smart card is a portable part of the hardware, which must be helping other equipment.

Can get an interview with some kind of display device or a network. Card

Insert the card reader, this is often referred to as a smart card terminal; it can also be connected to RF

Wave is now.

The smart card is in two ways to read the reader or the reader.

Touching a smart card: When the chip in front of the smart card is connected to the reader

There are only information between the two.

No touch smart card: This kind of information is passed through the antenna, save

The movement of the hand worker or unplugged the smart card. With no contactless

Card, you only need to go to the reading reader, then the post-information transfer will be automatically entered. This kind of class

The type of smart card can be used for speed requirements, or unbalanced

Application Environment.

Some manufacturers have started producing these two types of smart cards.

Create an open environment for the intelligent card application

For the way of opening a smart card, you only need these few things: one

Smart card reader, software with reader communication, with insert reading

Cartoon letter of the reader, is thereafter there must be a smart card and the relevant hardware device.

The intelligent card reader is transdermatic with the smart card, or to open one

The application program that is running on a smart card, you must have an reader. This

The reader makes the application program can be accepted from the smart card or send a command. In the city

There are many types of readers on the field, which is the most flowing in the SERIAL, PCCard and Keyboard models. (Keyboard model always does not disconnect, our expectations

The PC factory can directly provide this product directly before June 1998. )

The serial reader is supported in this article.

A serial reader is connected to the serial port of the computer. Please note that the generation mentioned here

The code is similar to the PCCard type reader; many lapcons have built PCCard

Port. Each factory has provided self-heritable agreements to read

Output data. Once you can exchange information with readers, you can use one

Agreement with a credit card to communicate with the APDU format and the smart card.

(Related to the APDU format.) If you want to buy a reader, please

揋 Emplus smart card readers in reading test information? / P>

Software with readers

The smart card listed in this article needs to be equipped with some face-oriented pairs.

The class of icons.

They are:

Comply with the ISO command class of the 7816 advisory communication

Class with reader communication

Transform data into a factory-specific class

Software for testing the program

Smart card and related hardware equipment

As mentioned in front of this article, it is similar to the following example.

Application procedure, you must have a set of hardware and a few wisdom of smart cards

Can card. You can buy smart cards from Gemplus and Schlumberger.

.

If you have read readers, you have to use it, but also

The interface class will be discussed. The front face has been told, in the intelligent card

Before the communication, we must first call the reader first. And just like the existing

A variety of smart cards, such as today has been a lot of readers.

Heavy intelligent card standard

The smart card should be programs to make people confused.

Problem. Based on our examples is the application and reading

Communication, after the reader, by the reader with a standard agreement with the intelligent card communication. and this

The standard is the 7816 protocol in the international standardized group.

It's like a lot of new technologies, it's a lot of more than a smart card.

Technical standards for eye flowers. Some of these standards are initially stepped in

After the solution, you will have a big handset to hold the base of the intelligent card application.

Technical points. The special standards for some systems must also be held. I

Take this direction, the entire set of standards? Is it horizontal? And? Longitudinal? Two parts:

The horizontal standard can be used in the application program, while the longitudinal standard is only

Suitable for specific systems.

Transverse standard ISO 7816 - Describes to the smart card underlayer interface standard. This standard definition smart card

What is the password stream between readers and smart cards.

PC / SC - Defining Win3.1 / Win95 / NT Machine and Smart Card

The standard of the letter.

OCF - defining communication standard between Java should use the environment and smart card, the standard is complete

All Java interfaces. (Soon, the OCF will allow the initiator to output to OCF, and

For this, this developer will no longer use PC / SC. )

Javacard - describes Javacard and the standard it supported. Vertical

MONDEX - the data campaign in intelligent card. Mondex is not allowed to survive in the card

The cashier outside the film.

Visacash - This borrowing card can be used to track cards on the server.

Proton - another form of electron currency card

MPCOS-EMV - this is a unicomotic smart card, which allows you to realize your own currency

Or a token.

I often feel suspiciency, I don't understand: for this small small plastic

The cartridge, why do you have a lot of documents to describe its standard, and

Can you hold a lot of knowledge to send it?

Because of the development of the intelligent card, you should seek high-degree expertise.

On the field, it is necessary to support the product of Beans. This product should be used in transverse

Metal to achieve longitudinal standard. This means you can use all kinds of horizontal

The beans product is issued to the standard combination, just like OpenCard,

One application program is used to use its several commercial standards or it should

Used.

Java should be used or a communication between Java applications and smart cards

Do you know how to connect all hardware. Now we need

If you use some API, these APIs can be used as a smart card from the application program.

The reader issued a command. (After reading the reader, play with the smart card, as a

The information transfer medium between the application to the smart card. ) Smart card reader shift

Move the piping of the gold belonging with the smart card. Smart card is made

After processing, the reader will be given, and the reader will pass the procedure. under

The problem of the surface is that when these data flows from the application program to the smart card, they

Where is it? As mentioned earlier, the application is used to communicate with the reader.

The reader will use the standards described above and the intelligent card communication. Basically, with

The development of smart card technology, ISO has launched a smart card standard. The standard definition

The mechanical and electrical characteristics of the intelligent card and the standard with the intelligent card communication. ISO

The standard related document is listed in the reference material. Unfortunately, ISOs have no standards that can be meticomatic communication with readers. Therefore, it is sent to the smart card.

A order, first you have to find a collection of intelligent cards, will make this order

Use the ISO command package to encapsulate, then then this package is later in a formula suitable for readers.

. The following cases are all made to have all the trivial things.

Application Procotols Data Units (APDUS)

Based unit with intelligent card exchange information is an APDU package. From application program

Layers passing the command message, plus from the smart card to the application program

The response message is called Application Procotols Data Units (APDU). With smart card

The communication with the reader is implemented in an APDU form. An APDU package can be seen in the package

The whole instruction or the responded data package. For this, the function of this, ISO7816

There is a part of the family to define a good role in APDU.

The APDU includes the following domain:

Order APDU Format CLA INS P1 P2 LC Data LE Back APDU Ground Data SW1 SW2

The lower side is a class and its functionality that supports APDU transmission:

Command - Sealing Mission APDU

Response - Sealing Back APDU

IsoCardReader - Regulates an interface. Every device must be implemented

Join

IsoCommand - configures is IsoCommand and is executed from ISOCARDReader interface

This order and intelligent card communication

SUN opened Java Electronic Commerce Framework (JECF),

This is the expansion of the core Java platform, it allows the developer to relax quickly and fast

Use electron application. JECF provides a few classes with intelligent card communication.

The smart cards in our discussion have a read data and write numbers.

According to the order. It is named GFM card by GEMPLUS. You can use it

Type smart cards, just want them to support ISO7816 standards and you understand their A

PDU command format. It is still necessary to do a bit of programming. The memory of the GFM card is 64

A bit or 8/2 is single. You must read data with an algorithm of the model 8.

In other words, you cannot do a length of 1K to a GFM card. Us

The Java code provided here complete this function. Some new smart cards are greater

Single bit read and write unit. Therefore, it is written in a string? 123456789 敚? You must

Send two commands for appropriate category. (Yes, the smart card is so difficult to edit

Process. This limit is also a promise when the storage card and the handler type card integrates.

Disappear.

To read the string of the string on the top, you should send an EAD? Command. This

Two commands are written in the next surface according to the APDU. Used Java read and write smart cards in our example. The value in the lower surface shows how to group

APDU. The structure of the APDU is determined in the GCM programming.

Location of Data Upper Lower

256 0x00 0x00

1023 0x00 0x00

3093 0x00 0x00

Shake PPER? And 搇 搇 是 是 地地 高 位 and low-bit bytes.

Several examples may be helpful in clarity. This table's Upper and Lower values

Provide a certain address for storing data. We are discussed to the GPM896 intelligent cartoon

The two ways of letters are:

IsoCommand (0,0xd0,0, upper, limited, 8); // Write 8 bytes Tothe Address

IsoCommand (0,0xB0, 0, Upper, Lower, 8); // r 8 8 bytes from

The address

Communication between the browser and the smart card

The existence of three local interfaces is lacking on the main issuer group.

Solution, can not be able to make a while, if you are in Java open environment

Developers provide an API that is easy to remember. If the sales of the fruit is supported

JNi, at least the interface can keep it, you don't have to make a large amount of time to tie the interface

set. Of course, you must write a small amount of local code, but there is a uniform interface

It is worthless. I tried all three APIs, and I finally happened that JNI is more than it.

It is more likely to be simple, and it is easy to implement. Quanhe Hotjava

It is best, this you can sign the class with the servant communication, then

Use them, more than two other navigers are much less. Sun is closest

It also announced the help of the browser company to realize the new JDK / JVM recommendation.

The pre-face discussion surroundes if and a hardware device communication that does not support JDK

. In the next few articles, we will no longer use? Local interface 敚?

Use a work standard with the intelligent card communication. I chose this standard

The quasi is the OpenCard standard with the PC / SC bridge. I will use OpenCard instead of PC / SC book

Write a application, what is it?

As a developer, you have a variety of choices. Talking about this is a good

Things, but this can also lead to inconsistency in the cost increase and functionality.

Especially when the API you choose is not supported by multiple platforms. For example, you decided

Write the PC / SC Standard Book Write the Win32 Series Pace Application Procedure. in case

Your application program is a customer use and will be used on WebTV,

Your choice is completely wrong. A message will be flashing on the display:

? Waiting for the Pentium version to be WEBTV. ? Smart card is used outside the Win32 table and CE unit

The market above the market. Then what should you like? Use the OpenCard standard to abandon the lack of the Internet Explorer. In fact, I think it will puminate all APIs.

Like a single platform is a very implied choice.

Recommended application

Now you should start writing a more real value of smart card applications

Order. In the coming, I went to see the doctor, and he recommended a specific treatment.

Treat, we may be in the face:

Doctors have to ask for your office card.

The card is inserted into the reader, and the doctor checks to see you before. (For complexion

People who have a history of medical treatment may need a special family system. )

Doctors are noted that the same time in the same time, a doctor is taking care of you, and both of them

There is a bad reaction to the drug. Because this doctor will lose to the smart card before this

Enter another medicine. (Identification results are: smart cards can pass medicine

Pharmacy. )

You are now able to take the card to the pharmacy and insert the reader in that there.

The pharmacter reads out your medicine house.

If you think that the pharmacist is more solving medicine than medical students, he believes that medical students should be rewarded.

The drug opened. The pharmacy teacher calls the doctor, and the phone number is included in the wisdom.

The record of the card can be recorded. After the short-term discussion, two people reached a result.

And update the records in the card.

Pharmacist fills in your medicine, and take the proposal of the hospital from the card, and

Trunk with the Advantaged Advancement.

The hospital is verified that you are a true member, the drug is self-emphasis on the hand of the doctor, and

Data on the new card.

The pharmacter took you 5 US dollars.

Is this not a more secure system? When is it better than a more

In the case of the system, it is currently the time of paper and pen, and people act as one of them.

Connection points of the diverse meter system system. In fact, in Germany, medical treatment-sensitive card has been

It is used.

Advantages of intelligence

For more than a comparative office, the card is called, the smart card is given to the bottom.

What good is it? Listed by them in the next side:

When you want to change the data in the card, out the door, or to the new medical treatment

Various prescriptions that can be opened in front of the treatment treatment.

Medical treatments that are time to pay in the urgency or ER worker needs

History history.

Details of the medical treatment history, including time, location and degree

interest.

It can be used to give the data to a specific person, and it is also possible to choose from

Where is it updated by data.

For the benefit of the above, we need to open a application

The program allows us to read data to the smart card with a safe form. in case

Have a hardware device, we need to write a specific string or from the smart card

read out. These things that must be transferred through callstrings.java are completed. This

Some original categories provide great convenience for the programming of the smart card.

We also added a beans style event handler to use to know the use of households.

Insertion of the smart card. (This is the final change to thank Jecf

High-level high-level open people Dan Guinab. )

Consider the code segment from rwstring.java:

Import java.commerce.smartcards. *; packages form Jecf to Supportsmart Cards

Import java.commerce.gemplus. *;

Import java.commerce.DeviceManager. *;

Import java.awt.event. *;

/ **

* Read and Write Gemplus Memory Cards. The Following Cards

* Aresuted:

* GFM 4K

* /

Public class rwstring {

Public static void main (string args []) {

WriteString WS = New WriteString (ARGS);

}

}

Class WriteString IMPLEments ActionListener {

IsocardReader isoreader = null;

Int portnumber;

String DeviceName;

Public WRITESTRING (String Args []) {

// process the arguments

For (int i = 0; i

IF (args [i] .equals ("- port")) {

Portnumber = 0;

} else if (args [i] .Equals ("- device")) {

DeviceName = New String (args [ i]);

} else if (args [i] .equals ("- help")) {

System.out.println ("USAGE: STRING

-Port # -Device com1 or / dev / ttya ");

System.exit (0);

}

}

SmartCardDetector Scdetector = New

SmartCardDetector (1000);

Scdetector.AddActionListener (this);

Scdetector.StartDetection ();

}

Public void actionPerformed (ActionEvent ActionEvent) {

System.out.println ("Action Performed:" ActionEvent;

Try {

// Open the Requested Port Number

SmartCardReader Scr = New SmartCardReader ();

Isoreader = scr.getDefault ();

Isoreader.BegincardardSession (GemplusserialReader.gfm);

Cardstrings.writegfmstring ("01234567", isoreader;

System.out.println (Cardstrings.Readgfmstring (isoreader);

Isoreader.endcardSession ();

} catch (exception e) {

System.out.println ("Exception" E);

E.PrintStackTrace ();

} finally {

Try {

Isoreader.endcardSession ();

} catch (exception efinally) {

System.out.println ("COULD NOT POWER)

Down Card Perform Manual Reset ");

}

}

}

}

The Cardstrings class provides a part for reading writing a string to the smart card.

law. These strings are started in two bytes in the memory store in the smart card.

The length field, followed by six empty bytes, and then the back is a string data.

For those who have been developed by the truthful starting smart card, they must

It is necessary to face a challenge, that is, the method of repairing CardString, completing

Java's read and write. This kind of work is more flexible than the read-write string.

If it is now the writing of Java objects, you don't have to consider the grid to store data.

formula. I want to ask a simple question from a big family to put the string.

Stored into the smart card.

The following example is a complete data read and write application.

Order, it applies to GCR400 readers and GEMPLUS GFM smart cards. Only one point of attachment

Once work, it can support its type reader. But you don't have to worry

That kind of work, because of the next month, we will provide one with OpenCard.

This kind of work is made. This OpenCard will quickly become the standard of this industry.

Package java.commerce.memorycards;

Import java.io.ioException;

Import java.commerce.smartcards. *;

Import java.commerce.gemplus. *;

Public class cardstrings {

/ **

* Write a string, Since the card is MODULO 8 and WE ARE

* NOT USING SERIALIZED Objects - The First Two Bytes Are

THE

* Length Followed by Six Spare Bytes. Strings Longer Than

4096 - 48

* bits will be truncated.

* /

Public Static Void Writegfmstring (String S,

IsocardReader isoreader) {

IsoCommand WCMD;

IsoCardinputstream Winput;

INT UPPER, LOWER;

Short Length = (Short) s.ley (); // length of the input string

System.out.println ("Length IS" Length);

Try {

// Write the Control Section Out

WCMD = New IsoCommand (0, 0xD0, 0, 0, 8, 0);

// Save the Length

Wcmd.data.writeshort (Length);

System.out.Println ("Write out the length");

Winput = wcmd.execute (isoreader,

New gemplusreaderfailurehandler ());

// Write the string OUT

INT whOLEAMOUNT = Length / 8;

// Groups of 8

Int remainder = length% 8;

// remainder

// write the string out groups of 8

For (int L = 1; l <= wholeamount; l ) {

System.out.println ("Writing 8 Bytes AT"

(l * 8));

Upper = (l * 8) >> 8;

Lower = (l * 8) & 0xff;

WCMD = New IsoCommand (0, 0xD0, Upper, Lower,

8,0);

INT INDEX = ((L-1) * 8);

Wcmd.data.writestring (S.Substring (INDEX), 8);

System.out.println ("Write Out Bytes AT"

Index);

Winput = wcmd.execute (isoreader,

New gemplusreaderfailurehandler ());

}

// Write the remainder out

Upper = ((WHOLEAMOUNT 1) * 8) >> 8;

Lower = ((WHOLEAMOUNT 1) * 8) & 0xFF;

WCMD = New IsoCommand (0, 0xD0, Upper,

Lower, Remainder, 0);

INT INDEX = (Wholeamount * 8);

Wcmd.data.writeString (S.Substring (Index), Remainder;

Winput = wcmd.execute (isoreader,

New gemplusreaderfailurehandler ());

} catch (exception e) {

System.out.println ("Exception" E);

E.PrintStackTrace ();

}

}

/ **

* Read A String, Since The Card Is MODULO 8 and WE Are

* NOT USING SERIALIZED Objects - The First Two Bytes Are

THE

* Length Followed by Six Spare Bytes. Strings Longer Than

4096 - 48

* bits will be truncated.

* /

Public Static String Readgfmstring (isocardReader isoreader) {

IsoCommand rcmd;

IsoCardinputStream Rinput;

INT UPPER, LOWER;

Short Length;

StringBuffer SB = new stringbuffer ();

Try {

// read the control section

Rcmd = new isocommand (0, 0xB0, 0, 0, 0, 8);

// read the length

Rinput = rcmd.execute (isoreader, New

GemplusReaderfailurehandler

));

Length = (short) rinput.readshort ();

System.out.println ("The Length IS:" Length;

// read the string

INT wholaamount = length / 8; // groups

Of 8

Int remainder = length% 8; //

Remainder

// read the string in groups of 8

For (int L = 1; l <= wholeamount; l ) {

System.out.println ("Reading 8 Bytes AT"

(l * 8));

Upper = (l * 8) >> 8;

Lower = (l * 8) & 0xff;

Rcmd = new isocommand (0, 0xB0, Upper, Lower, 0,

8);

Rinput = rcmd.execute (isoreader, New

GemplusReaderfailurehand

LER ());

Sb.append (Rinput.ReadString (8));

System.out.println ("String to this point:"

sb.toString ());

}

// read the remainder

Upper = ((WHOLEAMOUNT 1) * 8) >> 8;

Lower = ((WHOLEAMOUNT 1) * 8) & 0xFF;

RCMD = New IsoCommand (0, 0xB0, Upper, Lower, 0, 8);

Rinput = rcmd.execute (isoreader, New

GemplusReaderfailurehandler

));

Sb.append (Rinput.Readstring (remainder);

System.out.println ("String to this point:"

sb.toString ());

} catch (exception e) {

System.out.println ("Exception" E);

E.PrintStackTrace ();

Return (NULL);

}

Return (sb.toString ());

}

}

After the article

In the back of the article, we will discuss this question: medical students

How can I add an entry in your smart card to a full sign?

Name, this is a square card to play its actual role. This application must also provide the function of displaying the history of your office card. This kind of function can be used

The household is used, and it can also be provided to the pharmacist or a tight rescue person. again

Plus your past medical treatment history with a warning of the colors, and

Social diseases such as chronic diseases, your intelligence, the square card will provide a number of applications where applications.

in conclusion

This article is a paved work for this series of articles related to the smart card.

. This series of special questions in JavaWorld includes four articles. Will be made by this article

If you are available, I hope to benefit to your application procedure in your smart card.

. I will use Java Electronic Commerce Framework (JECF) as a construction

The basis of the order of the order. JECF provides several classes for simplification and intelligent cards. Approach

The large number of codes and examples in the order come from JECF. You can find it from the entrance

To download the JECF, it has been included in the support of the smart card.

转载请注明原文地址:https://www.9cbs.com/read-874.html

New Post(0)