NetIQ Mobile SDK for iOS  2.0
Access Manager iOS Framework for OAuth & OIDC
OIDAuthState.h
Go to the documentation of this file.
1 
18 #import <Foundation/Foundation.h>
19 
22 @class OIDAuthState;
24 @class OIDTokenResponse;
25 @class OIDTokenRequest;
26 @protocol OIDAuthorizationFlowSession;
30 
31 NS_ASSUME_NONNULL_BEGIN
32 
38 typedef void (^OIDAuthStateAction)(NSString *_Nullable accessToken,
39  NSString *_Nullable idToken,
40  NSError *_Nullable error);
41 
48 typedef void (^OIDAuthStateAuthorizationCallback)(OIDAuthState *_Nullable authState,
49  NSError *_Nullable error);
50 
54 @interface OIDAuthState : NSObject <NSSecureCoding>
55 
62 @property(nonatomic, readonly, nullable) NSString *refreshToken;
63 
69 @property(nonatomic, readonly, nullable) NSString *scope;
70 
74 @property(nonatomic, readonly) OIDAuthorizationResponse *lastAuthorizationResponse;
75 
79 @property(nonatomic, readonly, nullable) OIDTokenResponse *lastTokenResponse;
80 
84 @property(nonatomic, readonly, nullable) OIDRegistrationResponse *lastRegistrationResponse;
85 
94 @property(nonatomic, readonly, nullable) NSError *authorizationError;
95 
105 @property(nonatomic, readonly) BOOL isAuthorized;
106 
111 @property(nonatomic, weak, nullable) id<OIDAuthStateChangeDelegate> stateChangeDelegate;
112 
117 @property(nonatomic, weak, nullable) id<OIDAuthStateErrorDelegate> errorDelegate;
118 
129 + (id<OIDAuthorizationFlowSession>)
130  authStateByPresentingAuthorizationRequest:(OIDAuthorizationRequest *)authorizationRequest
131  UICoordinator:(id<OIDAuthorizationUICoordinator>)UICoordinator
132  callback:(OIDAuthStateAuthorizationCallback)callback;
133 
137 - (instancetype)init NS_UNAVAILABLE;
138 
142 - (instancetype)initWithAuthorizationResponse:(OIDAuthorizationResponse *)authorizationResponse;
143 
148 - (instancetype)initWithAuthorizationResponse:(OIDAuthorizationResponse *)authorizationResponse
149  tokenResponse:(nullable OIDTokenResponse *)tokenResponse;
150 
154 - (instancetype)initWithRegistrationResponse:(OIDRegistrationResponse *)registrationResponse;
155 
161 - (instancetype)initWithAuthorizationResponse:
162  (nullable OIDAuthorizationResponse *)authorizationResponse
163  tokenResponse:(nullable OIDTokenResponse *)tokenResponse
164  registrationResponse:(nullable OIDRegistrationResponse *)registrationResponse
165  NS_DESIGNATED_INITIALIZER;
166 
175 - (void)updateWithAuthorizationResponse:(nullable OIDAuthorizationResponse *)authorizationResponse
176  error:(nullable NSError *)error;
177 
186 - (void)updateWithTokenResponse:(nullable OIDTokenResponse *)tokenResponse
187  error:(nullable NSError *)error;
188 
194 - (void)updateWithRegistrationResponse:(nullable OIDRegistrationResponse *)registrationResponse;
195 
209 - (void)updateWithAuthorizationError:(NSError *)authorizationError;
210 
216 - (void)performActionWithFreshTokens:(OIDAuthStateAction)action;
217 
225 - (void)performActionWithFreshTokens:(OIDAuthStateAction)action
226  additionalRefreshParameters:
227  (nullable NSDictionary<NSString *, NSString *> *)additionalParameters;
228 
232 - (void)setNeedsTokenRefresh;
233 
242 
251 - (nullable OIDTokenRequest *)tokenRefreshRequestWithAdditionalParameters:
252  (nullable NSDictionary<NSString *, NSString *> *)additionalParameters;
253 
261 - (void)withFreshTokensPerformAction:(OIDAuthStateAction)action
262  __deprecated_msg("Use OIDAuthState.performActionWithFreshTokens:");
263 
264 @end
265 
266 NS_ASSUME_NONNULL_END
OIDTokenResponse * lastTokenResponse
The most recent token response used to update this authorization state. This will contain the latest ...
Definition: OIDAuthState.h:79
OIDAuthorizationResponse * lastAuthorizationResponse
The most recent authorization response used to update the authorization state. For the implicit flow...
Definition: OIDAuthState.h:74
Delegate of the OIDAuthState used to monitor various changes in state.
Definition: OIDAuthStateChangeDelegate.h:21
NS_ASSUME_NONNULL_BEGIN typedef void(^ OIDAuthStateAction)(NSString *_Nullable accessToken, NSString *_Nullable idToken, NSError *_Nullable error)
Represents a block used to call an action with a fresh access token.
NSString * refreshToken
The most recent refresh token received from the server. Rather than using this property directly...
Definition: OIDAuthState.h:62
NSString * scope
The scope of the current authorization grant. This represents the latest scope returned by the serve...
Definition: OIDAuthState.h:69
void setNeedsTokenRefresh()
Forces a token refresh the next time performActionWithFreshTokens: is called, even if the current tok...
An authorization UI coordinator that presents an authorization request. Clients may provide custom im...
Definition: OIDAuthorizationUICoordinator.h:30
Represents the response to an authorization request.
Definition: OIDAuthorizationResponse.h:31
Represents an authorization request.
Definition: OIDAuthorizationRequest.h:40
BOOL isAuthorized
Returns YES if the authorization state is not known to be invalid. Returns YES if no OAuth errors ha...
Definition: OIDAuthState.h:105
Represents a registration response.
Definition: OIDRegistrationResponse.h:53
Represents a token request.
Definition: OIDTokenRequest.h:34
OIDRegistrationResponse * lastRegistrationResponse
The most recent registration response used to update this authorization state. This will contain the ...
Definition: OIDAuthState.h:84
id< OIDAuthStateErrorDelegate > errorDelegate
The OIDAuthStateErrorDelegate delegate. Use the delegate to observe state changes (and update storag...
Definition: OIDAuthState.h:117
NSError * authorizationError
The authorization error that invalidated this OIDAuthState. The authorization error encountered by O...
Definition: OIDAuthState.h:94
Represents the response to an token request.
Definition: OIDTokenResponse.h:29
id< OIDAuthStateChangeDelegate > stateChangeDelegate
The OIDAuthStateChangeDelegate delegate. Use the delegate to observe state changes (and update stora...
Definition: OIDAuthState.h:111
A convenience class that retains the auth state between OIDAuthorizationResponses and OIDTokenRespons...
Definition: OIDAuthState.h:54
void(^ OIDAuthStateAuthorizationCallback)(OIDAuthState *_Nullable authState, NSError *_Nullable error)
The method called when the authStateByPresentingAuthorizationRequest:presentingViewController:callbac...
Definition: OIDAuthState.h:48
Delegate of the OIDAuthState used to monitor errors.
Definition: OIDAuthStateErrorDelegate.h:21
nullable OIDTokenRequest * tokenRefreshRequest()
Creates a token request suitable for refreshing an access token.