Access Terminal and select applet

Hi people,
I have a question about to run the aplet in a javacard. Is there any code or other useful material about getting terminal and select applet and run the methods of the apllet in a programmable manner? Thanks for your interest...
Edited by: POLAT on Mar 16, 2009 7:41 PM

Honestly I haven't figured out how to pass a pin when selecting the applet, however at the minute I have a way around it:
you will see in teh code below, I have hardcoded a default pin and I have a pin update method that can be called via a apdu,
NOTE this example works with the code above:
*Applet ID 41 63 63 6F 75 6E 74 41 70 70 6C
public class AccountApplet extends Applet {
     final static byte ACCOUNT_CLA = (byte)0xB0;
     final static byte VERIFY = (byte) 0x20;
     final static byte CREDIT = (byte) 0x30;
     final static byte DEBIT = (byte) 0x40;
     final static byte GET_BALANCE = (byte) 0x50;
     final static byte UPDATE_PIN = (byte) 0x60;
     final static short MAX_BALANCE = 10000;
     final static byte MAX_TRANSACTION_AMOUNT = 100;
     final static byte PIN_TRY_LIMIT =(byte)0x03;
     final static byte MAX_PIN_SIZE =(byte)0x08;
     // Applet-specific status words:
     OwnerPIN pin;
     short balance = 109; // Starting balance of decimal 109 is 6D in hex
     public static void install(byte[] bArray, short bOffset, byte bLength) {
                    new AccountApplet(bArray, (short) (bOffset + 1), bArray[bOffset]);
     private AccountApplet(byte[] bArray, short bOffset, byte bLength){
          pin = new OwnerPIN(PIN_TRY_LIMIT, MAX_PIN_SIZE);
          // bArray contains the default PIN initialization value (12345)
          bArray[0] = 01;
          bArray[1] = 02;
          bArray[2] = 03;
          bArray[3] = 04;
          bArray[4] = 05;
          bOffset = 0;
          bLength = 5;
          pin.update(bArray, bOffset, bLength);
          register();
     public boolean select() {
     if (pin.getTriesRemaining() == 0)
               return false;
          return true;
public void deselect() {
     pin.reset();
     public void process(APDU apdu) {
byte[] buffer = apdu.getBuffer();
          if (selectingApplet())
               return;
          if (buffer[ISO7816.OFFSET_CLA] != ACCOUNT_CLA)
               ISOException.throwIt(ISO7816.SW_CLA_NOT_SUPPORTED);
          switch (buffer[ISO7816.OFFSET_INS]) {
          case GET_BALANCE:          getBalance(apdu);      return;
          case DEBIT:                    debit(apdu);             return;
          case CREDIT:               credit(apdu);           return;
          case VERIFY:               verify(apdu);          return;
          case UPDATE_PIN:          updatePin(apdu);     return;
          default:                    ISOException.throwIt
          (ISO7816.SW_INS_NOT_SUPPORTED);
private void credit(APDU apdu) {
          if (!pin.isValidated())
               ISOException.throwIt(SW_PIN_VERIFICATION_REQUIRED);
          byte[] buffer = apdu.getBuffer();
     byte numBytes = buffer[ISO7816.OFFSET_LC];
          byte byteRead = (byte)(apdu.setIncomingAndReceive());
          if (( numBytes != 1 ) || (byteRead != 1))
               ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
          byte creditAmount = buffer[ISO7816.OFFSET_CDATA];
          if (( creditAmount > MAX_TRANSACTION_AMOUNT)
                    || ( creditAmount < 0 ))
               ISOException.throwIt(SW_INVALID_TRANSACTION_AMOUNT);
          if ((short)( balance + creditAmount)  > MAX_BALANCE)
               ISOException.throwIt(SW_EXCEED_MAXIMUM_BALANCE);
          balance = (short)(balance + creditAmount);
          return;
     private void updatePin(APDU apdu) {
          if (! pin.isValidated())
               ISOException.throwIt(SW_PIN_VERIFICATION_REQUIRED);
          byte[] buffer = apdu.getBuffer();
          byte numBytes = buffer[ISO7816.OFFSET_LC];
          byte byteRead = (byte)(apdu.setIncomingAndReceive());
               if (byteRead != numBytes) {
               ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
               if ( numBytes > 8 )
               ISOException.throwIt(SW_PIN_TO_LONG);
          if ( numBytes < 4 )
               ISOException.throwIt(SW_PIN_TO_SHORT);     
          short offset_cdata = 05;          
          pin.update(buffer, offset_cdata, numBytes);
          pin.resetAndUnblock();
     private void debit(APDU apdu) {
          if (! pin.isValidated())
               ISOException.throwIt(SW_PIN_VERIFICATION_REQUIRED);
          byte[] buffer = apdu.getBuffer();
          byte numBytes = (byte)(buffer[ISO7816.OFFSET_LC]);
     byte byteRead = (byte)(apdu.setIncomingAndReceive());
          if (( numBytes != 1 ) || (byteRead != 1))
               ISOException.throwIt(ISO7816.SW_WRONG_LENGTH);
     byte debitAmount = buffer[ISO7816.OFFSET_CDATA];
          if (( debitAmount > MAX_TRANSACTION_AMOUNT)
                    ||  ( debitAmount < 0 ))
               ISOException.throwIt(SW_INVALID_TRANSACTION_AMOUNT);
          if ((short)( balance - debitAmount ) < (short)0)
               ISOException.throwIt(SW_NEGATIVE_BALANCE);
          balance = (short) (balance - debitAmount);
     }      private void getBalance(APDU apdu) {
          byte[] buffer = apdu.getBuffer();
          short le = apdu.setOutgoing();
          apdu.setOutgoingLength((byte)2);
     Util.setShort(buffer, (short)0, balance);
          apdu.sendBytes((short)0, (short)2);
      * verification method to verify the PIN
     private void verify(APDU apdu) {
          byte[] buffer = apdu.getBuffer();
          byte byteRead = (byte)(apdu.setIncomingAndReceive());
          if (pin.check(buffer, ISO7816.OFFSET_CDATA,byteRead)
                    == false)
               ISOException.throwIt(SW_VERIFICATION_FAILED);
     } // end of verify method
} // end of class Account

Similar Messages

  • I have a new Apple TV which is working fine except that I cannot access .mov files which are in my iTunes Library. How can I get to these? I can run them on my computer and select Apple TV on the screen, but the Apple TV goes to a black screen

    I have a new Apple TV which is working fine except that I cannot access .mov files which are in my iTunes Library. How can I get to these? I can run them on my computer and select Apple TV on the screen, but the Apple TV goes to a black screen

    Mov is a container format, you'd need to look at the codec used by the movie file inside the container to know whether it will work with the Apple TV or not.

  • I'm using Mac with OS 10.9.4 and Photoshop CC. I am unable to access "Focus Area Selection". When I go to "Select" on menu its simply not there in the drop down menu. Any help?

    How do I access "Focus Area Selection" in Photoshop CC on a Mac? It's not showing in the "Select" drop-down menu.

    Select > Focus area is in Photoshop CC 2014, not Photoshop CC.  So you must download and install CC 2014 to have access to this new feature.

  • I can access a website and select the 'print' option but the print misses out

    I can access a website and select the 'print' option but the print misses out photos that should be included in the print. It happens on more than one website. If I use Explorer it doesn't happen. I guess there must be a setting or something that I have not found? Any help very gratefully received. Than you.

    I don't know if this will help, but I found it by accident. When I send Word projects to recipients, it doesn't always read properly depending on their format. If they have a PC It distortes my  program, or they may have newer versions of Word. If you have your document showing select 'print' and on my print menu at the bottom left corner it has a button that says 'PDF'. Click on that and it gives you several options for a PDF. What I do if I'm emailing to someone is select the email option then you can always print from the email. Hope that helps.
    jr

  • Access Web Database - Select record and make report with all associated records

    Hey everyone,
    Right now I'm in the middle of trying to convert an Access client database to be web compatible and I'm running into some problems. For this question, I think I may need to explain a little bit about the database:
    The database I'm making is designed to store information about music rights for different songs. The users can input information about writers, producers, organizations, properties, businesses - which is stored all in different related tables. Then, when a
    user inputs a song, they choose which writers, produces, organizations, etc. are affiliated with that song. 
    What I'm trying to do is make a report where you can choose a writer from the list of all the writers and then produce a report with all of the songs by that writer. 
    I was able to do this in the Access client by making a report that, when opened would trigger (using the On Open event) a form to open where you would choose a writer from a combo box and then click a button. When the button was clicked, it would use the value
    in the combo box in a query, which would find all of the songs by that writer and then open up the report which would have the writer and all of their songs on it. 
    Because web reports don't have many event options and web queries are very limited, I have not found a way to make this report.
    Any help at all would be greatly appreciated!

    Hi,
    I found that you've cross post the quesion on our Answer forum, are you satisfiled the reply from there?
    http://answers.microsoft.com/en-us/office/forum/office_2010-access/web-database-select-record-and-make-report-with/04ce4e25-a964-4146-9a34-f9cb26bb0496
    Regards,
    George Zhao
    TechNet Community Support

  • Can oracle audit logs keep info of Blocking or blacklisting a user ID, terminal or access port, and the reason for the action?

    Hello,
    I am workin on Oracle 11G STIGs and one STIGs states that audit log should include followings;
    - User ID.
    - Successful and unsuccessful attempts to access security files
    - Date and time of the event.
    - Type of event.
    - Success or failure of event.
    - Successful and unsuccessful logons.
    - Denial of access resulting from excessive number of logon attempts.
    - Blocking or blacklisting a user ID, terminal or access port, and the reason for the action.
    - Activities that might modify, bypass, or negate safeguards controlled by the system.
    I know how to enable audit trial with OS or DB, EXTENDED levels.  However, I could not find if it is possible that audit logs can contain info of Blocking or blacklisting a user ID, terminal or access port, and the reason for the action.

    2687254 wrote:
    Hello,
    I am workin on Oracle 11G STIGs and one STIGs states that audit log should include followings;
    - User ID.
    - Successful and unsuccessful attempts to access security files
    - Date and time of the event.
    - Type of event.
    - Success or failure of event.
    - Successful and unsuccessful logons.
    - Denial of access resulting from excessive number of logon attempts.
    - Blocking or blacklisting a user ID, terminal or access port, and the reason for the action.
    - Activities that might modify, bypass, or negate safeguards controlled by the system.
    I know how to enable audit trial with OS or DB, EXTENDED levels.  However, I could not find if it is possible that audit logs can contain info of Blocking or blacklisting a user ID, terminal or access port, and the reason for the action.
    Think about that.  If the port or terminal (client ip address) is blocked, then the communication never got to the database.  So how would the database be able to audit an action that never got there?

  • I accidentally selected "do note allow" Pages access to my photos. Now I can't insert photos. Message says go to settings and select Privacy - but there is no such option in the Settings. Help!

    I accidentally selected "do note allow" Pages access to my photos. Now I can't insert photos. Message says go to settings and select Privacy - but there is no such option in the Settings. Help! I want to be able to insert images in documents I create in the Pages app.

    Ok - I figured it out myself as soon as I posted this question. I went to my IPad settings - not the Settings in the Pages app. Problem fixed.

  • Apps do not have access to camera,microphone, anything. Went to settings and selected the app but the option to allow access to these things aren't there.

    Apps do not have access to camera,microphone, anything. Went to settings and selected the app but the option to allow access to these things aren't there.

    Did you go to Settings/Privacy and check the apps listed?

  • My finder keeps asking for my password when i try to delete things. and when i do enter in my password nothing is deleted. i tried going into terminal and typing in su, but it wouldnt let me type my password

    .

    Never empty the Trash in the shell (Terminal.)
    1. Triple-click the line below to select it:
    ~/.Trash
    2. Right-click or control-click the highlighted line and select
    Services ▹ Show Info
    from the contextual menu.* An Info dialog should open.
    3. The dialog should show "You can read and write" in the Sharing & Permissions section. If that's not what it shows, click the padlock icon in the lower right corner of the window and enter your password when prompted. Use the plus- and minus-sign buttons to give yourself Read & Write access and "everyone" No Access. Delete any other entries in the access list.
    4. In the General section, uncheck the box marked Locked if it's checked.
    5. From the action menu (gear icon) at the bottom of the dialog, select Apply to enclosed items and confirm.
    6. Close the Info window and test.
    *If you don't see the contextual menu item, copy the selected text to the Clipboard (command-C). Open a TextEdit window and paste into it (command-V). Select the line you just pasted and continue as above.

  • Can't reset password for admin, can't access admin and my home folder is missing?

    I am having huge issues! This morning everything was fine, then I took my computer to school and it had reset to default condition and says my home folder is inaccessible.
    I've tried multiple ways of resetting password in terminal, to no avail
    Gained access to the computer via standard user - but still no way of clicking or doing anything to my admin account.
    I'm running osx 10.7.5
    Please help :-(

    When you say you have tried multiple ways to reset the admin password, have you tried restarting while holding the Command and R keys, then when it has booted to the recovery HD partition, you should get a drop down of utility acctions, one of which is to open Terminal.  Open Terminal, and after the cursor type:
    resetpassword
    and press Return.
    You then should get a window to select the user, admin in this case, and you then enter the new password twice, do not enter a hint, click Reset and get a window that says Login Password Reset - click OK

  • Newbie Q about terminal and telnet

    Not sure this is the right forum but I posted on the osx server threads with no reply so here goes.
    Q. turning off the wan side telnet port on my router using telnet via the terminal.?
    I've seen instructions some where about how to use telnet to turn off sip in a router re getting ichat to work. Can I close or stealth my telnet port in a similar way. also ping and ftp and 80 are open not stealth. (re shields up site.)
    I'm used to seeing no real traffic over my old & possibly dead router unless I initiate it. I've just got the echolife hg520s over which their is continual if minor traffic and it bugs me.
    Btw... in the firmwares http gui I've disabled the cwmp option and selected all wan side options as disabled including ping and telnet.??
    Thanks

    This is very strange. Being the paranoid kind of guy that I am, whenever I go on business travel, I run nmap against my home network (I'd do it more frequently from the office, but my employer's IT Secret Police blocks almost all outgoing destination ports), and this last trip (last week) I found telnet 23, http 80, LM Social Server 1111 (what the heck is that?) and 52869 open. In Terminal, I typed telnet {myHomeDomainName} and got a login prompt to my modem! Previous nmap about one month prior all was ok. I freaked out.
    Once back home, I could not close the ports, even though the modem's configuration page said that the only port forwarded was my ssh port (as desired) and that remote management was disabled. I hard reset the router, I reinstalled the firmware from the critical recovery disk image, and I reinstalled the firmware update -- multiple times. That would close 'em off, for about an hour or two. I was on the phone with my ISP (Qwest) about three or more times for about 45 mins per call, and then, mysteriously, the ports have closed with no interaction on my part and have remained closed thus far for two days now. (It just so happens we have a WAP at work for visitors, puts 'em outside our really restrictive firewall, but when there, you can't access anything inside the corporate LAN when you do that, but I affiliated to that WAP anyways so I could run nmap this afternoon during lunch.) So I'm wondering whether my ISP's Secret Police have a backdoor programmed into their firmware set for the DSL modems that they sell, but they shut it down (at least temporarily) since I caught 'em, well, caught somebody, with my ports open?
    Check your firewall logs for unusual activity: in Terminal, as admin-privileged user, type
    +sudo cat /var/log/ipfw.log+
    if unusual probes or activity, get on the phone with your ISP, ask why your modem config pages say your firewall is on and no ports are forwrded but telnet's open, and if you have unusual acitivity in those logs, ask 'em to start an investigation.

  • Exchanging APDU's with selected applet fails

    Hi all,
    1. I developed a cardlet( normal, sample one) using JCOP
    2. Installed, selected and excanged APDU's with this applet ( on Nokia 6212,6131 and JCOP cards)
    3. Now i tried it on a SE of SIM. In this case, installation and selection succeeds but exchanging APDU's with selected applet is partial. by 'partial' what i mean is:
    i am using 0x90 as CLA byte for personalisation (now i am not checking the CLA byte from cardelt code)
    private static final byte STORE=0x01;
    private static final byte GET=0x02; , and these are INS values for getting and storing personalisation data.
    if i send STORE command like */send 90010000084142434445464748* (8 data bytes ), only first 5 bytes are being transferred to applet (i tested this fact by returning the buffer(apdu.getBuffer()) length from process(APDU apdu) function ), not the actual data. ie, only CLA, INS, P1, P2, and LC fields are being transferred to applet. so, currently the actual personlisation data is not been transferred to selected applet.
    Is there any specific data format that has to be send to a selected applet ?
    or
    In which point i am going wrong ?
    This is the cardlet code i'm using
    import javacard.framework.APDU;
    import javacard.framework.ISO7816;
    import javacard.framework.Applet;
    import javacard.framework.ISOException;
    import javacard.framework.Util;
    public class TestCard extends Applet
        private static final byte STORE=0x01;
        private static final byte GET=0x02;
        private static byte personalized=0x00;
        private static byte[] value=null;
       // private static byte testByte;
        public static void install(byte[] bArray, short bOffset, byte bLength)
            // GP-compliant JavaCard applet registration
            new TestCard().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
        public void process(APDU apdu)
            // Good practice: Return 9000 on SELECT
            if (selectingApplet())
                return;
            byte[] buf = apdu.getBuffer();
            switch (buf[ISO7816.OFFSET_INS])
                case STORE:
                    value=new byte[buf[ISO7816.OFFSET_LC]];
                    //testByte=(byte)buf.length;
                    Util.arrayCopy(buf, (short)(ISO7816.OFFSET_LC+1), value, (short)0, buf[ISO7816.OFFSET_LC]);
                    personalized=(byte)0x01;
                    break;
                case GET:
                    if(personalized==0x00)
                        ISOException.throwIt((short)0x6999);
                        break;
                    //value=new byte[]{testByte};
                    apdu.setOutgoing();
                    apdu.setOutgoingLength((short)value.length);
                    apdu.sendBytesLong(value, (short)0, (short)value.length);
                    break;
                default:
                    // good practice: If you don't know the INStruction, say so:
                    ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
    }and this is the JCOP script i'm using
    /echo Opening terminal
    /terminal "winscard:4|OMNIKEY CardMan 5x21-CL 0"
    /echo Resets card
    /atr
    /echo Selecting TestCard Applet
    /select 11223344556600
    /echo Sending 8-byte Personalisation data ABCDEFGH (4142434445464748)
    /send 90010000084142434445464748
    /echo Reading personalised data
    /send 90020000and the output trace is
    /echo Opening terminal
    Opening terminal
    /terminal "winscard:4|OMNIKEY CardMan 5x21-CL 0"
    --Opening terminal
    /echo Resets card
    Resets card
    /atr
    --Waiting for card...
    ATR=3B 88 80 01 01 02 03 04 00 81 C0 00 4C             ;...........L
    /echo Selecting TestCard Applet
    Selecting TestCard Applet
    /select 11223344556600
    => 00 A4 04 00 07 11 22 33 44 55 66 00 00             ......"3DUf..
    (84234 usec)
    <= 90 00                                              ..
    Status: No Error
    /echo Sending 8-byte Personalisation data ABCDEFGH (4142434445464748)
    Sending 8-byte Personalisation data ABCDEFGH (4142434445464748)
    /send 90010000084142434445464748
    => 90 01 00 00 08 41 42 43 44 45 46 47 48             .....ABCDEFGH
    (168449 usec)
    <= 90 00                                              ..
    Status: No Error
    /echo Reading personalised data
    Reading personalised data
    /send 90020000
    => 90 02 00 00                                        ....
    (22838 usec)
    <= 00 00 00 00 00 00 00 00 90 00                      ."3DUf.... // here not getting the actual needed data.
    Status: No ErrorThanks and regards
    Sunil

    Hi all,
    after lot of trial and error and research, i found that in the above code, i am not using
    apdu.setIncomingAndReceive();this is where the problem lies. i set incoming mode after reading the apdu buffer and the problem solved.
    thanks and regards
    sunil

  • How do i change my terminal and text edit privileges

    How do i change my privileges in terminal and text edit?
    Every time i try to drag something from text edit to terminal it says this;  "The file “server.command” could not be executed because you do not have appropriate access privileges.To view or change access privileges, select the file in the Finder and choose File > Get Info''
    and when i go to "Get Info" it says read&write is on!?
    Can somebody help me please??

    Hi Taysia_b,
    The convention that I have always used was to copy (Command-C) from the editor, and paste (Command-V) in the terminal and it has worked for me thus far.
    Found keyboard commands faster to work with, than trackpad stuff.
    Have fun
    Leo

  • Can't Find ODBC drivers to link MS Access 2013 and MySQL

    Can't Find ODBC drivers to link MS Access 2013 and MySQL.
    Is one available?
    Thanks,
    Larry

    Could to associate the problem at Office 2013?
    I just installed the ODBC Driver; The data source machine was available; When selected I had received the message. When it was selected I had received the message:
    "ODBC -- falha na chamada.
    [Microsoft][ODBC Driver Manager] O DSN especificado contém uma incompatibilidade de arquiteturas entre o Driver e o Aplicativo (#0)"
    In english, could to say: "ODBC -- fail on call.
    ... The specified DSN contains a architectural incompatibility between Driver and App (#0)"
    I don't know yet the reason for this. Anyone knows?

  • Access 2013 and SharePoint Foundation/Server 2010

    I have a real simple scenario that keeps happening.
    I simple click external data -> More -> SharePoint List from Access 2013 and point it to a SharePonint 2010 list ... then link the list.  It will link and show the data.  Once...  After closing the access file, it just freezes when opening
    it again.
    I've tried this on several windows clients (win7 and 8) and 2 different SharePoint 2010 installs (1 being Foundation, the other being Server).  Both are service packed.
    Any ideas?

    I believe i too am running into this issue.
    I have a CRM application i created in Access 2010 which links to lists on Sharepoint Foundation 2010 (As bundled with Small Business Server 2010) using SSL. I have this application running on various client machines, some on the local network and some via
    the internet. Until now we have been entirely Access 2010 and whenever a new client was required i just copied over the Access front end and it just worked.
    We have a new PC which has Win7 Pro 64bit and Office 2013 Pro. I copied over the front end but when i try and open one of the linked sharepoint lists Access just hangs with the spining circle. I have no problem accessing these lists on SP via Internet Explorer
    and furthermore if i select "Open with Access" and link a list it then opens within Access 2013 OK, (although Windows Security does prompt for the users password). However, if i save this database and re-open it i can no longer open the list!!
    I have noticed that if i run Access 2013 as administrator and open the front end application then there is no problem.
    Possible permissions issue???
    If i repeat what Eric describes, Access 2013 shows me all the lists on out SP site and successfully links it (i.e. It appears under Tables) however, unlike Eric the list won't open (not even once).

Maybe you are looking for

  • Billing doc external number range

    Hi Guys, As per my knowledge billing doc uses only Internal number range but when i check table: TVFK i can see No. range external maintained (XX) same maintained my company where shall i config this please give me idea and steps. Regards JACK

  • What's going on? Lots of problems!

    Hi there, I'm having a few different problems that seem to have happened all at the same time. They are all very annoying. Firstly, I have a 1gHz eMac, 768MB RAM, MacOS 10.2.8 My first problem is that Adobe Photoshop Elements 2.0 will no longer open.

  • Iphone 4 icon not showing up in itunes display

    When i plug my iphone into my USB the chim sound rings and Itune loads but the Iphone icon is not displayed and I can't do any updates or sync my phone due to the missing icon in itunes. I don't understand how the icon randomly disappears. I've never

  • Parts of an audio slider

    this is probably easier than i'm making it, but i'm not sure what my code needs to be for the previous button. i'm thinking i'll be able to use the next button script and just edit it a little. if someone could please look at this script and let me k

  • Video shooting in N-93

    Guys ! Those of you who own N-93 with firmware version 20.0.058 check this out ! When you do a video shooting in the night where kigting conditions is less than ideal you will notice video getting recorded in B/W instead of colour Again if you shoot