Inherits from NSObject
Declared in DCAuthenticationContext.h

Overview

Context of an authentication.

Properties

accessToken

An access token retrieved by DCAuthority.

@property (nonatomic, readonly) NSString *accessToken

Discussion

This is an access token retrieved by DCAuthority. If you want to access PhotoColle server without PhotoColleSDK, you can use this access token.

Declared In

DCAuthenticationContext.h

Class Methods

hasSavedByKey:error:

Check whether AuthenticateContext has stored or not.

+ (BOOL)hasSavedByKey:(NSString *)key error:(NSError **)error

Parameters

key

A key to specify an AuthenticationContext object to check. must not be nil or empty.

error

If an error occurs, upon returns contains an NSError object that describes the problem. nil can be passed but not recommended to handle errors property.

Return Value

Returns YES if DCAuthenticationContext exists, otherwise NO.

Discussion

Errors

A following error is notified from this method:

  • DCAuthenticationContextAccessErrorDomain

Detail of errors are described at loadByKey:error:

Exceptions

NSInvalidArgumentException

One or more arguments are invalid.

Declared In

DCAuthenticationContext.h

loadByKey:clientId:clientSecret:error:

Load DCAuthenticationContext object.

+ (DCAuthenticationContext *)loadByKey:(NSString *)key clientId:(NSString *)clientId clientSecret:(NSString *)clientSecret error:(NSError **)error

Parameters

key

A key to specify an DCAuthenticationContext object to load. must not be nil or empty.

clientId

A client ID issued by docomo Developer support. must not be nil or empty.

clientSecret

A client secret issued by docomo Developer support. must not be nil or empty.

error

If an error occurs, upon returns contains an NSError object that describes the problem. nil can be passed but not recommended to handle errors property.

Return Value

Loaded DCAuthenticationContext object. nil on failure.

Discussion

Errors

Error domains

This method notifies NSError at error situation. Domains notified by this method are followings:

Domain name Explanation
DCAuthenticationContextAccessErrorDomain This error is raised when failed to access stored.
DCAuthenticationContextNotFoundErrorDomain This error is raised when AuthenticationContext does not stored.
Error codes

DCAuthenticationContextAccessErrorDomain have an error code to show detail of the error. Type of error codes was DCAuthenticationContextAccessErrorReason.

User information

This section shows key and type of value in userInfo of NSError.

DCAuthenticationContextAccessErrorDomain
Key Type of Value Explanation
NSUnderlyingErrorKey NSError * Cause of authentication context access error.
NSLocalizedDescriptionKey NSString * Description of this error.

NSUnderlyingErrorKey contains error raised from gtm-oauth2 and KeyChain service since storing DCAuthenticationContext object depends on those components.

NSUnderlyingErrorKey and NSLocalizedDescriptionKey are defined NSError.h

Exceptions

NSInvalidArgumentException

One or more arguments are invalid.

Declared In

DCAuthenticationContext.h

loadByKey:error:

Load DCAuthenticationContext object. (Deprecated: This method is deprecated.)

+ (DCAuthenticationContext *)loadByKey:(NSString *)key error:(NSError **)error

Parameters

key

A key to specify an DCAuthenticationContext object to load. must not be nil or empty.

error

If an error occurs, upon returns contains an NSError object that describes the problem. nil can be passed but not recommended to handle errors property.

Return Value

Loaded DCAuthenticationContext object. nil on failure.

Discussion

Errors

Error domains

This method notifies NSError at error situation. Domains notified by this method are followings:

Domain name Explanation
DCAuthenticationContextAccessErrorDomain This error is raised when failed to access stored.
DCAuthenticationContextNotFoundErrorDomain This error is raised when AuthenticationContext does not stored.
Error codes

DCAuthenticationContextAccessErrorDomain have an error code to show detail of the error. Type of error codes was DCAuthenticationContextAccessErrorReason.

User information

This section shows key and type of value in userInfo of NSError.

DCAuthenticationContextAccessErrorDomain
Key Type of Value Explanation
NSUnderlyingErrorKey NSError * Cause of authentication context access error.
NSLocalizedDescriptionKey NSString * Description of this error.

NSUnderlyingErrorKey contains error raised from gtm-oauth2 and KeyChain service since storing DCAuthenticationContext object depends on those components.

NSUnderlyingErrorKey and NSLocalizedDescriptionKey are defined NSError.h

Warning: This method is deprecated. replaced by [DCAuthenticationContext loadByKey:clientId:clientSecret:error:].

Exceptions

NSInvalidArgumentException

One or more arguments are invalid.

Declared In

DCAuthenticationContext.h

removeAllWithError:

Remove all stored DCAuthenticationContext objects.

+ (BOOL)removeAllWithError:(NSError **)error

Parameters

error

If an error occurs, upon returns contains an NSError object that describes the problem. nil can be passed but not recommended to handle errors property.

Return Value

Return YES if success, NO on failure.

Discussion

Errors

Following errors are notified from this method:

  • DCAuthenticationContextAccessErrorDomain

Detail of errors are described at loadByKey:error:

Declared In

DCAuthenticationContext.h

removeByKey:error:

Remove an DCAuthenticationContext object.

+ (BOOL)removeByKey:(NSString *)key error:(NSError **)error

Parameters

key

A key to specify an DCAuthenticationContext object to remove. must not be nil or empty.

error

If an error occurs, upon returns contains an NSError object that describes the problem. nil can be passed but not recommended to handle errors property.

Return Value

Return YES if success, NO on failure.

Discussion

The DCAuthenticationContext object which is removed by this method can not load by the loadByKey:error:.

Errors

Following errors are notified from this method:

  • DCAuthenticationContextAccessErrorDomain

Detail of errors are described at loadByKey:error:

Exceptions

NSInvalidArgumentException

One or more arguments are invalid.

Declared In

DCAuthenticationContext.h

Instance Methods

remainingTimeInSeconds

Remaining time of this DCAuthenticationContext in seconds.

- (NSTimeInterval)remainingTimeInSeconds

Discussion

Returns remaining time of this DCAuthenticationContext in seconds. If remaining time is more than 0, access token of this DCAuthenticationContext is valid at the time. If remaining time is equals or less than 0, applications should refresh access token.

Declared In

DCAuthenticationContext.h

saveByKey:accessibility:error:

Save DCAuthenticationContext object.

- (BOOL)saveByKey:(NSString *)key accessibility:(CFTypeRef)accessibility error:(NSError **)error

Parameters

key

A key to save an DCAuthenticationContext object. must not be nil or empty.

accessibility

Accessibility of saved authentication context. Acceptable values are followrings:

  • kSecAttrAccessibleWhenUnlocked
  • kSecAttrAccessibleAfterFirstUnlock
  • kSecAttrAccessibleAlways
  • kSecAttrAccessibleWhenUnlockedThisDeviceOnly
  • kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
  • kSecAttrAccessibleAlwaysThisDeviceOnly

Detail of these value are described at Keychain Services Reference

error

If an error occurs, upon returns contains an NSError object that describes the problem. nil can be passed but not recommended to handle errors property.

Return Value

Return YES if success, NO on failure.

Discussion

Errors

Following errors are notified from this method:

  • DCAuthenticationContextAccessErrorDomain

Detail of errors are described at loadByKey:error:

Exceptions

NSInvalidArgumentException

One or more arguments are invalid.

Declared In

DCAuthenticationContext.h