FRAIdentity.h revision a3970d0ea62388e4ede01470a6436eb5c6c92353
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * The contents of this file are subject to the terms of the Common Development and
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * Distribution License (the License). You may not use this file except in compliance with the
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * License.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell *
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * specific language governing permission and limitations under the License.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell *
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * When distributing Covered Software, include this CDDL Header Notice in each file and include
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * Header, with the fields enclosed by brackets [] replaced by your own identifying
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * information: "Portions copyright [year] [name of copyright owner]".
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell *
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * Copyright 2016 ForgeRock AS.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell#import <Foundation/Foundation.h>
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#import "FRAModelObject.h"
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell@class FRAIdentityDatabase;
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott@class FRAMechanism;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * Identity is responsible for modelling the information that makes up part of a user's identity in
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * the context of logging into that user's account.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell@interface FRAIdentity : FRAModelObject
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * Name of the Identity Provider (IdP) that issued this identity.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell@property (copy, nonatomic, readonly) NSString *issuer;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * Name of this identity.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell@property (copy, nonatomic, readonly) NSString *accountName;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * URL pointing to an image (such as a logo) that represents the issuer of this identity.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell@property (copy, nonatomic, readonly) NSURL *image;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott/*!
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott * The Mechanisms assigned to the Identity. Maybe empty.
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell@property (getter=mechanisms, nonatomic, readonly) NSArray<FRAMechanism *> *mechanisms;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark -
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark Lifecycle
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell/*!
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * Prevent external use of super class' initWithDatabase: method.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database __unavailable;
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * Creates a new identity object with the provided property values.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database accountName:(NSString *)accountName issuer:(NSString *)issuer image:(NSURL *)image;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell * Creates a new identity object with the provided property values.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell+ (instancetype)identityWithDatabase:(FRAIdentityDatabase *)database accountName:(NSString *)accountName issuer:(NSString *)issuer image:(NSURL *)image;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark -
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark Mechanism Functions
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell/*!
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * Returns mechanism of the specified type if one has been registered to this identity.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell *
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param aClass The type of mechanism to look for.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @return The mechanism object, or nil if no such mechanism has been registered.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell- (FRAMechanism *)mechanismOfClass:(Class)aClass;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott/*!
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott * When a new Mechanism is created, it will assigned to the Identity via
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott * this call.
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott *
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param mechanism The new mechanism to add to this identity.
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell- (void)addMechanism:(FRAMechanism *)mechanism;
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott/*!
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott * Removes the Mechanism, only if it was assigned to this Identity.
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott *
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param mechanism The mechanism to remove from the identity.
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell- (void)removeMechanism:(FRAMechanism *)mechanism;
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott
a3970d0ea62388e4ede01470a6436eb5c6c92353Craig McDonnell#pragma mark -
a3970d0ea62388e4ede01470a6436eb5c6c92353Craig McDonnell#pragma mark Notification Functions
a3970d0ea62388e4ede01470a6436eb5c6c92353Craig McDonnell
a3970d0ea62388e4ede01470a6436eb5c6c92353Craig McDonnell/*!
a3970d0ea62388e4ede01470a6436eb5c6c92353Craig McDonnell * Count of notifications that have not yet been dealt with.
a3970d0ea62388e4ede01470a6436eb5c6c92353Craig McDonnell *
a3970d0ea62388e4ede01470a6436eb5c6c92353Craig McDonnell * @return The number of pending notifications.
a3970d0ea62388e4ede01470a6436eb5c6c92353Craig McDonnell */
a3970d0ea62388e4ede01470a6436eb5c6c92353Craig McDonnell- (NSInteger)pendingNotificationsCount;
a3970d0ea62388e4ede01470a6436eb5c6c92353Craig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell@end