{"id":1267,"date":"2009-09-01T09:32:22","date_gmt":"2009-09-01T14:32:22","guid":{"rendered":"http:\/\/www.coresecuritypatterns.com\/blogs\/?p=1267"},"modified":"2020-08-08T04:11:34","modified_gmt":"2020-08-08T04:11:34","slug":"java-card-30-deploying-and-running-web-applications-on-smartcard","status":"publish","type":"post","link":"https:\/\/websecuritypatterns.com\/blogs\/2009\/09\/01\/java-card-30-deploying-and-running-web-applications-on-smartcard\/","title":{"rendered":"Java Card 3.0: Deploying and Running &quot;Web applications&quot; on Smartcard."},"content":{"rendered":"<p><a href=\"http:\/\/java.sun.com\/javacard\/\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-medium wp-image-1282\" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/smartcard3-281x300.jpg\" alt=\"\" width=\"158\" height=\"168\"><\/a>Java Card technology&nbsp;has been a passion&nbsp;of mine for&nbsp;so long&nbsp;and I always tried my best to&nbsp;keep&nbsp;updated&nbsp;on Smart card technologies&#8230;&#8230; not just because&nbsp;of my role at&nbsp;Sun, I did get several opportunities to work closely with <em>citizen-scale<\/em> Java Card&nbsp;deployments with multiple National ID, eID\/ICAO, US DoD\/CAC, PIV\/FIPS-201 cards and&nbsp;related Identity management projects.&nbsp; It is always been quite adventurous everytime to experience&nbsp;a card issuance architecture and deployment scenario &#8211; right from applicant enrollment, demographic data provisioning,&nbsp;Biometrics\/PKI credentialing,&nbsp;adjudication\/background checks,&nbsp;post-issuance maintenance including card authentication\/verification\/usage and final&nbsp;retirement\/termination.&nbsp; In the early 2000&#8217;s, I even had an opportunity&nbsp;to write&nbsp;couple of&nbsp;Java Card applets for a big 5 financial organization using Java Card 2.x and it is still exists on production&nbsp;(No kidding! one of them may be in your wallet).&nbsp;With all those experiences,&nbsp;I did have my own stumbling issues with programming&nbsp;Smartcards, where I pulled my hair-out on understanding those evil&nbsp;&#8220;Application Protocol Data Units&#8221; (APDU) based commands and responses.&nbsp;In my opinion, APDUs are quite complex to understand when you jump in&nbsp;unless you read the docs in-and-out beforehand&nbsp;and then test-driving APDUs are&nbsp;even more&nbsp;hard unless you have the luxury of having a debugging environment &#8211; &nbsp;seriously, you may not want to experience those pains.&nbsp; Havingsaid, now we can breathe a sigh of relief &#8211; I am bit late to experience the newer features of Java Card 3.0&nbsp;&#8211;&nbsp;&nbsp;It has introduced &#8220;network-centric&#8221; and &#8220;Java\/J2EE developer&#8221; friendly&nbsp;features that radically changed&nbsp;the way we originally designed, developed, deployed, and integrated&nbsp;Smartcard applications.&nbsp; Interestingly, there are very compelling aspects about Java Card 3.0 technology&nbsp;&#8211;&nbsp; As I digged with&nbsp;my little experience&#8230;&nbsp;here is my observations.&nbsp;&nbsp;<\/p>\n<h2>Understanding Java Card 3.0&nbsp;&nbsp;<\/h2>\n<ol>\n<li>A Smartcard can act as a&nbsp;&#8220;Personal Web Application Server&#8221;&nbsp; or an user-centric&nbsp;miniature&nbsp;Java EE application server&nbsp;on a network.&nbsp; Java Card 3.0 has introduced a Servlet container environment referred to as &#8220;Connected Edition&#8221; &#8211; which allows the smartcard applications can built as Java servlets&nbsp;(Web applications) using Servlet 2.4 APIs&nbsp;and deployed as a &#8220;WAR&#8221; file to the Web container running on a Java Card 3.0 compliant Smart card. This&nbsp;Servlet based deployment is an addition to existing&nbsp;Java card applet deployment model referred to as Classic Edition&nbsp;(exists with Java card 2.2.x). The Java Card clients access the applications&nbsp;using a Web browser (ex. <a href=\"http:\/\/localhost:8019\/myJavaCardServlet\">http:\/\/localhost:8019\/myJavaCardServlet<\/a>).\n<p><div id=\"attachment_1366\" style=\"width: 510px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/09\/javacard-servletcontainer.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1366\" class=\"size-full wp-image-1366\" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/09\/javacard-servletcontainer.png\" alt=\"Java Card Platform - Architecture\" width=\"500\" height=\"266\"><\/a><p id=\"caption-attachment-1366\" class=\"wp-caption-text\">Java Card Platform - Architecture<\/p><\/div><\/li>\n<li>Java Card 3.0 supports 32-bit processor based Smartcards and handles more memory &#8211; upto 128k.<\/li>\n<li>Enough with pain of understanding\/testing APDUs, now you can readily develop Java Servlet 2.4 API compliant Web applications and deploy them&nbsp;to a Smart card.<\/li>\n<li>With Java Card 3.0,&nbsp;we can perform interact with using standards based communication with the card using HTTP\/HTTPS and also its supporting&nbsp;XML based protocols such as SOAP, REST etc.<\/li>\n<li>Support for Java crypto APIs and additionally&nbsp;you can&nbsp;enable access control with the card similiar to performing container-managed authentication in Java EE &#8211; using SSL\/TLS mechanisms.\n<div id=\"attachment_1321\" style=\"width: 466px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/javacard-connectivity.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1321\" class=\"size-full wp-image-1321\" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/javacard-connectivity.png\" alt=\"Java card 3.0 - Communication Protocols\" width=\"456\" height=\"317\"><\/a><p id=\"caption-attachment-1321\" class=\"wp-caption-text\">Java card 3.0 - Communication Protocols<\/p><\/div>\n<p>&nbsp;<\/li>\n<li>Java Card 3.0 based Web applications can be developed, debugged and deployed using Netbeans 6.7.1 and up.<\/li>\n<li>Smart card issuance (for Card holders) and updates&nbsp;using GCF can be done through Web based deployment model (via HTTP, TCP) &#8211; using both contact and contactless communication interfaces.<\/li>\n<li>Other features include full Java language support (Java 1.6 features)&nbsp;including all data types (except float and double), multi-threading, garbage collection, XML parsing\/generation capabilities&nbsp;etc.<\/li>\n<li>Allows Java developers to explore Java Card platform easily with strong potential for deploying security applications intended for National ID card schemes, passports and simplifying deployment of &nbsp;&#8220;Match-to-card Biometrics&#8221;, &#8220;On-card&#8221; credential persistence and secure transaction based applications.<\/li>\n<\/ol>\n<h2>Try&nbsp;it yourself<\/h2>\n<p>If you are curious to test drive Java Card 3.0 reference implementation especially using its &#8220;Connected Edition&#8221; to deploy Java Servlet based application to&nbsp;Smart card &#8211;&nbsp;Before you begin, make sure you obtain the list of pre-requistes :<\/p>\n<ol>\n<li><a href=\"http:\/\/java.sun.com\/javacard\/downloads\/index.jsp#devkit\" target=\"_blank\" rel=\"noopener noreferrer\">Java Card Connected Development Kit 3.0.1<\/a><\/li>\n<li><a href=\"http:\/\/www.netbeans.org\/\" target=\"_blank\" rel=\"noopener noreferrer\">Netbeans 6.7.1<\/a><\/li>\n<\/ol>\n<p>and then proceed with the&nbsp;following&nbsp;steps for deploying a &#8220;Hello World&#8221; Web application &#8211; <em><span style=\"underline;\">creating Java card applications can&#8217;t get easier than this<\/span><\/em> :<\/p>\n<ol>\n<li>Install the Java Card 3.0 plugins for&nbsp;Netbeans 6.7.1 &#8211; Go to Tools, Plugins and search for card to select plugins for &#8220;Java Card Projects&#8221; and &#8220;Java Card Console&#8221;.\n<div class=\"mceTemp mceIEcenter\">\n<dl>\n<dt><a href=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/javacardplugin-netbeans.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1337 \" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/javacardplugin-netbeans.png\" alt=\"Installing Java Card plugins for Netbeans\" width=\"500\" height=\"342\"><\/a><\/dt>\n<dd>Installing Java Card plugins for Netbeans<\/dd>\n<\/dl>\n<p>&nbsp;<\/p>\n<\/div>\n<\/li>\n<li>\n<div class=\"mceTemp\">&nbsp;Go to Netbeans IDE,&nbsp; Choose Project &#8211; &#8220;Java Card&#8221; and select Projects type &#8220;Web Project&#8221;.&nbsp;<\/div>\n<p><a href=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/javacard-webapplicationproject.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1341 \" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/javacard-webapplicationproject.png\" alt=\"Creating a Java Card &quot;Web Project&quot;\" width=\"500\" height=\"420\"><\/a><\/li>\n<li>\n<div class=\"mceTemp\">&nbsp;Assign Project name\/location\/folder and then select &#8220;Manage Platforms&#8221; to assign the Java Card 3.0 runtime environment.&nbsp;&nbsp;&nbsp;<\/div>\n<div id=\"attachment_1346\" style=\"width: 510px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/select-javacardplatform.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1346\" class=\"size-full wp-image-1346 \" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/select-javacardplatform.png\" alt=\"Assigning &quot;Java Card&quot; runtime environment\" width=\"500\" height=\"342\"><\/a><p id=\"caption-attachment-1346\" class=\"wp-caption-text\">Assigning Java Card Runtime Info<\/p><\/div>\n<p>&nbsp;<\/li>\n<li>\n<div class=\"mceTemp\">&nbsp;To assign the Java Card runtime info, select &#8220;Manage Platforms&#8221; and choose &#8220;Platform type&#8221; to Java Card Platform.&nbsp;&nbsp;<\/div>\n<p><div id=\"attachment_1348\" style=\"width: 510px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/select-javacardplatform2.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-1348\" class=\"size-full wp-image-1348 \" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/select-javacardplatform2.png\" alt=\"Choosing &quot;Java Card&quot; runtime environment\" width=\"500\" height=\"423\"><\/a><p id=\"caption-attachment-1348\" class=\"wp-caption-text\">Choosing Java Card as runtime<\/p><\/div><\/li>\n<li>\n<div class=\"mceTemp\">&nbsp;Select the location of your&nbsp;&#8220;Java Card 3.0 Connected Edition Dev kit&#8221; installation.&nbsp;<\/div>\n<a href=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/select-javacardplatform3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1350 \" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/select-javacardplatform3.png\" alt=\"Select &quot;Java Card 3.0 Connected Edition Dev Kit&quot; folder\" width=\"500\" height=\"303\"><\/a>\n<p>&nbsp;<\/li>\n<li>\n<div class=\"mceTemp\">&nbsp;Define the default device (assuming your Smartcard) attributes and press &#8220;Finish&#8221;:&nbsp;<\/div>\n<a href=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/select-defaultdevice.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1352 \" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/select-defaultdevice.png\" alt=\"Select your &quot;Java Card&quot;\" width=\"500\" height=\"302\"><\/a>\n<p>&nbsp;<\/li>\n<li>\n<div class=\"mceTemp\">&nbsp;As a result, you should see the Netbeans console showing your &#8220;Java Card Platform&#8221; environment for test-driving your applications.&nbsp; &nbsp;<a href=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/endresult.png\">&nbsp;<img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1354\" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/08\/endresult.png\" alt=\"\" width=\"500\" height=\"397\"><\/a>&nbsp;<\/div>\n<\/li>\n<li>\n<div class=\"mceTemp\">With above steps complete, now you are ready to develop\/debug\/deploy your Java Card web applications&#8230;. here is my first &#8220;Hello World&#8221; Java Card Web application excercise.&nbsp;&nbsp;&nbsp;<a href=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/09\/firstexcercise.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1355\" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/09\/firstexcercise.png\" alt=\"\" width=\"500\" height=\"394\"><\/a>&nbsp;&nbsp;&nbsp;&nbsp;<\/div>\n<\/li>\n<li>\n<div class=\"mceTemp\">&nbsp;Compile the application&nbsp;&#8211;&nbsp;&nbsp;In the Projects window, right-click the project node and choose <strong>Build <\/strong>to build the project.&nbsp;&nbsp;&nbsp; <a href=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/09\/compile-window.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1368\" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/09\/compile-window.png\" alt=\"\" width=\"500\" height=\"227\"><\/a>&nbsp;<\/div>\n<\/li>\n<li>\n<div class=\"mceTemp\">To deploy and run the Web application from your target Smartcard device (in my case the JavaCard RI), In the Projects window, right-click the project node and choose <strong>Load\/Create&nbsp;Instance<\/strong> or just<strong>&nbsp;Run<\/strong>&nbsp;to run the application.&nbsp; Netbeans will launch the browser, displaying the Hello world application prompting for your name&#8230;.&nbsp;&nbsp;and push the button to see &#8211; what happens !&nbsp;&nbsp;<a href=\"http:\/\/www.coresecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/09\/helloworld.png\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-1370\" src=\"http:\/\/www.websecuritypatterns.com\/blogs\/wp-content\/uploads\/2009\/09\/helloworld.png\" alt=\"\" width=\"500\" height=\"118\"><\/a>&nbsp;&nbsp;<\/div>\n<\/li>\n<\/ol>\n<p>Netbeans does all the magic for you &#8211; if something&nbsp;not working, no worries ! Like implementing anyother Web application in IDE,&nbsp; it is now easy for you to painlessly&nbsp;debug and redeploy the application &#8211; I am sure, you&#8217;ll find deploying applications on Java Card is nolonger a mystery.<\/p>\n<p>With Billions+ Java Cards already in use and so much&nbsp;demand for&nbsp;the Smartcard technology,&nbsp; Java Card 3.0&nbsp;promises beyond citizen IDs and can potentially act as your &#8220;Personal Web application server&#8221; on your wallet.<\/p>\n<p>Thanks to Anki Nelaturu and Saqib Ahmad who introduced me to Java Card 3 with their JavaOne &#8217;09 sessions. After playing with my first excercise on Java Card 3.0 RI, now I am chasing my friendly Smartcard vendors to loan me couple of Java Card 3.0 cards \ud83d\ude42<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java Card technology&nbsp;has been a passion&nbsp;of mine for&nbsp;so long&nbsp;and I always tried my best to&nbsp;keep&nbsp;updated&nbsp;on Smart card technologies&#8230;&#8230; not just because&nbsp;of my role at&nbsp;Sun, I did get several opportunities to work closely with citizen-scale Java Card&nbsp;deployments with multiple National ID, eID\/ICAO, US DoD\/CAC, PIV\/FIPS-201 cards and&nbsp;related Identity management projects.&nbsp; It is always been quite adventurous everytime to experience&nbsp;a card issuance&#8230; <a href=\"https:\/\/websecuritypatterns.com\/blogs\/2009\/09\/01\/java-card-30-deploying-and-running-web-applications-on-smartcard\/\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[2,5,21,6,8,11],"tags":[24,26,29,31,37,40,55,62,64],"class_list":["post-1267","post","type-post","status-publish","format-standard","hentry","category-biometrics","category-identity-management","category-java-security","category-main","category-pki-main","category-smartcards-pki","tag-biometrics-main","tag-cac","tag-eid","tag-fips-201","tag-j2ee","tag-java-security","tag-piv","tag-security","tag-smartcards"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/websecuritypatterns.com\/blogs\/wp-json\/wp\/v2\/posts\/1267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/websecuritypatterns.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/websecuritypatterns.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/websecuritypatterns.com\/blogs\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/websecuritypatterns.com\/blogs\/wp-json\/wp\/v2\/comments?post=1267"}],"version-history":[{"count":1,"href":"https:\/\/websecuritypatterns.com\/blogs\/wp-json\/wp\/v2\/posts\/1267\/revisions"}],"predecessor-version":[{"id":2836,"href":"https:\/\/websecuritypatterns.com\/blogs\/wp-json\/wp\/v2\/posts\/1267\/revisions\/2836"}],"wp:attachment":[{"href":"https:\/\/websecuritypatterns.com\/blogs\/wp-json\/wp\/v2\/media?parent=1267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/websecuritypatterns.com\/blogs\/wp-json\/wp\/v2\/categories?post=1267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/websecuritypatterns.com\/blogs\/wp-json\/wp\/v2\/tags?post=1267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}