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
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell@class FRAIdentity;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell@class FRAIdentityDatabase;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell@class FRAIdentityDatabaseSQLiteOperations;
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott@class FRAMechanism;
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott@class FRANotification;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell/*! Identifier for NSNotificationCenter event broadcast by FRAIdentityDatase when state change occurs. */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnellextern NSString * const FRAIdentityDatabaseChangedNotification;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell/*! Key identifying added objects in FRAIdentityDatabaseChangedNotification userInfo dictionary. */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnellextern NSString * const FRAIdentityDatabaseChangedNotificationAddedItems;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell/*! Key identifying removed objects in FRAIdentityDatabaseChangedNotification userInfo dictionary. */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnellextern NSString * const FRAIdentityDatabaseChangedNotificationRemovedItems;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell/*! Key identifying updated objects in FRAIdentityDatabaseChangedNotification userInfo dictionary. */
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnellextern NSString * const FRAIdentityDatabaseChangedNotificationUpdatedItems;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott * Data Access Object which encapsulates the underlying storage
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott * mechanism and provides a simplified interface to the caller.
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott *
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott * Responsible for manipulating Identity, Mechanism and Notification
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott * objects in the database.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell@interface FRAIdentityDatabase : NSObject
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell@property (strong, nonatomic, readonly) FRAIdentityDatabaseSQLiteOperations *sqlOperations;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark -
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark Lifecycle
e2d1c3c0c150e511b0df83a3c49451ae773ea93aCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell- (instancetype)initWithSqlOperations:(FRAIdentityDatabaseSQLiteOperations *)sqlOperations;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark -
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark Identity Functions
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * Save the identity to the database.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param identity The identity to save.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni * @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.
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott * @return NO if there was an error whilst processing. YES if the operation completed successfully.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott- (BOOL)insertIdentity:(FRAIdentity *)identity error:(NSError *__autoreleasing *)error;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
e2d1c3c0c150e511b0df83a3c49451ae773ea93aCraig McDonnell/*!
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * Remove the identity from the database.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param identity The identity to remove.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni * @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.
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott * @return NO if there was an error whilst processing. YES if the operation completed successfully.
e2d1c3c0c150e511b0df83a3c49451ae773ea93aCraig McDonnell */
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott- (BOOL)deleteIdentity:(FRAIdentity *)identity error:(NSError *__autoreleasing *)error;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark -
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark Mechanism Functions
e2d1c3c0c150e511b0df83a3c49451ae773ea93aCraig McDonnell
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott/*!
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * Save a new mechanism to the database.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param mechanism The mechanism to save.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni * @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.
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott * @return NO if there was an error whilst processing. YES if the operation completed successfully.
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott */
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott- (BOOL)insertMechanism:(FRAMechanism *)mechanism error:(NSError *__autoreleasing *)error;
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * Remove the mechanism from the database.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param mechanism The mechanism to remove.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni * @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.
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott * @return NO if there was an error whilst processing. YES if the operation completed successfully.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott- (BOOL)deleteMechanism:(FRAMechanism *)mechanism error:(NSError *__autoreleasing *)error;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * Save changes to an existing mechanism to the database.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param mechanism The mechanism to save.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni * @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.
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott * @return NO if there was an error whilst processing. YES if the operation completed successfully.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott- (BOOL)updateMechanism:(FRAMechanism *)mechanism error:(NSError *__autoreleasing *)error;
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark -
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark Notification Functions
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott/*!
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * Save a new notification to the database.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param notification The notification to save.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni * @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.
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott * @return NO if there was an error whilst processing. YES if the operation completed successfully.
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott */
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott- (BOOL)insertNotification:(FRANotification *)notification error:(NSError *__autoreleasing *)error;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5bRobert Wapshott * Remove the notification from the database.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param notification The notification to remove.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni * @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.
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott * @return NO if there was an error whilst processing. YES if the operation completed successfully.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott- (BOOL)deleteNotification:(FRANotification *)notification error:(NSError *__autoreleasing *)error;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell/*!
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * Save changes to an existing notification to the database.
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell * @param notification The notification to save.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni * @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.
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott * @return NO if there was an error whilst processing. YES if the operation completed successfully.
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell */
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott- (BOOL)updateNotification:(FRANotification *)notification error:(NSError *__autoreleasing *)error;
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell
2beebed98b4fc7f018fb224a1e4a3ab6103a4c0bCraig McDonnell@end