Client Event Listener
The ClientEventListener class exposes a number of events that are fired at certain points during the SDK's operation. Below is a list of the available events:
DataPacketIn
Fired when receiving a data packet from the server.public class MyClientEventListener implements ClientEventListener {
...
public void fireDataPacketIn(byte[] dataPacket) {
Log.i("ClientDataPacketIn", new String(dataPacket));
}
...
}
This event fires when a packet is received. The entire data packet (including all framing and error detection characters) is contained in the dataPacket parameter. This parameter may be inspected for advanced troubleshooting, or to extract additional response properties beyond the scope of the SDK.
DataPacketOut
Fired when sending a data packet to the server.public class MyClientEventListener implements ClientEventListener {
...
public void fireDataPacketOut(byte[] dataPacket) {
Log.i("ClientDataPacketOut", new String(dataPacket));
}
...
}
This event fires right before each data packet is sent. The entire data packet (including all framing and error detection characters) is contained in the dataPacket parameter. This parameter may be inspected for advanced troubleshooting.
Log
Fires once for each log message.public class MyClientEventListener implements ClientEventListener {
...
public void fireLog(int logLevel, String message, String logType) {
Log.i("ClientLog", logType + " - " + message);
}
...
}
Logging is handled through the Log event. This will fire any time a message is built or a response is parsed, including error messages.
When the Log event is fired, the message in question is made available via the message event parameter. The other event arguments are logType and logLevel.
The logType parameter indicates the type of the log entry. Possible values are:
- Info
- RequestHeaders
- ResponseHeaders
- RequestBody
- ResponseBody
- ProxyRequest
- ProxyResponse
- FirewallRequest
- FirewallResponse
- CReq
- CRes
- Erro
- EphemeralKey
- DeviceParams
- SW
A logType of SW indicates a Security Warning. When this value is present, the message parameter will contain a code to indicate a more specific cause of the warning. Below is a list of possible warning message values and their meanings:
SW Message Value | Description |
01 | Tampered; not installed from a trusted store |
02 | Tampered; internal error checking app store |
03 | Tampered; invalid appSignature |
04 | Tampered; suspicious app installed |
05 | Root; suspicious files present |
06 | Root; suspicious apk present |
07 | Root; root permissions |
08 | Root; root tag |
09 | Root; hooked |
10 | Debugging; debugger attached |
The logLevel parameter in the event indicates the log level to which the current message belongs. Possible values are:
- 0 - None
- 1 - Info
- 2 - Verbose
- 3 - Debug
It is recommended to output all messages raised in this event to a file for record keeping or troubleshooting purposes.
SSLServerAuthentication
Fired after the server presents its certificate to the client.public class MyClientEventListener implements ClientEventListener {
...
public void fireSSLServerAuthentication(byte[] certEncoded, String certSubject, String certIssuer, String status, boolean[] accept) {
//...
}
...
}
This event fires when establishing a TLS connection and provides information about the server's certificate. The accept parameter indicates whether the certificate is trusted by default.
When accept is False, status shows why the verification failed (otherwise, status contains the string "OK"). If it is decided to continue, you can override and accept the certificate by setting the accept parameter to True.
SSLStatus
Shows the progress of the secure connection.public class MyClientEventListener implements ClientEventListener {
...
public void fireSSLStatus(String message) {
Log.i("ClientSSLStatus", message);
}
...
}
The event is fired for informational and logging purposes only. Used to track the progress of the connection.