FRAUriMechanismReader.m revision f877f6ca2428244a6d0954a1dbef471577b32c60
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync/*
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * The contents of this file are subject to the terms of the Common Development and
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * Distribution License (the License). You may not use this file except in compliance with the
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * License.
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync *
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
772269936494ffaddd0750ba9e28e805ba81398cvboxsync * specific language governing permission and limitations under the License.
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync *
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * When distributing Covered Software, include this CDDL Header Notice in each file and include
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * Header, with the fields enclosed by brackets [] replaced by your own identifying
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * information: "Portions copyright [year] [name of copyright owner]".
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync *
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * Copyright 2016 ForgeRock AS.
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync *
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync * Portions Copyright 2014 Nathaniel McCallum, Red Hat
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync */
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync
772269936494ffaddd0750ba9e28e805ba81398cvboxsync
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync#import "FRAMechanismFactory.h"
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync#import "FRAOathMechanism.h"
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync#import "FRAIdentity.h"
003ce0fd7445c7e4cca0576f44f8b6a384cc9dcevboxsync#import "FRAIdentityDatabase.h"
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync#import "FRAIdentityModel.h"
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync#import "FRAMechanism.h"
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync#import "FRAUriMechanismReader.h"
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync
f8244da4b4e02d8d4ce0669eeb4093e31c301888vboxsync#include "base32.h"
f1acc1e99894e016bd1a6ee65c56b3fc064fa4ebvboxsync#include <CommonCrypto/CommonHMAC.h>
f8244da4b4e02d8d4ce0669eeb4093e31c301888vboxsync#include <sys/time.h>
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync
f1acc1e99894e016bd1a6ee65c56b3fc064fa4ebvboxsync@implementation FRAUriMechanismReader {
f1acc1e99894e016bd1a6ee65c56b3fc064fa4ebvboxsync
f8244da4b4e02d8d4ce0669eeb4093e31c301888vboxsync FRAIdentityDatabase *_database;
f8244da4b4e02d8d4ce0669eeb4093e31c301888vboxsync NSMutableDictionary *_mechanisms;
f8244da4b4e02d8d4ce0669eeb4093e31c301888vboxsync FRAIdentityModel *_identityModel;
f8244da4b4e02d8d4ce0669eeb4093e31c301888vboxsync}
f8244da4b4e02d8d4ce0669eeb4093e31c301888vboxsync
09ed5ee011f3a6cd9d4742216ad3bb7dbf855641vboxsync#pragma mark -
594cc1e3c91f160f6868007cdc23b25cd24e5395vboxsync#pragma mark Lifecyle
594cc1e3c91f160f6868007cdc23b25cd24e5395vboxsync
594cc1e3c91f160f6868007cdc23b25cd24e5395vboxsync- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database identityModel:(FRAIdentityModel *)identityModel {
594cc1e3c91f160f6868007cdc23b25cd24e5395vboxsync if (self = [super init]) {
594cc1e3c91f160f6868007cdc23b25cd24e5395vboxsync _database = database;
594cc1e3c91f160f6868007cdc23b25cd24e5395vboxsync _identityModel = identityModel;
772269936494ffaddd0750ba9e28e805ba81398cvboxsync _mechanisms = [NSMutableDictionary dictionary];
}
return self;
}
- (void) addMechanismFactory:(id<FRAMechanismFactory>)factory {
[_mechanisms setObject:factory forKey:[factory getSupportedProtocol]];
}
#pragma mark -
#pragma mark Factory Functions
- (FRAMechanism *)getMechanism:(NSURL *)url {
NSString* scheme = [url scheme];
id<FRAMechanismFactory> mechanismFactory = [_mechanisms objectForKey:scheme];
return [mechanismFactory buildMechanism:url database:_database identityModel:_identityModel];
}
- (FRAMechanism *)parseFromURL:(NSURL *)url {
FRAMechanism *mechanism = [self getMechanism:url];
return mechanism;
}
- (FRAMechanism *)parseFromString:(NSString *)string {
return [self parseFromURL:[[NSURL alloc]initWithString:string]];
}
@end