Skip to content

Commit

Permalink
updated to iOS 7 and fixed deallocated object issues
Browse files Browse the repository at this point in the history
  • Loading branch information
ezequielm committed Oct 30, 2013
1 parent 77a9669 commit a3e59db
Show file tree
Hide file tree
Showing 9 changed files with 75 additions and 64 deletions.
27 changes: 19 additions & 8 deletions Auth0Client/Auth0Client.m
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ - (void)dealloc

+ (Auth0Client*)auth0Client:(NSString *)subDomain clientId:(NSString *)clientId clientSecret:(NSString *)clientSecret
{
return [[[Auth0Client alloc] auth0Client:subDomain clientId:clientId clientSecret:clientSecret] autorelease];
static Auth0Client *instance = nil;
static dispatch_once_t predicate;

dispatch_once(&predicate, ^{ instance = [[Auth0Client alloc] auth0Client:subDomain clientId:clientId clientSecret:clientSecret]; });

return instance;
}

- (Auth0WebViewController*)getAuthenticator:(NSString *)connection withCompletionHandler:(void (^)(BOOL authenticated))block
Expand All @@ -64,17 +69,19 @@ - (Auth0WebViewController*)getAuthenticator:(NSString *)connection withCompletio

Auth0WebViewController *webController = [[Auth0WebViewController alloc] initWithAuthorizeUrl:[[NSURL URLWithString:url] retain] returnUrl:callback allowsClose:NO withCompletionHandler:^(NSString *token, NSString * jwtToken){
if(token) {
NSDictionary *accountProperties = [[[NSDictionary alloc] initWithObjectsAndKeys:
#ifndef __clang_analyzer__
NSDictionary* accountProperties = [[NSDictionary alloc] initWithObjectsAndKeys:
token ?: [NSNull null], @"access_token",
jwtToken?: [NSNull null], @"id_token",
nil
] autorelease];
];

_auth0User = [Auth0User auth0User:accountProperties];
#endif
}
block(!!token);
}];
return [webController autorelease];
return webController;
}

- (void)loginAsync:(UIViewController *)controller withCompletionHandler:(void (^)(BOOL authenticated))block
Expand Down Expand Up @@ -118,12 +125,16 @@ - (void)loginAsync:(UIViewController*)controller connection:(NSString *)connecti
{
if (error == nil) {
NSError* parseError;
NSDictionary* parseData = [NSJSONSerialization
JSONObjectWithData:data
options:kNilOptions
error:&parseError];

#ifndef __clang_analyzer__
NSDictionary* parseData = [[NSDictionary alloc] initWithDictionary:[NSJSONSerialization
JSONObjectWithData:data
options:kNilOptions
error:&parseError]];

_auth0User = [Auth0User auth0User:parseData];
#endif

block(true);
}
}];
Expand Down
17 changes: 10 additions & 7 deletions Auth0Client/Auth0Client.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
ONLY_ACTIVE_ARCH = YES;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = iphoneos;
VALID_ARCHS = "arm64 armv7 armv7s i386";
};
name = Debug;
};
Expand All @@ -224,9 +225,11 @@
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNINITIALIZED_AUTOS = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 6.1;
IPHONEOS_DEPLOYMENT_TARGET = 7.0;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = iphoneos;
VALIDATE_PRODUCT = YES;
VALID_ARCHS = "arm64 armv7 armv7s i386";
};
name = Release;
};
Expand All @@ -244,9 +247,9 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphonesimulator;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = iphonesimulator;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
VALID_ARCHS = i386;
};
name = Debug;
Expand All @@ -265,9 +268,9 @@
ONLY_ACTIVE_ARCH = YES;
OTHER_LDFLAGS = "-ObjC";
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = iphonesimulator;
SDKROOT = iphoneos;
SKIP_INSTALL = YES;
SUPPORTED_PLATFORMS = iphonesimulator;
SUPPORTED_PLATFORMS = "iphonesimulator iphoneos";
VALID_ARCHS = i386;
};
name = Release;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDESourceControlProjectFavoriteDictionaryKey</key>
<false/>
<key>IDESourceControlProjectIdentifier</key>
<string>5A29C2AC-1C62-48E3-BBF3-E05B3881B2B6</string>
<key>IDESourceControlProjectName</key>
<string>Auth0Client</string>
<key>IDESourceControlProjectOriginsDictionary</key>
<dict>
<key>24DE5F5A-7F1C-4FEC-AD9A-55CA9BA8E93E</key>
<string>ssh://github.com/auth0/Auth0.iOS.git</string>
</dict>
<key>IDESourceControlProjectPath</key>
<string>Auth0Client/Auth0Client.xcodeproj/project.xcworkspace</string>
<key>IDESourceControlProjectRelativeInstallPathDictionary</key>
<dict>
<key>24DE5F5A-7F1C-4FEC-AD9A-55CA9BA8E93E</key>
<string>../../..</string>
</dict>
<key>IDESourceControlProjectURL</key>
<string>ssh://github.com/auth0/Auth0.iOS.git</string>
<key>IDESourceControlProjectVersion</key>
<integer>110</integer>
<key>IDESourceControlProjectWCCIdentifier</key>
<string>24DE5F5A-7F1C-4FEC-AD9A-55CA9BA8E93E</string>
<key>IDESourceControlProjectWCConfigurations</key>
<array>
<dict>
<key>IDESourceControlRepositoryExtensionIdentifierKey</key>
<string>public.vcs.git</string>
<key>IDESourceControlWCCIdentifierKey</key>
<string>24DE5F5A-7F1C-4FEC-AD9A-55CA9BA8E93E</string>
<key>IDESourceControlWCCName</key>
<string>Auth0</string>
</dict>
</array>
</dict>
</plist>
10 changes: 5 additions & 5 deletions Auth0Client/Auth0User.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ - (id)auth0User:(NSDictionary *)accountProperties
if ((self = [super init])) {
_auth0AccessToken = [accountProperties objectForKey:@"access_token"];
_idToken = [accountProperties objectForKey:@"id_token"];
_profile = [self decodeBase64UrlEncode:[[[accountProperties objectForKey:@"id_token"] componentsSeparatedByString: @"."] objectAtIndex: 1]];
_profile = [[self decodeBase64UrlEncode:[[[accountProperties objectForKey:@"id_token"] componentsSeparatedByString: @"."] objectAtIndex: 1]] copy];
}

return self;
Expand Down Expand Up @@ -64,10 +64,10 @@ - (NSDictionary *)decodeBase64UrlEncode:(NSString *)encodedString

NSData *data = [[[NSData alloc] initWithData:[NSData dataFromBase64String:encodedString]] autorelease];
NSError* parseError;
NSDictionary* parseData = [NSJSONSerialization
JSONObjectWithData:data
options:kNilOptions
error:&parseError];
NSDictionary* parseData = [[[NSDictionary alloc] initWithDictionary:[NSJSONSerialization
JSONObjectWithData:data
options:kNilOptions
error:&parseError]] autorelease];

return parseData;
}
Expand Down
1 change: 0 additions & 1 deletion NSData+Base64/NSData+Base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@ char *NewBase64Encode(
@interface NSData (Base64)

+ (NSData *)dataFromBase64String:(NSString *)aString;
- (NSString *)base64EncodedString;

@end
21 changes: 0 additions & 21 deletions NSData+Base64/NSData+Base64.m
Original file line number Diff line number Diff line change
Expand Up @@ -286,25 +286,4 @@ + (NSData *)dataFromBase64String:(NSString *)aString
return result;
}

//
// base64EncodedString
//
// Creates an NSString object that contains the base 64 encoding of the
// receiver's data. Lines are broken at 64 characters long.
//
// returns an NSString being the base 64 representation of the
// receiver.
//
- (NSString *)base64EncodedString
{
size_t outputLength;
char *outputBuffer =
NewBase64Encode([self bytes], [self length], true, &outputLength);

NSString *result =
[[NSString alloc] initWithBytes:outputBuffer length:outputLength encoding:NSASCIIStringEncoding];
free(outputBuffer);
return result;
}

@end
1 change: 0 additions & 1 deletion iAuth0Client/include/Auth0Client/NSData+Base64.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,5 @@ char *NewBase64Encode(
@interface NSData (Base64)

+ (NSData *)dataFromBase64String:(NSString *)aString;
- (NSString *)base64EncodedString;

@end
21 changes: 0 additions & 21 deletions iAuth0Client/include/Auth0Client/NSData+Base64.m
Original file line number Diff line number Diff line change
Expand Up @@ -286,25 +286,4 @@ + (NSData *)dataFromBase64String:(NSString *)aString
return result;
}

//
// base64EncodedString
//
// Creates an NSString object that contains the base 64 encoding of the
// receiver's data. Lines are broken at 64 characters long.
//
// returns an NSString being the base 64 representation of the
// receiver.
//
- (NSString *)base64EncodedString
{
size_t outputLength;
char *outputBuffer =
NewBase64Encode([self bytes], [self length], true, &outputLength);

NSString *result =
[[NSString alloc] initWithBytes:outputBuffer length:outputLength encoding:NSASCIIStringEncoding];
free(outputBuffer);
return result;
}

@end
Binary file modified iAuth0Client/libAuth0Client.a
Binary file not shown.

0 comments on commit a3e59db

Please sign in to comment.