Skip to content

Commit

Permalink
Added support for Mac OS X 32-bit Applications.
Browse files Browse the repository at this point in the history
– Manually synthesized properties.
– Manually declared ivars
– Moved ivars from implementation to header.
– Converted the macOS sample to be a Universal Binary (adding 32-bit support).
  • Loading branch information
WilliamDenniss committed Apr 14, 2017
1 parent 69fa62e commit 8e4af3f
Show file tree
Hide file tree
Showing 38 changed files with 303 additions and 80 deletions.
8 changes: 8 additions & 0 deletions AppAuth.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,7 @@
340DAE551D58216A00EC285B /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_ANALYZER_NONNULL = YES;
CODE_SIGN_IDENTITY = "-";
EXECUTABLE_PREFIX = lib;
Expand All @@ -1800,6 +1801,7 @@
340DAE561D58216A00EC285B /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_ANALYZER_NONNULL = YES;
CODE_SIGN_IDENTITY = "-";
EXECUTABLE_PREFIX = lib;
Expand Down Expand Up @@ -1944,6 +1946,7 @@
341AA4D61E7F392C00FCA5C6 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_ANALYZER_NONNULL = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CODE_SIGN_IDENTITY = "-";
Expand All @@ -1961,6 +1964,7 @@
341AA4D71E7F392C00FCA5C6 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_ANALYZER_NONNULL = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CODE_SIGN_IDENTITY = "-";
Expand Down Expand Up @@ -2244,6 +2248,7 @@
343AAAD41E8348AA00F9D36E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_ANALYZER_NONNULL = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CODE_SIGN_IDENTITY = "-";
Expand All @@ -2270,6 +2275,7 @@
343AAAD51E8348AA00F9D36E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_ANALYZER_NONNULL = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CODE_SIGN_IDENTITY = "-";
Expand All @@ -2296,6 +2302,7 @@
343AAAD71E8348AA00F9D36E /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_ANALYZER_NONNULL = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CODE_SIGN_IDENTITY = "-";
Expand All @@ -2313,6 +2320,7 @@
343AAAD81E8348AA00F9D36E /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
CLANG_ANALYZER_NONNULL = YES;
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
CODE_SIGN_IDENTITY = "-";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 7FF583C8F7036437BE8875B3 /* Pods-Example-macOS.debug.xcconfig */;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
Expand All @@ -455,6 +456,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 60553B3AB5BA3E1BB259E487 /* Pods-Example-macOS.release.xcconfig */;
buildSettings = {
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
COMBINE_HIDPI_IMAGES = YES;
INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist";
Expand All @@ -474,6 +476,7 @@
341AA4C81E7F2E5000FCA5C6 /* Release */,
);
defaultConfigurationIsVisible = 0;
defaultConfigurationName = Release;
};
F6016E6B1D2AC11E003497D7 /* Build configuration list for PBXProject "Example-macOS" */ = {
isa = XCConfigurationList;
Expand Down
16 changes: 15 additions & 1 deletion Examples/Example-macOS/Source/AppAuthExampleViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,26 @@
@class AppDelegate;
@class OIDAuthState;
@class OIDServiceConfiguration;
@class OIDRedirectHTTPHandler;

NS_ASSUME_NONNULL_BEGIN

/*! @brief The example application's view controller.
*/
@interface AppAuthExampleViewController : NSViewController
@interface AppAuthExampleViewController : NSViewController {
// private variables
OIDRedirectHTTPHandler *_redirectHTTPHandler;
// property variables
NSButton *_authAutoButton;
NSButton *_authManual;
NSButton *_authAutoHTTPButton;
NSButton *_codeExchangeButton;
NSButton *_userinfoButton;
NSButton *_clearAuthStateButton;
NSTextView *_logTextView;
__weak AppDelegate *_appDelegate;
OIDAuthState *_authState;
}

@property(nullable) IBOutlet NSButton *authAutoButton;
@property(nullable) IBOutlet NSButton *authManual;
Expand Down
14 changes: 11 additions & 3 deletions Examples/Example-macOS/Source/AppAuthExampleViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,17 @@
@interface AppAuthExampleViewController () <OIDAuthStateChangeDelegate, OIDAuthStateErrorDelegate>
@end

@implementation AppAuthExampleViewController {
OIDRedirectHTTPHandler *_redirectHTTPHandler;
}
@implementation AppAuthExampleViewController

@synthesize authAutoButton = _authAutoButton;
@synthesize authManual = _authManual;
@synthesize authAutoHTTPButton = _authAutoHTTPButton;
@synthesize codeExchangeButton = _codeExchangeButton;
@synthesize userinfoButton = _userinfoButton;
@synthesize clearAuthStateButton = _clearAuthStateButton;
@synthesize logTextView = _logTextView;
@synthesize appDelegate = _appDelegate;
@synthesize authState = _authState;

- (void)viewDidLoad {
[super viewDidLoad];
Expand Down
8 changes: 7 additions & 1 deletion Examples/Example-macOS/Source/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ NS_ASSUME_NONNULL_BEGIN
/*! @class AppDelegate
@brief The example application's delegate.
*/
@interface AppDelegate : NSObject <NSApplicationDelegate>
@interface AppDelegate : NSObject <NSApplicationDelegate> {
// property variables
NSWindow *_window;
id<OIDAuthorizationFlowSession> _currentAuthorizationFlow;
}

/*! @property currentAuthorizationFlow
@brief The authorization flow session which receives the return URL from the browser.
Expand All @@ -34,6 +38,8 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property(nonatomic, strong, nullable) id<OIDAuthorizationFlowSession> currentAuthorizationFlow;

@property(nullable) IBOutlet NSWindow *window;

@end

NS_ASSUME_NONNULL_END
7 changes: 3 additions & 4 deletions Examples/Example-macOS/Source/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@

NS_ASSUME_NONNULL_BEGIN

@interface AppDelegate ()
@property(nullable) IBOutlet NSWindow *window;
@end

@implementation AppDelegate

@synthesize window = _window;
@synthesize currentAuthorizationFlow = _currentAuthorizationFlow;

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
_window.title = @"AppAuth Example for macOS";
AppAuthExampleViewController *contentViewController =
Expand Down
25 changes: 24 additions & 1 deletion Source/OIDAuthState.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,30 @@ typedef void (^OIDAuthStateAuthorizationCallback)(OIDAuthState *_Nullable authSt
/*! @brief A convenience class that retains the auth state between @c OIDAuthorizationResponse%s
and @c OIDTokenResponse%s.
*/
@interface OIDAuthState : NSObject <NSSecureCoding>
@interface OIDAuthState : NSObject <NSSecureCoding> {
// private variables
/*! @brief Array of pending actions (use @c _pendingActionsSyncObject to synchronize access).
*/
NSMutableArray *_pendingActions;

/*! @brief Object for synchronizing access to @c pendingActions.
*/
id _pendingActionsSyncObject;

/*! @brief If YES, tokens will be refreshed on the next API call regardless of expiry.
*/
BOOL _needsTokenRefresh;

// property variables
NSString *_refreshToken;
NSString *_scope;
OIDAuthorizationResponse *_lastAuthorizationResponse;
OIDTokenResponse *_lastTokenResponse;
OIDRegistrationResponse *_lastRegistrationResponse;
NSError *_authorizationError;
__weak id<OIDAuthStateChangeDelegate> _stateChangeDelegate;
__weak id<OIDAuthStateErrorDelegate> _errorDelegate;
}

/*! @brief The most recent refresh token received from the server.
@discussion Rather than using this property directly, you should call
Expand Down
23 changes: 10 additions & 13 deletions Source/OIDAuthState.m
Original file line number Diff line number Diff line change
Expand Up @@ -87,19 +87,16 @@ - (void)didChangeState;
@end


@implementation OIDAuthState {
/*! @brief Array of pending actions (use @c _pendingActionsSyncObject to synchronize access).
*/
NSMutableArray *_pendingActions;

/*! @brief Object for synchronizing access to @c pendingActions.
*/
id _pendingActionsSyncObject;

/*! @brief If YES, tokens will be refreshed on the next API call regardless of expiry.
*/
BOOL _needsTokenRefresh;
}
@implementation OIDAuthState

@synthesize refreshToken = _refreshToken;
@synthesize scope = _scope;
@synthesize lastAuthorizationResponse = _lastAuthorizationResponse;
@synthesize lastTokenResponse = _lastTokenResponse;
@synthesize lastRegistrationResponse = _lastRegistrationResponse;
@synthesize authorizationError = _authorizationError;
@synthesize stateChangeDelegate = _stateChangeDelegate;
@synthesize errorDelegate = _errorDelegate;

#pragma mark - Convenience initializers

Expand Down
15 changes: 14 additions & 1 deletion Source/OIDAuthorizationRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,20 @@ extern NSString *const OIDOAuthorizationRequestCodeChallengeMethodS256;
@see https://tools.ietf.org/html/rfc6749#section-4
@see https://tools.ietf.org/html/rfc6749#section-4.1.1
*/
@interface OIDAuthorizationRequest : NSObject <NSCopying, NSSecureCoding>
@interface OIDAuthorizationRequest : NSObject <NSCopying, NSSecureCoding> {
// property variables
OIDServiceConfiguration *_configuration;
NSString *_responseType;
NSString *_clientID;
NSString *_clientSecret;
NSString *_scope;
NSURL *_redirectURL;
NSString *_state;
NSString *_codeVerifier;
NSString *_codeChallenge;
NSString *_codeChallengeMethod;
NSDictionary<NSString *, NSString *> *_additionalParameters;
}

/*! @brief The service's configuration.
@remarks This configuration specifies how to connect to a particular OAuth provider.
Expand Down
12 changes: 12 additions & 0 deletions Source/OIDAuthorizationRequest.m
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,18 @@

@implementation OIDAuthorizationRequest

@synthesize configuration = _configuration;
@synthesize responseType = _responseType;
@synthesize clientID = _clientID;
@synthesize clientSecret = _clientSecret;
@synthesize scope = _scope;
@synthesize redirectURL = _redirectURL;
@synthesize state = _state;
@synthesize codeVerifier = _codeVerifier;
@synthesize codeChallenge = _codeChallenge;
@synthesize codeChallengeMethod = _codeChallengeMethod;
@synthesize additionalParameters = _additionalParameters;

- (instancetype)init
OID_UNAVAILABLE_USE_INITIALIZER(
@selector(initWithConfiguration:
Expand Down
13 changes: 12 additions & 1 deletion Source/OIDAuthorizationResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,18 @@ NS_ASSUME_NONNULL_BEGIN
@see https://tools.ietf.org/html/rfc6749#section-5.1
@see http://openid.net/specs/openid-connect-core-1_0.html#ImplicitAuthResponse
*/
@interface OIDAuthorizationResponse : NSObject <NSCopying, NSSecureCoding>
@interface OIDAuthorizationResponse : NSObject <NSCopying, NSSecureCoding> {
// property variables
OIDAuthorizationRequest *_request;
NSString *_authorizationCode;
NSString *_state;
NSString *_accessToken;
NSDate *_accessTokenExpirationDate;
NSString *_tokenType;
NSString *_idToken;
NSString *_scope;
NSDictionary<NSString *, NSObject<NSCopying> *> *_additionalParameters;
}

/*! @brief The request which was serviced.
*/
Expand Down
10 changes: 10 additions & 0 deletions Source/OIDAuthorizationResponse.m
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,16 @@

@implementation OIDAuthorizationResponse

@synthesize request = _request;
@synthesize authorizationCode = _authorizationCode;
@synthesize state = _state;
@synthesize accessToken = _accessToken;
@synthesize accessTokenExpirationDate = _accessTokenExpirationDate;
@synthesize tokenType = _tokenType;
@synthesize idToken = _idToken;
@synthesize scope = _scope;
@synthesize additionalParameters = _additionalParameters;

/*! @brief Returns a mapping of incoming parameters to instance variables.
@return A mapping of incoming parameters to instance variables.
*/
Expand Down
5 changes: 4 additions & 1 deletion Source/OIDAuthorizationService.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ typedef void (^OIDRegistrationCompletion)(OIDRegistrationResponse *_Nullable reg
/*! @brief Performs various OAuth and OpenID Connect related calls via the user agent or
\NSURLSession.
*/
@interface OIDAuthorizationService : NSObject
@interface OIDAuthorizationService : NSObject {
// property variables
OIDServiceConfiguration *_configuration;
}

/*! @brief The service's configuration.
@remarks Each authorization service is initialized with a configuration. This configuration
Expand Down
15 changes: 9 additions & 6 deletions Source/OIDAuthorizationService.m
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@

NS_ASSUME_NONNULL_BEGIN

@interface OIDAuthorizationFlowSessionImplementation : NSObject<OIDAuthorizationFlowSession>
@interface OIDAuthorizationFlowSessionImplementation : NSObject<OIDAuthorizationFlowSession> {
// private variables
OIDAuthorizationRequest *_request;
id<OIDAuthorizationUICoordinator> _UICoordinator;
OIDAuthorizationCallback _pendingauthorizationFlowCallback;
}

- (instancetype)init NS_UNAVAILABLE;

Expand All @@ -51,11 +56,7 @@ - (instancetype)initWithRequest:(OIDAuthorizationRequest *)request

@end

@implementation OIDAuthorizationFlowSessionImplementation {
OIDAuthorizationRequest *_request;
id<OIDAuthorizationUICoordinator> _UICoordinator;
OIDAuthorizationCallback _pendingauthorizationFlowCallback;
}
@implementation OIDAuthorizationFlowSessionImplementation

- (instancetype)initWithRequest:(OIDAuthorizationRequest *)request {
self = [super init];
Expand Down Expand Up @@ -176,6 +177,8 @@ - (void)didFinishWithResponse:(nullable OIDAuthorizationResponse *)response

@implementation OIDAuthorizationService

@synthesize configuration = _configuration;

+ (void)discoverServiceConfigurationForIssuer:(NSURL *)issuerURL
completion:(OIDDiscoveryCallback)completion {
NSURL *fullDiscoveryURL =
Expand Down
7 changes: 6 additions & 1 deletion Source/OIDFieldMapping.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ typedef _Nullable id(^OIDFieldMappingConversionFunction)(NSObject *_Nullable val
/*! @brief Describes the mapping of a key/value pair to an iVar with an optional conversion
function.
*/
@interface OIDFieldMapping : NSObject
@interface OIDFieldMapping : NSObject {
// property variables
NSString *_name;
Class _expectedType;
OIDFieldMappingConversionFunction _conversion;
}

/*! @brief The name of the instance variable the field should be mapped to.
*/
Expand Down
4 changes: 4 additions & 0 deletions Source/OIDFieldMapping.m
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@

@implementation OIDFieldMapping

@synthesize name = _name;
@synthesize expectedType = _expectedType;
@synthesize conversion = _conversion;

- (nonnull instancetype)init
OID_UNAVAILABLE_USE_INITIALIZER(@selector(initWithName:type:conversion:));

Expand Down
Loading

0 comments on commit 8e4af3f

Please sign in to comment.