diff --git a/src/uicc/connection/ConnectionException.java b/src/uicc/connection/ConnectionException.java index ff2d5b6c12a5b2f9532a98aeed61887f5d945d9c..6739944981dea3b3942b264111d500260bf2f1dc 100644 --- a/src/uicc/connection/ConnectionException.java +++ b/src/uicc/connection/ConnectionException.java @@ -47,6 +47,9 @@ public class ConnectionException extends CardRuntimeException /** Reason code to indicate that invalid header fields set by application */ public final static short INVALID_HEADER_FIELD = (short) 12; + + /** Reason code to indicate that no SCP82 key could be found to establish the DTLS session: 13 */ + public final static short SCP82_KEY_NOT_FOUND = (short) 13; /** * Construct a ConnectionException instance with the specified reason. To diff --git a/src/uicc/connection/ConnectionServer.java b/src/uicc/connection/ConnectionServer.java index ff6ee792a43ca066ff8969dc2d645574cf5bfda7..2c9803d4519350a2a565c7cd21c71bd58303b38d 100644 --- a/src/uicc/connection/ConnectionServer.java +++ b/src/uicc/connection/ConnectionServer.java @@ -122,6 +122,7 @@ public class ConnectionServer * Returns an instance providing an SCP81 connection. * The returned object is a Permanent Entry Point Object. * + * @deprecated * @param oObserver the Observer to be used for notifications about state changes * @return a SCP81Connection instance. * @throws ConnectionException with the following reason code: @@ -130,7 +131,24 @@ public class ConnectionServer * * @throws NullPointerException ifoObserver is equal to null */ - public static SCP81Connection createSCP81Connection(Observer oOserver) throws NullPointerException,ConnectionException + public static SCP81Connection createSCP81Connection(Observer oObserver) throws NullPointerException,ConnectionException + { + return null; + } + + /** + * Returns an instance providing an SCP8X connection. + * The returned object is a Permanent Entry Point Object. + * + * @param oObserver the Observer to be used for notifications about state changes + * @return a SCP8XConnection instance. + * @throws ConnectionException with the following reason code: + * + * @throws NullPointerException ifoObserver is equal to null + */ + public static SCP8XConnection createSCP8XConnection(Observer oObserver) throws NullPointerException,ConnectionException { return null; } diff --git a/src/uicc/connection/DataReceived.java b/src/uicc/connection/DataReceived.java index 3f30a5b0140730c01c7f72dd403e5f11f7c631be..e5b12eb171a6165fef12e461bd4b07ab89136dbe 100644 --- a/src/uicc/connection/DataReceived.java +++ b/src/uicc/connection/DataReceived.java @@ -13,12 +13,14 @@ public interface DataReceived extends Event /** * Returns the amount of data received, or -1 if data length is unknown (chunked transfer encoding is used), * or 0 if all received data have been read or discarded by the Observer. + * + * @return data length received or 0 if all data have been received or -1 if data length is unknown */ public int getReceivedDataLength(); /** * Copy the received data in a buffer. Data are handled as a stream, and are received upon applet request. - * It is not possible to move backward in the data by using the srcOffset>/code> parameter. + * It is not possible to move backward in the data by using the srcOffset parameter. * This is a non-blocking methid. * * @param srcOffset the offset of the first byte to copy in the received data diff --git a/src/uicc/connection/SCP81Connection.java b/src/uicc/connection/SCP81Connection.java index f0ee9c8e209c85947c2219e87a64fce72c7176da..cc431698ea78b289876aa94210c92ae868ba9b8e 100644 --- a/src/uicc/connection/SCP81Connection.java +++ b/src/uicc/connection/SCP81Connection.java @@ -7,8 +7,11 @@ package uicc.connection; * * Objects implementing SCP81Connectioninterface and returned by the * ConnectionServer.getConnection method are Permanent Entry Point Objects. + * + * @deprecated This interface is obsolete use SCP8XConnection instead * */ +@Deprecated public interface SCP81Connection extends Observable { /** * Request to open the SCP81 connection. @@ -19,12 +22,11 @@ public interface SCP81Connection extends Observable { * * Note: * - *

* * @param triggeringParameters this buffer contains the administration session triggering parameters * as defined in table 4-3 of Amendment B of Global Platform Card Specification version 2.2. Tag '81' and diff --git a/src/uicc/connection/SCP81ConnectionStatus.java b/src/uicc/connection/SCP81ConnectionStatus.java index 71aec2fb6ec74d17b6f512cf545994cf12132d4d..d659f5ac1af95077dc2f6ffc4f8f200676e1f84e 100644 --- a/src/uicc/connection/SCP81ConnectionStatus.java +++ b/src/uicc/connection/SCP81ConnectionStatus.java @@ -9,8 +9,10 @@ package uicc.connection; * communication error (corresponds to unexpected communication breakdown) * server switch to other application (corresponds to server selecting another application via Content-Type header field) * The object implementing SCP81ConnectionStatus interface is a Temporary Entry Point Object. + * + * * @deprecated This interface is obsolete use SCP8XConnectionStatus instead */ - +@Deprecated public interface SCP81ConnectionStatus extends Event { /** This constant is used if the connection was successfully opened.. */ diff --git a/src/uicc/connection/SCP8XConnection.java b/src/uicc/connection/SCP8XConnection.java new file mode 100644 index 0000000000000000000000000000000000000000..fa65086f9b8e66a8acd7408936d22ce2fe77afaf --- /dev/null +++ b/src/uicc/connection/SCP8XConnection.java @@ -0,0 +1,118 @@ + +package uicc.connection; + +/** + * The SCP8XConnection interface represents an SCP81 or SCP82 connection to + * a remote entity. + * + * Objects implementing SCP8XConnectioninterface and returned by the + * ConnectionServer.getConnection method are Permanent Entry Point Objects. + * + * + */ +public interface SCP8XConnection extends Observable { + /** + * Request to open the SCP81 or SCP82 connection. + *

+ * The associated (directly or indirectly) Security Domain of the calling application will handle the PSK TLS or DTLS security of the communication. + *

+ * The calling application will be notified once the connection is opened or once the setup failed. This method is non-blocking. + * + * Note: + *

+ * + * @param triggeringParameters this buffer contains the administration session triggering parameters + * as defined in table 3-3 of Amendment B [5] of Global Platform Card Specification version 2.3, + * with the appropriate adaptations described in Table 3-6 of Amendment M [8] for the SCP82 case Tag '81' and + * Length shall be present. Connection parameters defined in Tag '84' may be used if TCP or UDP transport is + * provided by the Bearer Independent Protocol of TS 102 223 [4]. Note: If a direct IP connection as specified + * in TS 102 483 [6] is used these parameters will be ignored. + * @param parameterOffset the starting offset of the parameters in the triggeringParameters byte array + * @param parameterLength the length of the parameters + * @param contentType this buffer contains the Content-Type header value to be used + * when sending an HTTP or CoAP POST request through this connection. + * @param contentTypeOffset the starting offset of the content-type in the contentType byte array + * @param contentTypeLength the length of the content-type + * + * @throws ConnectionException with the following reason code: + * + * + * @throws ArrayIndexOutOfBoundsException if parameterOffset and parameterLength are causing access + * outside of triggeringParameters array bounds or + * if contentTypeOffset and contentTypeLength are causing access + * outside of contentType array bounds. + * + * @throws NullPointerException if triggeringParameters + * or contentType are equal to null + */ + public void open(byte[] triggeringParameters, short parameterOffset, short parameterLength, + byte[] contentType, short contentTypeOffset, short contentTypeLength) + throws ConnectionException; + + /** + * Close the SCP81 or SCP82 Connection. The calling application will be notified once the connection is closed. This method is non-blocking. + * + * @throws ConnectionException with the following reason code: + * + */ + public void close() + throws ConnectionException; + + /** + * Sends data on the SCP81 or SCP82 Connection. + * + *

Note: The applet execution is resumed once the HTTP POST request or CoAP POST request containing the data has been sent.

+ *

Note: The chunked transfer coding may be used if necessary.

+ * + * @param baData byte array containing the data to be sent + * @param sOffset the starting offset of the data to be sent in the baData byte array + * @param sLength the length of the data to be sent + * + * @throws ArrayIndexOutOfBoundsException if sOffset and sLength are causing access + * outside of baData array bounds + * @throws ConnectionException with the following reason code: + * + * @throws NullPointerException if baData is equal to null + */ + public void send(byte[] baData, short sOffset, short sLength) + throws ArrayIndexOutOfBoundsException, + ConnectionException, + NullPointerException; +} diff --git a/src/uicc/connection/SCP8XConnectionStatus.java b/src/uicc/connection/SCP8XConnectionStatus.java new file mode 100644 index 0000000000000000000000000000000000000000..e071659760471cb8ed4af72780dd53e0837ae812 --- /dev/null +++ b/src/uicc/connection/SCP8XConnectionStatus.java @@ -0,0 +1,38 @@ +package uicc.connection; + +/** + * This interface defines event constants that are used for notifications of state changes of connections represented + * by SCP8XConnection: + * connection established (corresponds to successful open()) + * connection setup failed (corresponds to unsuccessful open()) + * connection closed (corresponds to successful close()) + * communication error (corresponds to unexpected communication breakdown) + * server switch to other application (corresponds to server selecting another application via Content-Type header field) + * The object implementing SCP8XConnectionStatus interface is a Temporary Entry Point Object. + */ + +public interface SCP8XConnectionStatus extends Event +{ + /** This constant is used if the connection was successfully opened.. */ + public static final short CONNECTION_ESTABLISHED = (short) 0x0001 ; + + /** This constant is used if the connection could not been opened. */ + public static final short CONNECTION_SETUP_FAILED = (short) 0x0002 ; + + /** This constant is used if connection was closed due to a communication error. */ + public static final short COMMUNICATION_ERROR = (short) 0x0003 ; + + /** This constant is used if connection was closed due an invocation of SCP81Connection.close(). */ + public static final short CONNECTION_CLOSED = (short) 0x0004 ; + + /** This constant is used if connection server switched to another application via Content-Type header field */ + public static final short SERVER_SWITCH = (short) 0x0005 ; + + + /** + * Used to retrieve detailed information about the state change.. + * @return the reason for closing this connection. + */ + public short getDetails(); +} +