FRAIdentity.h revision f877f6ca2428244a6d0954a1dbef471577b32c60
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller/*
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * The contents of this file are subject to the terms of the Common Development and
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * Distribution License (the License). You may not use this file except in compliance with the
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * License.
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller *
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * specific language governing permission and limitations under the License.
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller *
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * When distributing Covered Software, include this CDDL Header Notice in each file and include
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * Header, with the fields enclosed by brackets [] replaced by your own identifying
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * information: "Portions copyright [year] [name of copyright owner]".
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller *
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * Copyright 2016 ForgeRock AS.
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller */
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller#import "FRAModelObject.h"
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller@class FRAIdentityDatabase;
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller@class FRAMechanism;
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller/*!
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * Identity is responsible for modelling the information that makes up part of a user's identity in
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * the context of logging into that user's account.
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller */
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller@interface FRAIdentity : FRAModelObject
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller/*!
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * Name of the Identity Provider (IdP) that issued this identity.
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller */
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller@property (copy, nonatomic, readonly) NSString *issuer;
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller/*!
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * Name of this identity.
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller */
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller@property (copy, nonatomic, readonly) NSString *accountName;
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller/*!
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller * URL pointing to an image (such as a logo) that represents the issuer of this identity.
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller */
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller@property (copy, nonatomic, readonly) NSURL *image;
a4304c3b0aa2b23fc8e820616d5cd09d82f49927Brendan Mmiller
/*!
* Text representation of the background colour to be used by the user interface for this Identity.
*/
@property (copy, nonatomic, readonly) NSString *backgroundColor;
/*!
* The Mechanisms assigned to the Identity. Maybe empty.
*/
@property (getter=mechanisms, nonatomic, readonly) NSArray<FRAMechanism *> *mechanisms;
#pragma mark -
#pragma mark Lifecycle
/*!
* 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.
* @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.
* @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