Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. -(SecurityTokenServiceAssumeRoleWithWebIdentityResponse *)getAmazonSecurityTokenServiceWithAWSRoleResource:(NSString*)roleResourceName {
  2.  
  3. //get Amazon Security Token Service With AWS Role Resource for Facebook
  4.  
  5.  
  6. SecurityTokenServiceAssumeRoleWithWebIdentityRequest *awsSTRequest = [[SecurityTokenServiceAssumeRoleWithWebIdentityRequest alloc] init];
  7. awsSTRequest.roleArn = roleResourceName;
  8. awsSTRequest.roleSessionName = userFacebookID;
  9. awsSTRequest.webIdentityToken = FBAccessToken;
  10. awsSTRequest.providerId = @"graph.facebook.com";
  11.  
  12.  
  13. AmazonSecurityTokenServiceClient *awsTSClient = [[AmazonSecurityTokenServiceClient alloc] init];
  14. SecurityTokenServiceAssumeRoleWithWebIdentityResponse *response = [awsTSClient assumeRoleWithWebIdentity:awsSTRequest];
  15.  
  16.  
  17. return response;
  18. }
  19.  
  20. -(void)initializeAmazonDBClient {
  21.  
  22.  
  23. //Get security token for Facebook user
  24. SecurityTokenServiceAssumeRoleWithWebIdentityResponse *awsSTResponse = [appDelegate.facebookManager getAmazonSecurityTokenServiceWithAWSRoleResource:AWSDBROLERESOURCENAMEFACEBOOK];
  25.  
  26.  
  27. //initialize awsCredentials
  28. AmazonCredentials *awsCredentials = [[AmazonCredentials alloc] initWithAccessKey:awsSTResponse.credentials.accessKeyId withSecretKey:awsSTResponse.credentials.secretAccessKey withSecurityToken:awsSTResponse.credentials.sessionToken];
  29.  
  30.  
  31. //Initialize AmazonDynamoDBClient for sending requests to Amazon
  32. self.awsDBClient = [[AmazonDynamoDBClient alloc] initWithCredentials:awsCredentials];
  33. self.awsDBClient.endpoint = AMAZONDYNAMODBENDPOINT;
  34.  
  35.  
  36. //set up a DynamoDBDescribeTableRequest request
  37. DynamoDBDescribeTableRequest *request = [[DynamoDBDescribeTableRequest alloc] initWithTableName:@"my_table_name"];
  38. request.delegate = self;
  39.  
  40.  
  41.  
  42.  
  43. DynamoDBDescribeTableResponse *response = [awsDBClient describeTable:request];
  44.  
  45.  
  46. NSString *status = response.table.tableStatus;
  47.  
  48. NSLog(@"%@", status); //NULL
  49.  
  50.  
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement