org.simalliance.openmobileapi
Interface Channel


public interface Channel

Instances of this class represent an ISO7816-4 channel opened to a secure element. It can be either a logical channel or the default channel. They can be used to send APDUs to the secure element. Channels are opened by calling the Session.openBasicChannel(byte[]) or Session.openLogicalChannel(byte[]) methods.


Method Summary
 void close()
          Closes this channel to the secure element.
 Session getSession()
          Get the session that has opened this channel.
 boolean isBasicChannel()
          Returns a boolean telling if this channel is the basic channel.
 boolean isClosed()
          Tells if this channel is closed.
 byte[] transmit(byte[] command)
          Transmit an APDU command (as per ISO7816-4) to the secure element.
 

Method Detail

close

void close()
Closes this channel to the secure element. If the method is called when the channel is already closed, this method will be ignored. The close() method shall wait for completion of any pending transmit(byte[] command) before closing the channel.


isBasicChannel

boolean isBasicChannel()
Returns a boolean telling if this channel is the basic channel.

Returns:
true if this channel is a basic channel. false if this channel is a logical channel.

isClosed

boolean isClosed()
Tells if this channel is closed.

Returns:
true if the channel is closed.

getSession

Session getSession()
Get the session that has opened this channel.

Returns:
the session object this channel is bound to.

transmit

byte[] transmit(byte[] command)
                throws IOException,
                       IllegalStateException,
                       IllegalArgumentException,
                       SecurityException
Transmit an APDU command (as per ISO7816-4) to the secure element. The underlying layers generate as many TPDUs as necessary to transport this APDU. The transport part is invisible from the application. The generated response is the response of the APDU. The system ensures the synchronization between all the concurrent calls to this method, and that only one APDU will be sent at a time, irrespective of the number of TPDUs that might be required to transport it to the SE. The entire APDU communication to this SE is locked to the APDU. The channel information in the class byte in the APDU will be ignored. The system will add any required information to ensure the APDU is transported on this channel. There are restrictions on the set of commands that can be sent: - MANAGE_CHANNEL commands are not allowed. - SELECT by DF Name (p1=04) are not allowed - CLA bytes with channel numbers are de-masked

Parameters:
command - the APDU command to be transmitted, as a byte array
Returns:
the response received, as a byte array
Throws:
IOException - if there is a communication problem to the reader or the secure element
IllegalStateException - if the channel is used after being closed
IllegalArgumentException - if the command byte array is less than 4 bytes long or if the length of the APDU is not coherent with the length of the command byte array
SecurityException - if the command is filtered by the security policy

Copyright © 2010-2011 Inside Secure
Except as noted, this content is licensed under Apache 2.0 License.