├── .gitignore
├── Demo
├── Default-568h@2x.png
├── OAuthTwitterDemo.xcodeproj
│ └── project.pbxproj
├── Rsc
│ ├── MainWindow.xib
│ ├── OAuthTwitterDemo-Info.plist
│ └── OAuthTwitterDemoViewController.xib
└── Src
│ ├── OAuthTwitterDemoAppDelegate.h
│ ├── OAuthTwitterDemoAppDelegate.m
│ ├── OAuthTwitterDemoViewController.h
│ ├── OAuthTwitterDemoViewController.m
│ ├── OAuthTwitterDemo_Prefix.pch
│ └── main.m
├── OAuthConsumeriPhoneLib
├── .gitignore
├── BuildCombined.sh
├── OAuthConsumer-iPhoneLib.xcodeproj
│ └── project.pbxproj
├── OAuthConsumerSrc
│ ├── Crypto
│ │ ├── Base64Transcoder.c
│ │ ├── Base64Transcoder.h
│ │ ├── hmac.c
│ │ ├── hmac.h
│ │ ├── sha1.c
│ │ └── sha1.h
│ ├── NSMutableURLRequest+Parameters.h
│ ├── NSMutableURLRequest+Parameters.m
│ ├── NSString+URLEncoding.h
│ ├── NSString+URLEncoding.m
│ ├── NSURL+Base.h
│ ├── NSURL+Base.m
│ ├── OAAsynchronousDataFetcher.h
│ ├── OAAsynchronousDataFetcher.m
│ ├── OAConsumer.h
│ ├── OAConsumer.m
│ ├── OADataFetcher.h
│ ├── OADataFetcher.m
│ ├── OAHMAC_SHA1SignatureProvider.h
│ ├── OAHMAC_SHA1SignatureProvider.m
│ ├── OAMutableURLRequest.h
│ ├── OAMutableURLRequest.m
│ ├── OAPlaintextSignatureProvider.h
│ ├── OAPlaintextSignatureProvider.m
│ ├── OARequestParameter.h
│ ├── OARequestParameter.m
│ ├── OAServiceTicket.h
│ ├── OAServiceTicket.m
│ ├── OASignatureProviding.h
│ ├── OAToken.h
│ ├── OAToken.m
│ ├── OAToken_KeychainExtensions.h
│ ├── OAToken_KeychainExtensions.m
│ └── OAuthConsumer.h
├── OAuthConsumer_iPhone_Prefix.pch
└── ReadMe.txt
├── ReadMe.txt
└── Twitter+OAuth
├── Libraries & Headers
├── OAuthConsumer
│ ├── NSMutableURLRequest+Parameters.h
│ ├── NSString+URLEncoding.h
│ ├── NSURL+Base.h
│ ├── OAAsynchronousDataFetcher.h
│ ├── OAConsumer.h
│ ├── OADataFetcher.h
│ ├── OAHMAC_SHA1SignatureProvider.h
│ ├── OAMutableURLRequest.h
│ ├── OAPlaintextSignatureProvider.h
│ ├── OARequestParameter.h
│ ├── OAServiceTicket.h
│ ├── OASignatureProviding.h
│ ├── OAToken.h
│ ├── OAToken_KeychainExtensions.h
│ └── OAuthConsumer.h
├── jQueryInject.txt
├── jQueryInjectLandscape.txt
└── libOAuth.a
├── MGTwitterEngine
├── MGTwitterEngine.h
├── MGTwitterEngine.m
├── MGTwitterEngineDelegate.h
├── MGTwitterEngineGlobalHeader.h
├── MGTwitterHTTPURLConnection.h
├── MGTwitterHTTPURLConnection.m
├── MGTwitterLibXMLParser.h
├── MGTwitterLibXMLParser.m
├── MGTwitterMessagesLibXMLParser.h
├── MGTwitterMessagesLibXMLParser.m
├── MGTwitterMessagesParser.h
├── MGTwitterMessagesParser.m
├── MGTwitterMiscLibXMLParser.h
├── MGTwitterMiscLibXMLParser.m
├── MGTwitterMiscParser.h
├── MGTwitterMiscParser.m
├── MGTwitterParserDelegate.h
├── MGTwitterRequestTypes.h
├── MGTwitterStatusesLibXMLParser.h
├── MGTwitterStatusesLibXMLParser.m
├── MGTwitterStatusesParser.h
├── MGTwitterStatusesParser.m
├── MGTwitterUsersLibXMLParser.h
├── MGTwitterUsersLibXMLParser.m
├── MGTwitterUsersParser.h
├── MGTwitterUsersParser.m
├── MGTwitterXMLParser.h
├── MGTwitterXMLParser.m
├── NSData+Base64.h
├── NSData+Base64.m
├── NSString+UUID.h
└── NSString+UUID.m
└── SAOAuthTwitterEngine
├── SA_OAuthTwitterController.h
├── SA_OAuthTwitterController.m
├── SA_OAuthTwitterEngine.h
├── SA_OAuthTwitterEngine.m
└── twitter_load.png
/.gitignore:
--------------------------------------------------------------------------------
1 | .DS_Store
2 |
3 | /Twitter+OAuth/Libraries & Headers/OAuthConsumer/.svn/
4 | /OAuthConsumeriPhoneLib/OAuthConsumer-iPhoneLib.xcodeproj/xcuserdata/
5 | /OAuthConsumeriPhoneLib/OAuthConsumer-iPhoneLib.xcodeproj/project.xcworkspace/
6 | /Demo/OAuthTwitterDemo.xcodeproj/xcuserdata/
7 | /Demo/OAuthTwitterDemo.xcodeproj/project.xcworkspace/
8 | /Demo/build/
--------------------------------------------------------------------------------
/Demo/Default-568h@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/bengottlieb/Twitter-OAuth-iPhone/1e8d95c4e6f3f99352574b2448aa8c160ec9a323/Demo/Default-568h@2x.png
--------------------------------------------------------------------------------
/Demo/Rsc/MainWindow.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 768
5 | 10A288
6 | 715
7 | 1010
8 | 411.00
9 |
13 |
17 |
21 |
30 |
31 | YES
32 |
33 | IBFilesOwner
34 |
35 |
36 | IBFirstResponder
37 |
38 |
39 |
40 | OAuthTwitterDemoViewController
41 |
42 |
43 |
44 |
45 | 292
46 | {320, 480}
47 |
48 | 1
49 | MSAxIDEAA
50 |
51 | NO
52 | NO
53 |
54 |
55 |
56 |
57 |
58 | YES
59 |
60 |
61 | delegate
62 |
63 |
64 |
65 | 4
66 |
67 |
68 |
69 | viewController
70 |
71 |
72 |
73 | 11
74 |
75 |
76 |
77 | window
78 |
79 |
80 |
81 | 14
82 |
83 |
84 |
85 |
86 | YES
87 |
88 | 0
89 |
90 |
91 |
92 |
93 |
94 | -1
95 |
96 |
97 | File's Owner
98 |
99 |
100 | 3
101 |
102 |
103 | OAuthTwitterDemo App Delegate
104 |
105 |
106 | -2
107 |
108 |
109 |
110 |
111 | 10
112 |
113 |
114 |
115 |
116 | 12
117 |
118 |
119 |
120 |
121 |
122 |
123 | YES
124 |
125 | YES
126 | -1.CustomClassName
127 | -2.CustomClassName
128 | 10.CustomClassName
129 | 10.IBEditorWindowLastContentRect
130 | 10.IBPluginDependency
131 | 12.IBEditorWindowLastContentRect
132 | 12.IBPluginDependency
133 | 3.CustomClassName
134 | 3.IBPluginDependency
135 |
136 |
137 | YES
138 | UIApplication
139 | UIResponder
140 | OAuthTwitterDemoViewController
141 | {{512, 351}, {320, 480}}
142 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
143 | {{525, 346}, {320, 480}}
144 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
145 | OAuthTwitterDemoAppDelegate
146 | com.apple.InterfaceBuilder.IBCocoaTouchPlugin
147 |
148 |
149 |
150 | YES
151 |
152 |
153 | YES
154 |
155 |
156 |
157 |
158 | YES
159 |
160 |
161 | YES
162 |
163 |
164 |
165 | 14
166 |
167 |
168 |
169 | YES
170 |
171 | OAuthTwitterDemoAppDelegate
172 | NSObject
173 |
174 | YES
175 |
176 | YES
177 | viewController
178 | window
179 |
180 |
181 | YES
182 | OAuthTwitterDemoViewController
183 | UIWindow
184 |
185 |
186 |
187 | IBProjectSource
188 | Classes/OAuthTwitterDemoAppDelegate.h
189 |
190 |
191 |
192 | OAuthTwitterDemoAppDelegate
193 | NSObject
194 |
195 | IBUserSource
196 |
197 |
198 |
199 |
200 | OAuthTwitterDemoViewController
201 | UIViewController
202 |
203 | IBProjectSource
204 | Classes/OAuthTwitterDemoViewController.h
205 |
206 |
207 |
208 |
209 | 0
210 |
211 | com.apple.InterfaceBuilder.CocoaTouchPlugin.InterfaceBuilder3
212 |
213 |
214 | YES
215 | OAuthTwitterDemo.xcodeproj
216 | 3
217 |
218 |
219 |
--------------------------------------------------------------------------------
/Demo/Rsc/OAuthTwitterDemo-Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | English
7 | CFBundleDisplayName
8 | ${PRODUCT_NAME}
9 | CFBundleExecutable
10 | ${EXECUTABLE_NAME}
11 | CFBundleIconFile
12 |
13 | CFBundleIdentifier
14 | com.standalone.twitteroauthtest
15 | CFBundleInfoDictionaryVersion
16 | 6.0
17 | CFBundleName
18 | ${PRODUCT_NAME}
19 | CFBundlePackageType
20 | APPL
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 1.0
25 | LSRequiresIPhoneOS
26 |
27 | NSMainNibFile
28 | MainWindow
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Demo/Src/OAuthTwitterDemoAppDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAuthTwitterDemoAppDelegate.h
3 | // OAuthTwitterDemo
4 | //
5 | // Created by Ben Gottlieb on 7/24/09.
6 | // Copyright Stand Alone, Inc. 2009. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class OAuthTwitterDemoViewController;
12 |
13 | @interface OAuthTwitterDemoAppDelegate : NSObject {
14 | UIWindow *window;
15 | OAuthTwitterDemoViewController *viewController;
16 | }
17 |
18 | @property (nonatomic, retain) IBOutlet UIWindow *window;
19 | @property (nonatomic, retain) IBOutlet OAuthTwitterDemoViewController *viewController;
20 |
21 | @end
22 |
23 |
--------------------------------------------------------------------------------
/Demo/Src/OAuthTwitterDemoAppDelegate.m:
--------------------------------------------------------------------------------
1 | //
2 | // OAuthTwitterDemoAppDelegate.m
3 | // OAuthTwitterDemo
4 | //
5 | // Created by Ben Gottlieb on 7/24/09.
6 | // Copyright Stand Alone, Inc. 2009. All rights reserved.
7 | //
8 |
9 | #import "OAuthTwitterDemoAppDelegate.h"
10 | #import "OAuthTwitterDemoViewController.h"
11 |
12 | @implementation OAuthTwitterDemoAppDelegate
13 |
14 | @synthesize window;
15 | @synthesize viewController;
16 |
17 |
18 | - (void)applicationDidFinishLaunching:(UIApplication *)application {
19 |
20 | // Override point for customization after app launch
21 | window.rootViewController = viewController;
22 | [window makeKeyAndVisible];
23 | }
24 |
25 |
26 | - (void)dealloc {
27 | [viewController release];
28 | [window release];
29 | [super dealloc];
30 | }
31 |
32 |
33 | @end
34 |
--------------------------------------------------------------------------------
/Demo/Src/OAuthTwitterDemoViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAuthTwitterDemoViewController.h
3 | // OAuthTwitterDemo
4 | //
5 | // Created by Ben Gottlieb on 7/24/09.
6 | // Copyright Stand Alone, Inc. 2009. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "SA_OAuthTwitterController.h"
11 |
12 | @class SA_OAuthTwitterEngine;
13 |
14 |
15 | @interface OAuthTwitterDemoViewController : UIViewController {
16 | SA_OAuthTwitterEngine *_engine;
17 |
18 | }
19 |
20 | @end
21 |
22 |
--------------------------------------------------------------------------------
/Demo/Src/OAuthTwitterDemoViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // OAuthTwitterDemoViewController.m
3 | // OAuthTwitterDemo
4 | //
5 | // Created by Ben Gottlieb on 7/24/09.
6 | // Copyright Stand Alone, Inc. 2009. All rights reserved.
7 | //
8 |
9 | #import "OAuthTwitterDemoViewController.h"
10 | #import "SA_OAuthTwitterEngine.h"
11 |
12 |
13 | #define kOAuthConsumerKey @"" //REPLACE ME
14 | #define kOAuthConsumerSecret @"" //REPLACE ME
15 |
16 | @implementation OAuthTwitterDemoViewController
17 |
18 |
19 |
20 | //=============================================================================================================================
21 | #pragma mark SA_OAuthTwitterEngineDelegate
22 | - (void) storeCachedTwitterOAuthData: (NSString *) data forUsername: (NSString *) username {
23 | NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
24 |
25 | [defaults setObject: data forKey: @"authData"];
26 | [defaults synchronize];
27 | }
28 |
29 | - (NSString *) cachedTwitterOAuthDataForUsername: (NSString *) username {
30 | return [[NSUserDefaults standardUserDefaults] objectForKey: @"authData"];
31 | }
32 |
33 | //=============================================================================================================================
34 | #pragma mark SA_OAuthTwitterControllerDelegate
35 | - (void) OAuthTwitterController: (SA_OAuthTwitterController *) controller authenticatedWithUsername: (NSString *) username {
36 | NSLog(@"Authenicated for %@", username);
37 | }
38 |
39 | - (void) OAuthTwitterControllerFailed: (SA_OAuthTwitterController *) controller {
40 | NSLog(@"Authentication Failed!");
41 | }
42 |
43 | - (void) OAuthTwitterControllerCanceled: (SA_OAuthTwitterController *) controller {
44 | NSLog(@"Authentication Canceled.");
45 | }
46 |
47 | //=============================================================================================================================
48 | #pragma mark TwitterEngineDelegate
49 | - (void) requestSucceeded: (NSString *) requestIdentifier {
50 | NSLog(@"Request %@ succeeded", requestIdentifier);
51 | }
52 |
53 | - (void) requestFailed: (NSString *) requestIdentifier withError: (NSError *) error {
54 | NSLog(@"Request %@ failed with error: %@", requestIdentifier, error);
55 | }
56 |
57 |
58 |
59 | //=============================================================================================================================
60 | #pragma mark ViewController Stuff
61 | - (void)dealloc {
62 | [_engine release];
63 | [super dealloc];
64 | }
65 | - (void) viewDidAppear: (BOOL)animated {
66 | if (_engine) return;
67 | _engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate: self];
68 | _engine.consumerKey = kOAuthConsumerKey;
69 | _engine.consumerSecret = kOAuthConsumerSecret;
70 |
71 | UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self];
72 |
73 | if (controller)
74 | [self presentViewController: controller animated: YES completion: nil];
75 | else {
76 | [_engine sendUpdate: [NSString stringWithFormat: @"Already Updated. %@", [NSDate date]]];
77 | }
78 |
79 | }
80 |
81 |
82 | @end
83 |
--------------------------------------------------------------------------------
/Demo/Src/OAuthTwitterDemo_Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'OAuthTwitterDemo' target in the 'OAuthTwitterDemo' project
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #import
8 | #endif
9 |
--------------------------------------------------------------------------------
/Demo/Src/main.m:
--------------------------------------------------------------------------------
1 | //
2 | // main.m
3 | // OAuthTwitterDemo
4 | //
5 | // Created by Ben Gottlieb on 7/24/09.
6 | // Copyright Stand Alone, Inc. 2009. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | int main(int argc, char *argv[]) {
12 |
13 | NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
14 | int retVal = UIApplicationMain(argc, argv, nil, nil);
15 | [pool release];
16 | return retVal;
17 | }
18 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/.gitignore:
--------------------------------------------------------------------------------
1 | build/*
2 | OAuthConsumer-iPhoneLib.xcodeproj/*.mode1v3
3 | OAuthConsumer-iPhoneLib.xcodeproj/*.pbxuser
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/BuildCombined.sh:
--------------------------------------------------------------------------------
1 |
2 |
3 | xcodebuild -target "OAuthLib" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos clean build
4 | xcodebuild -target "OAuthLib" ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphonesimulator clean build
5 |
6 | lipo -create "Build/Debug-iphoneos/libOAuthConsumer_iPhone.a" "Build/Debug-iphonesimulator/libOAuthConsumer_iPhone.a" -output "../Twitter+OAuth/Libraries & Headers/libOAuth.a"
7 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/Crypto/Base64Transcoder.c:
--------------------------------------------------------------------------------
1 | /*
2 | * Base64Transcoder.c
3 | * Base64Test
4 | *
5 | * Created by Jonathan Wight on Tue Mar 18 2003.
6 | * Copyright (c) 2003 Toxic Software. All rights reserved.
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to deal
10 | * in the Software without restriction, including without limitation the rights
11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | * copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | * THE SOFTWARE.
25 | *
26 | */
27 |
28 | #include "Base64Transcoder.h"
29 |
30 | #include
31 | #include
32 |
33 | const u_int8_t kBase64EncodeTable[64] = {
34 | /* 0 */ 'A', /* 1 */ 'B', /* 2 */ 'C', /* 3 */ 'D',
35 | /* 4 */ 'E', /* 5 */ 'F', /* 6 */ 'G', /* 7 */ 'H',
36 | /* 8 */ 'I', /* 9 */ 'J', /* 10 */ 'K', /* 11 */ 'L',
37 | /* 12 */ 'M', /* 13 */ 'N', /* 14 */ 'O', /* 15 */ 'P',
38 | /* 16 */ 'Q', /* 17 */ 'R', /* 18 */ 'S', /* 19 */ 'T',
39 | /* 20 */ 'U', /* 21 */ 'V', /* 22 */ 'W', /* 23 */ 'X',
40 | /* 24 */ 'Y', /* 25 */ 'Z', /* 26 */ 'a', /* 27 */ 'b',
41 | /* 28 */ 'c', /* 29 */ 'd', /* 30 */ 'e', /* 31 */ 'f',
42 | /* 32 */ 'g', /* 33 */ 'h', /* 34 */ 'i', /* 35 */ 'j',
43 | /* 36 */ 'k', /* 37 */ 'l', /* 38 */ 'm', /* 39 */ 'n',
44 | /* 40 */ 'o', /* 41 */ 'p', /* 42 */ 'q', /* 43 */ 'r',
45 | /* 44 */ 's', /* 45 */ 't', /* 46 */ 'u', /* 47 */ 'v',
46 | /* 48 */ 'w', /* 49 */ 'x', /* 50 */ 'y', /* 51 */ 'z',
47 | /* 52 */ '0', /* 53 */ '1', /* 54 */ '2', /* 55 */ '3',
48 | /* 56 */ '4', /* 57 */ '5', /* 58 */ '6', /* 59 */ '7',
49 | /* 60 */ '8', /* 61 */ '9', /* 62 */ '+', /* 63 */ '/'
50 | };
51 |
52 | /*
53 | -1 = Base64 end of data marker.
54 | -2 = White space (tabs, cr, lf, space)
55 | -3 = Noise (all non whitespace, non-base64 characters)
56 | -4 = Dangerous noise
57 | -5 = Illegal noise (null byte)
58 | */
59 |
60 | const int8_t kBase64DecodeTable[128] = {
61 | /* 0x00 */ -5, /* 0x01 */ -3, /* 0x02 */ -3, /* 0x03 */ -3,
62 | /* 0x04 */ -3, /* 0x05 */ -3, /* 0x06 */ -3, /* 0x07 */ -3,
63 | /* 0x08 */ -3, /* 0x09 */ -2, /* 0x0a */ -2, /* 0x0b */ -2,
64 | /* 0x0c */ -2, /* 0x0d */ -2, /* 0x0e */ -3, /* 0x0f */ -3,
65 | /* 0x10 */ -3, /* 0x11 */ -3, /* 0x12 */ -3, /* 0x13 */ -3,
66 | /* 0x14 */ -3, /* 0x15 */ -3, /* 0x16 */ -3, /* 0x17 */ -3,
67 | /* 0x18 */ -3, /* 0x19 */ -3, /* 0x1a */ -3, /* 0x1b */ -3,
68 | /* 0x1c */ -3, /* 0x1d */ -3, /* 0x1e */ -3, /* 0x1f */ -3,
69 | /* ' ' */ -2, /* '!' */ -3, /* '"' */ -3, /* '#' */ -3,
70 | /* '$' */ -3, /* '%' */ -3, /* '&' */ -3, /* ''' */ -3,
71 | /* '(' */ -3, /* ')' */ -3, /* '*' */ -3, /* '+' */ 62,
72 | /* ',' */ -3, /* '-' */ -3, /* '.' */ -3, /* '/' */ 63,
73 | /* '0' */ 52, /* '1' */ 53, /* '2' */ 54, /* '3' */ 55,
74 | /* '4' */ 56, /* '5' */ 57, /* '6' */ 58, /* '7' */ 59,
75 | /* '8' */ 60, /* '9' */ 61, /* ':' */ -3, /* ';' */ -3,
76 | /* '<' */ -3, /* '=' */ -1, /* '>' */ -3, /* '?' */ -3,
77 | /* '@' */ -3, /* 'A' */ 0, /* 'B' */ 1, /* 'C' */ 2,
78 | /* 'D' */ 3, /* 'E' */ 4, /* 'F' */ 5, /* 'G' */ 6,
79 | /* 'H' */ 7, /* 'I' */ 8, /* 'J' */ 9, /* 'K' */ 10,
80 | /* 'L' */ 11, /* 'M' */ 12, /* 'N' */ 13, /* 'O' */ 14,
81 | /* 'P' */ 15, /* 'Q' */ 16, /* 'R' */ 17, /* 'S' */ 18,
82 | /* 'T' */ 19, /* 'U' */ 20, /* 'V' */ 21, /* 'W' */ 22,
83 | /* 'X' */ 23, /* 'Y' */ 24, /* 'Z' */ 25, /* '[' */ -3,
84 | /* '\' */ -3, /* ']' */ -3, /* '^' */ -3, /* '_' */ -3,
85 | /* '`' */ -3, /* 'a' */ 26, /* 'b' */ 27, /* 'c' */ 28,
86 | /* 'd' */ 29, /* 'e' */ 30, /* 'f' */ 31, /* 'g' */ 32,
87 | /* 'h' */ 33, /* 'i' */ 34, /* 'j' */ 35, /* 'k' */ 36,
88 | /* 'l' */ 37, /* 'm' */ 38, /* 'n' */ 39, /* 'o' */ 40,
89 | /* 'p' */ 41, /* 'q' */ 42, /* 'r' */ 43, /* 's' */ 44,
90 | /* 't' */ 45, /* 'u' */ 46, /* 'v' */ 47, /* 'w' */ 48,
91 | /* 'x' */ 49, /* 'y' */ 50, /* 'z' */ 51, /* '{' */ -3,
92 | /* '|' */ -3, /* '}' */ -3, /* '~' */ -3, /* 0x7f */ -3
93 | };
94 |
95 | const u_int8_t kBits_00000011 = 0x03;
96 | const u_int8_t kBits_00001111 = 0x0F;
97 | const u_int8_t kBits_00110000 = 0x30;
98 | const u_int8_t kBits_00111100 = 0x3C;
99 | const u_int8_t kBits_00111111 = 0x3F;
100 | const u_int8_t kBits_11000000 = 0xC0;
101 | const u_int8_t kBits_11110000 = 0xF0;
102 | const u_int8_t kBits_11111100 = 0xFC;
103 |
104 | size_t EstimateBas64EncodedDataSize(size_t inDataSize)
105 | {
106 | size_t theEncodedDataSize = (int)ceil(inDataSize / 3.0) * 4;
107 | theEncodedDataSize = theEncodedDataSize / 72 * 74 + theEncodedDataSize % 72;
108 | return(theEncodedDataSize);
109 | }
110 |
111 | size_t EstimateBas64DecodedDataSize(size_t inDataSize)
112 | {
113 | size_t theDecodedDataSize = (int)ceil(inDataSize / 4.0) * 3;
114 | //theDecodedDataSize = theDecodedDataSize / 72 * 74 + theDecodedDataSize % 72;
115 | return(theDecodedDataSize);
116 | }
117 |
118 | bool Base64EncodeData(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize)
119 | {
120 | size_t theEncodedDataSize = EstimateBas64EncodedDataSize(inInputDataSize);
121 | if (*ioOutputDataSize < theEncodedDataSize)
122 | return(false);
123 | *ioOutputDataSize = theEncodedDataSize;
124 | const u_int8_t *theInPtr = (const u_int8_t *)inInputData;
125 | u_int32_t theInIndex = 0, theOutIndex = 0;
126 | for (; theInIndex < (inInputDataSize / 3) * 3; theInIndex += 3)
127 | {
128 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_11111100) >> 2];
129 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_00000011) << 4 | (theInPtr[theInIndex + 1] & kBits_11110000) >> 4];
130 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex + 1] & kBits_00001111) << 2 | (theInPtr[theInIndex + 2] & kBits_11000000) >> 6];
131 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex + 2] & kBits_00111111) >> 0];
132 | if (theOutIndex % 74 == 72)
133 | {
134 | outOutputData[theOutIndex++] = '\r';
135 | outOutputData[theOutIndex++] = '\n';
136 | }
137 | }
138 | const size_t theRemainingBytes = inInputDataSize - theInIndex;
139 | if (theRemainingBytes == 1)
140 | {
141 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_11111100) >> 2];
142 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_00000011) << 4 | (0 & kBits_11110000) >> 4];
143 | outOutputData[theOutIndex++] = '=';
144 | outOutputData[theOutIndex++] = '=';
145 | if (theOutIndex % 74 == 72)
146 | {
147 | outOutputData[theOutIndex++] = '\r';
148 | outOutputData[theOutIndex++] = '\n';
149 | }
150 | }
151 | else if (theRemainingBytes == 2)
152 | {
153 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_11111100) >> 2];
154 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex] & kBits_00000011) << 4 | (theInPtr[theInIndex + 1] & kBits_11110000) >> 4];
155 | outOutputData[theOutIndex++] = kBase64EncodeTable[(theInPtr[theInIndex + 1] & kBits_00001111) << 2 | (0 & kBits_11000000) >> 6];
156 | outOutputData[theOutIndex++] = '=';
157 | if (theOutIndex % 74 == 72)
158 | {
159 | outOutputData[theOutIndex++] = '\r';
160 | outOutputData[theOutIndex++] = '\n';
161 | }
162 | }
163 | return(true);
164 | }
165 |
166 | bool Base64DecodeData(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize)
167 | {
168 | memset(ioOutputData, '.', *ioOutputDataSize);
169 |
170 | size_t theDecodedDataSize = EstimateBas64DecodedDataSize(inInputDataSize);
171 | if (*ioOutputDataSize < theDecodedDataSize)
172 | return(false);
173 | *ioOutputDataSize = 0;
174 | const u_int8_t *theInPtr = (const u_int8_t *)inInputData;
175 | u_int8_t *theOutPtr = (u_int8_t *)ioOutputData;
176 | size_t theInIndex = 0, theOutIndex = 0;
177 | u_int8_t theOutputOctet;
178 | size_t theSequence = 0;
179 | for (; theInIndex < inInputDataSize; )
180 | {
181 | int8_t theSextet = 0;
182 |
183 | int8_t theCurrentInputOctet = theInPtr[theInIndex];
184 | theSextet = kBase64DecodeTable[theCurrentInputOctet];
185 | if (theSextet == -1)
186 | break;
187 | while (theSextet == -2)
188 | {
189 | theCurrentInputOctet = theInPtr[++theInIndex];
190 | theSextet = kBase64DecodeTable[theCurrentInputOctet];
191 | }
192 | while (theSextet == -3)
193 | {
194 | theCurrentInputOctet = theInPtr[++theInIndex];
195 | theSextet = kBase64DecodeTable[theCurrentInputOctet];
196 | }
197 | if (theSequence == 0)
198 | {
199 | theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 2 & kBits_11111100;
200 | }
201 | else if (theSequence == 1)
202 | {
203 | theOutputOctet |= (theSextet >- 0 ? theSextet : 0) >> 4 & kBits_00000011;
204 | theOutPtr[theOutIndex++] = theOutputOctet;
205 | }
206 | else if (theSequence == 2)
207 | {
208 | theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 4 & kBits_11110000;
209 | }
210 | else if (theSequence == 3)
211 | {
212 | theOutputOctet |= (theSextet >= 0 ? theSextet : 0) >> 2 & kBits_00001111;
213 | theOutPtr[theOutIndex++] = theOutputOctet;
214 | }
215 | else if (theSequence == 4)
216 | {
217 | theOutputOctet = (theSextet >= 0 ? theSextet : 0) << 6 & kBits_11000000;
218 | }
219 | else if (theSequence == 5)
220 | {
221 | theOutputOctet |= (theSextet >= 0 ? theSextet : 0) >> 0 & kBits_00111111;
222 | theOutPtr[theOutIndex++] = theOutputOctet;
223 | }
224 | theSequence = (theSequence + 1) % 6;
225 | if (theSequence != 2 && theSequence != 4)
226 | theInIndex++;
227 | }
228 | *ioOutputDataSize = theOutIndex;
229 | return(true);
230 | }
231 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/Crypto/Base64Transcoder.h:
--------------------------------------------------------------------------------
1 | /*
2 | * Base64Transcoder.h
3 | * Base64Test
4 | *
5 | * Created by Jonathan Wight on Tue Mar 18 2003.
6 | * Copyright (c) 2003 Toxic Software. All rights reserved.
7 | *
8 | * Permission is hereby granted, free of charge, to any person obtaining a copy
9 | * of this software and associated documentation files (the "Software"), to deal
10 | * in the Software without restriction, including without limitation the rights
11 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | * copies of the Software, and to permit persons to whom the Software is
13 | * furnished to do so, subject to the following conditions:
14 | *
15 | * The above copyright notice and this permission notice shall be included in
16 | * all copies or substantial portions of the Software.
17 | *
18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | * THE SOFTWARE.
25 | *
26 | */
27 |
28 | #include
29 | #include
30 |
31 | extern size_t EstimateBas64EncodedDataSize(size_t inDataSize);
32 | extern size_t EstimateBas64DecodedDataSize(size_t inDataSize);
33 |
34 | extern bool Base64EncodeData(const void *inInputData, size_t inInputDataSize, char *outOutputData, size_t *ioOutputDataSize);
35 | extern bool Base64DecodeData(const void *inInputData, size_t inInputDataSize, void *ioOutputData, size_t *ioOutputDataSize);
36 |
37 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/Crypto/hmac.c:
--------------------------------------------------------------------------------
1 | //
2 | // hmac.c
3 | // OAuthConsumer
4 | //
5 | // Created by Jonathan Wight on 4/8/8.
6 | // Copyright 2008 Jonathan Wight. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | /*
27 | * Implementation of HMAC-SHA1. Adapted from example at http://tools.ietf.org/html/rfc2104
28 |
29 | */
30 |
31 | #include "sha1.h"
32 |
33 | #include
34 | #include
35 |
36 | void hmac_sha1(const unsigned char *inText, size_t inTextLength, unsigned char* inKey, size_t inKeyLength, unsigned char *outDigest)
37 | {
38 | const size_t B = 64;
39 | const size_t L = 20;
40 |
41 | SHA1_CTX theSHA1Context;
42 | unsigned char k_ipad[B + 1]; /* inner padding - key XORd with ipad */
43 | unsigned char k_opad[B + 1]; /* outer padding - key XORd with opad */
44 |
45 | /* if key is longer than 64 bytes reset it to key=SHA1 (key) */
46 | if (inKeyLength > B)
47 | {
48 | SHA1Init(&theSHA1Context);
49 | SHA1Update(&theSHA1Context, inKey, (unsigned int) inKeyLength);
50 | SHA1Final(inKey, &theSHA1Context);
51 | inKeyLength = L;
52 | }
53 |
54 | /* start out by storing key in pads */
55 | memset(k_ipad, 0, sizeof k_ipad);
56 | memset(k_opad, 0, sizeof k_opad);
57 | memcpy(k_ipad, inKey, inKeyLength);
58 | memcpy(k_opad, inKey, inKeyLength);
59 |
60 | /* XOR key with ipad and opad values */
61 | int i;
62 | for (i = 0; i < B; i++)
63 | {
64 | k_ipad[i] ^= 0x36;
65 | k_opad[i] ^= 0x5c;
66 | }
67 |
68 | /*
69 | * perform inner SHA1
70 | */
71 | SHA1Init(&theSHA1Context); /* init context for 1st pass */
72 | SHA1Update(&theSHA1Context, k_ipad, B); /* start with inner pad */
73 | SHA1Update(&theSHA1Context, (unsigned char *)inText, (unsigned int) inTextLength); /* then text of datagram */
74 | SHA1Final((unsigned char *)outDigest, &theSHA1Context); /* finish up 1st pass */
75 |
76 | /*
77 | * perform outer SHA1
78 | */
79 | SHA1Init(&theSHA1Context); /* init context for 2nd
80 | * pass */
81 | SHA1Update(&theSHA1Context, k_opad, B); /* start with outer pad */
82 | SHA1Update(&theSHA1Context, outDigest, L); /* then results of 1st
83 | * hash */
84 | SHA1Final(outDigest, &theSHA1Context); /* finish up 2nd pass */
85 |
86 | }
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/Crypto/hmac.h:
--------------------------------------------------------------------------------
1 | //
2 | // hmac.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jonathan Wight on 4/8/8.
6 | // Copyright 2008 Jonathan Wight. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | #ifndef HMAC_H
27 | #define HMAC_H 1
28 |
29 | extern void hmac_sha1(const unsigned char *inText, int inTextLength, unsigned char* inKey, const unsigned int inKeyLength, unsigned char *outDigest);
30 |
31 | #endif /* HMAC_H */
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/Crypto/sha1.c:
--------------------------------------------------------------------------------
1 | /*
2 | SHA-1 in C
3 | By Steve Reid
4 | 100% Public Domain
5 |
6 | Test Vectors (from FIPS PUB 180-1)
7 | "abc"
8 | A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D
9 | "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq"
10 | 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1
11 | A million repetitions of "a"
12 | 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F
13 | */
14 |
15 | /* #define LITTLE_ENDIAN * This should be #define'd if true. */
16 | #if __LITTLE_ENDIAN__
17 | #define LITTLE_ENDIAN
18 | #endif
19 |
20 | #define SHA1HANDSOFF
21 | /* #define SHA1HANDSOFF * Copies data before messing with it. */
22 |
23 | #include
24 | #include
25 |
26 | #include "sha1.h"
27 |
28 | void SHA1Transform(unsigned long state[5], unsigned char buffer[64]);
29 |
30 | #define rol(value, bits) (((value) << (bits)) | ((value) >> (32 - (bits))))
31 |
32 | /* blk0() and blk() perform the initial expand. */
33 | /* I got the idea of expanding during the round function from SSLeay */
34 | #ifdef LITTLE_ENDIAN
35 | #define blk0(i) (block->l[i] = (rol(block->l[i],24)&0xFF00FF00) \
36 | |(rol(block->l[i],8)&0x00FF00FF))
37 | #else
38 | #define blk0(i) block->l[i]
39 | #endif
40 | #define blk(i) (block->l[i&15] = rol(block->l[(i+13)&15]^block->l[(i+8)&15] \
41 | ^block->l[(i+2)&15]^block->l[i&15],1))
42 |
43 | /* (R0+R1), R2, R3, R4 are the different operations used in SHA1 */
44 | #define R0(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk0(i)+0x5A827999+rol(v,5);w=rol(w,30);
45 | #define R1(v,w,x,y,z,i) z+=((w&(x^y))^y)+blk(i)+0x5A827999+rol(v,5);w=rol(w,30);
46 | #define R2(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0x6ED9EBA1+rol(v,5);w=rol(w,30);
47 | #define R3(v,w,x,y,z,i) z+=(((w|x)&y)|(w&x))+blk(i)+0x8F1BBCDC+rol(v,5);w=rol(w,30);
48 | #define R4(v,w,x,y,z,i) z+=(w^x^y)+blk(i)+0xCA62C1D6+rol(v,5);w=rol(w,30);
49 |
50 |
51 | /* Hash a single 512-bit block. This is the core of the algorithm. */
52 |
53 | void SHA1Transform(unsigned long state[5], unsigned char buffer[64])
54 | {
55 | unsigned long a, b, c, d, e;
56 | typedef union {
57 | unsigned char c[64];
58 | unsigned long l[16];
59 | } CHAR64LONG16;
60 | CHAR64LONG16* block;
61 | #ifdef SHA1HANDSOFF
62 | static unsigned char workspace[64];
63 | block = (CHAR64LONG16*)workspace;
64 | memcpy(block, buffer, 64);
65 | #else
66 | block = (CHAR64LONG16*)buffer;
67 | #endif
68 | /* Copy context->state[] to working vars */
69 | a = state[0];
70 | b = state[1];
71 | c = state[2];
72 | d = state[3];
73 | e = state[4];
74 | /* 4 rounds of 20 operations each. Loop unrolled. */
75 | R0(a,b,c,d,e, 0); R0(e,a,b,c,d, 1); R0(d,e,a,b,c, 2); R0(c,d,e,a,b, 3);
76 | R0(b,c,d,e,a, 4); R0(a,b,c,d,e, 5); R0(e,a,b,c,d, 6); R0(d,e,a,b,c, 7);
77 | R0(c,d,e,a,b, 8); R0(b,c,d,e,a, 9); R0(a,b,c,d,e,10); R0(e,a,b,c,d,11);
78 | R0(d,e,a,b,c,12); R0(c,d,e,a,b,13); R0(b,c,d,e,a,14); R0(a,b,c,d,e,15);
79 | R1(e,a,b,c,d,16); R1(d,e,a,b,c,17); R1(c,d,e,a,b,18); R1(b,c,d,e,a,19);
80 | R2(a,b,c,d,e,20); R2(e,a,b,c,d,21); R2(d,e,a,b,c,22); R2(c,d,e,a,b,23);
81 | R2(b,c,d,e,a,24); R2(a,b,c,d,e,25); R2(e,a,b,c,d,26); R2(d,e,a,b,c,27);
82 | R2(c,d,e,a,b,28); R2(b,c,d,e,a,29); R2(a,b,c,d,e,30); R2(e,a,b,c,d,31);
83 | R2(d,e,a,b,c,32); R2(c,d,e,a,b,33); R2(b,c,d,e,a,34); R2(a,b,c,d,e,35);
84 | R2(e,a,b,c,d,36); R2(d,e,a,b,c,37); R2(c,d,e,a,b,38); R2(b,c,d,e,a,39);
85 | R3(a,b,c,d,e,40); R3(e,a,b,c,d,41); R3(d,e,a,b,c,42); R3(c,d,e,a,b,43);
86 | R3(b,c,d,e,a,44); R3(a,b,c,d,e,45); R3(e,a,b,c,d,46); R3(d,e,a,b,c,47);
87 | R3(c,d,e,a,b,48); R3(b,c,d,e,a,49); R3(a,b,c,d,e,50); R3(e,a,b,c,d,51);
88 | R3(d,e,a,b,c,52); R3(c,d,e,a,b,53); R3(b,c,d,e,a,54); R3(a,b,c,d,e,55);
89 | R3(e,a,b,c,d,56); R3(d,e,a,b,c,57); R3(c,d,e,a,b,58); R3(b,c,d,e,a,59);
90 | R4(a,b,c,d,e,60); R4(e,a,b,c,d,61); R4(d,e,a,b,c,62); R4(c,d,e,a,b,63);
91 | R4(b,c,d,e,a,64); R4(a,b,c,d,e,65); R4(e,a,b,c,d,66); R4(d,e,a,b,c,67);
92 | R4(c,d,e,a,b,68); R4(b,c,d,e,a,69); R4(a,b,c,d,e,70); R4(e,a,b,c,d,71);
93 | R4(d,e,a,b,c,72); R4(c,d,e,a,b,73); R4(b,c,d,e,a,74); R4(a,b,c,d,e,75);
94 | R4(e,a,b,c,d,76); R4(d,e,a,b,c,77); R4(c,d,e,a,b,78); R4(b,c,d,e,a,79);
95 | /* Add the working vars back into context.state[] */
96 | state[0] += a;
97 | state[1] += b;
98 | state[2] += c;
99 | state[3] += d;
100 | state[4] += e;
101 | /* Wipe variables */
102 | a = b = c = d = e = 0;
103 | }
104 |
105 |
106 | /* SHA1Init - Initialize new context */
107 |
108 | void SHA1Init(SHA1_CTX* context)
109 | {
110 | /* SHA1 initialization constants */
111 | context->state[0] = 0x67452301;
112 | context->state[1] = 0xEFCDAB89;
113 | context->state[2] = 0x98BADCFE;
114 | context->state[3] = 0x10325476;
115 | context->state[4] = 0xC3D2E1F0;
116 | context->count[0] = context->count[1] = 0;
117 | }
118 |
119 |
120 | /* Run your data through this. */
121 |
122 | void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len)
123 | {
124 | unsigned long i, j;
125 |
126 | j = (context->count[0] >> 3) & 63;
127 | if ((context->count[0] += len << 3) < (len << 3)) context->count[1]++;
128 | context->count[1] += (len >> 29);
129 | if ((j + len) > 63) {
130 | memcpy(&context->buffer[j], data, (i = 64-j));
131 | SHA1Transform(context->state, context->buffer);
132 | for ( ; i + 63 < len; i += 64) {
133 | SHA1Transform(context->state, &data[i]);
134 | }
135 | j = 0;
136 | }
137 | else i = 0;
138 | memcpy(&context->buffer[j], &data[i], len - i);
139 | }
140 |
141 |
142 | /* Add padding and return the message digest. */
143 |
144 | void SHA1Final(unsigned char digest[20], SHA1_CTX* context)
145 | {
146 | unsigned long i, j;
147 | unsigned char finalcount[8];
148 |
149 | for (i = 0; i < 8; i++) {
150 | finalcount[i] = (unsigned char)((context->count[(i >= 4 ? 0 : 1)]
151 | >> ((3-(i & 3)) * 8) ) & 255); /* Endian independent */
152 | }
153 | SHA1Update(context, (unsigned char *)"\200", 1);
154 | while ((context->count[0] & 504) != 448) {
155 | SHA1Update(context, (unsigned char *)"\0", 1);
156 | }
157 | SHA1Update(context, finalcount, 8); /* Should cause a SHA1Transform() */
158 | for (i = 0; i < 20; i++) {
159 | digest[i] = (unsigned char)
160 | ((context->state[i>>2] >> ((3-(i & 3)) * 8) ) & 255);
161 | }
162 | /* Wipe variables */
163 | i = j = 0;
164 | memset(context->buffer, 0, 64);
165 | memset(context->state, 0, 20);
166 | memset(context->count, 0, 8);
167 | memset(&finalcount, 0, 8);
168 | #ifdef SHA1HANDSOFF /* make SHA1Transform overwrite it's own static vars */
169 | SHA1Transform(context->state, context->buffer);
170 | #endif
171 | }
172 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/Crypto/sha1.h:
--------------------------------------------------------------------------------
1 |
2 | // From http://www.mirrors.wiretapped.net/security/cryptography/hashes/sha1/sha1.c
3 |
4 | typedef struct {
5 | unsigned long state[5];
6 | unsigned long count[2];
7 | unsigned char buffer[64];
8 | } SHA1_CTX;
9 |
10 | extern void SHA1Init(SHA1_CTX* context);
11 | extern void SHA1Update(SHA1_CTX* context, unsigned char* data, unsigned int len);
12 | extern void SHA1Final(unsigned char digest[20], SHA1_CTX* context);
13 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/NSMutableURLRequest+Parameters.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSMutableURLRequest+Parameters.h
3 | //
4 | // Created by Jon Crosby on 10/19/07.
5 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import
26 | #import "OARequestParameter.h"
27 | #import "NSURL+Base.h"
28 |
29 |
30 | @interface NSMutableURLRequest (OAParameterAdditions)
31 |
32 | - (NSArray *)parameters;
33 | - (void)setParameters:(NSArray *)parameters;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/NSMutableURLRequest+Parameters.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSMutableURLRequest+Parameters.m
3 | //
4 | // Created by Jon Crosby on 10/19/07.
5 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 |
26 | #import "NSMutableURLRequest+Parameters.h"
27 |
28 |
29 | @implementation NSMutableURLRequest (OAParameterAdditions)
30 |
31 | - (NSArray *)parameters
32 | {
33 | NSString *encodedParameters;
34 | BOOL shouldfree = NO;
35 |
36 | if ([[self HTTPMethod] isEqualToString:@"GET"] || [[self HTTPMethod] isEqualToString:@"DELETE"])
37 | encodedParameters = [[self URL] query];
38 | else
39 | {
40 | // POST, PUT
41 | shouldfree = YES;
42 | encodedParameters = [[NSString alloc] initWithData:[self HTTPBody] encoding:NSASCIIStringEncoding];
43 | }
44 |
45 | if ((encodedParameters == nil) || ([encodedParameters isEqualToString:@""]))
46 | return nil;
47 |
48 | NSArray *encodedParameterPairs = [encodedParameters componentsSeparatedByString:@"&"];
49 | NSMutableArray *requestParameters = [[NSMutableArray alloc] initWithCapacity:16];
50 |
51 | for (NSString *encodedPair in encodedParameterPairs)
52 | {
53 | NSArray *encodedPairElements = [encodedPair componentsSeparatedByString:@"="];
54 | OARequestParameter *parameter = [OARequestParameter requestParameterWithName:[[encodedPairElements objectAtIndex:0] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]
55 | value:[[encodedPairElements objectAtIndex:1] stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
56 | [requestParameters addObject:parameter];
57 | }
58 |
59 | // Cleanup
60 | if (shouldfree)
61 | [encodedParameters release];
62 |
63 | return [requestParameters autorelease];
64 | }
65 |
66 | - (void)setParameters:(NSArray *)parameters
67 | {
68 | NSMutableString *encodedParameterPairs = [NSMutableString stringWithCapacity:256];
69 |
70 | int position = 1;
71 | for (OARequestParameter *requestParameter in parameters)
72 | {
73 | [encodedParameterPairs appendString:[requestParameter URLEncodedNameValuePair]];
74 | if (position < [parameters count])
75 | [encodedParameterPairs appendString:@"&"];
76 |
77 | position++;
78 | }
79 |
80 | if ([[self HTTPMethod] isEqualToString:@"GET"] || [[self HTTPMethod] isEqualToString:@"DELETE"])
81 | [self setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@", [[self URL] URLStringWithoutQuery], encodedParameterPairs]]];
82 | else
83 | {
84 | // POST, PUT
85 | NSData *postData = [encodedParameterPairs dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
86 | [self setHTTPBody:postData];
87 | [self setValue:[NSString stringWithFormat:@"%d", (UInt16) [postData length]] forHTTPHeaderField:@"Content-Length"];
88 | [self setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
89 | }
90 | }
91 |
92 | @end
93 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/NSString+URLEncoding.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+URLEncoding.h
3 | //
4 | // Created by Jon Crosby on 10/19/07.
5 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 |
26 | #import
27 |
28 |
29 | @interface NSString (OAURLEncodingAdditions)
30 |
31 | - (NSString *)URLEncodedString;
32 | - (NSString *)URLDecodedString;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/NSString+URLEncoding.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+URLEncoding.m
3 | //
4 | // Created by Jon Crosby on 10/19/07.
5 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 |
26 | #import "NSString+URLEncoding.h"
27 |
28 |
29 | @implementation NSString (OAURLEncodingAdditions)
30 |
31 | - (NSString *)URLEncodedString
32 | {
33 | NSString *result = (NSString *)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault,
34 | (CFStringRef)self,
35 | NULL,
36 | CFSTR("!*'();:@&=+$,/?%#[]"),
37 | kCFStringEncodingUTF8);
38 | [result autorelease];
39 | return result;
40 | }
41 |
42 | - (NSString*)URLDecodedString
43 | {
44 | NSString *result = (NSString *)CFURLCreateStringByReplacingPercentEscapesUsingEncoding(kCFAllocatorDefault,
45 | (CFStringRef)self,
46 | CFSTR(""),
47 | kCFStringEncodingUTF8);
48 | [result autorelease];
49 | return result;
50 | }
51 |
52 | @end
53 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/NSURL+Base.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSURL+Base.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 |
29 |
30 | @interface NSURL (OABaseAdditions)
31 |
32 | - (NSString *)URLStringWithoutQuery;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/NSURL+Base.m:
--------------------------------------------------------------------------------
1 | //
2 | // NSURL+Base.m
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import "NSURL+Base.h"
28 |
29 |
30 | @implementation NSURL (OABaseAdditions)
31 |
32 | - (NSString *)URLStringWithoutQuery
33 | {
34 | NSArray *parts = [[self absoluteString] componentsSeparatedByString:@"?"];
35 | return [parts objectAtIndex:0];
36 | }
37 |
38 | @end
39 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAAsynchronousDataFetcher.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAAsynchronousDataFetcher.h
3 | // OAuthConsumer
4 | //
5 | // Created by Zsombor Szabó on 12/3/08.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import
26 |
27 | #import "OAMutableURLRequest.h"
28 |
29 | @interface OAAsynchronousDataFetcher : NSObject {
30 | OAMutableURLRequest *request;
31 | NSURLResponse *response;
32 | NSURLConnection *connection;
33 | NSMutableData *responseData;
34 | id delegate;
35 | SEL didFinishSelector;
36 | SEL didFailSelector;
37 | }
38 |
39 | + (id)asynchronousFetcherWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector;
40 | - (id)initWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector;
41 |
42 | - (void)start;
43 | - (void)cancel;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAAsynchronousDataFetcher.m:
--------------------------------------------------------------------------------
1 | //
2 | // OAAsynchronousDataFetcher.m
3 | // OAuthConsumer
4 | //
5 | // Created by Zsombor Szabó on 12/3/08.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import "OAAsynchronousDataFetcher.h"
26 |
27 | #import "OAServiceTicket.h"
28 |
29 | @implementation OAAsynchronousDataFetcher
30 |
31 | + (id)asynchronousFetcherWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector
32 | {
33 | return [[[OAAsynchronousDataFetcher alloc] initWithRequest:aRequest delegate:aDelegate didFinishSelector:finishSelector didFailSelector:failSelector] autorelease];
34 | }
35 |
36 | - (id)initWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector
37 | {
38 | if (self = [super init])
39 | {
40 | request = [aRequest retain];
41 | delegate = aDelegate;
42 | didFinishSelector = finishSelector;
43 | didFailSelector = failSelector;
44 | }
45 | return self;
46 | }
47 |
48 | - (void)start
49 | {
50 | [request prepare];
51 |
52 | if (connection)
53 | [connection release];
54 |
55 | connection = [[NSURLConnection alloc] initWithRequest:request delegate:self];
56 |
57 | if (connection)
58 | {
59 | if (responseData)
60 | [responseData release];
61 | responseData = [[NSMutableData data] retain];
62 | }
63 | else
64 | {
65 | OAServiceTicket *ticket= [[OAServiceTicket alloc] initWithRequest:request
66 | response:nil
67 | didSucceed:NO];
68 | [delegate performSelector:didFailSelector
69 | withObject:ticket
70 | withObject:nil];
71 | [ticket release];
72 | }
73 | }
74 |
75 | - (void)cancel
76 | {
77 | if (connection)
78 | {
79 | [connection cancel];
80 | [connection release];
81 | connection = nil;
82 | }
83 | }
84 |
85 | - (void)dealloc
86 | {
87 | if (request) [request release];
88 | if (connection) [connection release];
89 | if (response) [response release];
90 | if (responseData) [responseData release];
91 | [super dealloc];
92 | }
93 |
94 | #pragma mark -
95 | #pragma mark NSURLConnection methods
96 |
97 | - (void)connection:(NSURLConnection *)aConnection didReceiveResponse:(NSURLResponse *)aResponse
98 | {
99 | if (response)
100 | [response release];
101 | response = [aResponse retain];
102 | [responseData setLength:0];
103 | }
104 |
105 | - (void)connection:(NSURLConnection *)aConnection didReceiveData:(NSData *)data
106 | {
107 | [responseData appendData:data];
108 | }
109 |
110 | - (void)connection:(NSURLConnection *)aConnection didFailWithError:(NSError *)error
111 | {
112 | OAServiceTicket *ticket= [[OAServiceTicket alloc] initWithRequest:request
113 | response:response
114 | didSucceed:NO];
115 | [delegate performSelector:didFailSelector
116 | withObject:ticket
117 | withObject:error];
118 |
119 | [ticket release];
120 | }
121 |
122 | - (void)connectionDidFinishLoading:(NSURLConnection *)aConnection
123 | {
124 | OAServiceTicket *ticket = [[OAServiceTicket alloc] initWithRequest:request
125 | response:response
126 | didSucceed:[(NSHTTPURLResponse *)response statusCode] < 400];
127 | [delegate performSelector:didFinishSelector
128 | withObject:ticket
129 | withObject:responseData];
130 |
131 | [ticket release];
132 | }
133 |
134 | @end
135 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAConsumer.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAConsumer.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 |
29 |
30 | @interface OAConsumer : NSObject {
31 | @protected
32 | NSString *key;
33 | NSString *secret;
34 | }
35 | @property(retain) NSString *key;
36 | @property(retain) NSString *secret;
37 |
38 | - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret;
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAConsumer.m:
--------------------------------------------------------------------------------
1 | //
2 | // OAConsumer.m
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | #import "OAConsumer.h"
27 |
28 |
29 | @implementation OAConsumer
30 | @synthesize key, secret;
31 |
32 | #pragma mark init
33 |
34 | - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret
35 | {
36 | if (self = [super init])
37 | {
38 | self.key = aKey;
39 | self.secret = aSecret;
40 | }
41 | return self;
42 | }
43 |
44 | - (void)dealloc
45 | {
46 | [key release];
47 | [secret release];
48 | [super dealloc];
49 | }
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OADataFetcher.h:
--------------------------------------------------------------------------------
1 | //
2 | // OADataFetcher.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 11/5/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | #import
27 | #import "OAMutableURLRequest.h"
28 | #import "OAServiceTicket.h"
29 |
30 |
31 | @interface OADataFetcher : NSObject {
32 | @private
33 | OAMutableURLRequest *request;
34 | NSURLResponse *response;
35 | NSURLConnection *connection;
36 | NSError *error;
37 | NSData *responseData;
38 | id delegate;
39 | SEL didFinishSelector;
40 | SEL didFailSelector;
41 | }
42 |
43 | - (void)fetchDataWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OADataFetcher.m:
--------------------------------------------------------------------------------
1 | //
2 | // OADataFetcher.m
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 11/5/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import "OADataFetcher.h"
28 |
29 |
30 | @implementation OADataFetcher
31 |
32 | - (void)fetchDataWithRequest:(OAMutableURLRequest *)aRequest
33 | delegate:(id)aDelegate
34 | didFinishSelector:(SEL)finishSelector
35 | didFailSelector:(SEL)failSelector
36 | {
37 | request = aRequest;
38 | delegate = aDelegate;
39 | didFinishSelector = finishSelector;
40 | didFailSelector = failSelector;
41 |
42 | [request prepare];
43 |
44 | responseData = [NSURLConnection sendSynchronousRequest:request
45 | returningResponse:&response
46 | error:&error];
47 |
48 | if (response == nil || responseData == nil || error != nil) {
49 | OAServiceTicket *ticket= [[[OAServiceTicket alloc] initWithRequest:request
50 | response:response
51 | didSucceed:NO] autorelease];
52 | [delegate performSelector:didFailSelector
53 | withObject:ticket
54 | withObject:error];
55 | } else {
56 | OAServiceTicket *ticket = [[[OAServiceTicket alloc] initWithRequest:request
57 | response:response
58 | didSucceed:[(NSHTTPURLResponse *)response statusCode] < 400] autorelease];
59 | [delegate performSelector:didFinishSelector
60 | withObject:ticket
61 | withObject:responseData];
62 | }
63 | }
64 |
65 | @end
66 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAHMAC_SHA1SignatureProvider.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAHMAC_SHA1SignatureProvider.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 | #import "OASignatureProviding.h"
29 |
30 |
31 | @interface OAHMAC_SHA1SignatureProvider : NSObject
32 | @end
33 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAHMAC_SHA1SignatureProvider.m:
--------------------------------------------------------------------------------
1 | //
2 | // OAHMAC_SHA1SignatureProvider.m
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import "OAHMAC_SHA1SignatureProvider.h"
28 | #import
29 | #include
30 |
31 | #include "hmac.h"
32 | #include "Base64Transcoder.h"
33 |
34 | @implementation OAHMAC_SHA1SignatureProvider
35 |
36 | - (NSString *)name
37 | {
38 | return @"HMAC-SHA1";
39 | }
40 |
41 | - (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret
42 | {
43 | const char *cKey = [secret cStringUsingEncoding:NSASCIIStringEncoding];
44 | const char *cData = [text cStringUsingEncoding:NSASCIIStringEncoding];
45 |
46 | unsigned char cHMAC[CC_SHA1_DIGEST_LENGTH];
47 |
48 | CCHmac(kCCHmacAlgSHA1, cKey, strlen(cKey), cData, strlen(cData), cHMAC);
49 |
50 | NSData *HMAC = [[NSData alloc] initWithBytes:cHMAC
51 | length:sizeof(cHMAC)];
52 |
53 | NSString *hash = [HMAC base64EncodedStringWithOptions: 0];
54 | return hash;
55 | }
56 |
57 | @end
58 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAMutableURLRequest.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAMutableURLRequest.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 | #import "OAConsumer.h"
29 | #import "OAToken.h"
30 | #import "OAHMAC_SHA1SignatureProvider.h"
31 | #import "OASignatureProviding.h"
32 | #import "NSMutableURLRequest+Parameters.h"
33 | #import "NSURL+Base.h"
34 |
35 |
36 | @interface OAMutableURLRequest : NSMutableURLRequest {
37 | @protected
38 | OAConsumer *consumer;
39 | OAToken *token;
40 | NSString *realm;
41 | NSString *signature;
42 | id signatureProvider;
43 | NSString *nonce;
44 | NSString *timestamp;
45 | }
46 | @property(readonly) NSString *signature;
47 | @property(readonly) NSString *nonce;
48 | @property(nonatomic, readwrite, retain) NSArray *parameters;
49 |
50 | - (id)initWithURL:(NSURL *)aUrl
51 | consumer:(OAConsumer *)aConsumer
52 | token:(OAToken *)aToken
53 | realm:(NSString *)aRealm
54 | signatureProvider:(id)aProvider;
55 |
56 | - (id)initWithURL:(NSURL *)aUrl
57 | consumer:(OAConsumer *)aConsumer
58 | token:(OAToken *)aToken
59 | realm:(NSString *)aRealm
60 | signatureProvider:(id)aProvider
61 | nonce:(NSString *)aNonce
62 | timestamp:(NSString *)aTimestamp;
63 |
64 | - (void)prepare;
65 |
66 |
67 | - (void)_generateTimestamp;
68 | - (void)_generateNonce;
69 | - (NSString *)_signatureBaseString;
70 |
71 | - (NSString *)URLStringWithoutQueryFromURL: (NSURL *) url;
72 | - (NSString *) URLEncodedString: (NSString *) string;
73 | @end
74 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAPlaintextSignatureProvider.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAPlaintextSignatureProvider.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 | #import "OASignatureProviding.h"
29 |
30 | @interface OAPlaintextSignatureProvider : NSObject
31 | @end
32 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAPlaintextSignatureProvider.m:
--------------------------------------------------------------------------------
1 | //
2 | // OAPlaintextSignatureProvider.m
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import "OAPlaintextSignatureProvider.h"
28 | #import "NSString+URLEncoding.h"
29 |
30 |
31 | @implementation OAPlaintextSignatureProvider
32 |
33 | - (NSString *)name
34 | {
35 | return @"PLAINTEXT";
36 | }
37 |
38 | - (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret
39 | {
40 | return secret;
41 | }
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OARequestParameter.h:
--------------------------------------------------------------------------------
1 | //
2 | // OARequestParameter.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 | #import "NSString+URLEncoding.h"
29 |
30 |
31 | @interface OARequestParameter : NSObject {
32 | @protected
33 | NSString *name;
34 | NSString *value;
35 | }
36 | @property(retain) NSString *name;
37 | @property(retain) NSString *value;
38 |
39 | + (id)requestParameterWithName:(NSString *)aName value:(NSString *)aValue;
40 | - (id)initWithName:(NSString *)aName value:(NSString *)aValue;
41 | - (NSString *)URLEncodedName;
42 | - (NSString *)URLEncodedValue;
43 | - (NSString *)URLEncodedNameValuePair;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OARequestParameter.m:
--------------------------------------------------------------------------------
1 | //
2 | // OARequestParameter.m
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import "OARequestParameter.h"
28 |
29 |
30 | @implementation OARequestParameter
31 | @synthesize name, value;
32 |
33 | + (id)requestParameterWithName:(NSString *)aName value:(NSString *)aValue
34 | {
35 | return [[[OARequestParameter alloc] initWithName:aName value:aValue] autorelease];
36 | }
37 |
38 | - (id)initWithName:(NSString *)aName value:(NSString *)aValue
39 | {
40 | if (self = [super init])
41 | {
42 | self.name = aName;
43 | self.value = aValue;
44 | }
45 | return self;
46 | }
47 |
48 | - (void)dealloc
49 | {
50 | [name release];
51 | [value release];
52 | [super dealloc];
53 | }
54 |
55 | -(NSString *)urlEncode:(NSString*)stringThatNeedsEncoding
56 | {
57 | NSString *result = (NSString*)CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, (CFStringRef)stringThatNeedsEncoding, NULL, CFSTR("!*'\"();:@&=+$,/?#[]%<>{} "), kCFStringEncodingUTF8);
58 | return [result autorelease];
59 | }
60 |
61 | - (NSString *)URLEncodedName
62 | {
63 | return [self urlEncode:self.name]; //[self.name stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
64 | }
65 |
66 | - (NSString *)URLEncodedValue
67 | {
68 | return [self urlEncode:self.value]; //[self.value stringByAddingPercentEscapesUsingEncoding: NSUTF8StringEncoding];
69 | }
70 |
71 | - (NSString *)URLEncodedNameValuePair
72 | {
73 | return [NSString stringWithFormat:@"%@=%@", [self URLEncodedName], [self URLEncodedValue]];
74 | }
75 |
76 | @end
77 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAServiceTicket.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAServiceTicket.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 11/5/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 | #import "OAMutableURLRequest.h"
29 |
30 |
31 | @interface OAServiceTicket : NSObject {
32 | @private
33 | OAMutableURLRequest *request;
34 | NSURLResponse *response;
35 | BOOL didSucceed;
36 | }
37 | @property(retain) OAMutableURLRequest *request;
38 | @property(retain) NSURLResponse *response;
39 | @property(assign) BOOL didSucceed;
40 |
41 | - (id)initWithRequest:(OAMutableURLRequest *)aRequest response:(NSURLResponse *)aResponse didSucceed:(BOOL)success;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAServiceTicket.m:
--------------------------------------------------------------------------------
1 | //
2 | // OAServiceTicket.m
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 11/5/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import "OAServiceTicket.h"
28 |
29 |
30 | @implementation OAServiceTicket
31 | @synthesize request, response, didSucceed;
32 |
33 | - (id)initWithRequest:(OAMutableURLRequest *)aRequest response:(NSURLResponse *)aResponse didSucceed:(BOOL)success
34 | {
35 | if (self = [super init])
36 | {
37 | self.request = aRequest;
38 | self.response = aResponse;
39 | self.didSucceed = success;
40 | }
41 | return self;
42 | }
43 |
44 | - (void)dealloc
45 | {
46 | [request release];
47 | [response release];
48 | [super dealloc];
49 | }
50 |
51 | @end
52 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OASignatureProviding.h:
--------------------------------------------------------------------------------
1 | //
2 | // OASignatureProviding.h
3 | //
4 | // Created by Jon Crosby on 10/19/07.
5 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 |
26 | #import
27 |
28 |
29 | @protocol OASignatureProviding
30 |
31 | - (NSString *)name;
32 | - (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAToken.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAToken.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | #import
27 |
28 | @interface OAToken : NSObject {
29 | NSString *pin; //added for the Twitter OAuth implementation
30 |
31 | @protected
32 | NSString *key;
33 | NSString *secret;
34 | }
35 | @property(retain) NSString *pin; //added for the Twitter OAuth implementation
36 |
37 | @property(retain) NSString *key;
38 | @property(retain) NSString *secret;
39 |
40 | - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret;
41 | - (id)initWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix;
42 | - (id)initWithHTTPResponseBody:(NSString *)body;
43 | - (int)storeInUserDefaultsWithServiceProviderName:(NSString *)provider prefix:(NSString *)prefix;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAToken.m:
--------------------------------------------------------------------------------
1 | //
2 | // OAToken.m
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import "OAToken.h"
28 |
29 |
30 | @implementation OAToken
31 |
32 | @synthesize key, secret;
33 | @synthesize pin; //added for the Twitter OAuth implementation
34 |
35 | #pragma mark init
36 |
37 | - (id)init
38 | {
39 | if (self = [super init])
40 | {
41 | self.key = @"";
42 | self.secret = @"";
43 | }
44 | return self;
45 | }
46 |
47 | - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret
48 | {
49 | if (self = [super init])
50 | {
51 | self.key = aKey;
52 | self.secret = aSecret;
53 | }
54 | return self;
55 | }
56 |
57 | - (id)initWithHTTPResponseBody:(NSString *)body
58 | {
59 | if (self = [super init])
60 | {
61 | NSArray *pairs = [body componentsSeparatedByString:@"&"];
62 |
63 | for (NSString *pair in pairs) {
64 | NSArray *elements = [pair componentsSeparatedByString:@"="];
65 | if ([[elements objectAtIndex:0] isEqualToString:@"oauth_token"]) {
66 | self.key = [elements objectAtIndex:1];
67 | } else if ([[elements objectAtIndex:0] isEqualToString:@"oauth_token_secret"]) {
68 | self.secret = [elements objectAtIndex:1];
69 | } else if ([[elements objectAtIndex:0] isEqualToString:@"oauth_verifier"]) {
70 | self.pin = [elements objectAtIndex:1];
71 | }
72 | }
73 | }
74 | return self;
75 | }
76 |
77 | - (id)initWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix
78 | {
79 | if (self = [super init])
80 | {
81 | NSString *theKey = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"OAUTH_%@_%@_KEY", prefix, provider]];
82 | NSString *theSecret = [[NSUserDefaults standardUserDefaults] stringForKey:[NSString stringWithFormat:@"OAUTH_%@_%@_SECRET", prefix, provider]];
83 | if (theKey == NULL || theSecret == NULL)
84 | return(nil);
85 | self.key = theKey;
86 | self.secret = theSecret;
87 | }
88 | return self;
89 | }
90 |
91 | - (void)dealloc
92 | {
93 | [key release];
94 | [secret release];
95 | [super dealloc];
96 | }
97 |
98 | #pragma mark -
99 |
100 | - (int)storeInUserDefaultsWithServiceProviderName:(NSString *)provider prefix:(NSString *)prefix
101 | {
102 | [[NSUserDefaults standardUserDefaults] setObject:self.key forKey:[NSString stringWithFormat:@"OAUTH_%@_%@_KEY", prefix, provider]];
103 | [[NSUserDefaults standardUserDefaults] setObject:self.secret forKey:[NSString stringWithFormat:@"OAUTH_%@_%@_SECRET", prefix, provider]];
104 | [[NSUserDefaults standardUserDefaults] synchronize];
105 | return(0);
106 | }
107 |
108 | @end
109 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAToken_KeychainExtensions.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAToken_KeychainExtensions.h
3 | // TouchTheFireEagle
4 | //
5 | // Created by Jonathan Wight on 04/04/08.
6 | // Copyright 2008 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #import "OAToken.h"
10 |
11 | #import
12 |
13 | @interface OAToken (OAToken_KeychainExtensions)
14 |
15 | - (id)initWithKeychainUsingAppName:(NSString *)name serviceProviderName:(NSString *)provider;
16 | - (int)storeInDefaultKeychainWithAppName:(NSString *)name serviceProviderName:(NSString *)provider;
17 | - (int)storeInKeychain:(SecKeychainRef)keychain appName:(NSString *)name serviceProviderName:(NSString *)provider;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAToken_KeychainExtensions.m:
--------------------------------------------------------------------------------
1 | //
2 | // OAToken_KeychainExtensions.m
3 | // TouchTheFireEagle
4 | //
5 | // Created by Jonathan Wight on 04/04/08.
6 | // Copyright 2008 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #import "OAToken_KeychainExtensions.h"
10 |
11 | @implementation OAToken (OAToken_KeychainExtensions)
12 |
13 | - (id)initWithKeychainUsingAppName:(NSString *)name serviceProviderName:(NSString *)provider
14 | {
15 | [super init];
16 | SecKeychainItemRef item;
17 | NSString *serviceName = [NSString stringWithFormat:@"%@::OAuth::%@", name, provider];
18 | OSStatus status = SecKeychainFindGenericPassword(NULL,
19 | strlen([serviceName UTF8String]),
20 | [serviceName UTF8String],
21 | 0,
22 | NULL,
23 | NULL,
24 | NULL,
25 | &item);
26 | if (status != noErr) {
27 | return nil;
28 | }
29 |
30 | // from Advanced Mac OS X Programming, ch. 16
31 | UInt32 length;
32 | char *password;
33 | SecKeychainAttribute attributes[8];
34 | SecKeychainAttributeList list;
35 |
36 | attributes[0].tag = kSecAccountItemAttr;
37 | attributes[1].tag = kSecDescriptionItemAttr;
38 | attributes[2].tag = kSecLabelItemAttr;
39 | attributes[3].tag = kSecModDateItemAttr;
40 |
41 | list.count = 4;
42 | list.attr = attributes;
43 |
44 | status = SecKeychainItemCopyContent(item, NULL, &list, &length, (void **)&password);
45 |
46 | if (status == noErr) {
47 | self.key = [NSString stringWithCString:list.attr[0].data
48 | length:list.attr[0].length];
49 | if (password != NULL) {
50 | char passwordBuffer[1024];
51 |
52 | if (length > 1023) {
53 | length = 1023;
54 | }
55 | strncpy(passwordBuffer, password, length);
56 |
57 | passwordBuffer[length] = '\0';
58 | self.secret = [NSString stringWithCString:passwordBuffer];
59 | }
60 |
61 | SecKeychainItemFreeContent(&list, password);
62 |
63 | } else {
64 | // TODO find out why this always works in i386 and always fails on ppc
65 | NSLog(@"Error from SecKeychainItemCopyContent: %d", status);
66 | return nil;
67 | }
68 |
69 | NSMakeCollectable(item);
70 |
71 | return self;
72 | }
73 |
74 |
75 | - (int)storeInDefaultKeychainWithAppName:(NSString *)name serviceProviderName:(NSString *)provider
76 | {
77 | return [self storeInKeychain:NULL appName:name serviceProviderName:provider];
78 | }
79 |
80 | - (int)storeInKeychain:(SecKeychainRef)keychain appName:(NSString *)name serviceProviderName:(NSString *)provider
81 | {
82 | OSStatus status = SecKeychainAddGenericPassword(keychain,
83 | [name length] + [provider length] + 9,
84 | [[NSString stringWithFormat:@"%@::OAuth::%@", name, provider] UTF8String],
85 | [self.key length],
86 | [self.key UTF8String],
87 | [self.secret length],
88 | [self.secret UTF8String],
89 | NULL
90 | );
91 | return status;
92 | }
93 |
94 | @end
95 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumerSrc/OAuthConsumer.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAuthConsumer.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | #import
27 | #import
28 | #import
29 | #import
30 | #import
31 | #import
32 | #import
33 | #import
34 | #import
35 | #import
36 | #import
37 | #import
38 | #import
39 | #import
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/OAuthConsumer_iPhone_Prefix.pch:
--------------------------------------------------------------------------------
1 | //
2 | // Prefix header for all source files of the 'CocoaTouchStaticLibrary' target in the 'CocoaTouchStaticLibrary' project.
3 | //
4 |
5 | #ifdef __OBJC__
6 | #import
7 | #endif
8 |
--------------------------------------------------------------------------------
/OAuthConsumeriPhoneLib/ReadMe.txt:
--------------------------------------------------------------------------------
1 | To build a combined library for use in both the sim and on device, build both individual libraries, then cd to the build directory in terminal and execute the following:
2 |
3 | lipo -create Release-iphoneos/libOAuthConsumer_iPhone.a Debug-iphonesimulator/libOAuthConsumer_iPhone.a -output libOAuth.a
4 |
--------------------------------------------------------------------------------
/ReadMe.txt:
--------------------------------------------------------------------------------
1 | Twitter+OAuth Source and Example for iPhone
2 | Glommed together by Ben Gottlieb
3 | copyright 2009-2015 Stand Alone, Inc - all rights reserved.
4 | License: BSD, If you use it, please include the following text somewhere in your application's user-facing text:
5 | "Includes Twitter+OAuth code by Ben Gottlieb"
6 |
7 | The goal of this was to create a drop-in code package for iPhone apps that want to access Twitter via OAuth. The main benefit here is that the source line on the Twitter page will say your app name, rather than "from web".
8 |
9 | This includes source taken from several other open frameworks, listed below. Most of the heavy lifting was all done by them, I just synthesized it into a (hopefully) easily digestible chunk.
10 |
11 | I decided not to do the whole thing as a static library since most developers are already using Matt Gemmell's MGTwitterEngine, and there was no reason to duplicate code. It adds about 200k to the final size of your project, mainly due to the OAuth library.
12 |
13 | Enjoy, and please let me know if you have any feedback!
14 |
15 | Ben Gottlieb
16 | ben@standalone.com
17 |
18 | == Major Changes Log ==
19 | 2/14/15 - updated for 64 bit ARM and iOS 8
20 | 2/24/10 - added additional PIN checks in case Twitter changes the way they pass the PIN back
21 | - if all else fails, prompt the user to copy their PIN. The app will grab this and use it
22 | - this last part only works on OS 3.x and later, Everything else should work fine on 2.x.
23 | - integrated the latest build of MGTwitterEngine
24 |
25 |
26 | Example:
27 | Use the project in the Demo folder. You'll need to replace the strings in Demo/Src/OAuthTwitterDemoViewController.m with your own consumer key and consumer secret (visit http://twitter.com/oauth_clients/new to obtain these).
28 |
29 |
30 | Built using:
31 | MGTwitterEngine by Matt Gemmell
32 | http://mattgemmell.com
33 | License: http://mattgemmell.com/license
34 | I have included 1.0.8 release of the MGTwitterEngine unchanged in this project.
35 | The goal is to create an easily buildable project that has no dependancies.
36 |
37 |
38 | OAuthConsumer Framework
39 | Jon Crosby
40 | http://code.google.com/p/oauth/
41 | License: http://www.apache.org/licenses/LICENSE-2.0
42 | I have included a pre-built binary of the OAuthConsumer Framework unchanged in this project.
43 | The goal is to create an easily buildable project that has no dependancies.
44 |
45 |
46 | OAuth-MyTwitter
47 | Chris Kimpton
48 | http://github.com/kimptoc/MGTwitterEngine-1.0.8-OAuth-MyTwitter/tree/master
49 | License: Couldn't find one. Will amend this if I do.
50 | Some code from this project was used to create the YHOATwitterEngine subclass of MGTwitterEngine.
51 | Thanks Chris, you made this project a simple!
52 |
53 |
54 | OAuth Test Application
55 | Isaiah Carew
56 | http://github.com/yourhead/OAuth_ObjC_Test_App/tree/master
57 | License: None found.
58 | Isaiah's test app worked great on the Mac, but didn't make use of the PIN number passed back by Twitter, and also needed to be re-worked to work on the phone.
59 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/NSMutableURLRequest+Parameters.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSMutableURLRequest+Parameters.h
3 | //
4 | // Created by Jon Crosby on 10/19/07.
5 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import
26 | #import "OARequestParameter.h"
27 | #import "NSURL+Base.h"
28 |
29 |
30 | @interface NSMutableURLRequest (OAParameterAdditions)
31 |
32 | - (NSArray *)parameters;
33 | - (void)setParameters:(NSArray *)parameters;
34 |
35 | @end
36 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/NSString+URLEncoding.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSString+URLEncoding.h
3 | //
4 | // Created by Jon Crosby on 10/19/07.
5 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 |
26 | #import
27 |
28 |
29 | @interface NSString (OAURLEncodingAdditions)
30 |
31 | - (NSString *)URLEncodedString;
32 | - (NSString *)URLDecodedString;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/NSURL+Base.h:
--------------------------------------------------------------------------------
1 | //
2 | // NSURL+Base.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 |
29 |
30 | @interface NSURL (OABaseAdditions)
31 |
32 | - (NSString *)URLStringWithoutQuery;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OAAsynchronousDataFetcher.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAAsynchronousDataFetcher.h
3 | // OAuthConsumer
4 | //
5 | // Created by Zsombor Szabó on 12/3/08.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 | #import
26 |
27 | #import "OAMutableURLRequest.h"
28 |
29 | @interface OAAsynchronousDataFetcher : NSObject {
30 | OAMutableURLRequest *request;
31 | NSURLResponse *response;
32 | NSURLConnection *connection;
33 | NSMutableData *responseData;
34 | id delegate;
35 | SEL didFinishSelector;
36 | SEL didFailSelector;
37 | }
38 |
39 | + (id)asynchronousFetcherWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector;
40 | - (id)initWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector;
41 |
42 | - (void)start;
43 | - (void)cancel;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OAConsumer.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAConsumer.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 |
29 |
30 | @interface OAConsumer : NSObject {
31 | @protected
32 | NSString *key;
33 | NSString *secret;
34 | }
35 | @property(retain) NSString *key;
36 | @property(retain) NSString *secret;
37 |
38 | - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret;
39 |
40 | @end
41 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OADataFetcher.h:
--------------------------------------------------------------------------------
1 | //
2 | // OADataFetcher.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 11/5/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | #import
27 | #import "OAMutableURLRequest.h"
28 | #import "OAServiceTicket.h"
29 |
30 |
31 | @interface OADataFetcher : NSObject {
32 | @private
33 | OAMutableURLRequest *request;
34 | NSURLResponse *response;
35 | NSURLConnection *connection;
36 | NSError *error;
37 | NSData *responseData;
38 | id delegate;
39 | SEL didFinishSelector;
40 | SEL didFailSelector;
41 | }
42 |
43 | - (void)fetchDataWithRequest:(OAMutableURLRequest *)aRequest delegate:(id)aDelegate didFinishSelector:(SEL)finishSelector didFailSelector:(SEL)failSelector;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OAHMAC_SHA1SignatureProvider.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAHMAC_SHA1SignatureProvider.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 | #import "OASignatureProviding.h"
29 |
30 |
31 | @interface OAHMAC_SHA1SignatureProvider : NSObject
32 | @end
33 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OAMutableURLRequest.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAMutableURLRequest.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 | #import "OAConsumer.h"
29 | #import "OAToken.h"
30 | #import "OAHMAC_SHA1SignatureProvider.h"
31 | #import "OASignatureProviding.h"
32 | #import "NSMutableURLRequest+Parameters.h"
33 | #import "NSURL+Base.h"
34 |
35 |
36 | @interface OAMutableURLRequest : NSMutableURLRequest {
37 | @protected
38 | OAConsumer *consumer;
39 | OAToken *token;
40 | NSString *realm;
41 | NSString *signature;
42 | id signatureProvider;
43 | NSString *nonce;
44 | NSString *timestamp;
45 | }
46 | @property(readonly) NSString *signature;
47 | @property(readonly) NSString *nonce;
48 |
49 | - (id)initWithURL:(NSURL *)aUrl
50 | consumer:(OAConsumer *)aConsumer
51 | token:(OAToken *)aToken
52 | realm:(NSString *)aRealm
53 | signatureProvider:(id)aProvider;
54 |
55 | - (id)initWithURL:(NSURL *)aUrl
56 | consumer:(OAConsumer *)aConsumer
57 | token:(OAToken *)aToken
58 | realm:(NSString *)aRealm
59 | signatureProvider:(id)aProvider
60 | nonce:(NSString *)aNonce
61 | timestamp:(NSString *)aTimestamp;
62 |
63 | - (void)prepare;
64 |
65 | @end
66 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OAPlaintextSignatureProvider.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAPlaintextSignatureProvider.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 | #import "OASignatureProviding.h"
29 |
30 | @interface OAPlaintextSignatureProvider : NSObject
31 | @end
32 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OARequestParameter.h:
--------------------------------------------------------------------------------
1 | //
2 | // OARequestParameter.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 | #import "NSString+URLEncoding.h"
29 |
30 |
31 | @interface OARequestParameter : NSObject {
32 | @protected
33 | NSString *name;
34 | NSString *value;
35 | }
36 | @property(retain) NSString *name;
37 | @property(retain) NSString *value;
38 |
39 | + (id)requestParameterWithName:(NSString *)aName value:(NSString *)aValue;
40 | - (id)initWithName:(NSString *)aName value:(NSString *)aValue;
41 | - (NSString *)URLEncodedName;
42 | - (NSString *)URLEncodedValue;
43 | - (NSString *)URLEncodedNameValuePair;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OAServiceTicket.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAServiceTicket.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 11/5/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 |
27 | #import
28 | #import "OAMutableURLRequest.h"
29 |
30 |
31 | @interface OAServiceTicket : NSObject {
32 | @private
33 | OAMutableURLRequest *request;
34 | NSURLResponse *response;
35 | BOOL didSucceed;
36 | }
37 | @property(retain) OAMutableURLRequest *request;
38 | @property(retain) NSURLResponse *response;
39 | @property(assign) BOOL didSucceed;
40 |
41 | - (id)initWithRequest:(OAMutableURLRequest *)aRequest response:(NSURLResponse *)aResponse didSucceed:(BOOL)success;
42 |
43 | @end
44 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OASignatureProviding.h:
--------------------------------------------------------------------------------
1 | //
2 | // OASignatureProviding.h
3 | //
4 | // Created by Jon Crosby on 10/19/07.
5 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
6 | //
7 | // Permission is hereby granted, free of charge, to any person obtaining a copy
8 | // of this software and associated documentation files (the "Software"), to deal
9 | // in the Software without restriction, including without limitation the rights
10 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 | // copies of the Software, and to permit persons to whom the Software is
12 | // furnished to do so, subject to the following conditions:
13 | //
14 | // The above copyright notice and this permission notice shall be included in
15 | // all copies or substantial portions of the Software.
16 | //
17 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 | // THE SOFTWARE.
24 |
25 |
26 | #import
27 |
28 |
29 | @protocol OASignatureProviding
30 |
31 | - (NSString *)name;
32 | - (NSString *)signClearText:(NSString *)text withSecret:(NSString *)secret;
33 |
34 | @end
35 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OAToken.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAToken.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | #import
27 |
28 | @interface OAToken : NSObject {
29 | NSString *pin; //added for the Twitter OAuth implementation
30 |
31 | @protected
32 | NSString *key;
33 | NSString *secret;
34 | }
35 | @property(retain) NSString *pin; //added for the Twitter OAuth implementation
36 |
37 | @property(retain) NSString *key;
38 | @property(retain) NSString *secret;
39 |
40 | - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret;
41 | - (id)initWithUserDefaultsUsingServiceProviderName:(NSString *)provider prefix:(NSString *)prefix;
42 | - (id)initWithHTTPResponseBody:(NSString *)body;
43 | - (int)storeInUserDefaultsWithServiceProviderName:(NSString *)provider prefix:(NSString *)prefix;
44 |
45 | @end
46 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OAToken_KeychainExtensions.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAToken_KeychainExtensions.h
3 | // TouchTheFireEagle
4 | //
5 | // Created by Jonathan Wight on 04/04/08.
6 | // Copyright 2008 __MyCompanyName__. All rights reserved.
7 | //
8 |
9 | #import "OAToken.h"
10 |
11 | #import
12 |
13 | @interface OAToken (OAToken_KeychainExtensions)
14 |
15 | - (id)initWithKeychainUsingAppName:(NSString *)name serviceProviderName:(NSString *)provider;
16 | - (int)storeInDefaultKeychainWithAppName:(NSString *)name serviceProviderName:(NSString *)provider;
17 | - (int)storeInKeychain:(SecKeychainRef)keychain appName:(NSString *)name serviceProviderName:(NSString *)provider;
18 |
19 | @end
20 |
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/OAuthConsumer/OAuthConsumer.h:
--------------------------------------------------------------------------------
1 | //
2 | // OAuthConsumer.h
3 | // OAuthConsumer
4 | //
5 | // Created by Jon Crosby on 10/19/07.
6 | // Copyright 2007 Kaboomerang LLC. All rights reserved.
7 | //
8 | // Permission is hereby granted, free of charge, to any person obtaining a copy
9 | // of this software and associated documentation files (the "Software"), to deal
10 | // in the Software without restriction, including without limitation the rights
11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12 | // copies of the Software, and to permit persons to whom the Software is
13 | // furnished to do so, subject to the following conditions:
14 | //
15 | // The above copyright notice and this permission notice shall be included in
16 | // all copies or substantial portions of the Software.
17 | //
18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24 | // THE SOFTWARE.
25 |
26 | #import
27 | #import "OAToken.h"
28 | #import "OAConsumer.h"
29 | #import "OAMutableURLRequest.h"
30 | #import "NSString+URLEncoding.h"
31 | #import "NSMutableURLRequest+Parameters.h"
32 | #import "NSURL+Base.h"
33 | #import "OASignatureProviding.h"
34 | #import "OAHMAC_SHA1SignatureProvider.h"
35 | #import "OAPlaintextSignatureProvider.h"
36 | #import "OARequestParameter.h"
37 | #import "OAServiceTicket.h"
38 | #import "OADataFetcher.h"
39 | #import "OAAsynchronousDataFetcher.h"
--------------------------------------------------------------------------------
/Twitter+OAuth/Libraries & Headers/jQueryInject.txt:
--------------------------------------------------------------------------------
1 | $('html').css({'-webkit-background-size':'200px'});
2 | $('body').css({'font-size':'12px','background':'#9AE4E8'});
3 | $('#header').width(270);
4 | $('#header').height(46);
5 | $('.signin-content').css({'padding' : '15px','width' : '270px'});
6 | $('#twitainer').width(270);
7 | $('#twitainer').css({'margin-left' : '8px'});
8 | $('#login_form').width(30);
9 | $('#content').width(270);
10 | $('#content').css({'margin':'0px','float':'left'});
11 | $('.tos').hide();
12 | $('.newtos').remove();
13 | $('.newtos').css({'text-align':'left', 'border':'1px solid red','color':'#555555','font-size':'12px','line-height':'1.3','margin':'20px 15px 5px'});
14 | $('.newtos p').css({'margin' : '8px'});
15 | $('h2').hide();
16 | $('.oauth-errors').after("