Permalink
Browse files

Merge pull request #10 from adamjernst/master

Two more changes for oauthconsumer
  • Loading branch information...
2 parents a155fc1 + 42c4283 commit 9048745e103d5d456d24acc74cfc2e0432e6047d @jdg committed Jun 4, 2011
Showing with 29 additions and 2 deletions.
  1. +2 −1 OAToken.h
  2. +27 −1 OAToken.m
View
@@ -25,7 +25,7 @@
#import <Foundation/Foundation.h>
-@interface OAToken : NSObject {
+@interface OAToken : NSObject <NSCoding> {
@protected
NSString *key;
NSString *secret;
@@ -40,6 +40,7 @@
@property(retain, readwrite) NSString *secret;
@property(retain, readwrite) NSString *session;
@property(retain, readwrite) NSNumber *duration;
+@property(retain, readwrite) NSString *verifier;
@property(retain, readwrite) NSDictionary *attributes;
@property(readwrite, getter=isForRenewal) BOOL forRenewal;
View
@@ -39,7 +39,7 @@ + (NSDictionary *)attributesWithString:(NSString *)theAttributes;
@implementation OAToken
-@synthesize key, secret, session, duration, attributes, forRenewal;
+@synthesize key, secret, session, duration, verifier, attributes, forRenewal;
#pragma mark init
@@ -68,6 +68,18 @@ - (id)initWithKey:(NSString *)aKey secret:(NSString *)aSecret session:(NSString
return self;
}
+- (id)initWithCoder:(NSCoder *)aDecoder {
+ OAToken *t = [self initWithKey:[aDecoder decodeObjectForKey:@"key"]
+ secret:[aDecoder decodeObjectForKey:@"secret"]
+ session:[aDecoder decodeObjectForKey:@"session"]
+ duration:[aDecoder decodeObjectForKey:@"duration"]
+ attributes:[aDecoder decodeObjectForKey:@"attributes"]
+ created:[aDecoder decodeObjectForKey:@"created"]
+ renewable:[aDecoder decodeBoolForKey:@"renewable"]];
+ [t setVerifier:[aDecoder decodeObjectForKey:@"verifier"]];
+ return t;
+}
+
- (id)initWithHTTPResponseBody:(const NSString *)body {
NSString *aKey = nil;
NSString *aSecret = nil;
@@ -127,6 +139,7 @@ - (void)dealloc {
self.key = nil;
self.secret = nil;
self.duration = nil;
+ self.verifier = nil;
self.attributes = nil;
[super dealloc];
}
@@ -150,6 +163,16 @@ - (int)storeInUserDefaultsWithServiceProviderName:(const NSString *)provider pre
return(0);
}
+- (void)encodeWithCoder:(NSCoder *)aCoder {
+ [aCoder encodeObject:[self key] forKey:@"key"];
+ [aCoder encodeObject:[self secret] forKey:@"secret"];
+ [aCoder encodeObject:[self session] forKey:@"session"];
+ [aCoder encodeObject:[self duration] forKey:@"duration"];
+ [aCoder encodeObject:[self attributes] forKey:@"attributes"];
+ [aCoder encodeBool:renewable forKey:@"renewable"];
+ [aCoder encodeObject:[self verifier] forKey:@"verifier"];
+}
+
#pragma mark duration
- (void)setDurationWithString:(NSString *)aDuration {
@@ -231,6 +254,9 @@ - (NSDictionary *)parameters
[params setObject:[self attributeString] forKey:@"oauth_token_attributes"];
}
}
+ if (self.verifier) {
+ [params setObject:self.verifier forKey:@"oauth_verifier"];
+ }
return params;
}

0 comments on commit 9048745

Please sign in to comment.