Permalink
Browse files

GREENHOUSE-522, GREENHOUSE-525 major authentication updates

- replaced externalized safari sign on with native in app sign in functionality
- removed OAuthConsumer library and OAuth 1.x support
- implemented OAuth 2 authorization
- updated all authenticated requests to use OAuth 2
  • Loading branch information...
1 parent 363c9c7 commit 2c550ab9d7ecd1f6aacd91206d802c8b2f1cfdc2 @royclarkson royclarkson committed Aug 30, 2012
Showing with 4,661 additions and 3,629 deletions.
  1. +200 −148 Greenhouse.xcodeproj/project.pbxproj
  2. +5 −0 Greenhouse/Constants.h
  3. +29 −0 Greenhouse/GHAuthorizeNavigationViewController.h
  4. +60 −0 Greenhouse/GHAuthorizeNavigationViewController.m
  5. +4 −2 Greenhouse/GHAuthorizeViewController.h
  6. +8 −4 Greenhouse/GHAuthorizeViewController.m
  7. +27 −0 Greenhouse/GHAuthorizedRequest.h
  8. +34 −0 Greenhouse/GHAuthorizedRequest.m
  9. +6 −6 Greenhouse/{GHOAuthController.h → GHBaseController.h}
  10. +7 −33 Greenhouse/{GHOAuthController.m → GHBaseController.m}
  11. +1 −1 Greenhouse/GHEvent.m
  12. +4 −5 Greenhouse/GHEventController.h
  13. +29 −42 Greenhouse/GHEventController.m
  14. +1 −1 Greenhouse/GHEventDetailsViewController.m
  15. +1 −1 Greenhouse/GHEventSession.m
  16. +14 −15 Greenhouse/GHEventSessionController.h
  17. +237 −300 Greenhouse/GHEventSessionController.m
  18. +1 −1 Greenhouse/GHEventSessionDetailsViewController.m
  19. +4 −4 Greenhouse/GHEventSessionsMenuViewController.m
  20. +0 −3 Greenhouse/GHEventsMainViewController.m
  21. +44 −6 Greenhouse/GHInfoContent.html
  22. +34 −0 Greenhouse/GHKeychainManager.h
  23. +94 −0 Greenhouse/GHKeychainManager.m
  24. +36 −0 Greenhouse/GHOAuth2Controller.h
  25. +90 −0 Greenhouse/GHOAuth2Controller.m
  26. +0 −51 Greenhouse/GHOAuthManager.h
  27. +0 −297 Greenhouse/GHOAuthManager.m
  28. +4 −5 Greenhouse/GHProfileController.h
  29. +20 −37 Greenhouse/GHProfileController.m
  30. +2 −3 Greenhouse/GHProfileMainViewController.m
  31. +42 −0 Greenhouse/GHSignInViewController.h
  32. +296 −0 Greenhouse/GHSignInViewController.m
  33. +3 −3 Greenhouse/GHTweet.m
  34. +0 −3 Greenhouse/GHTweetDetailsViewController.m
  35. +2 −5 Greenhouse/GHTweetViewController.m
  36. +0 −3 Greenhouse/GHTweetsViewController.m
  37. +8 −9 Greenhouse/GHTwitterController.h
  38. +150 −179 Greenhouse/GHTwitterController.m
  39. +30 −0 Greenhouse/GHURLPostRequest.h
  40. +40 −0 Greenhouse/GHURLPostRequest.m
  41. +31 −0 Greenhouse/GHURLRequest.h
  42. +53 −0 Greenhouse/GHURLRequest.m
  43. +6 −5 Greenhouse/{GHOAuthResponseDelegate.h → GHURLRequestParameters.h}
  44. +64 −0 Greenhouse/GHURLRequestParameters.m
  45. +1 −1 Greenhouse/GHVenueDetailsViewController.m
  46. +3 −3 Greenhouse/Greenhouse-Prefix.pch
  47. +4 −6 Greenhouse/GreenhouseAppDelegate.h
  48. +18 −55 Greenhouse/GreenhouseAppDelegate.m
  49. +42 −0 Greenhouse/NSData+Base64.h
  50. +309 −0 Greenhouse/NSData+Base64.m
  51. +1 −1 Greenhouse/NSDictionary+Helpers.m
  52. +6 −4 Greenhouse/{NSString+XmlEncoding.h → NSString+Encoding.h}
  53. +24 −5 Greenhouse/{NSString+XmlEncoding.m → NSString+Encoding.m}
  54. +43 −0 Greenhouse/OA2AccessGrant.h
  55. +176 −0 Greenhouse/OA2AccessGrant.m
  56. +16 −0 Greenhouse/OA2AuthorizedRequest.h
  57. +27 −0 Greenhouse/OA2AuthorizedRequest.m
  58. +17 −0 Greenhouse/OA2SignInRequest.h
  59. +29 −0 Greenhouse/OA2SignInRequest.m
  60. +29 −0 Greenhouse/OA2SignInRequestParameters.h
  61. +54 −0 Greenhouse/OA2SignInRequestParameters.m
  62. +0 −230 Greenhouse/OAuthConsumer/Crypto/Base64Transcoder.c
  63. +0 −36 Greenhouse/OAuthConsumer/Crypto/Base64Transcoder.h
  64. +0 −35 Greenhouse/OAuthConsumer/NSMutableURLRequest+Parameters.h
  65. +0 −86 Greenhouse/OAuthConsumer/NSMutableURLRequest+Parameters.m
  66. +0 −34 Greenhouse/OAuthConsumer/NSString+URLEncoding.h
  67. +0 −50 Greenhouse/OAuthConsumer/NSString+URLEncoding.m
  68. +0 −34 Greenhouse/OAuthConsumer/NSURL+Base.h
  69. +0 −38 Greenhouse/OAuthConsumer/NSURL+Base.m
  70. +0 −46 Greenhouse/OAuthConsumer/OAAsynchronousDataFetcher.h
  71. +0 −116 Greenhouse/OAuthConsumer/OAAsynchronousDataFetcher.m
  72. +0 −40 Greenhouse/OAuthConsumer/OAConsumer.h
  73. +0 −44 Greenhouse/OAuthConsumer/OAConsumer.m
  74. +0 −44 Greenhouse/OAuthConsumer/OADataFetcher.h
  75. +0 −76 Greenhouse/OAuthConsumer/OADataFetcher.m
  76. +0 −32 Greenhouse/OAuthConsumer/OAHMAC_SHA1SignatureProvider.h
  77. +0 −57 Greenhouse/OAuthConsumer/OAHMAC_SHA1SignatureProvider.m
  78. +0 −68 Greenhouse/OAuthConsumer/OAMutableURLRequest.h
  79. +0 −223 Greenhouse/OAuthConsumer/OAMutableURLRequest.m
  80. +0 −31 Greenhouse/OAuthConsumer/OAPlaintextSignatureProvider.h
  81. +0 −43 Greenhouse/OAuthConsumer/OAPlaintextSignatureProvider.m
  82. +0 −45 Greenhouse/OAuthConsumer/OARequestParameter.h
  83. +0 −63 Greenhouse/OAuthConsumer/OARequestParameter.m
  84. +0 −43 Greenhouse/OAuthConsumer/OAServiceTicket.h
  85. +0 −44 Greenhouse/OAuthConsumer/OAServiceTicket.m
  86. +0 −34 Greenhouse/OAuthConsumer/OASignatureProviding.h
  87. +0 −41 Greenhouse/OAuthConsumer/OAToken.h
  88. +0 −98 Greenhouse/OAuthConsumer/OAToken.m
  89. +0 −19 Greenhouse/OAuthConsumer/OAToken_KeychainExtensions.h
  90. +0 −224 Greenhouse/OAuthConsumer/OAToken_KeychainExtensions.m
  91. +0 −40 Greenhouse/OAuthConsumer/OAuthConsumer.h
  92. +316 −0 Greenhouse/en.lproj/GHAuthorizeNavigationViewController.xib
  93. +190 −28 Greenhouse/en.lproj/GHAuthorizeViewController.xib
  94. +168 −6 Greenhouse/en.lproj/GHEventsNavigationViewController.xib
  95. +39 −9 Greenhouse/en.lproj/GHInfoViewController.xib
  96. +714 −0 Greenhouse/en.lproj/GHSignInViewController.xib
  97. +10 −233 Greenhouse/en.lproj/MainWindow.xib
  98. +27 −0 GreenhouseApplicationTests/GHKeychainManagerTests.h
  99. +102 −0 GreenhouseApplicationTests/GHKeychainManagerTests.m
  100. +27 −0 GreenhouseApplicationTests/GHOauth2ControllerTests.h
  101. +71 −0 GreenhouseApplicationTests/GHOauth2ControllerTests.m
  102. +5 −0 GreenhouseApplicationTests/GreenhouseApplicationTests-Prefix.pch
  103. +0 −13 GreenhouseApplicationTests/GreenhouseApplicationTests.h
  104. +0 −32 GreenhouseApplicationTests/GreenhouseApplicationTests.m
  105. +29 −0 GreenhouseLogicTests/GHServiceValidator.h
  106. +147 −0 GreenhouseLogicTests/GHServiceValidator.m
  107. +4 −0 GreenhouseLogicTests/GreenhouseLogicTests-Prefix.pch
  108. +0 −13 GreenhouseLogicTests/GreenhouseLogicTests.h
  109. +0 −32 GreenhouseLogicTests/GreenhouseLogicTests.m
  110. +0 −1 GreenhouseLogicTests/NSDictionary_HelpersTests.h
  111. +28 −0 GreenhouseLogicTests/OA2AccessGrantTests.h
  112. +264 −0 GreenhouseLogicTests/OA2AccessGrantTests.m
  113. +0 −1 GreenhouseLogicTests/UIColor_CustomColorsTests.h

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -55,6 +55,11 @@
#define OAUTH_ACCESS_TOKEN_URL [NSString stringWithFormat:@"%@%@", GREENHOUSE_URL, @"/oauth/access_token"]
#define OAUTH_CALLBACK_URL @"x-com-springsource-greenhouse://oauth-response"
+#pragma mark -
+#pragma mark OAuth 2
+
+#define OAUTH_TOKEN_URL [NSString stringWithFormat:@"%@%@", GREENHOUSE_URL, @"/oauth/token"]
+
#pragma mark -
#pragma mark Member Profile
@@ -0,0 +1,29 @@
+//
+// Copyright 2012 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// GHAuthorizeNavigationViewController.h
+// Greenhouse
+//
+// Created by Roy Clarkson on 7/30/12.
+//
+
+#import <UIKit/UIKit.h>
+
+@interface GHAuthorizeNavigationViewController : UIViewController <UINavigationControllerDelegate>
+
+@property (nonatomic, strong) IBOutlet UINavigationController *navigationController;
+
+@end
@@ -0,0 +1,60 @@
+//
+// Copyright 2012 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// GHAuthorizeNavigationViewController.m
+// Greenhouse
+//
+// Created by Roy Clarkson on 7/30/12.
+//
+
+#import "GHAuthorizeNavigationViewController.h"
+
+@interface GHAuthorizeNavigationViewController ()
+
+@end
+
+@implementation GHAuthorizeNavigationViewController
+
+@synthesize navigationController;
+
+
+#pragma mark -
+#pragma mark UIViewController methods
+
+- (void)viewDidLoad
+{
+ [super viewDidLoad];
+
+ // correct the layout of the subview
+ navigationController.view.frame = self.view.bounds;
+
+ // add the home screen view
+ [self.view addSubview:navigationController.view];
+}
+
+- (void)didReceiveMemoryWarning
+{
+ [super didReceiveMemoryWarning];
+}
+
+- (void)viewDidUnload
+{
+ [super viewDidUnload];
+
+ self.navigationController = nil;
+}
+
+@end
@@ -21,10 +21,12 @@
//
#import <UIKit/UIKit.h>
-
+#import "GHSignInViewController.h"
@interface GHAuthorizeViewController : UIViewController
-- (IBAction)actionAuthorize:(id)sender;
+@property (nonatomic, strong) IBOutlet GHSignInViewController *signInViewController;
+
+- (IBAction)actionSignIn:(id)sender;
@end
@@ -21,14 +21,14 @@
//
#import "GHAuthorizeViewController.h"
-#import "GHOAuthManager.h"
-
@implementation GHAuthorizeViewController
-- (IBAction)actionAuthorize:(id)sender
+@synthesize signInViewController;
+
+- (IBAction)actionSignIn:(id)sender
{
- [[GHOAuthManager sharedInstance] fetchUnauthorizedRequestToken];
+ [self.navigationController pushViewController:signInViewController animated:YES];
}
@@ -38,6 +38,8 @@ - (IBAction)actionAuthorize:(id)sender
- (void)viewDidLoad
{
[super viewDidLoad];
+
+ [self.navigationController setNavigationBarHidden:YES];
}
- (void)didReceiveMemoryWarning
@@ -48,6 +50,8 @@ - (void)didReceiveMemoryWarning
- (void)viewDidUnload
{
[super viewDidUnload];
+
+ self.signInViewController = nil;
}
@end
@@ -0,0 +1,27 @@
+//
+// Copyright 2012 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// GHAuthorizedRequest.h
+// Greenhouse
+//
+// Created by Roy Clarkson on 8/29/12.
+//
+
+#import "OA2AuthorizedRequest.h"
+
+@interface GHAuthorizedRequest : OA2AuthorizedRequest
+
+@end
@@ -0,0 +1,34 @@
+//
+// Copyright 2012 the original author or authors.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+//
+// GHAuthorizedRequest.m
+// Greenhouse
+//
+// Created by Roy Clarkson on 8/29/12.
+//
+
+#import "GHAuthorizedRequest.h"
+#import "GHOAuth2Controller.h"
+
+@implementation GHAuthorizedRequest
+
+- (id)initWithURL:(NSURL *)URL
+{
+ OA2AccessGrant *accessGrant = [[GHOAuth2Controller sharedInstance] fetchAccessGrant];
+ return [super initWithURL:URL accessToken:accessGrant.accessToken];
+}
+
+@end
@@ -14,19 +14,20 @@
// limitations under the License.
//
//
-// GHOAuthController.h
+// GHBaseController.h
// Greenhouse
//
// Created by Roy Clarkson on 9/16/10.
//
#import <Foundation/Foundation.h>
+#import "GHAuthorizedRequest.h"
+#import "OA2AccessGrant.h"
#import "GHActivityAlertView.h"
-@interface GHOAuthController : NSObject
+@interface GHBaseController : NSObject
{
- OAAsynchronousDataFetcher *_dataFetcher;
GHActivityAlertView *_activityAlertView;
id _didFailDelegate;
SEL _didFailSelector;
@@ -35,8 +36,7 @@
@property (nonatomic, strong) GHActivityAlertView *activityAlertView;
-- (void)cancelDataFetcherRequest;
-- (void)request:(OAServiceTicket *)ticket didNotSucceedWithDefaultMessage:(NSString *)message;
-- (void)request:(OAServiceTicket *)ticket didFailWithError:(NSError *)error;
+- (void)requestDidNotSucceedWithDefaultMessage:(NSString *)message response:(NSURLResponse *)response;
+- (void)requestDidFailWithError:(NSError *)error;
@end
@@ -14,36 +14,21 @@
// limitations under the License.
//
//
-// GHOAuthController.m
+// GHBaseController.m
// Greenhouse
//
// Created by Roy Clarkson on 9/16/10.
//
-#import "GHOAuthController.h"
-#import "GHOAuthManager.h"
+#import "GHBaseController.h"
-
-@implementation GHOAuthController
+@implementation GHBaseController
@synthesize activityAlertView = _activityAlertView;
-- (void)cancelDataFetcherRequest
+- (void)requestDidNotSucceedWithDefaultMessage:(NSString *)message response:(NSURLResponse *)response
{
- if (_dataFetcher)
- {
- DLog(@"");
-
- [_dataFetcher cancel];
- _dataFetcher = nil;
- }
-}
-
-- (void)request:(OAServiceTicket *)ticket didNotSucceedWithDefaultMessage:(NSString *)message
-{
- NSHTTPURLResponse *response = (NSHTTPURLResponse *)ticket.response;
- NSInteger statusCode = [response statusCode];
-
+ NSInteger statusCode = [(NSHTTPURLResponse *)response statusCode];
DLog(@"status code: %d", statusCode);
if (statusCode == 401)
@@ -66,10 +51,8 @@ - (void)request:(OAServiceTicket *)ticket didNotSucceedWithDefaultMessage:(NSStr
}
}
-- (void)request:(OAServiceTicket *)ticket didFailWithError:(NSError *)error
-{
- _dataFetcher = nil;
-
+- (void)requestDidFailWithError:(NSError *)error
+{
DLog(@"%@", [error localizedDescription]);
if ([error code] == NSURLErrorUserCancelledAuthentication)
@@ -92,13 +75,4 @@ - (void)request:(OAServiceTicket *)ticket didFailWithError:(NSError *)error
}
}
-
-#pragma mark -
-#pragma mark NSObject methods
-
-- (void)dealloc
-{
- [self cancelDataFetcherRequest];
-}
-
@end
View
@@ -83,7 +83,7 @@ - (id)initWithDictionary:(NSDictionary *)dictionary
self.startTime = [dictionary dateWithMillisecondsSince1970ForKey:@"startTime"];
self.endTime = [dictionary dateWithMillisecondsSince1970ForKey:@"endTime"];
self.location = [dictionary stringByReplacingPercentEscapesForKey:@"location" usingEncoding:NSUTF8StringEncoding];
- self.description = [[dictionary stringForKey:@"description"] stringBySimpleXmlDecoding];
+ self.description = [[dictionary stringForKey:@"description"] stringByXMLDecoding];
self.name = [dictionary stringByReplacingPercentEscapesForKey:@"name" usingEncoding:NSUTF8StringEncoding];
self.hashtag = [dictionary stringByReplacingPercentEscapesForKey:@"hashtag" usingEncoding:NSUTF8StringEncoding];
self.groupName = [dictionary stringByReplacingPercentEscapesForKey:@"groupName" usingEncoding:NSUTF8StringEncoding];
@@ -20,17 +20,16 @@
// Created by Roy Clarkson on 8/31/10.
//
-#import <Foundation/Foundation.h>
-#import "GHOAuthController.h"
+#import "GHBaseController.h"
#import "GHEventControllerDelegate.h"
-@interface GHEventController : GHOAuthController
+@interface GHEventController : GHBaseController
@property (nonatomic, unsafe_unretained) id<GHEventControllerDelegate> delegate;
- (void)fetchEvents;
-- (void)fetchEvents:(OAServiceTicket *)ticket didFinishWithData:(NSData *)data;
-- (void)fetchEvents:(OAServiceTicket *)ticket didFailWithError:(NSError *)error;
+- (void)fetchEventsDidFinishWithData:(NSData *)data;
+- (void)fetchEventsDidFailWithError:(NSError *)error;
@end
Oops, something went wrong.

0 comments on commit 2c550ab

Please sign in to comment.