@ReactMethod public void initCredentialsProvider(String identityPoolId, String token, String region) { RegionUtils regionUtils = new RegionUtils(); Region awsRegion = regionUtils.getRegion(region); cognitoCredentialsProvider = new CognitoCachingCredentialsProvider( mActivityContext.getApplicationContext(), identityPoolId, // awsRegion); Regions.EU_WEST_1); cognitoClient = new CognitoSyncManager( mActivityContext.getApplicationContext(), // awsRegion, Regions.EU_WEST_1, cognitoCredentialsProvider); }
protected AmazonSimpleDBClient doInBackground(String... urls) { if (isNetworkAvailable(getActivity())) { try { // Initialize the Amazon Cognito credentials provider CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider( getActivity().getApplicationContext(), // Context "us-east-1:1caef7b3-7585-4ded-961d-0cc8f4bbc87f", // Identity Pool ID Regions.US_EAST_1 // Region ); Map<String, String> logins = new HashMap<String, String>(); logins.put("graph.facebook.com", Session.getActiveSession().getAccessToken()); credentialsProvider.withLogins(logins); Log.d("SimpleDBClient", "My ID is " + credentialsProvider.getIdentityId()); AmazonSimpleDBClient client = new AmazonSimpleDBClient(credentialsProvider); return client; } catch (Exception e) { this.exception = e; return null; } } else return null; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); // Initialize the Amazon Cognito credentials provider credentialsProvider = new CognitoCachingCredentialsProvider( getApplicationContext(), COGNITO_POOL_ID, // Identity Pool ID MY_REGION // Region ); iotDataClient = new AWSIotDataClient(credentialsProvider); String iotDataEndpoint = CUSTOMER_SPECIFIC_ENDPOINT; iotDataClient.setEndpoint(iotDataEndpoint); NumberPicker np = (NumberPicker) findViewById(R.id.setpoint); np.setMinValue(60); np.setMaxValue(80); np.setWrapSelectorWheel(false); getShadows(); }
NetworkStore() { kwalaCookieStore = new KwalaCookieStore(KwalaApplication.getInstance()); CookieManager cookieManager = new CookieManager(kwalaCookieStore, CookiePolicy.ACCEPT_ORIGINAL_SERVER); CookieHandler.setDefault(cookieManager); okHttpClient = new OkHttpClient.Builder() .cookieJar(new JavaNetCookieJar(cookieManager)) .authenticator(authenticator) .readTimeout(30, TimeUnit.SECONDS) .writeTimeout(30, TimeUnit.SECONDS) .build(); KwalaApplication application = KwalaApplication.getInstance(); // Initialize the Amazon Cognito credentials provider CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider(application, KwalaConstants.Network.AWS_IDENTITY_POOL_ID, Regions.US_EAST_1 ); // Initialize Amazon S3 and transfer utility s3Client = new AmazonS3Client(credentialsProvider); transferUtility = new TransferUtility(s3Client, application); }
private void initPollyClient(Context context, String awsPoolId) { CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider( context, awsPoolId, Regions.US_EAST_1 ); pollyClient = new AmazonPollyPresigningClient(credentialsProvider); }
private void initializeCognito(final Context context, final ClientConfiguration clientConfiguration) { AWSRefreshingCognitoIdentityProvider cognitoIdentityProvider = new AWSRefreshingCognitoIdentityProvider( null, AWSConfiguration.AMAZON_COGNITO_IDENTITY_POOL_ID, clientConfiguration); credentialsProvider = new CognitoCachingCredentialsProvider(context, cognitoIdentityProvider, AWSConfiguration.AMAZON_COGNITO_REGION, clientConfiguration ); }
@Override protected Void doInBackground(Void... params) { // init iria data IriaData.initIriaData(); // Initialize the Amazon Cognito credentials provider CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider( getApplicationContext(), "eu-west-1:75f8b90a-9b52-485b-86c4-bc517b8ad22b", // Identity Pool ID Regions.EU_WEST_1 // Region ); AmazonDynamoDBClient ddbClient = Region.getRegion(Regions.EU_WEST_1) .createClient( AmazonDynamoDBClient.class, credentialsProvider, new ClientConfiguration() ); mapper = new DynamoDBMapper(ddbClient); // get iria data try { ConstantsFromTable bikePathLayerUrl = mapper.load(ConstantsFromTable.class, "bikePathLayerUrl"); ConstantsFromTable telOfanLayerUrl = mapper.load(ConstantsFromTable.class, "telOfanLayerUrl"); ConstantsFromTable telOFunSiteURL = mapper.load(ConstantsFromTable.class, "telOFunStationsURL"); IriaData.getIriaData(bikePathLayerUrl, telOfanLayerUrl, telOFunSiteURL); IriaData.isDataReceived = true; } catch (Exception e) { // There was a problem getting the data from the Municipality site Log.i("INFO:", "in main activity Data from iria is NOT OK"); IriaData.isDataReceived = false; e.printStackTrace(); } return null; }
public static void init(Context context) { provider = new CognitoCachingCredentialsProvider(context, AWS_ACCOUNT_ID, COGNITO_POOL_ID, COGNTIO_ROLE_UNAUTH, COGNITO_ROLE_AUTH, Regions.US_EAST_1); //initialize the clients cognitosync = new CognitoSyncManager(context, Regions.US_EAST_1, provider); manager = new TransferManager(provider); ddb = new AmazonDynamoDBClient(provider); //ddbmapper = new DynamoDBMapper(ddb); analytics = MobileAnalyticsManager.getOrCreateInstance(context, MOBILE_ANALYTICS_APP_ID, Regions.US_EAST_1, provider); kinesis = new KinesisRecorder(context.getDir(KINESIS_DIRECTORY_NAME, 0), Regions.US_EAST_1, provider); lambda = new LambdaInvokerFactory(context, Regions.US_WEST_2, provider); }
/** * Initializes the AWS S3 credentials provider and transfer manager */ public static void init(Context context) { // Initialize the Amazon Cognito credentials provider CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider( context.getApplicationContext(), // Context AWS_IDENTITY_POOL_ID, // Identity Pool ID AWS_REGION // Region ); mS3Client = new AmazonS3Client(credentialsProvider); sTransferUtility = new TransferUtility(mS3Client, context); }
public static TransferManager getTransferManager(Context context) { CognitoCachingCredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider( context, "us-east-1:c2432cb5-55e1-42ec-a12f-4be2bc8abd9a", Regions.US_EAST_1 ); TransferManager transferManager = new TransferManager(credentialsProvider); return transferManager; }
public static void init(Context context) { provider = new CognitoCachingCredentialsProvider(context, AWS_ACCOUNT_ID, COGNITO_POOL_ID, COGNTIO_ROLE_UNAUTH, COGNITO_ROLE_AUTH, Regions.US_EAST_1); //initialize the Cognito Sync Client //initialize the Other Clients manager = new TransferManager(provider); analytics = MobileAnalyticsManager.getOrCreateInstance(context, "App_ID_Here", Regions.US_EAST_1, provider); }
void initPollyClient() { // Initialize the Amazon Cognito credentials provider. credentialsProvider = new CognitoCachingCredentialsProvider( getApplicationContext(), COGNITO_POOL_ID, MY_REGION ); // Create a client that supports generation of presigned URLs. client = new AmazonPollyPresigningClient(credentialsProvider); }
/** * Creates a new DatabaseAccess instance. * @param context the calling context */ private DatabaseAccess(Context context) { this.context = context; // Create a new credentials provider credentialsProvider = new CognitoCachingCredentialsProvider(context, COGNITO_POOL_ID, COGNITO_REGION); // Create a connection to the DynamoDB service dbClient = new AmazonDynamoDBClient(credentialsProvider); // Create a table reference dbTable = Table.loadTable(dbClient, DYNAMODB_TABLE); }
private void initClients() { CognitoCachingCredentialsProvider credentials = new CognitoCachingCredentialsProvider( context, Constants.IDENTITY_POOL_ID, Constants.COGNITO_REGION); ddb = new AmazonDynamoDBClient(credentials); ddb.setRegion(Region.getRegion(Constants.DYNAMODB_REGION)); }
/** * @return the Cognito credentials provider. */ public CognitoCachingCredentialsProvider getCredentialsProvider() { return this.credentialsProvider; }
/** * Hidden default constructor (singleton) */ private AccountManager() { // Initializing the CredentialsProvider credentialsProvider = new CognitoCachingCredentialsProvider ( context, context.getString(R.string.aws_identity_pool), // Identity Pool ID Regions.EU_WEST_1 // Put your own region here ); // Initializing the Sync Manager syncManager = new CognitoSyncManager( context, Regions.EU_WEST_1, credentialsProvider); dataset = syncManager.openOrCreateDataset(DATASET_NAME); Log.v(TAG, "Created AccountManager..."); }
private static AWSCredentialsProvider getCredentitalsProvider(Context context) { return new CognitoCachingCredentialsProvider( context.getApplicationContext(), context.getString(R.string.identity_pool_id), Regions.US_EAST_1); }
public static CognitoCachingCredentialsProvider getCognito() { if (provider == null) { throw new IllegalStateException("client not initialized yet"); } return provider; }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); txtSubscribe = (EditText) findViewById(R.id.txtSubscribe); txtTopic = (EditText) findViewById(R.id.txtTopic); txtMessage = (EditText) findViewById(R.id.txtMessage); tvLastMessage = (TextView) findViewById(R.id.tvLastMessage); tvClientId = (TextView) findViewById(R.id.tvClientId); tvStatus = (TextView) findViewById(R.id.tvStatus); btnConnect = (Button) findViewById(R.id.btnConnect); btnConnect.setOnClickListener(connectClick); btnConnect.setEnabled(false); btnSubscribe = (Button) findViewById(R.id.btnSubscribe); btnSubscribe.setOnClickListener(subscribeClick); btnPublish = (Button) findViewById(R.id.btnPublish); btnPublish.setOnClickListener(publishClick); btnDisconnect = (Button) findViewById(R.id.btnDisconnect); btnDisconnect.setOnClickListener(disconnectClick); // MQTT client IDs are required to be unique per AWS IoT account. // This UUID is "practically unique" but does not _guarantee_ // uniqueness. clientId = UUID.randomUUID().toString(); tvClientId.setText(clientId); // Initialize the AWS Cognito credentials provider credentialsProvider = new CognitoCachingCredentialsProvider( getApplicationContext(), // context COGNITO_POOL_ID, // Identity Pool ID MY_REGION // Region ); // MQTT Client mqttManager = new AWSIotMqttManager(clientId, CUSTOMER_SPECIFIC_ENDPOINT); // The following block uses a Cognito credentials provider for authentication with AWS IoT. new Thread(new Runnable() { @Override public void run() { runOnUiThread(new Runnable() { @Override public void run() { btnConnect.setEnabled(true); } }); } }).start(); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); keystorePath = getFilesDir().getPath(); // Initialize the AWS Cognito credentials provider credentialsProvider = new CognitoCachingCredentialsProvider( getApplicationContext(), // context COGNITO_POOL_ID, // Identity Pool ID MY_REGION // Region ); iotClient = new AWSIotClient(credentialsProvider); iotClient.setRegion(Region.getRegion(MY_REGION)); btnCreateCertificate = (Button) findViewById(R.id.btnCreateCertificate); btnCreateCertificate.setEnabled(false); tvCertificateStatus = (TextView) findViewById(R.id.tvCertificateStatus); // To load cert/key from keystore on filesystem try { if (AWSIotKeystoreHelper.isKeystorePresent(keystorePath, KEYSTORE_NAME)) { Log.i(LOG_TAG, "Keystore " + KEYSTORE_NAME + " found in " + keystorePath + "."); if (AWSIotKeystoreHelper.keystoreContainsAlias(CERTIFICATE_ID, keystorePath, KEYSTORE_NAME, KEYSTORE_PASSWORD)) { Log.i(LOG_TAG, "Certificate and key found in keystore."); tvCertificateStatus.setText("Certificate and key found in keystore."); btnCreateCertificate.setEnabled(false); } else { Log.i(LOG_TAG, "Certificate and key NOT found in keystore."); tvCertificateStatus .setText("Certificate and key NOT found in keystore. Click to create one with a CSR."); btnCreateCertificate.setEnabled(true); } } else { Log.i(LOG_TAG, "Keystore " + KEYSTORE_NAME + " NOT found in " + keystorePath + "."); tvCertificateStatus.setText("Keystore " + KEYSTORE_NAME + " NOT found in " + keystorePath + ". Click to create a certificate with a CSR and store in keystore."); btnCreateCertificate.setEnabled(true); } } catch (Exception e) { Log.e(LOG_TAG, "An error occurred accessing the keystore and retrieving cert/key.", e); } }
/** * Gets the singleton instance of the CredentialsProvider. init() must be * call prior to this. * * @return an instance of CognitoCachingCredentialsProvider */ public static CognitoCachingCredentialsProvider getCredentials() { checkCredentialAvailability(); return provider; }