9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings/*
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * The contents of this file are subject to the terms of the Common Development and
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Distribution License (the License). You may not use this file except in compliance with the
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * License.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * specific language governing permission and limitations under the License.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * When distributing Covered Software, include this CDDL Header Notice in each file and include
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Header, with the fields enclosed by brackets [] replaced by your own identifying
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * information: "Portions copyright [year] [name of copyright owner]".
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Copyright 2016 ForgeRock AS.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings */
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings#import "FRAMechanismFactory.h"
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings@class FRAIdentity;
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings@class FRAIdentityModel;
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings@class FRAMechanism;
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings/*!
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * This Authenticator Application makes use of the existing OATH
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * URL scheme for encoding Identity and Mechanism information.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * This is defined in detail here:
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * https://github.com/google/google-authenticator/wiki/Key-Uri-Format
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * This factory will also be able to parse a similar URL scheme
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Push Authentication when it is supported by this Application.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Note: Only responsible for generating the instances of Identity and
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Mechanism. Will not be responsible for database persistence.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings */
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings@interface FRAUriMechanismReader : NSObject
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings#pragma mark -
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings#pragma mark Lifecycle
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings/*!
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Init method.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * @param database The database to which this object can be persisted.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * @return The initialized object or nil if initialization failed.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings */
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database identityModel:(FRAIdentityModel *)identityModel;
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings/*!
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Adds a mechanism factory to this Mechanism Readert.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * The added mechanism Factory adds the capability to decode a new type of message.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * @param factory The FRAMechanismFactory to add to this reader.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings */
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings- (void)addMechanismFactory:(id<FRAMechanismFactory>)factory;
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings#pragma mark -
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings#pragma mark URL Reading Functions
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings/*!
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Given a URL, convert this into a FRAMechanism, complete with associated Identity.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * @param url The URL to parse, non-nil.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni * @param handler The block to invoke when asynchronous operation is completed.
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.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * @return non nil FRAMechanism initialsed with the values present in the URL.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings */
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni- (FRAMechanism*)parseFromURL:(NSURL*)url handler:(void(^)(BOOL, NSError *))handler error:(NSError *__autoreleasing *)error;
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings/*!
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * Convenience function which will call parseFromURL.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings *
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni * @param string the String uri to parse a mechanism from.
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni * @param handler The block to invoke when asynchronous operation is completed.
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.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings * @return the FRAMechanism object extracted from the string.
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings */
7c51d54f23c5581d2cf894f9eafb9798e3febd22Diego Colantoni- (FRAMechanism*)parseFromString:(NSString*)string handler:(void(^)(BOOL, NSError *))handler error:(NSError *__autoreleasing *)error;
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings@end