JabberGuestCall provides callbacks that can be overridden to prompt users of your app if they wish to continue placing a call when the certificate provided is invalid. By default, the abstract BaseFragment class provides an implementation where users will be prompted with an AlertDialog if such an event takes place. This functionality is used by the CallFragment and PreviewFragment fragment sub-classes of BaseFragment, and also by the JabberGuestCallActivity activity class which uses the CallFragment and PreviewFragment classes directly. This behavior can be overridden by implementing your own invalid certificate handling.
If you are using the high-level JabberGuestCallActivity activity class, or the CallFragment and PreviewFragment fragment classes, then you can not override the default invalid certificate behavior. You can simply skip this section.
This interface allows you to control your app's behavior when encountering an invalid certificate.
To override this behavior you will first need to define a custom implementation of the JabberGuestInvalidCertificateCallback interface, and override the onInvalidCertificate method in your implementation. From inside this method, you can accept the certificate by calling the acceptInvalidCertificate method on your current JabberGuestCall instance, or you can reject the certificate by calling the rejectInvalidCertificate method on your current JabberGuestCall instance.
Once you have defined your own custom JabberGuestInvalidCertificateCallback implementation, you will need to be sure to register and unregister an instance of this implementation with the JabberGuestCall class, via the registerInvalidCertificateHandler and unregisterInvalidCertificateHandler static methods, respectively. Typically, this is done inside your activity's onResume and onPause methods.
Here is an example that demonstrates how to override the certificate handling behavior to always accept all invalid certificates in an Android activity:
// Class to handle invalid certificate notifications
private class JabberGuestCertificateHandler implements JabberGuestInvalidCertificateCallback {
@Override
public void onInvalidCertificate(String certFingerprint,
String identifierToDisplay,
String certSubjectCN, String referenceID,
List invalidReason, String subjectCertificateData,
List intermediateCACertificateData,
boolean allowUserToAccept) {
// For this sample we are accepting all certificates
JabberGuestCall.getInstance().acceptInvalidCertificate(referenceID, subjectCertificateData);
}
}
JabberGuestCertificateHandler mCertificateHandler = new JabberGuestCertificateHandler();
@Override
protected void onResume() {
super.onResume();
...
JabberGuestCall.registerInvalidCertificateHandler(mCertificateHandler);
...
}
@Override
protected void onPause() {
super.onPause();
...
JabberGuestCall.unregisterInvalidCertificateHandler(mCertificateHandler);
...
}