Last active
March 28, 2018 19:46
-
-
Save adrianhall/15a506022730202d3e83820cb3cd82b1 to your computer and use it in GitHub Desktop.
Boilerplate code for the AWSProvider
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.amazonaws.mobile.samples.customauth | |
import android.content.Context | |
import com.amazonaws.auth.CognitoCachingCredentialsProvider | |
import com.amazonaws.mobile.config.AWSConfiguration | |
class AWSProvider { | |
companion object { | |
private var mConfiguration: AWSConfiguration? = null | |
private var mCredentialsProvider: Cognito | |
private var mInstance: AWSProvider? = null | |
/** | |
* Read-only property for storing the AWSConfiguration | |
*/ | |
var configuration: AWSConfiguration? | |
get() = mConfiguration | |
private set(value) { mConfiguration = value } | |
/** | |
* Read-only property for storing the current instance | |
*/ | |
var instance: AWSProvider? | |
get() = mInstance | |
private set(value) { mInstance = value } | |
/** | |
* Read-only property for storing the Amazon Cognito credentials provider | |
*/ | |
var credentialsProvider: CognitoCachingCredentialsProvider? | |
get() = mCredentialsProvider | |
private set(value) { mCredentialsProvider = value } | |
/** | |
* Initialize the AWSProvider | |
* | |
* @param context the application context | |
*/ | |
@Synchronized | |
fun initialize(context: Context) { | |
configuration = AWSConfiguration(context) | |
credentialsProvider = CognitoCachingCredentialsProvider(context, configuration) | |
} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment