FRAIdentity.h revision 7c51d54f23c5581d2cf894f9eafb9798e3febd22
127N/A/*
127N/A * The contents of this file are subject to the terms of the Common Development and
127N/A * Distribution License (the License). You may not use this file except in compliance with the
127N/A * License.
127N/A *
127N/A * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
127N/A * specific language governing permission and limitations under the License.
127N/A *
127N/A * When distributing Covered Software, include this CDDL Header Notice in each file and include
127N/A * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
127N/A * Header, with the fields enclosed by brackets [] replaced by your own identifying
127N/A * information: "Portions copyright [year] [name of copyright owner]".
127N/A *
127N/A * Copyright 2016 ForgeRock AS.
127N/A */
127N/A
127N/A
127N/A
127N/A#import "FRAModelObject.h"
127N/A
127N/A@class FRAIdentityDatabase;
127N/A@class FRAMechanism;
127N/A
127N/A/*!
127N/A * Identity is responsible for modelling the information that makes up part of a user's identity in
127N/A * the context of logging into that user's account.
127N/A */
127N/A@interface FRAIdentity : FRAModelObject
127N/A
127N/A/*!
127N/A * Name of the Identity Provider (IdP) that issued this identity.
127N/A */
127N/A@property (copy, nonatomic, readonly) NSString *issuer;
127N/A/*!
127N/A * Name of this identity.
127N/A */
127N/A@property (copy, nonatomic, readonly) NSString *accountName;
127N/A/*!
127N/A * URL pointing to an image (such as a logo) that represents the issuer of this identity.
127N/A */
127N/A@property (copy, nonatomic, readonly) NSURL *image;
127N/A
127N/A/*!
127N/A * Text representation of the background colour to be used by the user interface for this Identity.
127N/A */
127N/A@property (copy, nonatomic, readonly) NSString *backgroundColor;
127N/A
127N/A/*!
127N/A * The Mechanisms assigned to the Identity. Maybe empty.
127N/A */
127N/A@property (getter=mechanisms, nonatomic, readonly) NSArray<FRAMechanism *> *mechanisms;
127N/A
127N/A#pragma mark -
127N/A#pragma mark Lifecycle
127N/A
127N/A/*!
* Prevent external use of super class' initWithDatabase: method.
*/
- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database identityModel:(FRAIdentityModel *)identityModel __unavailable;
/*!
* Creates a new identity object with the provided property values.
*/
- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database identityModel:(FRAIdentityModel *)identityModel accountName:(NSString *)accountName issuer:(NSString *)issuer image:(NSURL *)image backgroundColor:(NSString *)color;
/*!
* Creates a new identity object with the provided property values.
*/
+ (instancetype)identityWithDatabase:(FRAIdentityDatabase *)database identityModel:(FRAIdentityModel *)identityModel accountName:(NSString *)accountName issuer:(NSString *)issuer image:(NSURL *)image backgroundColor:(NSString *)color;
#pragma mark -
#pragma mark Mechanism Functions
/*!
* Returns mechanism of the specified type if one has been registered to this identity.
*
* @param aClass The type of mechanism to look for.
* @return The mechanism object, or nil if no such mechanism has been registered.
*/
- (FRAMechanism *)mechanismOfClass:(Class)aClass;
/*!
* When a new mechanism is created, it will assigned to the identity via
* this call.
*
* @param mechanism The new mechanism to add to this identity.
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
* @return BOOL False if there was an error with the operation, in which case check the error parameter for details.
*/
- (BOOL)addMechanism:(FRAMechanism *)mechanism error:(NSError *__autoreleasing *)error;
/*!
* Removes the mechanism, only if it was assigned to this identity.
* If the identity has no more mechanisms, the identity is removed from the identity model.
*
* @param mechanism The mechanism to remove from the identity.
* @param error If an error occurs, upon returns contains an NSError object that describes the problem. If you are not interested in possible errors, you may pass in NULL.
* @return BOOL False if there was an error with the operation, in which case check the error parameter for details.
*/
- (BOOL)removeMechanism:(FRAMechanism *)mechanism error:(NSError *__autoreleasing *)error;
#pragma mark -
#pragma mark Notification Functions
/*!
* Count of notifications that have not yet been dealt with.
*
* @return The number of pending notifications.
*/
- (NSInteger)pendingNotificationsCount;
@end