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