-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMPOAuthConnection.m
More file actions
58 lines (46 loc) · 2.25 KB
/
MPOAuthConnection.m
File metadata and controls
58 lines (46 loc) · 2.25 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// MPOAuthConnection.m
// MPOAuthConnection
//
// Created by Karl Adam on 08.12.05.
// Copyright 2008 matrixPointer. All rights reserved.
//
#import "MPOAuthConnection.h"
#import "MPOAuthURLRequest.h"
#import "MPOAuthURLResponse.h"
#import "MPOAuthParameterFactory.h"
#import "MPOAuthCredentialConcreteStore.h"
@interface MPOAuthURLResponse ()
@property (nonatomic, readwrite, retain) NSURLResponse *urlResponse;
@property (nonatomic, readwrite, retain) NSDictionary *oauthParameters;
@end
@implementation MPOAuthConnection
+ (MPOAuthConnection *)connectionWithRequest:(MPOAuthURLRequest *)inRequest delegate:(id)inDelegate credentials:(NSObject <MPOAuthCredentialStore, MPOAuthParameterFactory> *)inCredentials {
MPOAuthConnection *aConnection = [[MPOAuthConnection alloc] initWithRequest:inRequest delegate:inDelegate credentials:inCredentials];
return [aConnection autorelease];
}
+ (NSData *)sendSynchronousRequest:(MPOAuthURLRequest *)inRequest usingCredentials:(NSObject <MPOAuthCredentialStore, MPOAuthParameterFactory> *)inCredentials returningResponse:(MPOAuthURLResponse **)outResponse error:(NSError **)inError {
[inRequest addParameters:[inCredentials oauthParameters]];
NSURLRequest *urlRequest = [inRequest urlRequestSignedWithSecret:[inCredentials signingKey] usingMethod:[inCredentials signatureMethod]];
NSURLResponse *urlResponse = nil;
NSData *responseData = [self sendSynchronousRequest:urlRequest returningResponse:&urlResponse error:inError];
MPOAuthURLResponse *oauthResponse = [[[MPOAuthURLResponse alloc] init] autorelease];
oauthResponse.urlResponse = urlResponse;
*outResponse = oauthResponse;
return responseData;
}
- (id)initWithRequest:(MPOAuthURLRequest *)inRequest delegate:(id)inDelegate credentials:(NSObject <MPOAuthCredentialStore, MPOAuthParameterFactory> *)inCredentials {
[inRequest addParameters:[inCredentials oauthParameters]];
NSURLRequest *urlRequest = [inRequest urlRequestSignedWithSecret:[inCredentials signingKey] usingMethod:[inCredentials signatureMethod]];
if (self = [super initWithRequest:urlRequest delegate:inDelegate]) {
_credentials = [inCredentials retain];
}
return self;
}
- (oneway void)dealloc {
[_credentials release];
[super dealloc];
}
@synthesize credentials = _credentials;
#pragma mark -
@end