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

## javax.microedition.io
Interface SecureConnection

All Superinterfaces:
  Connection, InputConnection, OutputConnection, SocketConnection, StreamConnection

public interface SecureConnection
extends SocketConnection

This interface defines the secure socket stream connection. A secure connection is established using `Connector.open` with the scheme "ssl" and the secure connection is established before `open` returns. If the secure connection cannot be established due to errors related to certificates a `CertificateException` is thrown.

A secure socket is accessed using a generic connection string with an explicit host and port number. The host may be specified as a fully qualified host name or IPv4 number. e.g. `ssl://host.com:79` defines a target socket on the `host.com` system at port `79`.

Note that RFC1900 recommends the use of names rather than IP numbers for best results in the event of IP number reassignment.

A secure connection MUST be implemented by one or more of the following specifications:

- TLS Protocol Version 1.0 as specified in RFC 2246.
- SSL V3 as specified in The SSL Protocol Version 3.0
- WAP(TM) TLS Profile and Tunneling Specification as specified in WAP-219-TLS-20010411-a

## BNF Format for Connector.open() string

The URI must conform to the BNF syntax specified below. If the URI does not conform to this syntax, an `IllegalArgumentException` is thrown.

<socket_connection_string> | ::= "ssl://"<hostport>
<hostport> | ::= host ":" port
<host> | ::= host name or IP address
<port> | ::= numeric port number

Optional parameters are: See SocketConnection.

## Examples

The following examples show how a `SecureConnection` would be used to access a sample loopback program.

       SecureConnection sc = (SecureConnection)
                             Connector.open("ssl://host.com:79");
       SecurityInfo info = sc.getSecurityInfo();
       boolean isTLS = (info.getProtocolName().equals("TLS"));

       sc.setSocketOption(SocketConnection.LINGER, 5);

       InputStream is  = sc.openInputStream();
       OutputStream os = sc.openOutputStream();

       os.write("\r\n".getBytes());
       int ch = 0;
       while(ch != -1) {
           ch = is.read();
       }

       is.close();
       os.close();
       sc.close();

Since:
  MIDP 2.0

Field Summary

Fields inherited from interface javax.microedition.io.SocketConnection
`DELAY, KEEPALIVE, LINGER, RCVBUF, SNDBUF`

Method Summary
`SecurityInfo` | `getSecurityInfo()` Return the security information associated with this connection when it was opened.

Methods inherited from interface javax.microedition.io.SocketConnection
`getAddress, getLocalAddress, getLocalPort, getPort, getSocketOption, setSocketOption`

Methods inherited from interface javax.microedition.io.InputConnection
`openDataInputStream, openInputStream`

Methods inherited from interface javax.microedition.io.Connection
`close`

Methods inherited from interface javax.microedition.io.OutputConnection
`openDataOutputStream, openOutputStream`

Method Detail

### getSecurityInfo

    public SecurityInfo getSecurityInfo()
                                 throws IOException

  Return the security information associated with this connection when it was opened.

  Returns:
    the security information associated with this open connection.
  Throws:
    `IOException` - if an arbitrary connection failure occurs

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

Submit a comment or suggestion Version 2.0 of IM Profile Specification
Java is a trademark or registered trademark of Sun Microsystems, Inc. in the US and other countries. Copyright (c) 1993-2002 Sun Microsystems, Inc. 901 San Antonio Road,Palo Alto, California, 94303, U.S.A. All Rights Reserved.