...
First we recommend to implement the LoaderCallback interface in order to receive the "onLoaded" event. This call is triggered as soon as the cgJCE finished loading. Loading itsself happens asynchrously i.e. the loader starts the loading process and returns immediately in fact it is not completely but almost immediately since we have to preload a legacy provider in order to guarantee compatibilityness to programs using older versions of our JCE.. When the job has finished "onLoaded" is called when the callback is implemented and given as parameter on "load" call.
We also recommend checking whether the cgJCE is installed by isProviderInstalled. Also check if the providers are already loaded by isProviderAvailable before calling the load function.
An example could look like this:
Code Block | ||||||||||
---|---|---|---|---|---|---|---|---|---|---|
| ||||||||||
public class LoaderSample implements LoaderCallback { Context _c; public LoaderSample(Context c) { this._c = c; } @Override public void onLoaded() { //loading the JCE has finished //get provider Provider p = Security.getProvider("CERTGATE"); //do something with the provider ... } public void startLoading() throws ProviderLoadingFailedException, ProviderSignatureInvalidException, ProviderNotFoundException { if (ProviderLoader.isProviderInstalled(this._c)) { if (!ProviderLoader.isProviderAvailable()) { ProviderLoader.load(this._c, this); } else { //already loaded! } } else { //not installed! } } } |
...