Permalink
Browse files

Added verifier to OAToken

  • Loading branch information...
1 parent 13e6dc4 commit 5ed7e5f276aa0bd82ee2d3cdaa966ecee568cb4b Jesse Armand committed Jul 5, 2010
Showing with 21 additions and 7 deletions.
  1. +3 −1 OAToken.h
  2. +18 −6 OAToken.m
View
@@ -29,6 +29,7 @@
@protected
NSString *key;
NSString *secret;
+ NSString *verifier;
NSString *session;
NSNumber *duration;
NSMutableDictionary *attributes;
@@ -38,13 +39,14 @@
}
@property(retain, readwrite) NSString *key;
@property(retain, readwrite) NSString *secret;
+@property(retain, readwrite) NSString *verifier;
@property(retain, readwrite) NSString *session;
@property(retain, readwrite) NSNumber *duration;
@property(retain, readwrite) NSDictionary *attributes;
@property(readwrite, getter=isForRenewal) BOOL forRenewal;
- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret;
-- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret session:(NSString *)aSession
+- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret verifier:(NSString *)aVerifier session:(NSString *)aSession
duration:(NSNumber *)aDuration attributes:(NSDictionary *)theAttributes created:(NSDate *)creation
renewable:(BOOL)renew;
- (id)initWithHTTPResponseBody:(NSString *)body;
View
@@ -39,7 +39,8 @@ + (NSDictionary *)attributesWithString:(NSString *)theAttributes;
@implementation OAToken
-@synthesize key, secret, session, duration, attributes, forRenewal;
+@synthesize key, secret, verifier, session, duration, forRenewal;
+@dynamic attributes;
#pragma mark init
@@ -48,16 +49,17 @@ - (id)init {
}
- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret {
- return [self initWithKey:aKey secret:aSecret session:nil duration:nil
- attributes:nil created:nil renewable:NO];
+ return [self initWithKey:aKey secret:aSecret verifier:nil session:nil duration:nil
+ attributes:nil created:nil renewable:NO];
}
-- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret session:(NSString *)aSession
+- (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret verifier:(NSString *)aVerifier session:(NSString *)aSession
duration:(NSNumber *)aDuration attributes:(NSDictionary *)theAttributes created:(NSDate *)creation
renewable:(BOOL)renew {
[super init];
self.key = aKey;
self.secret = aSecret;
+ self.verifier = aVerifier;
self.session = aSession;
self.duration = aDuration;
self.attributes = theAttributes;
@@ -71,6 +73,7 @@ - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret session:(NSString
- (id)initWithHTTPResponseBody:(const NSString *)body {
NSString *aKey = nil;
NSString *aSecret = nil;
+ NSString *aVerifier = nil;
NSString *aSession = nil;
NSNumber *aDuration = nil;
NSDate *creationDate = nil;
@@ -84,6 +87,8 @@ - (id)initWithHTTPResponseBody:(const NSString *)body {
aKey = [elements objectAtIndex:1];
} else if ([[elements objectAtIndex:0] isEqualToString:@"oauth_token_secret"]) {
aSecret = [elements objectAtIndex:1];
+ } else if ([[elements objectAtIndex:0] isEqualToString:@"oauth_verifier"]) {
+ aVerifier = [elements objectAtIndex:1];
} else if ([[elements objectAtIndex:0] isEqualToString:@"oauth_session_handle"]) {
aSession = [elements objectAtIndex:1];
} else if ([[elements objectAtIndex:0] isEqualToString:@"oauth_token_duration"]) {
@@ -99,14 +104,15 @@ - (id)initWithHTTPResponseBody:(const NSString *)body {
}
}
- return [self initWithKey:aKey secret:aSecret session:aSession duration:aDuration
- attributes:attrs created:creationDate renewable:renew];
+ return [self initWithKey:aKey secret:aSecret verifier:aVerifier session:aSession duration:aDuration
+ attributes:attrs created:creationDate renewable:renew];
}
- (id)initWithUserDefaultsUsingServiceProviderName:(const NSString *)provider prefix:(const NSString *)prefix {
[super init];
self.key = [OAToken loadSetting:@"key" provider:provider prefix:prefix];
self.secret = [OAToken loadSetting:@"secret" provider:provider prefix:prefix];
+ self.verifier = [OAToken loadSetting:@"verifier" provider:provider prefix:prefix];
self.session = [OAToken loadSetting:@"session" provider:provider prefix:prefix];
self.duration = [OAToken loadSetting:@"duration" provider:provider prefix:prefix];
self.attributes = [OAToken loadSetting:@"attributes" provider:provider prefix:prefix];
@@ -126,6 +132,7 @@ - (id)initWithUserDefaultsUsingServiceProviderName:(const NSString *)provider pr
- (void)dealloc {
self.key = nil;
self.secret = nil;
+ self.verifier = nil;
self.duration = nil;
self.attributes = nil;
[super dealloc];
@@ -140,6 +147,7 @@ - (BOOL)isValid {
- (int)storeInUserDefaultsWithServiceProviderName:(const NSString *)provider prefix:(const NSString *)prefix {
[OAToken saveSetting:@"key" object:key provider:provider prefix:prefix];
[OAToken saveSetting:@"secret" object:secret provider:provider prefix:prefix];
+ [OAToken saveSetting:@"verifier" object:verifier provider:provider prefix:prefix];
[OAToken saveSetting:@"created" object:created provider:provider prefix:prefix];
[OAToken saveSetting:@"duration" object:duration provider:provider prefix:prefix];
[OAToken saveSetting:@"session" object:session provider:provider prefix:prefix];
@@ -176,6 +184,10 @@ - (void)setAttribute:(const NSString *)aKey value:(const NSString *)aAttribute {
[attributes setObject: aAttribute forKey: aKey];
}
+- (NSDictionary *)attributes {
+ return [attributes autorelease];
+}
+
- (void)setAttributes:(NSDictionary *)theAttributes {
[attributes release];
attributes = [[NSMutableDictionary alloc] initWithDictionary:theAttributes];

0 comments on commit 5ed7e5f

Please sign in to comment.