| File |
Line |
| BluetoothTCKAgent/PushBTConnectionThread.java |
471
|
| BluetoothTCKAgent/PushBTConnectionThread.java |
549
|
int bytes_read = -1;
byte[] buffer = new byte[512];
String msg = (handshake != null) ? handshake : "HANDSHAKE";
String recvdMsg = "";
String protocol = url.substring(0, url.indexOf(":"));
if (!protocol.equals("btl2cap")) {
return false;
}
try {
clientChannel = (L2CAPConnection) Connector.open(url);
buffer = new byte[clientChannel.getReceiveMTU()];
System.out.println("PushBTConnectionThread: Connected "
+ "successfully to device");
clientChannel.send(msg.getBytes());
clientChannel.send(MSG_TERMINATOR.getBytes());
System.out.println("PushBTConnectionThread: Sent " + "message \""
+ msg + "\" to the device.");
if (verify) {
System.out.println("PushBTConnectionThread: Waiting for "
+ "handshake from the device ...");
TCKAgentUtil.pause(TCKAgentUtil.MEDIUM);
recvdMsg = "";
// Read the handshake message, terminated by a \n
while (recvdMsg.indexOf('\n') == -1) {
timeout = 0;
while (!clientChannel.ready() && timeout < 10) {
TCKAgentUtil.pause(TCKAgentUtil.MEDIUM);
timeout++;
}
if (timeout < 10) {
bytes_read = clientChannel.receive(buffer);
if (bytes_read > 0) {
recvdMsg += new String(buffer);
}
} else {
System.out.println("PushBTConnectionThread: Timed out "
+ "waiting for handshake ...");
break;
}
}
if (recvdMsg.indexOf('\n') != -1) {
return msg.trim().equals(
recvdMsg.substring(0, recvdMsg.indexOf('\n'))
.trim());
} else {
return false;
}
} else {
return true;
}
} catch (Exception e) {
System.out.println("PushBTConnectionThread: Caught an exception "
+ "while connecting to the URL: " + url);
System.out.println("Message: " + msg);
System.out.println("Exception : " + e);
} finally {
try {
TCKAgentUtil.pause(TCKAgentUtil.SHORT);
clientChannel.close();
} catch (Exception e) {
}
}
return false;
}
|
| File |
Line |
| OBEXTCKAgent/OBEXTCKAgentApp.java |
599
|
| OBEXTCKAgent/OBEXTCKAgentApp.java |
826
|
System.out.println("General Exception Occured: " + e);
return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
}
}
// Challenge the client
if ((testName.equals("TESTAUTHENTICATE")) && (AUTHENTICATE_TESTED == 0)) {
try {
// server request client to authenticate itself
HeaderSet headerSet = createHeaderSet();
headerSet.createAuthenticationChallenge("Server Auth Test", true, true);
tran.sendHeaders(headerSet);
} catch (Exception ex) {
System.out.println("Exception Occured " + ex.getMessage());
return ResponseCodes.OBEX_HTTP_INTERNAL_ERROR;
}
parent.agentthread.resetAgent();
return ResponseCodes.OBEX_HTTP_UNAUTHORIZED;
} else if ((testName.equals("TESTAUTHENTICATE")) && AUTHENTICATE_TESTED == 1) {
return ResponseCodes.OBEX_HTTP_OK;
} else if ((testName.equals("TESTAUTHENTICATE")) && AUTHENTICATE_TESTED > 1) {
System.out
.println("onPut() TESTAUTHENTICATE returns OBEX_HTTP_INTERNAL_ERROR with AUTHENTICATE_TESTED: "
|