...
Code Block |
---|
// Get the class instance and start provisioning var secureClient = SecureClient.getInstance(activity, AOneAppSecurityCbk(activity)) ... secureClient.provision(settings) .provision(settings) |
Note |
---|
The SecureClient.getInstance() function needs to be called from the main thread for security related reasons. But all other secure client related actions (functions calls) need to be performed from another thread. |
Now there are a few things to consider in this example: the callbacks class AOneAppSecurityCbk
and the provisioning settings.
Callbacks
Some of the AOneAppSecurity
SecureClient
class methods are asynchronous. The AOneAppSecurityCbk
class purpose is to provide callback functions for when the asynchronous tasks are complete or terminated for some reason.
The AOneAppSecurityCbk
class must derive the IAOneAppSecurityCbk
IAppSecurityCbk
interface. The rest of its content is implementation dependent. Find below an basic implementation example:
...
domain: Secure Backend IP address or hostname
port
osType (should be set to “Android”)
hardwareDescription
terminalId: terminal ID received when registering the device in the database
clientId: client ID received when registering the user in the database
secret: client secret received when registering the user in the database
ownCertPass: the owner of the backend certificate
checkServCert: some field to be verified inside the backend certficates
certDir: certificates location inside the phone
Which gives us the following code as example:
Code Block |
---|
// Provisioning parameters
val settings = """
|{
|"domain":"my.domain.name",
|"port":8090,
|"osType":"Android",
|"hardwareDescription":"AmadisOneClient",
|"terminalId":"1234567891"
|"clientId":2
|"secret":"DbIHpPvGbfnj6j8gh6mG7FtB8eAgO1yM8V0DnDPT"
|"ownCertPass":"amadis",
|"checkSrvCert":"iSSuer.Cn = Alexandre Munsch | subJect/St ~ Quebec ",
|"certDir":"${getSecureClientDir()}"
|}""".trimMargin() |
Flow
The provisioning step is supposed to happen only once in the application lifetime (unless some parameters need to be changed - for example, a change of user ID or a change of domain name, etc…).
...