Skip to content

Commit 12f9b0c

Browse files
committed
WS
1 parent 9356a6b commit 12f9b0c

31 files changed

+1098
-1098
lines changed

NXOAuth2Account+Private.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
// Copyright 2011 nxtbgthng. All rights reserved.
88
//
99
// Licenced under the new BSD-licence.
10-
// See README.md in this repository for
10+
// See README.md in this repository for
1111
// the full licence.
1212
//
1313

Sources/NSData+NXOAuth2.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
//
55
// Created by Thomas Kollbach on 18.05.11
66
//
7-
// Copyright 2011 nxtbgthng. All rights reserved.
7+
// Copyright 2011 nxtbgthng. All rights reserved.
88
//
99
// Licenced under the new BSD-licence.
10-
// See README.md in this repository for
10+
// See README.md in this repository for
1111
// the full licence.
1212
//
1313

Sources/NSData+NXOAuth2.m

+17-17
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
//
55
// Created by Thomas Kollbach on 18.05.11
66
//
7-
// Copyright 2011 nxtbgthng. All rights reserved.
7+
// Copyright 2011 nxtbgthng. All rights reserved.
88
//
99
// Licenced under the new BSD-licence.
10-
// See README.md in this repository for
10+
// See README.md in this repository for
1111
// the full licence.
1212
//
1313

@@ -23,25 +23,25 @@ @implementation NSData (NXOAuth2)
2323

2424
- (NSData *)nx_SHA1Digest;
2525
{
26-
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
27-
CC_SHA1(self.bytes, (CC_LONG)self.length, digest);
28-
29-
return [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];
26+
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
27+
CC_SHA1(self.bytes, (CC_LONG)self.length, digest);
28+
29+
return [NSData dataWithBytes:digest length:CC_SHA1_DIGEST_LENGTH];
3030
}
3131

3232
- (NSString *)nx_SHA1Hexdigest;
3333
{
34-
NSData *binDigest = [self nx_SHA1Digest];
35-
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
36-
[binDigest getBytes:digest length:CC_SHA1_DIGEST_LENGTH];
37-
38-
NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
39-
40-
for (NSUInteger i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
41-
[output appendFormat:@"%02x", digest[i]];
42-
}
43-
44-
return [output copy];
34+
NSData *binDigest = [self nx_SHA1Digest];
35+
uint8_t digest[CC_SHA1_DIGEST_LENGTH];
36+
[binDigest getBytes:digest length:CC_SHA1_DIGEST_LENGTH];
37+
38+
NSMutableString* output = [NSMutableString stringWithCapacity:CC_SHA1_DIGEST_LENGTH * 2];
39+
40+
for (NSUInteger i = 0; i < CC_SHA1_DIGEST_LENGTH; i++) {
41+
[output appendFormat:@"%02x", digest[i]];
42+
}
43+
44+
return [output copy];
4545
}
4646

4747

Sources/NSString+NXOAuth2.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
//
55
// Created by Ullrich Schäfer on 07.10.09.
66
//
7-
// Copyright 2010 nxtbgthng. All rights reserved.
7+
// Copyright 2010 nxtbgthng. All rights reserved.
88
//
99
// Licenced under the new BSD-licence.
10-
// See README.md in this repository for
10+
// See README.md in this repository for
1111
// the full licence.
1212
//
1313

Sources/NSString+NXOAuth2.m

+19-19
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
//
55
// Created by Ullrich Schäfer on 07.10.09.
66
//
7-
// Copyright 2010 nxtbgthng. All rights reserved.
7+
// Copyright 2010 nxtbgthng. All rights reserved.
88
//
99
// Licenced under the new BSD-licence.
10-
// See README.md in this repository for
10+
// See README.md in this repository for
1111
// the full licence.
1212
//
1313

@@ -19,7 +19,7 @@ @implementation NSString (NXOAuth2)
1919
+ (NSString *)nxoauth2_stringWithUUID;
2020
{
2121
__autoreleasing NSString *result;
22-
CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault);
22+
CFUUIDRef theUUID = CFUUIDCreate(kCFAllocatorDefault);
2323
result = (__bridge_transfer NSString *)CFUUIDCreateString(kCFAllocatorDefault, theUUID);
2424
CFRelease(theUUID);
2525
return result;
@@ -30,28 +30,28 @@ + (NSString *)nxoauth2_stringWithUUID;
3030

3131
+ (NSString *)nxoauth2_stringWithEncodedQueryParameters:(NSDictionary *)parameters;
3232
{
33-
34-
NSMutableArray *parameterPairs = [NSMutableArray array];
35-
for (NSString *key in [parameters allKeys]) {
36-
NSString *pair = [NSString stringWithFormat:@"%@=%@", [key nxoauth2_URLEncodedString], [[parameters objectForKey:key] nxoauth2_URLEncodedString]];
37-
[parameterPairs addObject:pair];
38-
}
39-
return [parameterPairs componentsJoinedByString:@"&"];
33+
34+
NSMutableArray *parameterPairs = [NSMutableArray array];
35+
for (NSString *key in [parameters allKeys]) {
36+
NSString *pair = [NSString stringWithFormat:@"%@=%@", [key nxoauth2_URLEncodedString], [[parameters objectForKey:key] nxoauth2_URLEncodedString]];
37+
[parameterPairs addObject:pair];
38+
}
39+
return [parameterPairs componentsJoinedByString:@"&"];
4040
}
4141

4242
- (NSDictionary *)nxoauth2_parametersFromEncodedQueryString;
4343
{
44-
NSArray *encodedParameterPairs = [self componentsSeparatedByString:@"&"];
44+
NSArray *encodedParameterPairs = [self componentsSeparatedByString:@"&"];
4545
NSMutableDictionary *requestParameters = [NSMutableDictionary dictionary];
4646

4747
for (NSString *encodedPair in encodedParameterPairs) {
4848
NSArray *encodedPairElements = [encodedPair componentsSeparatedByString:@"="];
49-
if (encodedPairElements.count == 2) {
50-
[requestParameters setValue:[[encodedPairElements objectAtIndex:1] nxoauth2_URLDecodedString]
51-
forKey:[[encodedPairElements objectAtIndex:0] nxoauth2_URLDecodedString]];
52-
}
49+
if (encodedPairElements.count == 2) {
50+
[requestParameters setValue:[[encodedPairElements objectAtIndex:1] nxoauth2_URLDecodedString]
51+
forKey:[[encodedPairElements objectAtIndex:0] nxoauth2_URLDecodedString]];
52+
}
5353
}
54-
return requestParameters;
54+
return requestParameters;
5555
}
5656

5757

@@ -60,13 +60,13 @@ - (NSDictionary *)nxoauth2_parametersFromEncodedQueryString;
6060
- (NSString *)nxoauth2_URLEncodedString;
6161
{
6262

63-
CFStringRef cfResult = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, //Allocator
63+
CFStringRef cfResult = CFURLCreateStringByAddingPercentEscapes(kCFAllocatorDefault, //Allocator
6464
(__bridge CFStringRef)self, //Original String
6565
NULL, //Characters to leave unescaped
6666
(CFStringRef)@"!*'();:@&=+$,/?%#[]", //Legal Characters to be escaped
6767
kCFStringEncodingUTF8); //Encoding
6868
__autoreleasing NSString *result = (__bridge_transfer NSString *)cfResult;
69-
return result;
69+
return result;
7070
}
7171

7272
- (NSString *)nxoauth2_URLDecodedString;
@@ -76,7 +76,7 @@ - (NSString *)nxoauth2_URLDecodedString;
7676
CFSTR(""),
7777
kCFStringEncodingUTF8);
7878
__autoreleasing NSString *result = (__bridge_transfer NSString *)cfResult;
79-
return result;
79+
return result;
8080
}
8181

8282
@end

Sources/NSURL+NXOAuth2.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
//
55
// Created by Ullrich Schäfer on 07.10.09.
66
//
7-
// Copyright 2010 nxtbgthng. All rights reserved.
7+
// Copyright 2010 nxtbgthng. All rights reserved.
88
//
99
// Licenced under the new BSD-licence.
10-
// See README.md in this repository for
10+
// See README.md in this repository for
1111
// the full licence.
1212
//
1313

Sources/NSURL+NXOAuth2.m

+20-20
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
//
55
// Created by Ullrich Schäfer on 07.10.09.
66
//
7-
// Copyright 2010 nxtbgthng. All rights reserved.
7+
// Copyright 2010 nxtbgthng. All rights reserved.
88
//
99
// Licenced under the new BSD-licence.
10-
// See README.md in this repository for
10+
// See README.md in this repository for
1111
// the full licence.
1212
//
1313

@@ -19,32 +19,32 @@
1919
@implementation NSURL (NXOAuth2)
2020

2121
- (NSURL *)nxoauth2_URLByAddingParameters:(NSDictionary *)parameterDictionary {
22-
if (!parameterDictionary || [parameterDictionary count] == 0) {
23-
return self;
24-
}
25-
26-
NSString *newParameterString = [NSString nxoauth2_stringWithEncodedQueryParameters:parameterDictionary];
27-
28-
NSString *absoluteString = [self absoluteString];
29-
if ([absoluteString rangeOfString:@"?"].location == NSNotFound) { // append parameters?
30-
absoluteString = [NSString stringWithFormat:@"%@?%@", absoluteString, newParameterString];
31-
} else {
32-
absoluteString = [NSString stringWithFormat:@"%@&%@", absoluteString, newParameterString];
33-
}
34-
35-
return [NSURL URLWithString:absoluteString];
22+
if (!parameterDictionary || [parameterDictionary count] == 0) {
23+
return self;
24+
}
25+
26+
NSString *newParameterString = [NSString nxoauth2_stringWithEncodedQueryParameters:parameterDictionary];
27+
28+
NSString *absoluteString = [self absoluteString];
29+
if ([absoluteString rangeOfString:@"?"].location == NSNotFound) { // append parameters?
30+
absoluteString = [NSString stringWithFormat:@"%@?%@", absoluteString, newParameterString];
31+
} else {
32+
absoluteString = [NSString stringWithFormat:@"%@&%@", absoluteString, newParameterString];
33+
}
34+
35+
return [NSURL URLWithString:absoluteString];
3636
}
3737

3838
- (NSString *)nxoauth2_valueForQueryParameterKey:(NSString *)key;
3939
{
40-
NSString *queryString = [self query];
41-
NSDictionary *parameters = [queryString nxoauth2_parametersFromEncodedQueryString];
42-
return [parameters objectForKey:key];
40+
NSString *queryString = [self query];
41+
NSDictionary *parameters = [queryString nxoauth2_parametersFromEncodedQueryString];
42+
return [parameters objectForKey:key];
4343
}
4444

4545
- (NSURL *)nxoauth2_URLWithoutQueryString;
4646
{
47-
return [NSURL URLWithString:[self nxoauth2_URLStringWithoutQueryString]];
47+
return [NSURL URLWithString:[self nxoauth2_URLStringWithoutQueryString]];
4848
}
4949

5050
- (NSString *)nxoauth2_URLStringWithoutQueryString;

Sources/OAuth2Client/NXOAuth2.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
//
55
// Created by Ullrich Schäfer on 13.09.10.
66
//
7-
// Copyright 2010 nxtbgthng. All rights reserved.
7+
// Copyright 2010 nxtbgthng. All rights reserved.
88
//
99
// Licenced under the new BSD-licence.
10-
// See README.md in this repository for
10+
// See README.md in this repository for
1111
// the full licence.
1212
//
1313

Sources/OAuth2Client/NXOAuth2AccessToken.h

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
//
55
// Created by Ullrich Schäfer on 27.08.10.
66
//
7-
// Copyright 2010 nxtbgthng. All rights reserved.
7+
// Copyright 2010 nxtbgthng. All rights reserved.
88
//
99
// Licenced under the new BSD-licence.
10-
// See README.md in this repository for
10+
// See README.md in this repository for
1111
// the full licence.
1212
//
1313

@@ -17,10 +17,10 @@
1717

1818
@interface NXOAuth2AccessToken : NSObject <NSCoding> {
1919
@private
20-
NSString *accessToken;
21-
NSString *refreshToken;
22-
NSDate *expiresAt;
23-
NSSet *scope;
20+
NSString *accessToken;
21+
NSString *refreshToken;
22+
NSDate *expiresAt;
23+
NSSet *scope;
2424
NSString *responseBody;
2525
}
2626
@property (nonatomic, readonly) NSString *accessToken;

0 commit comments

Comments
 (0)