Fields Summary |
---|
private static final boolean | DEBUGSet to false in RR version - then the javac skip the code. |
private static final String | cnDEBUG: this class name for debug. |
private boolean | clientPermittedShows whether slient permissions checked. |
private boolean | serverPermittedShows whether server permissions checked. |
private static com.sun.midp.security.SecurityToken | classSecurityTokenThis class has a different security domain than the MIDlet suite. |
protected String | origNameConnection url for netmon. |
Methods Summary |
---|
private void | checkForPermission(int permission, java.lang.String name)Makes sure caller has the com.sun.midp permission set to "allowed".
MIDletSuite midletSuite =
MIDletStateHandler.getMidletStateHandler().getMIDletSuite();
if (midletSuite != null) {
try {
midletSuite.checkForPermission(permission, name);
} catch (InterruptedException ie) {
throw new InterruptedIOException(
"Interrupted while trying to ask the user permission");
}
}
|
protected TCPOBEXConnection | createTransportConnection(java.lang.String host, int port)Create tcp obex transport connection.
if (this.getClass() != Protocol.class) {
throw new SecurityException(
"Illegal Access to tcpobex implementation");
}
return new TCPOBEXConnection(classSecurityToken, host, port);
|
protected TCPOBEXNotifier | createTransportNotifier(int port)Create tcp obex transport notifier.
if (this.getClass() != Protocol.class) {
throw new SecurityException(
"Illegal Access to tcpobex implementation");
}
return new TCPOBEXNotifier(classSecurityToken, port);
|
public javax.microedition.io.Connection | openPrim(java.lang.String name, int mode, boolean timeouts)Creates the tcpsocket connection or notifier.
// print what do we have here
if (DEBUG) {
System.out.println(cn + ":name = " + name + " mode = " + mode
+ " timeouts = " + timeouts);
}
final String errorMsg = "Malformed URL: tcpobex:" + name;
origName = "tcpobex:" + name;
// this implementation supports READ_WRITE mode only
if (mode != Connector.READ_WRITE) {
throw new IllegalArgumentException("Unsupported mode: " + mode);
}
// do the URL parsing here
if (!name.startsWith("//")) {
throw new IllegalArgumentException(errorMsg);
}
/**
* JSR82 Specification 1.0a contains two contradicting forms of
* tcpobex server url. See 11.4.2 and 11.4.4. Supporting only
* for described in example:pIndex
* tcpobex://:port
*
* The possible URL values are:
*
* tcpobex:// - server on default port (650)
* tcpobex://:port - server on specified port
* tcpobex://<name/ip> - client on default port
* tcpobex://<name/ip>:port - client on specified port
*
*/
int pIndex = name.indexOf(':");
boolean isServer = name.length() == 2 || pIndex == 2;
int port = 650;
// extract the port if specified
if (pIndex != -1) {
if (pIndex == name.length() - 1) {
throw new IllegalArgumentException(errorMsg);
}
try {
port = Integer.parseInt(name.substring(pIndex + 1));
if (port <= 0) {
throw new NumberFormatException();
}
} catch (NumberFormatException e) {
throw new IllegalArgumentException(errorMsg);
}
}
// server connection on specified port
if (isServer) {
// check for server permissions
if (!serverPermitted) {
checkForPermission(Permissions.TCP_OBEX_SERVER, name);
serverPermitted = true;
}
return new SessionNotifierImpl(createTransportNotifier(port));
}
// check for client permissions
if (!clientPermitted) {
checkForPermission(Permissions.TCP_OBEX_CLIENT, name);
clientPermitted = true;
}
// get the client target host name (ip address)
pIndex = pIndex == -1 ? name.length() : pIndex;
String host = name.substring(2, pIndex);
return new ClientSessionImpl(createTransportConnection(host, port));
|