Methods Summary |
---|
public boolean | authorize()Authorizes this connection. It is assumed that the remote device has
previously been authenticated. This connection must represent the server
side, i.e. isServer() should return true.
authorized = BCC.getInstance().authorize(
remoteDevice.getBluetoothAddress(), getServiceRecordHandle());
return authorized;
|
protected void | checkOpen()Checks if this connection is open.
if (isClosed()) {
throw new IOException("Connection is closed.");
}
|
protected void | checkReadMode()Checks read access.
if ((mode & Connector.READ) == 0) {
throw new IOException("Invalid mode: " + mode);
}
|
protected void | checkSecurity()Performs security checks, such as authentication, authorization, and
encryption setup.
if (url.authenticate) {
if (!remoteDevice.authenticate()) {
throw new BluetoothConnectionException(
BluetoothConnectionException.SECURITY_BLOCK,
"Authentication failed.");
}
}
if (url.authorize) {
if (!remoteDevice.authorize((Connection)this)) {
throw new BluetoothConnectionException(
BluetoothConnectionException.SECURITY_BLOCK,
"Authorization failed.");
}
}
if (url.encrypt) {
if (!remoteDevice.encrypt((Connection)this, true)) {
throw new BluetoothConnectionException(
BluetoothConnectionException.SECURITY_BLOCK,
"Encryption failed.");
}
}
|
protected void | checkWriteMode()Checks write access.
if ((mode & Connector.WRITE) == 0) {
throw new IOException("Invalid mode: " + mode);
}
|
public boolean | encrypt(boolean enable)Changes encryption for this connection.
if (enable == encrypted) {
return true;
}
BCC.getInstance().encrypt(remoteDevice.getBluetoothAddress(), enable);
if (remoteDevice.isEncrypted()) {
if (enable) {
encrypted = true;
return true;
}
encrypted = false;
return false;
} else {
if (enable) {
return false;
}
encrypted = false;
return true;
}
|
public static com.sun.kvem.jsr082.bluetooth.BluetoothConnection | getConnection(javax.microedition.io.Connection conn)Retrieves BluetoothConnection from given one.
Connection given is supposed to be either Bluetooth connection
or a connection that uses Bluetooth as transport. All involved
connections supposed to be open.
if (conn == null) {
throw new NullPointerException("Null connection specified.");
}
if (conn instanceof ObexPacketStream) {
conn = ((ObexPacketStream)conn).getTransport();
}
if (!(conn instanceof BluetoothConnection)) {
throw new IllegalArgumentException("The specified connection " +
"is not a Bluetooth connection.");
}
BluetoothConnection btConn = (BluetoothConnection)conn;
btConn.checkOpen();
return btConn;
|
public javax.bluetooth.RemoteDevice | getRemoteDevice()Returns remote device for this connection.
checkOpen();
return remoteDevice;
|
public abstract java.lang.String | getRemoteDeviceAddress()Returns Bluetooth address of the remote device for this connection.
|
protected int | getServiceRecordHandle()Returns handle for the service record of the service this connection
is attached to. Valid for server-side (incoming) connections only.
return 0;
|
public boolean | isAuthorized()Returns the authorization state of this connection.
return authorized;
|
public boolean | isClosed()Determines if this connection is closed.
return remoteDevice == null;
|
public boolean | isServerSide()Determines whether this connection represents the server side,
i.e. this connection was created by a notifier in acceptAndOpen().
return url.isServer;
|
protected void | resetRemoteDevice()Removes reference to the remote device.
if (encrypted) {
encrypt(false);
}
remoteDevice = null;
BCC.getInstance().removeConnection(getRemoteDeviceAddress());
|
protected void | setRemoteDevice()Retrieves reference to the remote device for this connection.
remoteDevice = DiscoveryAgentImpl.getInstance().
getRemoteDevice(getRemoteDeviceAddress());
BCC.getInstance().addConnection(getRemoteDeviceAddress());
|