Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.sun.javacard.apduio
Class T1Block

    java.lang.Object
      com.sun.javacard.apduio.T1Block

    public class T1Block

extends java.lang.Object

The T1Block class implemenys a Java representation of the T=1 transport protocol for APDU, as defined in the ISO 7816-3 specifications. T=1 messages have the following block format: +-----+-----+-----+-------------+-----+ | NAD | PCB | LEN | ... INF ... | LRC | +-----+-----+-----+-------------+-----+ The NAD, PCB, LEN and LRC fields are one byte in length each. The INF field, if existent, is LEN bytes in length. There are three types of blocks: - Information blocks (I-blocks) which carry data. - Receive blocks (R-blocks) which convey acknowledgements. - Supervisory block (S-blocks) used for control purposes. The NAD byte is encoded as follows: 7 6 5 4 3 2 1 0 +---+-----------+---+-----------+ | R | S A D | R | D A D | +---+-----------+---+-----------+ where: SAD is "Source Address" DAD is "Destination Address" "R" is "Reserved for Future Use" In our reference case, the terminal is identified by 1, whereas the card is identified by 2. The PCB field for an I-block is encoded as follows: 7 6 5 4 3 2 1 0 +---+-----------+---+-----------+ | 0 | S | M | R F U | +---+-----------+---+-----------+ where: S is the sequence bit N(S) M is the chanining bit, where "1" means chained block, "0" means last block in chain. The PCB field for an R-block is encoded as follows: 7 6 5 4 3 2 1 0 +---+-----------+---+-----------+ | 1 0 | E r r o r C o d e | +---+-----------+---+-----------+ where: Error code of 0-N(R)-0000 means error free acknowledgement. Error code of 0-N(R)-0001 means character parity error. Error code of 0-N(R)-0010 means other errors. The PCB field for an S-block is encoded as follows: 7 6 5 4 3 2 1 0 +---+-----------+---+-----------+ | 1 1 | O p C o d e | +---+-----------+---+-----------+ where: 000000 means RESYNC. 000001 means IFS request and 100001 means IFS response. 000010 means ABORT request and 100010 means ABORT response. 000011 means WTX request and 100011 means WTX response. The LEN field conveys the information length. '00' means INF field not present; '01' to 'FE' is the length of the INF field; 'FF' is RFU. INF carries information. When present, INF in an I-block carries application information. INF is absent from R-blocks; and INF conveys control information on S-blocks performing a IFS or WTX commands, absent otherwise. LRC is the longitudinal redundancy check for the entire block. When computed across all fields from NAD to LRC inclusive by xor-ing all bytes, it shall yield '00' as a result.

Field Summary
`static byte` | `NULL_ADDRESS` Null adrress value
`static byte` | `S_ABORT_REQ` S_ABORT_REQ = 11000010
`static byte` | `S_ABORT_RES` S_ABORT_REQ = 11100010
`static byte` | `S_IFS_REQ` S_IFS_REQ = 11000001
`static byte` | `S_IFS_RES` S_IFS_REQ = 11100001
`static byte` | `S_RESYNC_REQ` S_RESYNC_REQ = 11000000
`static byte` | `S_RESYNC_RES` S_RESYNC_REQ = 11100000
`static byte` | `S_WTX_REQ` S_WTX_REQ = 11000011
`static byte` | `S_WTX_RES` S_WTX_REQ = 11100011

Constructor Summary
`T1Block()` Main constructor.

Method Summary
`boolean` | `checkBlock()` Verifies the consistency of this T=1 Block by calculating the LRC.
`static boolean` | `checkBlock(T1Block theBlock)` Verifies the consistency of the T=1 Block by calculating the LRC.
`byte` | `getBlockType()` Returns the T=1 Block type.
`byte[]` | `getINFBytes()` Returns the T=1 Block INF bytes.
`int` | `getIntINF()` Returns the T=1 Block INF first byte.
`int` | `getLEN()` Returns the T=1 Block LEN field
`byte` | `getSBlockType()` Returns the control parameter type for this S-Block.
`boolean` | `getSequence()` Returns the sequence flag for this I-Block or R-Block.
`boolean` | `isLastBlock()` Returns the last block flag for this I-Block.
`static T1Block` | `readBlock(byte[] buffer, int offset, int len)` Reads T=1 block information from the specified buffer and reconstructs a T1Block object from it.
`void` | `readBlockInstance(byte[] buffer, int offset, int len)` Reads T=1 block information from the specified buffer and reconstructs it in this block.
`void` | `setIBlock(byte src, byte dst, boolean seqFlag, boolean chainingFlag, byte[] infoData, int infoSize)` Sets this T1Block object as an I-Block with the parameters specified.
`void` | `setIBlock(byte src, byte dst, boolean seqFlag, boolean chainingFlag, byte[] infoData, int infoOffset, int infoSize)` Sets this T1Block object as an I-Block with the parameters specified.
`void` | `setRBlock(byte src, byte dst, boolean seqFlag)` Sets this T1Block object as an R-Block with the parameters specified.
`void` | `setSBlock(byte src, byte dst, int ctrlType, int infData)` Sets this T1Block object as an S-Block with the parameters specified.
`byte[]` | `toByteArray()` Transfers the current T=1 Block into a byte array representation.
`java.lang.String` | `toString()` Returns a string representation of this I-Block object for debugging and tracing purposes.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Field Detail

### NULL_ADDRESS

    public static final byte NULL_ADDRESS

  Null adrress value

  See Also:
    Constant Field Values

### S_RESYNC_REQ

    public static final byte S_RESYNC_REQ

  S_RESYNC_REQ = 11000000

  See Also:
    Constant Field Values

### S_RESYNC_RES

    public static final byte S_RESYNC_RES

  S_RESYNC_REQ = 11100000

  See Also:
    Constant Field Values

### S_IFS_REQ

    public static final byte S_IFS_REQ

  S_IFS_REQ = 11000001

  See Also:
    Constant Field Values

### S_IFS_RES

    public static final byte S_IFS_RES

  S_IFS_REQ = 11100001

  See Also:
    Constant Field Values

### S_ABORT_REQ

    public static final byte S_ABORT_REQ

  S_ABORT_REQ = 11000010

  See Also:
    Constant Field Values

### S_ABORT_RES

    public static final byte S_ABORT_RES

  S_ABORT_REQ = 11100010

  See Also:
    Constant Field Values

### S_WTX_REQ

    public static final byte S_WTX_REQ

  S_WTX_REQ = 11000011

  See Also:
    Constant Field Values

### S_WTX_RES

    public static final byte S_WTX_RES

  S_WTX_REQ = 11100011

  See Also:
    Constant Field Values

Constructor Detail

### T1Block

    public T1Block()

  Main constructor.

Method Detail

### setIBlock

    public void setIBlock(byte src,
                          byte dst,
                          boolean seqFlag,
                          boolean chainingFlag,
                          byte[] infoData,
                          int infoSize)
                   throws T1Exception

  Sets this T1Block object as an I-Block with the parameters specified. This version assumes data at offset 0.

  Parameters:
    `src` - Source address.
    `dst` - Destination address.
    `seqFlag` - Sequence flag.
    `chainingFlag` - chaining flag.
    `infoData` - Byte array containing I-Block data.
    `infoSize` - Size in bytes of data to copy.
  Throws:
    `T1Exception` - if a T=1 protocol inconsistency occurs.

### setIBlock

    public void setIBlock(byte src,
                          byte dst,
                          boolean seqFlag,
                          boolean chainingFlag,
                          byte[] infoData,
                          int infoOffset,
                          int infoSize)
                   throws T1Exception

  Sets this T1Block object as an I-Block with the parameters specified.

  Parameters:
    `src` - Source address.
    `dst` - Destination address.
    `seqFlag` - Sequence flag.
    `chainingFlag` - chaining flag.
    `infoData` - Byte array containing I-Block data.
    `infoSize` - Size in bytes of data to copy.
    `infoOffset` - Offset of data to copy from byte array.
  Throws:
    `T1Exception` - if a T=1 protocol inconsistency occurs.

### setRBlock

    public void setRBlock(byte src,
                          byte dst,
                          boolean seqFlag)
                   throws T1Exception

  Sets this T1Block object as an R-Block with the parameters specified.

  Parameters:
    `src` - Source address.
    `dst` - Destination address.
    `seqFlag` - Sequence flag.
  Throws:
    `T1Exception` - if a T=1 protocol inconsistency occurs.

### setSBlock

    public void setSBlock(byte src,
                          byte dst,
                          int ctrlType,
                          int infData)
                   throws T1Exception

  Sets this T1Block object as an S-Block with the parameters specified.

  Parameters:
    `src` - Source address.
    `dst` - Destination address.
    `ctrlType` - S-Block control parameter.
    `infData` - Optional INF field data for S-Block, conly LSB is considered.
  Throws:
    `T1Exception` - if a T=1 protocol inconsistency occurs.

### toByteArray

    public byte[] toByteArray()

  Transfers the current T=1 Block into a byte array representation.

  Returns:
    byte array representing the binary contents of the Block as it is transmitted.

### readBlock

    public static T1Block readBlock(byte[] buffer,
                                    int offset,
                                    int len)
                             throws T1Exception

  Reads T=1 block information from the specified buffer and reconstructs a T1Block object from it.

  Parameters:
    `buffer` - Buffer containing block information.
    `offset` - Offset inside the buffer containing block information.
    `len` - Length inside the buffer with the block information.
  Throws:
    `T1Exception` - if an error in the data is found.

### readBlockInstance

    public void readBlockInstance(byte[] buffer,
                                  int offset,
                                  int len)
                           throws T1Exception

  Reads T=1 block information from the specified buffer and reconstructs it in this block.

  Parameters:
    `buffer` - Buffer containing block information.
    `offset` - Offset inside the buffer containing block information.
    `len` - Length inside the buffer with the block information.
  Throws:
    `T1Exception` - if an error in the data is found.

### checkBlock

    public boolean checkBlock()

  Verifies the consistency of this T=1 Block by calculating the LRC. Static version.

  Returns:
    true if block is consistent,
    false otherwise.

### checkBlock

    public static boolean checkBlock(T1Block theBlock)

  Verifies the consistency of the T=1 Block by calculating the LRC. Static version.

  Parameters:
    `theBlock` - Block to check.
  Returns:
    true if block is consistent,
    false otherwise.

### getBlockType

    public byte getBlockType()

  Returns the T=1 Block type.

  Returns:
    byte array containing the T=1 block type in PCB field.

### getINFBytes

    public byte[] getINFBytes()

  Returns the T=1 Block INF bytes.

  Returns:
    byte array containing the INF field bytes.

### getIntINF

    public int getIntINF()

  Returns the T=1 Block INF first byte.

  Returns:
    byte containing the INF[0] byte.

### getLEN

    public int getLEN()

  Returns the T=1 Block LEN field

  Returns:
    byte containing the LEN field.

### isLastBlock

    public boolean isLastBlock()

  Returns the last block flag for this I-Block.

  Returns:
    byte containing the last block flag.

### getSequence

    public boolean getSequence()

  Returns the sequence flag for this I-Block or R-Block.

  Returns:
    byte containing the block sequence flag.

### getSBlockType

    public byte getSBlockType()

  Returns the control parameter type for this S-Block.

  Returns:
    byte containing the S-Block control parameter.

### toString

    public java.lang.String toString()

  Returns a string representation of this I-Block object for debugging and tracing purposes. Uses ISO 7816-3 notation.

  Overrides:
    `toString` in class `java.lang.Object`
  Returns:
    String holding protocol data about this block.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright (c) 2009 Sun Microsystems, Inc. All rights reserved.