Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

AWS SDK for iOS 1.3.1

  • Loading branch information...
commit 4bdf4a9dc838d2ed63cc4732865894af3a39e9ed 1 parent 21701a3
Bob Kinney authored June 21, 2012

Showing 208 changed files with 238,256 additions and 0 deletions. Show diff stats Hide diff stats

  1. 32  samples/AWSPersistence_Locations2/Classes/AmazonClientManager.h
  2. 114  samples/AWSPersistence_Locations2/Classes/AmazonClientManager.m
  3. 41  samples/AWSPersistence_Locations2/Classes/AmazonKeyChainWrapper.h
  4. 225  samples/AWSPersistence_Locations2/Classes/AmazonKeyChainWrapper.m
  5. 37  samples/AWSPersistence_Locations2/Classes/AmazonTVMClient.h
  6. 135  samples/AWSPersistence_Locations2/Classes/AmazonTVMClient.m
  7. 28  samples/AWSPersistence_Locations2/Classes/Checkin.h
  8. 27  samples/AWSPersistence_Locations2/Classes/Checkin.m
  9. 31  samples/AWSPersistence_Locations2/Classes/CheckinsViewController.h
  10. 211  samples/AWSPersistence_Locations2/Classes/CheckinsViewController.m
  11. 36  samples/AWSPersistence_Locations2/Classes/Constants.h
  12. 20  samples/AWSPersistence_Locations2/Classes/Constants.m
  13. 30  samples/AWSPersistence_Locations2/Classes/Crypto.h
  14. 97  samples/AWSPersistence_Locations2/Classes/Crypto.m
  15. 31  samples/AWSPersistence_Locations2/Classes/GetTokenRequest.h
  16. 45  samples/AWSPersistence_Locations2/Classes/GetTokenRequest.m
  17. 33  samples/AWSPersistence_Locations2/Classes/GetTokenResponse.h
  18. 39  samples/AWSPersistence_Locations2/Classes/GetTokenResponse.m
  19. 25  samples/AWSPersistence_Locations2/Classes/GetTokenResponseHandler.h
  20. 53  samples/AWSPersistence_Locations2/Classes/GetTokenResponseHandler.m
  21. 24  samples/AWSPersistence_Locations2/Classes/JSONUtilities.h
  22. 39  samples/AWSPersistence_Locations2/Classes/JSONUtilities.m
  23. 36  samples/AWSPersistence_Locations2/Classes/Location.h
  24. 28  samples/AWSPersistence_Locations2/Classes/Location.m
  25. 35  samples/AWSPersistence_Locations2/Classes/LocationsAppDelegate.h
  26. 176  samples/AWSPersistence_Locations2/Classes/LocationsAppDelegate.m
  27. 31  samples/AWSPersistence_Locations2/Classes/RegisterDeviceRequest.h
  28. 40  samples/AWSPersistence_Locations2/Classes/RegisterDeviceRequest.m
  29. 24  samples/AWSPersistence_Locations2/Classes/Request.h
  30. 26  samples/AWSPersistence_Locations2/Classes/Request.m
  31. 32  samples/AWSPersistence_Locations2/Classes/RequestDelegate.h
  32. 75  samples/AWSPersistence_Locations2/Classes/RequestDelegate.m
  33. 30  samples/AWSPersistence_Locations2/Classes/Response.h
  34. 40  samples/AWSPersistence_Locations2/Classes/Response.m
  35. 24  samples/AWSPersistence_Locations2/Classes/ResponseHandler.h
  36. 27  samples/AWSPersistence_Locations2/Classes/ResponseHandler.m
  37. 30  samples/AWSPersistence_Locations2/Classes/RootViewController.h
  38. 326  samples/AWSPersistence_Locations2/Classes/RootViewController.m
  39. 27  samples/AWSPersistence_Locations2/Classes/Utilities.h
  40. 129  samples/AWSPersistence_Locations2/Classes/Utilities.m
  41. BIN  samples/AWSPersistence_Locations2/CoreData-Checkin.png
  42. BIN  samples/AWSPersistence_Locations2/CoreData-Location.png
  43. BIN  samples/AWSPersistence_Locations2/CoreData-Model.png
  44. 346  samples/AWSPersistence_Locations2/CoreData.html
  45. 39  samples/AWSPersistence_Locations2/Info.plist
  46. 466  samples/AWSPersistence_Locations2/Locations2.xcodeproj/project.pbxproj
  47. 26  samples/AWSPersistence_Locations2/Locations2_Prefix.pch
  48. 8  samples/AWSPersistence_Locations2/Model.xcdatamodeld/.xccurrentversion
  49. 20  samples/AWSPersistence_Locations2/Model.xcdatamodeld/Model.xcdatamodel/contents
  50. 192  samples/AWSPersistence_Locations2/en.lproj/MainWindow.xib
  51. BIN  samples/AWSPersistence_Locations2/images/Icon-72.png
  52. BIN  samples/AWSPersistence_Locations2/images/Icon-Small-50.png
  53. BIN  samples/AWSPersistence_Locations2/images/Icon-Small.png
  54. BIN  samples/AWSPersistence_Locations2/images/Icon-Small@2x.png
  55. BIN  samples/AWSPersistence_Locations2/images/Icon.png
  56. BIN  samples/AWSPersistence_Locations2/images/Icon@2x.png
  57. BIN  samples/AWSPersistence_Locations2/images/iTunesArtwork
  58. 22  samples/AWSPersistence_Locations2/main.m
  59. 17  samples/DynamoDB_UserPreference/README.html
  60. 470  samples/DynamoDB_UserPreference/UserPreference.html
  61. 416  samples/DynamoDB_UserPreference/UserPreference.xcodeproj/project.pbxproj
  62. 7  samples/DynamoDB_UserPreference/UserPreference.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  63. 31  samples/DynamoDB_UserPreference/UserPreference/AmazonClientManager.h
  64. 99  samples/DynamoDB_UserPreference/UserPreference/AmazonClientManager.m
  65. 41  samples/DynamoDB_UserPreference/UserPreference/AmazonKeyChainWrapper.h
  66. 221  samples/DynamoDB_UserPreference/UserPreference/AmazonKeyChainWrapper.m
  67. 37  samples/DynamoDB_UserPreference/UserPreference/AmazonTVMClient.h
  68. 140  samples/DynamoDB_UserPreference/UserPreference/AmazonTVMClient.m
  69. 27  samples/DynamoDB_UserPreference/UserPreference/AppDelegate.h
  70. 95  samples/DynamoDB_UserPreference/UserPreference/AppDelegate.m
  71. 30  samples/DynamoDB_UserPreference/UserPreference/Constants.h
  72. 33  samples/DynamoDB_UserPreference/UserPreference/Constants.m
  73. 30  samples/DynamoDB_UserPreference/UserPreference/Crypto.h
  74. 97  samples/DynamoDB_UserPreference/UserPreference/Crypto.m
  75. 32  samples/DynamoDB_UserPreference/UserPreference/DynamoDBManager.h
  76. 191  samples/DynamoDB_UserPreference/UserPreference/DynamoDBManager.m
  77. 31  samples/DynamoDB_UserPreference/UserPreference/GetTokenRequest.h
  78. 52  samples/DynamoDB_UserPreference/UserPreference/GetTokenRequest.m
  79. 33  samples/DynamoDB_UserPreference/UserPreference/GetTokenResponse.h
  80. 48  samples/DynamoDB_UserPreference/UserPreference/GetTokenResponse.m
  81. 25  samples/DynamoDB_UserPreference/UserPreference/GetTokenResponseHandler.h
  82. 59  samples/DynamoDB_UserPreference/UserPreference/GetTokenResponseHandler.m
  83. 24  samples/DynamoDB_UserPreference/UserPreference/JSONUtilities.h
  84. 39  samples/DynamoDB_UserPreference/UserPreference/JSONUtilities.m
  85. 31  samples/DynamoDB_UserPreference/UserPreference/RegisterDeviceRequest.h
  86. 47  samples/DynamoDB_UserPreference/UserPreference/RegisterDeviceRequest.m
  87. 24  samples/DynamoDB_UserPreference/UserPreference/Request.h
  88. 26  samples/DynamoDB_UserPreference/UserPreference/Request.m
  89. 32  samples/DynamoDB_UserPreference/UserPreference/RequestDelegate.h
  90. 85  samples/DynamoDB_UserPreference/UserPreference/RequestDelegate.m
  91. 30  samples/DynamoDB_UserPreference/UserPreference/Response.h
  92. 45  samples/DynamoDB_UserPreference/UserPreference/Response.m
  93. 24  samples/DynamoDB_UserPreference/UserPreference/ResponseHandler.h
  94. 27  samples/DynamoDB_UserPreference/UserPreference/ResponseHandler.m
  95. 37  samples/DynamoDB_UserPreference/UserPreference/SelectionViewController.h
  96. 98  samples/DynamoDB_UserPreference/UserPreference/SelectionViewController.m
  97. 24  samples/DynamoDB_UserPreference/UserPreference/UserListViewController.h
  98. 131  samples/DynamoDB_UserPreference/UserPreference/UserListViewController.m
  99. 47  samples/DynamoDB_UserPreference/UserPreference/UserPreference-Info.plist
  100. 15  samples/DynamoDB_UserPreference/UserPreference/UserPreference-Prefix.pch
  101. 29  samples/DynamoDB_UserPreference/UserPreference/UserViewController.h
  102. 192  samples/DynamoDB_UserPreference/UserPreference/UserViewController.m
  103. 536  samples/DynamoDB_UserPreference/UserPreference/WelcomeView.xib
  104. 36  samples/DynamoDB_UserPreference/UserPreference/WelcomeViewController.h
  105. 144  samples/DynamoDB_UserPreference/UserPreference/WelcomeViewController.m
  106. 2  samples/DynamoDB_UserPreference/UserPreference/en.lproj/InfoPlist.strings
  107. 25  samples/DynamoDB_UserPreference/UserPreference/main.m
  108. 571  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo.xcodeproj/project.pbxproj
  109. 7  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  110. 38  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/AWSiOSDemo-Info.plist
  111. 14  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/AWSiOSDemo-Prefix.pch
  112. 29  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/AWSiOSDemoAppDelegate.h
  113. 49  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/AWSiOSDemoAppDelegate.m
  114. 30  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/AWSiOSDemoViewController.h
  115. 129  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/AWSiOSDemoViewController.m
  116. 36  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/AmazonClientManager.h
  117. 83  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/AmazonClientManager.m
  118. 35  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/Constants.h
  119. 26  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/Constants.m
  120. 26  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AddBucketViewController.h
  121. 54  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AddBucketViewController.m
  122. 586  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AddBucketViewController.xib
  123. 32  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AddObjectViewController.h
  124. 60  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AddObjectViewController.m
  125. 676  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AddObjectViewController.xib
  126. 36  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AsyncImageDownloader.h
  127. 168  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AsyncImageDownloader.m
  128. 35  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AsyncImageUploader.h
  129. 167  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/AsyncImageUploader.m
  130. 28  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/BucketList.h
  131. 137  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/BucketList.m
  132. 573  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/BucketList.xib
  133. 32  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/ObjectListing.h
  134. 158  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/ObjectListing.m
  135. 538  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/ObjectListing.xib
  136. 35  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/ObjectViewController.h
  137. 54  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/ObjectViewController.m
  138. 393  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/ObjectViewController.xib
  139. 40  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3AsyncViewController.h
  140. 114  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3AsyncViewController.m
  141. 548  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3AsyncViewController.xib
  142. 862  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3NSOperationDemoView.xib
  143. 47  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3NSOperationDemoViewController.h
  144. 125  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3NSOperationDemoViewController.m
  145. 45  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3ResponseHandler.h
  146. 101  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/S3/S3ResponseHandler.m
  147. 26  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/DomainList.h
  148. 102  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/DomainList.m
  149. 556  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/DomainList.xib
  150. 30  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/ItemListing.h
  151. 112  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/ItemListing.m
  152. 522  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/ItemListing.xib
  153. 32  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/ItemViewController.h
  154. 94  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/ItemViewController.m
  155. 520  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/ItemViewController.xib
  156. 47  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/SdbAsyncViewController.h
  157. 169  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/SdbAsyncViewController.m
  158. 547  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/SdbAsyncViewController.xib
  159. 46  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/SdbRequestDelegate.h
  160. 100  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SDB/SdbRequestDelegate.m
  161. 26  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SNS/TopicList.h
  162. 94  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SNS/TopicList.m
  163. 321  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SNS/TopicList.xib
  164. 26  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/AddQueue.h
  165. 40  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/AddQueue.m
  166. 384  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/AddQueue.xib
  167. 30  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/Message.h
  168. 44  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/Message.m
  169. 407  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/Message.xib
  170. 31  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/MessageList.h
  171. 132  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/MessageList.m
  172. 336  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/MessageList.xib
  173. 28  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/QueueList.h
  174. 140  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/QueueList.m
  175. 372  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/QueueList.xib
  176. 32  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/SendMessage.h
  177. 54  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/SendMessage.m
  178. 478  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/SQS/SendMessage.xib
  179. BIN  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/image1.png
  180. BIN  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/image2.png
  181. BIN  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/image3.png
  182. 214,201  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/Classes/temp.txt
  183. 542  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/en.lproj/AWSiOSDemoViewController.xib
  184. 2  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/en.lproj/InfoPlist.strings
  185. 444  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/en.lproj/MainWindow.xib
  186. 25  samples/S3_SimpleDB_SNS_SQS_Demo/AWSiOSDemo/main.m
  187. 16  samples/S3_SimpleDB_SNS_SQS_Demo/README.html
  188. 619  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM.xcodeproj/project.pbxproj
  189. 7  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM.xcodeproj/project.xcworkspace/contents.xcworkspacedata
  190. 46  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/AWSiOSDemoTVM-Info.plist
  191. 14  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/AWSiOSDemoTVM-Prefix.pch
  192. 29  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/AWSiOSDemoTVMAppDelegate.h
  193. 49  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/AWSiOSDemoTVMAppDelegate.m
  194. 31  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/AWSiOSDemoTVMViewController.h
  195. 162  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/AWSiOSDemoTVMViewController.m
  196. 38  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/AmazonClientManager.h
  197. 113  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/AmazonClientManager.m
  198. 44  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/Constants.h
  199. 36  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/Constants.m
  200. 26  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/AddBucketViewController.h
  201. 60  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/AddBucketViewController.m
  202. 586  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/AddBucketViewController.xib
  203. 32  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/AddObjectViewController.h
  204. 66  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/AddObjectViewController.m
  205. 676  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/AddObjectViewController.xib
  206. 28  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/BucketList.h
  207. 149  samples/S3_SimpleDB_SNS_SQS_DemoTVM/AWSiOSDemoTVM/Classes/S3/BucketList.m
32  samples/AWSPersistence_Locations2/Classes/AmazonClientManager.h
... ...
@@ -0,0 +1,32 @@
  1
+/*
  2
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License").
  5
+ * You may not use this file except in compliance with the License.
  6
+ * A copy of the License is located at
  7
+ *
  8
+ *  http://aws.amazon.com/apache2.0
  9
+ *
  10
+ * or in the "license" file accompanying this file. This file is distributed
  11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12
+ * express or implied. See the License for the specific language governing
  13
+ * permissions and limitations under the License.
  14
+ */
  15
+
  16
+#import <Foundation/Foundation.h>
  17
+#import <AWSiOSSDK/DynamoDB/AmazonDynamoDBClient.h>
  18
+#import "Constants.h"
  19
+#import "Response.h"
  20
+
  21
+@interface AmazonClientManager:NSObject
  22
+{
  23
+}
  24
+
  25
++(AmazonDynamoDBClient *)ddb;
  26
++(AmazonCredentials *)credentials;
  27
++(bool)hasCredentials;
  28
++(Response *)validateCredentials;
  29
++(void)clearCredentials;
  30
++(void)wipeAllCredentials;
  31
+
  32
+@end
114  samples/AWSPersistence_Locations2/Classes/AmazonClientManager.m
... ...
@@ -0,0 +1,114 @@
  1
+/*
  2
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License").
  5
+ * You may not use this file except in compliance with the License.
  6
+ * A copy of the License is located at
  7
+ *
  8
+ *  http://aws.amazon.com/apache2.0
  9
+ *
  10
+ * or in the "license" file accompanying this file. This file is distributed
  11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12
+ * express or implied. See the License for the specific language governing
  13
+ * permissions and limitations under the License.
  14
+ */
  15
+
  16
+#import "AmazonClientManager.h"
  17
+#import <AWSiOSSDK/AmazonLogger.h>
  18
+#import "AmazonKeyChainWrapper.h"
  19
+#import "AmazonTVMClient.h"
  20
+#import <AWSiOSSDK/S3/AmazonS3Client.h>
  21
+#import <AWSiOSSDK/S3/S3GetObjectRequest.h>
  22
+#import <AWSiOSSDK/S3/S3GetObjectResponse.h>
  23
+
  24
+static AmazonCredentials    *credentials = nil;
  25
+static AmazonDynamoDBClient *ddb         = nil;
  26
+static AmazonTVMClient      *tvm         = nil;
  27
+
  28
+
  29
+@implementation AmazonClientManager
  30
+
  31
++(AmazonDynamoDBClient *)ddb
  32
+{
  33
+    @try
  34
+    {
  35
+        [AmazonClientManager validateCredentials];
  36
+        return ddb;
  37
+    }
  38
+    @catch (NSException *exception)
  39
+    {
  40
+        NSLog(@"Exception: %@", exception);
  41
+    }
  42
+}
  43
+
  44
++(AmazonCredentials *)credentials;
  45
+{
  46
+    @try
  47
+    {
  48
+        [AmazonClientManager validateCredentials];
  49
+        return credentials;
  50
+    }
  51
+    @catch (NSException *exception)
  52
+    {
  53
+        NSLog(@"Exception: %@", exception);
  54
+    }
  55
+}
  56
+
  57
++(AmazonTVMClient *)tvm
  58
+{
  59
+    if (tvm == nil) {
  60
+        tvm = [[AmazonTVMClient alloc] initWithEndpoint:TOKEN_VENDING_MACHINE_URL useSSL:USE_SSL];
  61
+    }
  62
+
  63
+    return tvm;
  64
+}
  65
+
  66
++(bool)hasCredentials
  67
+{
  68
+    return ![TOKEN_VENDING_MACHINE_URL isEqualToString:@"CHANGE ME"];
  69
+}
  70
+
  71
++(Response *)validateCredentials
  72
+{
  73
+    Response *ableToGetToken = nil;
  74
+
  75
+    if ([AmazonKeyChainWrapper areCredentialsExpired]) {
  76
+        [AmazonClientManager clearCredentials];
  77
+
  78
+        ableToGetToken = [[AmazonClientManager tvm] anonymousRegister];
  79
+
  80
+        if ( [ableToGetToken wasSuccessful])
  81
+        {
  82
+            ableToGetToken = [[AmazonClientManager tvm] getToken];
  83
+        }
  84
+    }
  85
+    else
  86
+    {
  87
+        ableToGetToken = [[Response alloc] initWithCode:200 andMessage:@"OK"];
  88
+    }
  89
+
  90
+    if ( [ableToGetToken wasSuccessful] && credentials == nil)
  91
+    {
  92
+        [AmazonClientManager clearCredentials];
  93
+
  94
+        credentials = [AmazonKeyChainWrapper getCredentialsFromKeyChain];
  95
+        
  96
+        ddb = [[AmazonDynamoDBClient alloc] initWithCredentials:credentials];
  97
+    }
  98
+
  99
+    return ableToGetToken;
  100
+}
  101
+
  102
++(void)clearCredentials
  103
+{
  104
+    ddb = nil;
  105
+    credentials = nil;
  106
+}
  107
+
  108
++(void)wipeAllCredentials
  109
+{
  110
+    [AmazonClientManager clearCredentials];
  111
+    [AmazonKeyChainWrapper wipeCredentialsFromKeyChain];
  112
+}
  113
+
  114
+@end
41  samples/AWSPersistence_Locations2/Classes/AmazonKeyChainWrapper.h
... ...
@@ -0,0 +1,41 @@
  1
+/*
  2
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License").
  5
+ * You may not use this file except in compliance with the License.
  6
+ * A copy of the License is located at
  7
+ *
  8
+ *  http://aws.amazon.com/apache2.0
  9
+ *
  10
+ * or in the "license" file accompanying this file. This file is distributed
  11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12
+ * express or implied. See the License for the specific language governing
  13
+ * permissions and limitations under the License.
  14
+ */
  15
+
  16
+#import <Foundation/Foundation.h>
  17
+#import <AWSiOSSDK/AmazonCredentials.h>
  18
+
  19
+
  20
+@interface AmazonKeyChainWrapper:NSObject {
  21
+}
  22
+
  23
++(bool)areCredentialsExpired;
  24
++(AmazonCredentials *)getCredentialsFromKeyChain;
  25
++(void)storeCredentialsInKeyChain:(NSString *)theAccessKey secretKey:(NSString *)theSecretKey securityToken:(NSString *)theSecurityToken expiration:(NSString *)theExpirationDate;
  26
+
  27
++(NSString *)getValueFromKeyChain:(NSString *)key;
  28
++(void)storeValueInKeyChain:(NSString *)value forKey:(NSString *)key;
  29
+
  30
++(void)registerDeviceId:(NSString *)uid andKey:(NSString *)key;
  31
++(NSString *)getUidForDevice;
  32
++(NSString *)getKeyForDevice;
  33
+
  34
++(NSDate *)convertStringToDate:(NSString *)expiration;
  35
++(bool)isExpired:(NSDate *)date;
  36
+
  37
++(void)wipeKeyChain;
  38
++(void)wipeCredentialsFromKeyChain;
  39
++(NSMutableDictionary *)createKeychainDictionaryForKey:(NSString *)key;
  40
+
  41
+@end
225  samples/AWSPersistence_Locations2/Classes/AmazonKeyChainWrapper.m
... ...
@@ -0,0 +1,225 @@
  1
+/*
  2
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License").
  5
+ * You may not use this file except in compliance with the License.
  6
+ * A copy of the License is located at
  7
+ *
  8
+ *  http://aws.amazon.com/apache2.0
  9
+ *
  10
+ * or in the "license" file accompanying this file. This file is distributed
  11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12
+ * express or implied. See the License for the specific language governing
  13
+ * permissions and limitations under the License.
  14
+ */
  15
+
  16
+#import "AmazonKeyChainWrapper.h"
  17
+#import <AWSiOSSDK/AmazonLogger.h>
  18
+
  19
+
  20
+
  21
+
  22
+NSString *kKeychainAccessKeyIdentifier;
  23
+NSString *kKeychainSecretKeyIdentifier;
  24
+NSString *kKeychainSecrutiyTokenIdentifier;
  25
+NSString *kKeychainExpirationDateIdentifier;
  26
+
  27
+NSString *kKeychainUidIdentifier;
  28
+NSString *kKeychainKeyIdentifier;
  29
+
  30
+
  31
+@implementation AmazonKeyChainWrapper
  32
+
  33
++(void)initialize {
  34
+    NSString *bundleID = [NSBundle mainBundle].bundleIdentifier;
  35
+    kKeychainAccessKeyIdentifier = [NSString stringWithFormat:@"%@.AWSAccessKey", bundleID];
  36
+    kKeychainSecretKeyIdentifier= [NSString stringWithFormat:@"%@.AWSSecretKey", bundleID];
  37
+    kKeychainSecrutiyTokenIdentifier  = [NSString stringWithFormat:@"%@.AWSSecurityToken", bundleID];
  38
+    kKeychainExpirationDateIdentifier = [NSString stringWithFormat:@"%@.AWSExpirationDate", bundleID];
  39
+    
  40
+    kKeychainUidIdentifier = [NSString stringWithFormat:@"%@.UID", bundleID]; 
  41
+    kKeychainKeyIdentifier = [NSString stringWithFormat:@"%@.KEY", bundleID];
  42
+}
  43
+
  44
++(bool)areCredentialsExpired
  45
+{
  46
+    AMZLogDebug(@"areCredentialsExpired");
  47
+    
  48
+    NSString *expiration = [AmazonKeyChainWrapper getValueFromKeyChain:kKeychainExpirationDateIdentifier];
  49
+    if (expiration == nil) {
  50
+        return YES;
  51
+    }
  52
+    else {
  53
+        NSDate *expirationDate = [AmazonKeyChainWrapper convertStringToDate:expiration];
  54
+        
  55
+        AMZLog(@"expirationDate : %@, %@", expiration, expirationDate);
  56
+        
  57
+        return [AmazonKeyChainWrapper isExpired:expirationDate];
  58
+    }
  59
+}
  60
+
  61
++(void)registerDeviceId:(NSString *)uid andKey:(NSString *)key
  62
+{
  63
+    [AmazonKeyChainWrapper storeValueInKeyChain:uid forKey:kKeychainUidIdentifier];
  64
+    [AmazonKeyChainWrapper storeValueInKeyChain:key forKey:kKeychainKeyIdentifier];
  65
+}
  66
+
  67
++(NSString *)getKeyForDevice
  68
+{
  69
+    return [AmazonKeyChainWrapper getValueFromKeyChain:kKeychainKeyIdentifier];
  70
+}
  71
+
  72
++(NSString *)getUidForDevice
  73
+{
  74
+    return [AmazonKeyChainWrapper getValueFromKeyChain:kKeychainUidIdentifier];
  75
+}
  76
+
  77
++(AmazonCredentials *)getCredentialsFromKeyChain
  78
+{
  79
+    NSString *accessKey     = [AmazonKeyChainWrapper getValueFromKeyChain:kKeychainAccessKeyIdentifier];
  80
+    NSString *secretKey     = [AmazonKeyChainWrapper getValueFromKeyChain:kKeychainSecretKeyIdentifier];
  81
+    NSString *securityToken = [AmazonKeyChainWrapper getValueFromKeyChain:kKeychainSecrutiyTokenIdentifier];
  82
+    
  83
+    if ((accessKey != nil) && (secretKey != nil) && (securityToken != nil)) {
  84
+        if (![AmazonKeyChainWrapper areCredentialsExpired]) {
  85
+            AmazonCredentials *credentials = [[AmazonCredentials alloc] initWithAccessKey:accessKey withSecretKey:secretKey];
  86
+            credentials.securityToken = securityToken;
  87
+            
  88
+            return credentials;
  89
+        }
  90
+    }
  91
+    
  92
+    return nil;
  93
+}
  94
+
  95
++(void)storeCredentialsInKeyChain:(NSString *)theAccessKey secretKey:(NSString *)theSecretKey securityToken:(NSString *)theSecurityToken expiration:(NSString *)theExpirationDate
  96
+{
  97
+    [AmazonKeyChainWrapper storeValueInKeyChain:theAccessKey forKey:kKeychainAccessKeyIdentifier];
  98
+    [AmazonKeyChainWrapper storeValueInKeyChain:theSecretKey forKey:kKeychainSecretKeyIdentifier];
  99
+    [AmazonKeyChainWrapper storeValueInKeyChain:theSecurityToken forKey:kKeychainSecrutiyTokenIdentifier];
  100
+    [AmazonKeyChainWrapper storeValueInKeyChain:theExpirationDate forKey:kKeychainExpirationDateIdentifier];
  101
+}
  102
+
  103
++(bool)isExpired:(NSDate *)date
  104
+{
  105
+    NSDate *soon = [NSDate dateWithTimeIntervalSinceNow:(15 * 60)];  // Fifteen minutes from now.
  106
+    
  107
+    if ( [soon compare:date] == NSOrderedDescending) {
  108
+        return YES;
  109
+    }
  110
+    else {
  111
+        return NO;
  112
+    }
  113
+}
  114
+
  115
++(NSDate *)convertStringToDate:(NSString *)expiration
  116
+{
  117
+    if (expiration != nil)
  118
+    {
  119
+        long long exactSecondOfExpiration = (long long)([expiration longLongValue] / 1000);
  120
+        return [[NSDate alloc] initWithTimeIntervalSince1970:exactSecondOfExpiration];
  121
+    }
  122
+    else
  123
+    {
  124
+        return nil;
  125
+    }
  126
+}
  127
+
  128
++(NSString *)getValueFromKeyChain:(NSString *)key
  129
+{
  130
+    AMZLogDebug(@"Get Value for KeyChain key:[%@]", key);
  131
+    
  132
+    NSMutableDictionary *queryDictionary = [[NSMutableDictionary alloc] init];
  133
+    
  134
+    [queryDictionary setObject:[key dataUsingEncoding:NSUTF8StringEncoding] forKey:(__bridge id)kSecAttrGeneric];
  135
+    [queryDictionary setObject:(id) kCFBooleanTrue forKey:(__bridge id)kSecReturnAttributes];
  136
+    [queryDictionary setObject:(__bridge id) kSecMatchLimitOne forKey:(__bridge id)kSecMatchLimit];
  137
+    [queryDictionary setObject:(id) kCFBooleanTrue forKey:(__bridge id)kSecReturnData];
  138
+    [queryDictionary setObject:(__bridge id) kSecClassGenericPassword forKey:(__bridge id)kSecClass];
  139
+    
  140
+    CFDictionaryRef cfQueryDictionary = (__bridge_retained CFDictionaryRef)queryDictionary;
  141
+    CFDictionaryRef cfReturnedDictionary = NULL;
  142
+    OSStatus keychainError = SecItemCopyMatching(cfQueryDictionary, (CFTypeRef *)&cfReturnedDictionary);
  143
+    CFRelease(cfQueryDictionary);
  144
+    NSDictionary *returnedDictionary = (__bridge_transfer NSDictionary *)cfReturnedDictionary;
  145
+    
  146
+    if (keychainError == noErr)
  147
+    {
  148
+        NSData *rawData = [returnedDictionary objectForKey:(__bridge id)kSecValueData];
  149
+        return [[NSString alloc] initWithBytes:[rawData bytes] length:[rawData length] encoding:NSUTF8StringEncoding];
  150
+    }
  151
+    else
  152
+    {
  153
+        return nil;
  154
+    }
  155
+}
  156
+
  157
++(void)storeValueInKeyChain:(NSString *)value forKey:(NSString *)key
  158
+{
  159
+    AMZLogDebug(@"Storing value:[%@] in KeyChain as key:[%@]", value, key);
  160
+    
  161
+    NSMutableDictionary *keychainDictionary = [[NSMutableDictionary alloc] init];
  162
+    [keychainDictionary setObject:[key dataUsingEncoding:NSUTF8StringEncoding]      forKey:(__bridge id)kSecAttrGeneric];
  163
+    [keychainDictionary setObject:(__bridge id) kSecClassGenericPassword forKey:(__bridge id)kSecClass];
  164
+    [keychainDictionary setObject:[value dataUsingEncoding:NSUTF8StringEncoding]    forKey:(__bridge id)kSecValueData];
  165
+    [keychainDictionary setObject:[key dataUsingEncoding:NSUTF8StringEncoding]      forKey:(__bridge id)kSecAttrAccount];
  166
+    [keychainDictionary setObject:(__bridge id) kSecAttrAccessibleWhenUnlockedThisDeviceOnly forKey:(__bridge id)kSecAttrAccessible];
  167
+    
  168
+    OSStatus keychainError = SecItemAdd((__bridge CFDictionaryRef)keychainDictionary, NULL);
  169
+    if (keychainError == errSecDuplicateItem) {
  170
+        SecItemDelete((__bridge CFDictionaryRef)keychainDictionary);
  171
+        SecItemAdd((__bridge CFDictionaryRef)keychainDictionary, NULL);
  172
+    }
  173
+}
  174
+
  175
++(void)wipeKeyChain
  176
+{
  177
+    OSStatus keychainError = SecItemDelete((__bridge CFDictionaryRef)[AmazonKeyChainWrapper createKeychainDictionaryForKey : kKeychainAccessKeyIdentifier]);
  178
+    
  179
+    AMZLogDebug(@"Keychain Key: kKeychainAccessKeyIdentifier, Error Code: %ld", keychainError);
  180
+    
  181
+    keychainError = SecItemDelete((__bridge CFDictionaryRef)[AmazonKeyChainWrapper createKeychainDictionaryForKey : kKeychainSecretKeyIdentifier]);
  182
+    AMZLogDebug(@"Keychain Key: kKeychainSecretKeyIdentifier, Error Code: %ld", keychainError);
  183
+    
  184
+    keychainError = SecItemDelete((__bridge CFDictionaryRef)[AmazonKeyChainWrapper createKeychainDictionaryForKey : kKeychainSecrutiyTokenIdentifier]);
  185
+    AMZLogDebug(@"Keychain Key: kKeychainSecrutiyTokenIdentifier, Error Code: %ld", keychainError);
  186
+    
  187
+    keychainError = SecItemDelete((__bridge CFDictionaryRef)[AmazonKeyChainWrapper createKeychainDictionaryForKey : kKeychainExpirationDateIdentifier]);
  188
+    AMZLogDebug(@"Keychain Key: kKeychainExpirationDateIdentifier, Error Code: %ld", keychainError);
  189
+    
  190
+    keychainError = SecItemDelete((__bridge CFDictionaryRef)[AmazonKeyChainWrapper createKeychainDictionaryForKey : kKeychainUidIdentifier]);
  191
+    AMZLogDebug(@"Keychain Key: kKeychainUidIdentifier, Error Code: %ld", keychainError);
  192
+    
  193
+    keychainError = SecItemDelete((__bridge CFDictionaryRef)[AmazonKeyChainWrapper createKeychainDictionaryForKey : kKeychainKeyIdentifier]);
  194
+    AMZLogDebug(@"Keychain Key: kKeychainKeyIdentifier, Error Code: %ld", keychainError);
  195
+}
  196
+
  197
++(void)wipeCredentialsFromKeyChain
  198
+{
  199
+    OSStatus keychainError = SecItemDelete((__bridge CFDictionaryRef)[AmazonKeyChainWrapper createKeychainDictionaryForKey : kKeychainAccessKeyIdentifier]);
  200
+    
  201
+    AMZLogDebug(@"Keychain Key: kKeychainAccessKeyIdentifier, Error Code: %ld", keychainError);
  202
+    
  203
+    keychainError = SecItemDelete((__bridge CFDictionaryRef)[AmazonKeyChainWrapper createKeychainDictionaryForKey : kKeychainSecretKeyIdentifier]);
  204
+    AMZLogDebug(@"Keychain Key: kKeychainSecretKeyIdentifier, Error Code: %ld", keychainError);
  205
+    
  206
+    keychainError = SecItemDelete((__bridge CFDictionaryRef)[AmazonKeyChainWrapper createKeychainDictionaryForKey : kKeychainSecrutiyTokenIdentifier]);
  207
+    AMZLogDebug(@"Keychain Key: kKeychainSecrutiyTokenIdentifier, Error Code: %ld", keychainError);
  208
+    
  209
+    keychainError = SecItemDelete((__bridge CFDictionaryRef)[AmazonKeyChainWrapper createKeychainDictionaryForKey : kKeychainExpirationDateIdentifier]);
  210
+    AMZLogDebug(@"Keychain Key: kKeychainExpirationDateIdentifier, Error Code: %ld", keychainError);
  211
+}
  212
+
  213
++(NSMutableDictionary *)createKeychainDictionaryForKey:(NSString *)key
  214
+{
  215
+    NSMutableDictionary *dictionary = [[NSMutableDictionary alloc] init];
  216
+    
  217
+    [dictionary setObject:[key dataUsingEncoding:NSUTF8StringEncoding]      forKey:(__bridge id)kSecAttrGeneric];
  218
+    [dictionary setObject:(__bridge id) kSecClassGenericPassword forKey:(__bridge id)kSecClass];
  219
+    [dictionary setObject:[key dataUsingEncoding:NSUTF8StringEncoding]      forKey:(__bridge id)kSecAttrAccount];
  220
+    [dictionary setObject:(__bridge id) kSecAttrAccessibleWhenUnlockedThisDeviceOnly forKey:(__bridge id)kSecAttrAccessible];
  221
+    
  222
+    return dictionary;
  223
+}
  224
+
  225
+@end
37  samples/AWSPersistence_Locations2/Classes/AmazonTVMClient.h
... ...
@@ -0,0 +1,37 @@
  1
+/*
  2
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License").
  5
+ * You may not use this file except in compliance with the License.
  6
+ * A copy of the License is located at
  7
+ *
  8
+ *  http://aws.amazon.com/apache2.0
  9
+ *
  10
+ * or in the "license" file accompanying this file. This file is distributed
  11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12
+ * express or implied. See the License for the specific language governing
  13
+ * permissions and limitations under the License.
  14
+ */
  15
+
  16
+#import <Foundation/Foundation.h>
  17
+#import "Request.h"
  18
+#import "Response.h"
  19
+#import "ResponseHandler.h"
  20
+
  21
+
  22
+@interface AmazonTVMClient:NSObject {
  23
+    NSString        *endpoint;
  24
+    bool            useSSL;
  25
+}
  26
+
  27
+@property (nonatomic) NSString        *endpoint;
  28
+@property (nonatomic) bool                    useSSL;
  29
+
  30
+-(id)initWithEndpoint:(NSString *)endpoint useSSL:(bool)useSSL;
  31
+-(Response *)anonymousRegister;
  32
+-(Response *)getToken;
  33
+-(Response *)processRequest:(Request *)request responseHandler:(ResponseHandler *)handler;
  34
+-(NSString *)getEndpointDomain:(NSString *)originalEndpoint;
  35
+
  36
+@end
  37
+
135  samples/AWSPersistence_Locations2/Classes/AmazonTVMClient.m
... ...
@@ -0,0 +1,135 @@
  1
+/*
  2
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License").
  5
+ * You may not use this file except in compliance with the License.
  6
+ * A copy of the License is located at
  7
+ *
  8
+ *  http://aws.amazon.com/apache2.0
  9
+ *
  10
+ * or in the "license" file accompanying this file. This file is distributed
  11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12
+ * express or implied. See the License for the specific language governing
  13
+ * permissions and limitations under the License.
  14
+ */
  15
+
  16
+#import "AmazonTVMClient.h"
  17
+#import "AmazonKeyChainWrapper.h"
  18
+#import <AWSiOSSDK/AmazonLogger.h>
  19
+#import <AWSiOSSDK/AmazonAuthUtils.h>
  20
+
  21
+#import "RequestDelegate.h"
  22
+
  23
+#import "GetTokenResponseHandler.h"
  24
+#import "GetTokenRequest.h"
  25
+#import "GetTokenResponse.h"
  26
+
  27
+#import "RegisterDeviceRequest.h"
  28
+
  29
+#import "Crypto.h"
  30
+
  31
+@implementation AmazonTVMClient
  32
+
  33
+@synthesize endpoint, useSSL;
  34
+
  35
+-(id)initWithEndpoint:(NSString *)theEndpoint useSSL:(bool)usingSSL;
  36
+{
  37
+    if ((self = [super init])) {
  38
+        self.endpoint = [self getEndpointDomain:[theEndpoint lowercaseString]];
  39
+        self.useSSL   = usingSSL;
  40
+    }
  41
+
  42
+    return self;
  43
+}
  44
+
  45
+-(Response *)anonymousRegister
  46
+{
  47
+    Response *response = [[Response alloc] initWithCode:200 andMessage:@"OK"];
  48
+
  49
+    if ( [AmazonKeyChainWrapper getUidForDevice] == nil) {
  50
+        NSString              *uid = [Crypto generateRandomString];
  51
+        NSString              *key = [Crypto generateRandomString];
  52
+
  53
+        RegisterDeviceRequest *request = [[RegisterDeviceRequest alloc] initWithEndpoint:self.endpoint andUid:uid andKey:key usingSSL:self.useSSL];
  54
+        ResponseHandler       *handler = [[ResponseHandler alloc] init];
  55
+
  56
+        response = [self processRequest:request responseHandler:handler];
  57
+        if ( [response wasSuccessful]) {
  58
+            [AmazonKeyChainWrapper registerDeviceId:uid andKey:key];
  59
+        }
  60
+        else {
  61
+            AMZLogDebug(@"Token Vending Machine responded with Code: [%d] and Messgae: [%@]", response.code, response.message);
  62
+        }
  63
+    }
  64
+
  65
+    return response;
  66
+}
  67
+
  68
+-(Response *)getToken
  69
+{
  70
+    NSString         *uid = [AmazonKeyChainWrapper getUidForDevice];
  71
+    NSString         *key = [AmazonKeyChainWrapper getKeyForDevice];
  72
+
  73
+    Request          *request = [[GetTokenRequest alloc] initWithEndpoint:self.endpoint andUid:uid andKey:key usingSSL:self.useSSL];
  74
+    ResponseHandler  *handler = [[GetTokenResponseHandler alloc] initWithKey:key];
  75
+
  76
+    GetTokenResponse *response = (GetTokenResponse *)[self processRequest:request responseHandler:handler];
  77
+
  78
+    if ( [response wasSuccessful]) {
  79
+        [AmazonKeyChainWrapper storeCredentialsInKeyChain:response.accessKey secretKey:response.secretKey securityToken:response.securityToken expiration:response.expirationDate];
  80
+    }
  81
+    else {
  82
+        AMZLogDebug(@"Token Vending Machine responded with Code: [%d] and Messgae: [%@]", response.code, response.message);
  83
+    }
  84
+
  85
+    return response;
  86
+}
  87
+
  88
+-(Response *)processRequest:(Request *)request responseHandler:(ResponseHandler *)handler
  89
+{
  90
+    int             retries   = 2;
  91
+    RequestDelegate *delegate = [[RequestDelegate alloc] init];
  92
+
  93
+    do {
  94
+        AMZLogDebug(@"Request URL: %@", [request buildRequestUrl]);
  95
+
  96
+        NSURL             *url        = [[NSURL alloc] initWithString:[request buildRequestUrl]];
  97
+        NSURLRequest      *theRequest = [NSURLRequest requestWithURL:url cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:30.0];
  98
+        NSError           *error      = nil;
  99
+        NSHTTPURLResponse *response   = nil;
  100
+
  101
+        NSData            *data       = [NSURLConnection sendSynchronousRequest:theRequest returningResponse:&response error:&error];
  102
+
  103
+        if (error == nil)
  104
+        {
  105
+            return [handler handleResponse:response.statusCode body:[[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]];
  106
+        }
  107
+    } while (delegate.failed && retries-- > 0);
  108
+
  109
+    return [[Response alloc] initWithCode:500 andMessage:delegate.responseBody];
  110
+}
  111
+
  112
+-(NSString *)getEndpointDomain:(NSString *)originalEndpoint
  113
+{
  114
+    NSRange endpointRange;
  115
+
  116
+    if ( [originalEndpoint hasPrefix:@"http://"] || [originalEndpoint hasPrefix:@"https://"]) {
  117
+        NSRange startOfDomain = [originalEndpoint rangeOfString:@"://"];
  118
+        endpointRange.location = startOfDomain.location + 3;
  119
+    }
  120
+    else {
  121
+        endpointRange.location = 0;
  122
+    }
  123
+
  124
+    if ( [originalEndpoint hasSuffix:@"/"]) {
  125
+        endpointRange.length = ([originalEndpoint length] - 1) - endpointRange.location;
  126
+    }
  127
+    else {
  128
+        endpointRange.length = [originalEndpoint length] - endpointRange.location;
  129
+    }
  130
+
  131
+    return [originalEndpoint substringWithRange:endpointRange];
  132
+}
  133
+
  134
+
  135
+@end
28  samples/AWSPersistence_Locations2/Classes/Checkin.h
... ...
@@ -0,0 +1,28 @@
  1
+/*
  2
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License").
  5
+ * You may not use this file except in compliance with the License.
  6
+ * A copy of the License is located at
  7
+ *
  8
+ *  http://aws.amazon.com/apache2.0
  9
+ *
  10
+ * or in the "license" file accompanying this file. This file is distributed
  11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12
+ * express or implied. See the License for the specific language governing
  13
+ * permissions and limitations under the License.
  14
+ */
  15
+
  16
+#import <Foundation/Foundation.h>
  17
+#import <CoreData/CoreData.h>
  18
+
  19
+@class Location;
  20
+
  21
+@interface Checkin : NSManagedObject
  22
+
  23
+@property (nonatomic) NSString * checkinId;
  24
+@property (nonatomic) NSDate * checkinTime;
  25
+@property (nonatomic) NSString * comment;
  26
+@property (nonatomic) Location *location;
  27
+
  28
+@end
27  samples/AWSPersistence_Locations2/Classes/Checkin.m
... ...
@@ -0,0 +1,27 @@
  1
+/*
  2
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License").
  5
+ * You may not use this file except in compliance with the License.
  6
+ * A copy of the License is located at
  7
+ *
  8
+ *  http://aws.amazon.com/apache2.0
  9
+ *
  10
+ * or in the "license" file accompanying this file. This file is distributed
  11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12
+ * express or implied. See the License for the specific language governing
  13
+ * permissions and limitations under the License.
  14
+ */
  15
+
  16
+#import "Checkin.h"
  17
+#import "Location.h"
  18
+
  19
+
  20
+@implementation Checkin
  21
+
  22
+@dynamic checkinId;
  23
+@dynamic checkinTime;
  24
+@dynamic comment;
  25
+@dynamic location;
  26
+
  27
+@end
31  samples/AWSPersistence_Locations2/Classes/CheckinsViewController.h
... ...
@@ -0,0 +1,31 @@
  1
+/*
  2
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License").
  5
+ * You may not use this file except in compliance with the License.
  6
+ * A copy of the License is located at
  7
+ *
  8
+ *  http://aws.amazon.com/apache2.0
  9
+ *
  10
+ * or in the "license" file accompanying this file. This file is distributed
  11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12
+ * express or implied. See the License for the specific language governing
  13
+ * permissions and limitations under the License.
  14
+ */
  15
+
  16
+#import <UIKit/UIKit.h>
  17
+#import "Location.h"
  18
+#import "Checkin.h"
  19
+#import "Utilities.h"
  20
+
  21
+@interface CheckinsViewController : UITableViewController
  22
+{
  23
+    Location *location;
  24
+    NSMutableArray *checkinsArray;
  25
+    NSManagedObjectContext *managedObjectContext;
  26
+}
  27
+
  28
+@property (nonatomic) Location *location;
  29
+@property (nonatomic) NSManagedObjectContext *managedObjectContext;
  30
+
  31
+@end
211  samples/AWSPersistence_Locations2/Classes/CheckinsViewController.m
... ...
@@ -0,0 +1,211 @@
  1
+/*
  2
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License").
  5
+ * You may not use this file except in compliance with the License.
  6
+ * A copy of the License is located at
  7
+ *
  8
+ *  http://aws.amazon.com/apache2.0
  9
+ *
  10
+ * or in the "license" file accompanying this file. This file is distributed
  11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12
+ * express or implied. See the License for the specific language governing
  13
+ * permissions and limitations under the License.
  14
+ */
  15
+
  16
+#import <AWSPersistence/AWSPersistenceDynamoDBIncrementalStore.h>
  17
+#import "CheckinsViewController.h"
  18
+#import "RootViewController.h"
  19
+
  20
+@implementation CheckinsViewController
  21
+
  22
+@synthesize location, managedObjectContext;
  23
+
  24
+- (void)mergeDeletedObject:(NSNotification *)notification
  25
+{
  26
+    [self performSelectorOnMainThread:@selector(processMergeDeletedObject:) withObject:notification waitUntilDone:YES];
  27
+}
  28
+
  29
+- (void)processMergeDeletedObject:(NSNotification *)notification
  30
+{
  31
+    for(int i = [checkinsArray count] - 1; i >= 0; i--)
  32
+    {
  33
+        Checkin *c = [checkinsArray objectAtIndex:i];
  34
+        
  35
+        if([[c.objectID URIRepresentation] isEqual:[[notification.userInfo objectForKey:AWSPersistenceDynamoDBObjectDeletedNotificationObjectID] URIRepresentation]])
  36
+        {
  37
+            [checkinsArray removeObjectAtIndex:i];
  38
+        }
  39
+    }
  40
+    
  41
+    [self.tableView reloadData];
  42
+}
  43
+
  44
+- (void)viewDidLoad
  45
+{
  46
+    [super viewDidLoad];
  47
+
  48
+    [[NSNotificationCenter defaultCenter] addObserver:self 
  49
+                                             selector:@selector(mergeDeletedObject:) 
  50
+                                                 name:AWSPersistenceDynamoDBObjectDeletedNotification 
  51
+                                               object:nil];
  52
+    
  53
+    self.clearsSelectionOnViewWillAppear = NO;
  54
+ 
  55
+    self.navigationItem.rightBarButtonItem = self.editButtonItem;
  56
+    
  57
+    // put the contents of a set in an array for table view
  58
+    checkinsArray = [[NSMutableArray alloc] initWithCapacity: self.location.checkins.count];
  59
+    for (Checkin *checkin in self.location.checkins) {
  60
+        [checkinsArray addObject:checkin];
  61
+    }
  62
+}
  63
+
  64
+- (void)viewDidUnload
  65
+{
  66
+    [super viewDidUnload];
  67
+    
  68
+    [[NSNotificationCenter defaultCenter] removeObserver:self 
  69
+                                                    name:AWSPersistenceDynamoDBObjectDeletedNotification 
  70
+                                                  object:nil];
  71
+    
  72
+    // Release any retained subviews of the main view.
  73
+    self.managedObjectContext = nil;
  74
+    self.location = nil;
  75
+}
  76
+
  77
+- (void)viewWillDisappear:(BOOL)animated
  78
+{
  79
+    [super viewWillDisappear:animated];
  80
+    
  81
+    [managedObjectContext refreshObject:location mergeChanges:YES];
  82
+}
  83
+
  84
+- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
  85
+{
  86
+    return (interfaceOrientation == UIInterfaceOrientationPortrait);
  87
+}
  88
+
  89
+#pragma mark - Table view data source
  90
+
  91
+- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  92
+{
  93
+    // Return the number of sections.
  94
+    return 1;
  95
+}
  96
+
  97
+- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  98
+{
  99
+    // Return the number of rows in the section.
  100
+    return checkinsArray.count + 1;
  101
+}
  102
+
  103
+- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  104
+{
  105
+    static NSString *CellIdentifier = @"CheckinCell";
  106
+    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
  107
+    if (cell == nil) {
  108
+        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
  109
+    }
  110
+    
  111
+    if (indexPath.row < checkinsArray.count) {
  112
+        // Get the event corresponding to the current index path and configure the table view cell.
  113
+        Checkin *checkin = (Checkin *)[checkinsArray objectAtIndex:indexPath.row];
  114
+        
  115
+        cell.textLabel.text = [NSString stringWithFormat:@"%@", checkin.comment];
  116
+        
  117
+        cell.detailTextLabel.text = [NSString stringWithFormat:@"@ %@", checkin.checkinTime];
  118
+    }
  119
+    else {
  120
+        cell.textLabel.text = @"Add new...";
  121
+    }
  122
+	return cell;
  123
+}
  124
+
  125
+
  126
+// Override to support conditional editing of the table view.
  127
+- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
  128
+{
  129
+    // Return NO if you do not want the specified item to be editable.
  130
+    return indexPath.row < checkinsArray.count;
  131
+}
  132
+
  133
+
  134
+
  135
+// Override to support editing the table view.
  136
+- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
  137
+{
  138
+    if (editingStyle == UITableViewCellEditingStyleDelete) {
  139
+		
  140
+        // Delete the managed object at the given index path.
  141
+		Checkin *checkin = (Checkin *)[checkinsArray objectAtIndex:indexPath.row];
  142
+        [location removeCheckinsObject:checkin];
  143
+		[managedObjectContext deleteObject:checkin];
  144
+		
  145
+		// Update the array and table view.
  146
+        [checkinsArray removeObjectAtIndex:indexPath.row];
  147
+        [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:YES];
  148
+    }  
  149
+}
  150
+
  151
+#pragma mark - Table view delegate
  152
+
  153
+- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  154
+{
  155
+    if (indexPath.row == checkinsArray.count) {
  156
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Checkin Comment" message:@"Add your comment" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
  157
+        alert.alertViewStyle = UIAlertViewStylePlainTextInput;
  158
+        alert.tag = NEW_CHECKIN;
  159
+        [alert show];
  160
+    }
  161
+    else {
  162
+        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Checkin Comment" message:@"Add your comment" delegate:self cancelButtonTitle:@"Done" otherButtonTitles:nil];
  163
+        alert.alertViewStyle = UIAlertViewStylePlainTextInput;
  164
+        alert.tag = indexPath.row;
  165
+        [alert show];
  166
+    }
  167
+    
  168
+    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
  169
+}
  170
+
  171
+-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
  172
+{
  173
+    NSString *comment = [alertView textFieldAtIndex:0].text;
  174
+    NSLog(@"%@", comment);
  175
+    if ((comment == nil) || [comment isEqualToString:@""]) {
  176
+        return;
  177
+    }
  178
+    
  179
+    if (alertView.tag == NEW_CHECKIN) {
  180
+        [self newCheckin:comment];
  181
+    }
  182
+    else {
  183
+        // Tag stores the index of this checkin
  184
+        [self modifyCheckin:alertView.tag withComment:comment];
  185
+    }
  186
+}
  187
+
  188
+-(void)modifyCheckin:(NSInteger)checkinNo withComment:(NSString *)comment 
  189
+{
  190
+    // Modifying the checking is a simple operation
  191
+    Checkin *checkin = [checkinsArray objectAtIndex:checkinNo];
  192
+    checkin.comment = comment;
  193
+    
  194
+    [self.tableView reloadData];
  195
+}
  196
+
  197
+-(void)newCheckin:(NSString *)comment 
  198
+{
  199
+    // Create a new checking object
  200
+    Checkin *checkin = (Checkin *)[NSEntityDescription insertNewObjectForEntityForName:@"Checkin" inManagedObjectContext:managedObjectContext];
  201
+    checkin.checkinId = [Utilities getUUID];
  202
+    checkin.checkinTime = [NSDate date];
  203
+    checkin.comment = comment;
  204
+    
  205
+    checkin.location = self.location;
  206
+    [self.location addCheckinsObject:checkin];
  207
+    [checkinsArray addObject:checkin];
  208
+    [self.tableView reloadData];
  209
+}
  210
+
  211
+@end
36  samples/AWSPersistence_Locations2/Classes/Constants.h
... ...
@@ -0,0 +1,36 @@
  1
+/*
  2
+ * Copyright 2010-2012 Amazon.com, Inc. or its affiliates. All Rights Reserved.
  3
+ *
  4
+ * Licensed under the Apache License, Version 2.0 (the "License").
  5
+ * You may not use this file except in compliance with the License.
  6
+ * A copy of the License is located at
  7
+ *
  8
+ *  http://aws.amazon.com/apache2.0
  9
+ *
  10
+ * or in the "license" file accompanying this file. This file is distributed
  11
+ * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
  12
+ * express or implied. See the License for the specific language governing
  13
+ * permissions and limitations under the License.
  14
+ */
  15
+
  16
+#import <Foundation/Foundation.h>
  17
+
  18
+#define TOKEN_VENDING_MACHINE_URL    @"CHANGEME.elasticbeanstalk.com"
  19
+#define USE_SSL                      NO
  20
+#define CREDENTIALS_ALERT_MESSAGE    @"Please update the Constants.h file with the Token Vending Machine URL."
  21
+
  22
+#define LOCATIONS_TABLE              @"AWS-Locations"
  23
+#define CHECKINS_TABLE               @"AWS-Checkins"
  24
+#define LOCATIONS_KEY                @"locationId"
  25
+#define CHECKINS_KEY                 @"checkinId"
  26
+#define LOCATIONS_VERSIONS           @"version"