<Instance Aid="A0000000185000000000000052414441" Index="1" ApplicationSpecificParameters="7110A0000000185201050000000040534357" EepromSize="0000" RamSize="0000" InstallToken="" Privilege="00">
<!--If you add another Instance, you should increase his Index number-->
<GSMParameter TextMaxLength="14" MaxNumberOfMenuEntries="01" PriorityLevel="FF" TimerMaxNumber="00" Menus="0000">
<!--You can customize the GSM parameters of this Instance here-->
<SIMR5Parameter MaximumChannels="02">
<!--2 Channel -->
</SIMR5Parameter>
</GSMParameter>
<UICCParameter>
<!--You can customize the UICC parameters of this Instance here-->
<UICCToolkitParameter>
<UICCR6ToolkitParameter MaximumNumberOfServices="00"/>
</UICCToolkitParameter>
<!--You can customize the UICC Access Application parameters of this Instance here-->
<UICCAccessApplicationParameter Index="1">
<UICCR6AccessApplicationParameter AccessDomainParameter="00" AccessDomainData=""/>
</UICCAccessApplicationParameter>
</UICCParameter>
</Instance>
Friday, March 21, 2008
Sunday, March 16, 2008
Multimedia Ready Card
AID : A0 00 00 00 18 43 4D 08 09 0A 0B 0C 00 00 00
Edit : C:\Documents and Settings\$User\GemXploreDeveloper\keyfiles\scws carddefault.keys
aid.security_domain=hex/A0 00 00 00 18 43 4D 08 09 0A 0B 0C 00 00 00
And For MMready1.0 card, you need modify something in your .gdp file to be able to load it in your real card.
Remove the SecurityDomainAid value in gdp file. For example,
Edit : C:\Documents and Settings\$User\GemXploreDeveloper\keyfiles\scws carddefault.keys
aid.security_domain=hex/A0 00 00 00 18 43 4D 08 09 0A 0B 0C 00 00 00
And For MMready1.0 card, you need modify something in your .gdp file to be able to load it in your real card.
Remove the SecurityDomainAid value in gdp file. For example,
- Modify SecurityDomainAid="A0000000185201050000000030534357" to SecurityDomainAid=""
- Modify ApplicationSpecificParameters="7110A0000000185201050000000040534357" to ApplicationSpecificParameters="7110A0000000185201050000000030534357"
Parsing Query in Smart Web Server
SharedByteString name = new SharedByteString();
formParser.parse(this, queryString, stringValueBuffer, name,value);
SharedByteString value= new SharedByteString();
StringValueBuffer stringValueBuffer = new StringValueBuffer((short) 50, (short) 100); //short sizeRAM, short sizeEEPROM
FormParser formParser = new FormParser(true);
ByteString queryString = req.getQueryString();
if (queryString != null) {
}
Display response page in SCWS
HttpCardServletOutputStream
You can call it in following methods :
You can call it in following methods :
- public void doDelete(HttpCardServletRequest req,httpCardServletResponse resp) throws Exception
- public void doGet(HttpCardServletRequest req, HttpCardServletResponse resp)throws Exception
- public void doHead(HttpCardServletRequest req, HttpCardServletResponse resp)throws UserException, Exception
- public void doOptions(HttpCardServletRequest req,HttpCardServletResponse resp) throws Exception
- public void doPost(HttpCardServletRequest req, HttpCardServletResponse resp)throws Exception
- public void doPut(HttpCardServletRequest req, HttpCardServletResponse resp)throws Exception
byte [] hello = {'h','e','l','l','o'};
resp.setStatus(HttpCardServletResponse.SC_OK);
resp.setContentType(stringContainer.getConstantString(HttpStringContainer.TEXT_HTML_KEY));
HttpCardServletOutputStream out = resp.getOutputStream();
resp.setContentLength((short)5);
out.write(hello, (short) 0,(short)5);
Friday, March 14, 2008
Get Input stream content in Smart Card Web Server
HttpCardServletInputStream
You can call it in following methods :
You can call it in following methods :
- public void doDelete(HttpCardServletRequest req,httpCardServletResponse resp) throws Exception
- public void doGet(HttpCardServletRequest req, HttpCardServletResponse resp)throws Exception
- public void doHead(HttpCardServletRequest req, HttpCardServletResponse resp)throws UserException, Exception
- public void doOptions(HttpCardServletRequest req,HttpCardServletResponse resp) throws Exception
- public void doPost(HttpCardServletRequest req, HttpCardServletResponse resp)throws Exception
- public void doPut(HttpCardServletRequest req, HttpCardServletResponse resp)throws Exception
byte data;
byte[] content = JCSystem.makeTransientByteArray((short) req .getContentLength(), JCSystem.CLEAR_ON_RESET);
HttpCardServletInputStream in = req.getInputStream();
try {
for (short i = 0; i < content.length; i++)
{
data = in.read();
content[i] = data;
}
}
catch (EndOfStreamException e) { }
// or
in.read(content,0,content.length);
HttpCardServletContainer
It manages (add and remove) servlet
You can call it http://URL/post
HttpCardServlet servlet
HttpCardServletContainer servletContainer;
static byte[] prefix = { '/', 'p','o','s','t'}
AID server = JCSystem.lookupAID(buffer, offset, aidLen);
servletContainer = (HttpCardServletContainer) JCSystem.getAppletShareableInterfaceObject( server, HttpCardServletContainer.HTTP_CARD_SERVLET_CONTAINER_SERVICE);
servletContainer.add(servlet, new ByteString(prefix));
servletContainer.remove(servlet)
You can call it http://URL/post
Thursday, March 13, 2008
Parsing Form in Smart Web Server
There are 2 class that have been already provided FormHandler and FormParser.
FormHandler
We should implement FormHandler in class. This class has 3 methods, start , form and end.
Start : start of the document parsing, perhaps you can add some codes that initialized the value of variable
Form : Each form value will be known in here. Just compare the form value with the first input parameter.
End : end of the document parsing
for example :
FormHandler
We should implement FormHandler in class. This class has 3 methods, start , form and end.
Start : start of the document parsing, perhaps you can add some codes that initialized the value of variable
Form : Each form value will be known in here. Just compare the form value with the first input parameter.
End : end of the document parsing
for example :
import com.gemplus.javacard.multimedia.framework.ByteString;
import com.gemplus.javacard.multimedia.framework.FormHandler;
public class FormPosting implements FormHandler {
public byte [] username;
public byte [] usermail;
private static final byte[] USERNAME={'u','s','e','r','n','a','m','e'};
private static final byte[] USERMAIL={'u','s','e','r','m','a','i','l'};
public void start() {
username=null;
usermail=null;
}
public void form(ByteString arg0, ByteString arg1) {
if (arg0.compareTo(USERNAME, (short) 0, (short) USERNAME.length) == 0)
{
username = arg1.getBytes();
}
else if (arg0.compareTo(USERMAIL, (short) 0, (short) USERMAIL.length) == 0)
usermail = arg1.getBytes();
}
public void end() {
// TODO Auto-generated method stub
}
}
FormParserSharedByteString name = new SharedByteString();
SharedByteString value= new SharedByteString();
StringValueBuffer stringValueBuffer = new StringValueBuffer((short) 50, (short) 100); //short sizeRAM, short sizeEEPROM
FormParser formParser = new FormParser(true);
// some methods
HttpCardServletRequest req
byte data;
byte[] content = JCSystem.makeTransientByteArray((short) req.getContentLength(), JCSystem.CLEAR_ON_RESET);
stringValueBuffer.reset();
HttpCardServletInputStream in = req.getInputStream();
try {
for (short i = 0; i < content.length; i++) {
data = in.read();
content[i] = data;
} } catch (EndOfStreamException e) { }
// URL encoded
formParser.parse(FormPosting, new ByteString(content), stringValueBuffer, name, value);
Saturday, February 23, 2008
Create File with Java Card code
You should read
EF TAG
- ETSI TS 102.226 (8.2.1.3.2.2.2 and 8.2.1.3.2.2.4) that explains the UICC access parameters. The Application is only granted to access files according UICC access parameters.
- ETSI TS 102.241(8) that describes AdminFIleView objects and operation
- Each file operation is mentioned at ETSI TS 102.222 (8)
- Dedicated files DF (directories)
- Elementary files EF (data files)
- Transparent files
- Linear fixed files
- Cyclic files
EF TAG
- File descriptor(TS 102.221 11.1.1.4.3)*
- Tag = '82'
- Length = '02' or '04'
- value :
- Data Coding ='21'
- File Desc value :
- No Information given = '20'
- Transparent Structure ='41'
- Linear Fixed = '42'
- Cyclic = '46'
- Record length = '0001' to '00FF'
- Number of record = '01' to 'FE'
- File ID*
- Tag = '83'
- Length = '02'
- Life Cycle Status Information*
- Tag = '8A'
- Length = '01'
- Security attribute *
- Tag Compact ='8A', Expanded = 'AB', Referenced ='8B'
- Length = n
- File Size *
- Tag = '80'
- Length = n
- Short File Identifier
- Tag ='88'
- Length = '00' or '01'
- Proprietary
- Tag = 'A5' or '85'
- File descriptor*
- Tag = '82'
- Length = '02'
- File ID*
- Tag = '83'
- Length = '02'
- DF Name(AID)
- Tag = '84'
- Length
- Value 1-16 byte
- Life Cycle Status Information*
- Tag = '8A'
- Length = '01'
- Total File Size*
- tag ='81'
- length
- Security Atribute*
- Tag Compact ='8C', Expanded = 'AB', Referenced ='8B'
- Length = n
- Pin Status Template *
- Tag = 'C6'
- length
- Length = n
- Data Coding Byte
- Tag ='21'
- Proprietary
- Tag = 'A5' or '85'
Friday, February 22, 2008
SCWS Local Server
- Open BIP TCP Server mode
- At least support 2 channel, HTTP and HTTPS
- HTTP port 3516
- HTTPS (TLS) port 4116
- Enable automatically, not such BIP Client mode
Thursday, February 21, 2008
Terminal Response
- OPEN CHANNEL <-- Channel Identifier
ProRespHdlr = ProactiveResponseHandlerSystem.getTheHandler();
ChannelID = ProRespHdlr.getChannelIdentifier() ;
- SEND DATA <-- Channel Data Length
- CLOSE CHANNEL <-- OK
- GET CHANNEL STATUS <-- Channel Status
- RECEIVE DATA <-- Channel Data Length , Data
ProRespHdlr = ProactiveResponseHandlerSystem.getTheHandler();
ProRespHdlr.findTLV(TAG_CHANNEL_DATA ,0);
sOffset= ProRespHdlr.copyChannelData(byte[] dstBuffer, short dstOffset, short dstLength) ;
ProRespHdlr.findTLV(TAG_CHANNEL_DATA_LENGTH ,0);
datalength=ProRespHdlr.getValueVyte((short)0x0000);
EVENT DOWNLOAD CHANNEL STATUS
- Channel Status*
- Channel Status Tag = '38'
- Length = '02'
- Channel Status
- bit 1 -3 : Channel Identifier 1- 7 , 0 --> No Channel Available
- BIP TCP Client
- bit 4-7 : RFU
- bit 8 : 0 -> Link not established/Packet data service not activated, 1 -> Opposite
- BIP TCP Server
- bit 4-6 : RFU
- bit 7-8 :
- 00 = TCP in CLOSED state
- 01 = TCP in LISTEN state
- 10 = TCP in ESTABLISHED state
- 11 = reserved
- Device identities*
- device identities tag = '82'
- Length = '02'
- Source Device identity = '82' --> Terminal
- Destination Device Identity ='81' --> UICC
- Event List*
- Event List Tag= '19'
- Length = '01'
- Event List : Channel Status = '0A'
- Bearer Description
- Bearer Description Tag = '35'
- Length
- Bearer Type = '02' (GSM/3GPP) --> GPRS
- Bearer Parameter
- Precedence Class ( Priority) = '00'
- Delay Class = '00'
- Reability Class = '03'
- Peak Throughput '00'
- Mean Throughput = '00'
- PDP IP = '02'
- Other Data Destination Address Tag = '3E'
- Length = '05'
- Type of Address = '21' (IPv4)
- Address ( 4 byte , XX.XX.XX.XX)
note :
* mark means mandatory
Only one event in Event list
Bearer Description is needed after OPEN Channel
Device Identities SCWS
Command | Source | Destination |
Open Channel | UICC | Terminal |
Set Up Event List | UICC | Terminal |
Close Channel | UICC | Channel x |
Receive data | UICC | Channel x |
Send Data | UICC | Channel x |
Get Channel Status | UICC | Terminal |
Event Download Data Available | Terminal | UICC |
Event Download Channel Status | Terminal | UICC |
Command Coding SCWS
- Open Channel ='40'
- Set Up Even List = '05'
- Close Channel = '41'
- Receive data = '42'
- Send data = '43'
- Get Channel Status = '44'
EVENT DOWNLOAD DATA AVAILABLE
- Event Download Tag* = '22'
- Device identities*
- device identities tag = '82'
- Length = '02'
- Source Device identity = '82' --> Terminal
- Destination Device Identity = '81' --> UICC
- Channel Status*
- Channel Status Tag = '38'
- Length = '02'
- Channel Status
- bit 1 -3 : Channel Identifier 1- 7 , 0 --> No Channel Available
- BIP TCP Client
- bit 4-7 : RFU
- bit 8 : 0 -> Link not established/Packet data service not activated, 1 -> Opposite
- BIP TCP Server
- bit 4-6 : RFU
- bit 7-8 :
- 00 = TCP in CLOSED state
- 01 = TCP in LISTEN state
- 10 = TCP in ESTABLISHED state
- 11 = reserved
- Channel Data Length*
- Channel Data Length Tag = '37'
- Length = '01'
- Channel data length
- Event List*
- Event List Tag= '19'
- Length = '01'
- Event List = '09' --> Data Available
note :
* mark means mandatory
Wednesday, February 20, 2008
SET UP EVENT LIST
Set Up Event List can be used for set new event, replace old event or remove an event.
The terminal will send TERMINAL RESPONSE(OK) if it has been removed or set the list of event. If Event list is null, it means the terminal to remove all events in the list.
note :
* mark means mandatory
The terminal will send TERMINAL RESPONSE(OK) if it has been removed or set the list of event. If Event list is null, it means the terminal to remove all events in the list.
- Command details*
- command details tag = '81'
- length = '03' (1 byte)
- command number 01 - FE (1 byte)
- Type of Command ='05' (SET UP EVENT LIST)
- Command Qualifier : RFU
- Device identities*
- device identities tag = '82'
- Length = '02'
- Source Device identity = '81' --> UICC
- Destination Device Identity ='82' --> Terminal
- Event List*
- Event List Tag= '19'
- Length = '01'
- Event List
- Data Available = '09'
- Channel Status = '0A'
note :
* mark means mandatory
GET CHANNEL STATUS
- Command details*
- command details tag = '81'
- length = '03' (1 byte)
- command number 01 - FE (1 byte)
- Type of Command ='44' (GET CHANNEL STATUS)
- Command Qualifier : RFU
- Device identities*
- device identities tag = '82'
- Length = '02'
- Source Device identity = '81' --> UICC
- Destination Device Identity = '82' --> Terminal
SEND DATA
The data can be sent immediately or store in a Tx buffer.
note :
* mark means mandatory
- Command details*
- command details tag = '81'
- length = '03' (1 byte)
- command number 01 - FE (1 byte)
- Type of Command ='43' (SEND DATA)
- Command Qualifier : RFU
- Device identities*
- device identities tag = '82'
- Length = '02'
- Source Device identity = '81' --> UICC
- Destination Device Identity = '21'-'27' --> channel ID (PRE_ID _CHANNEL_BASE='20')
- Channel Data
- Channel Data Length = '36'
- Length = '01'
- Channel data length
- Alpha Identifier
- Alpha identifier TAG = '05'
- Length = 0
- Alpha Identifier (TS 131 102)
- Icon Identifier
- Icon Identifier Tag
- Length = '02'
- Icon Qualifier
- bit 1, 0 = self explanatory, 1 = non self explanatory
- bit 2-8 =0 (RFU)
- Icon Identifier (TS 131 102)
- Text Attribute
- Text Attribute Tag = '50'
- Length
- Text formatting ( TS 123 040)
- Frame Identifier
- Frame Identifier Tag
- Length = '03'
- Identifier of Frame, the value is between '00' - '0F'
note :
* mark means mandatory
RECEIVE DATA
- Command details*
- command details tag = '81'
- length = '03' (1 byte)
- command number 01 - FE (1 byte)
- Type of Command ='42' (RECEIVE DATA)
- Command Qualifier : RFU
- Device identities*
- device identities tag = '82'
- Length = '02'
- Source Device identity = '81' --> UICC
- Destination Device Identity = '21'-'27' --> channel ID (PRE_ID _CHANNEL_BASE='20')
- Channel Data Length
- Channel Data Length Tag = '37'
- Length = '01'
- Channel data length
- Alpha Identifier
- Alpha identifier TAG = '05'
- Length = 0
- Alpha Identifier (TS 131 102)
- Icon Identifier
- Icon Identifier Tag
- Length = '02'
- Icon Qualifier
- bit 1, 0 = self explanatory, 1 = non self explanatory
- bit 2-8 =0 (RFU)
- Icon Identifier (TS 131 102)
- Text Attribute
- Text Attribute Tag = '50'
- Length
- Text formatting ( TS 123 040)
- Frame Identifier
- Frame Identifier Tag
- Length = '03'
- Identifier of Frame, the value is between '00' - '0F'
note :
* mark means mandatory
CLOSE CHANNEL BIP
After OPEN Channel, You should know how to close it. Here are some important things you should be aware.
note :
* mark means mandatory
Channel indentifier must be valid
- Command details*
- command details tag = '81'
- length = '03' (1 byte)
- command number 01 - FE (1 byte)
- Type of Command ='41' (CLOSE CHANNEL)
- Command Qualifier :
- RFU for BIP Client Mode
- bit 1
- 0 : close TCP Connection and go to "TCP in CLOSED state"
- 1 : close TCP Connection and go to "TCP in LISTEN state"
- Device identities*
- device identities tag = '82'
- Length = '02'
- Source Device identity = '81' --> UICC
- Destination Device Identity = '21'-'27' --> channel ID (PRE_ID _CHANNEL_BASE='20')
- Alpha Identifier
- Alpha identifier TAG = '05'
- Length = 0
- Alpha Identifier (TS 131 102)
- Icon Identifier
- Icon Identifier Tag
- Length = '02'
- Icon Qualifier
- bit 1, 0 = self explanatory, 1 = non self explanatory
- bit 2-8 =0 (RFU)
- Icon Identifier (TS 131 102)
- Text Attribute
- Text Attribute Tag = '50'
- Length
- Text formatting ( TS 123 040)
- Frame Identifier
- Frame Identifier Tag
- Length = '03'
- Identifier of Frame, the value is between '00' - '0F'
note :
* mark means mandatory
Channel indentifier must be valid
OPEN CHANNEL BIP TCP Server Mode
I have already posted BIP TCP client mode requirement before. Here are my little explanation for TCP Server mode.
note :
* mark means mandatory
- Command details*
- command details tag = '81'
- length = '03' (1 byte)
- command number 01 - FE (1 byte)
- Type of Command ='40' (OPEN CHANNEL)
- Command Qualifier : RFU
- Device identities*
- device identities tag = '82'
- Length = '02'
- Source Device identity = '81' --> UICC
- Destination Device Identity = '82' --> Terminal
- Alpha Identifier
- Alpha identifier TAG = '05'
- Length = 0
- Alpha Identifier (TS 131 102)
- Icon Identifier
- Icon Identifier Tag
- Length = '02'
- Icon Qualifier
- bit 1, 0 = self explanatory, 1 = non self explanatory
- bit 2-8 =0 (RFU)
- Icon Identifier (TS 131 102)
- Buffer Size*
- Buffer Size Tag = '39'
- Length = '02'
- Byte 3-4 = Buffer size, for example 1000 bytes = 03E8
- UICC/ Terminal Interface
- UICC/ Terminal Interface level tag = '3C'
- Length = '03'
- Transport Protocol Type = '03' (TCP,UICC in server mode)
- Port Number(2 bytes) = '0DBC' (3516)
- Text Attribute
- Text Attribute Tag = '50'
- Length
- Text formatting ( TS 123 040)
- Frame Identifier
- Frame Identifier Tag
- Length = '03'
- Identifier of Frame, the value is between '00' - '0F'
note :
* mark means mandatory
OPEN CHANNEL BIP TCP Client Mode
According to TS 102 223(6.6.27.2), the requirement for setting up Open Channel command in BIP TCP Client are
note :
* mark means mandatory
- Command details*
- command details tag = '81'
- length = '03' (1 byte)
- command number 01 - FE (1 byte)
- Type of Command ='40' (OPEN CHANNEL)
- Command Qualifier :
- bit 1 : 0 = for Demand link establishment, 1 = immediate link establishment
- bit 2 : 0 = no automatic reconnection, 1 = automatic reconnection
- bit 3 : 0 = no background mode, 1 = immediate link establishment in background mode
- bit 4-8 = RFU
- Device identities*
- device identities tag = '82'
- Length = '02'
- Source Device identity = '81' --> UICC
- Destination Device Identity = '82' --> Terminal
- Alpha Identifier
- Alpha identifier TAG = '05'
- Length = 0
- Alpha Identifier (TS 131 102)
- Icon Identifier
- Icon Identifier Tag
- Length = '02'
- Icon Qualifier
- bit 1, 0 = self explanatory, 1 = non self explanatory
- bit 2-8 =0 (RFU)
- Icon Identifier (TS 131 102)
- Bearer Description*
- Bearer Description Tag = '35'
- Length
- Bearer Type = '02' (GSM/3GPP) --> GPRS
- Bearer Parameter
- Precedence Class ( Priority) = '00'
- Delay Class = '00'
- Reability Class = '03'
- Peak Throughput '00'
- Mean Throughput = '00'
- PDP IP = '02'
- Buffer Size*
- Buffer Size Tag = '39'
- Length = '02'
- Byte 3-4 = Buffer size, for example 1000 bytes = 03E8
- Network Access Name
- Network Access Name Tag = '47'
- Length
- Network Access Name
- Other Data Destination Address (local)
- Other Data Destination Address Tag = '3E'
- Length = '05'
- Type of Address = '21' (IPv4)
- Address ( 4 byte , XX.XX.XX.XX)
- Login
- Text String Tag = '0D'
- Length
- Data Coding Scheme = null
- Text String = your username
- Password
- Text String Tag = '0D'
- Length
- Data Coding Scheme = null
- Text String = your password
- UICC/ Terminal Interface
- UICC/ Terminal Interface level tag = '3C'
- Length = '03'
- Transport Protocol Type = '02' (TCP,UICC in client mode)
- Port Number(2 bytes) = '00' '50' (80)
- Data destination address
- Data Destination Address Tag = '3E'
- Length = '05'
- Type of Address = '21' (IPv4)
- Address ( 4 byte , XX.XX.XX.XX)
- Text Attribute
- Text Attribute Tag = '50'
- Length
- Text formatting ( TS 123 040)
- Frame Identifier
- Frame Identifier Tag
- Length = '03'
- Identifier of Frame, the value is between '00' - '0F'
note :
* mark means mandatory
Friday, January 4, 2008
Declaration String to bytes variable in Smart Card Coding
/**
* This program is really useful for programmer who is so lazy
* to type word/ sentence in bytes when he/she codes in Smart card
*/
import java.lang.*;
/**
* @version 1.0
* @author kapulaga
*
*/
public class stringtobyte {
public stringtobyte(String variablename, String variablevalue)
{
int i;
System.out.print("byte[] "+variablename+"={");
for(i=0;i
{
if(i
System.out.print("'"+variablevalue.charAt(i)+"'"+",");
else
System.out.print("'"+variablevalue.charAt(i)+"'"+"};");
}
}
public static void main(String[] args) {
stringtobyte stb = new stringtobyte("variable","byte value");
}
}
Subscribe to:
Posts (Atom)