FRAMechanismFactory.m revision 91f0e3cb60de3eba8cbb70c7e36cc0df22d71f5b
/*
* The contents of this file are subject to the terms of the Common Development and
* Distribution License (the License). You may not use this file except in compliance with the
* License.
*
* You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
* specific language governing permission and limitations under the License.
*
* When distributing Covered Software, include this CDDL Header Notice in each file and include
* the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
* Header, with the fields enclosed by brackets [] replaced by your own identifying
* information: "Portions copyright [year] [name of copyright owner]".
*
* Copyright 2016 ForgeRock AS.
*
* Portions Copyright 2014 Nathaniel McCallum, Red Hat
*/
#import <Foundation/Foundation.h>
#import "FRAIdentity.h"
#import "FRAIdentityDatabase.h"
#import "FRAMechanism.h"
#import "FRAMechanismFactory.h"
#import "FRAOathMechanism.h"
#include "base32.h"
/*!
* Resolves the Identity from the URL that has been provided.
* @return an initialised but not persisted Identity.
*/
// TODO: Currently hardcoded to one scheme, upgrade to support multiple.
return nil;
}
// Get the path and strip it of its leading '/'
return nil;
}
}
return nil;
}
// Get issuer and label
return nil;
}
} else {
_issuer = @"";
}
// Get image
NSURL* _image = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"forgerock-logo" ofType:@"png"]];
}
return nil;
}
return nil;
}
// Get the path and strip it of its leading '/'
return nil;
}
}
return nil;
}
// Get issuer and label
return nil;
}
} else {
_issuer = @"";
}
// Parse query
// Value can contain '=' symbols, so look for first symbol.
continue;
}
}
// Get key
return nil;
}
// Get algorithm and digits
// Get period
if (period == 0) {
period = 30;
}
// Get counter
counter = 0;
}
// TODO: Implicit conversion loses integer precision: 'uint64_t' (aka 'unsigned long long')
// to 'NSUInteger' (aka 'unsigned int')
return [[FRAOathMechanism alloc] initWithType:_type usingSecretKey:key andHMACAlgorithm:algo withKeyLength:_digits andEitherPeriod:period orCounter:counter];
}
// Find Identity in existing Identities list
FRAIdentity* search = [_database identityWithIssuer:[identity issuer] accountName:[identity accountName]];
}
return mechanism;
}
}
if (c >= '0' && c <= '9') {
return YES;
}
if (c >= 'A' && c <= 'F') {
return YES;
}
if (c >= 'a' && c <= 'f') {
return YES;
}
return NO;
}
if (c >= '0' && c <= '9') {
return c - '0';
}
if (c >= 'A' && c <= 'F') {
return c - 'A' + 10;
}
if (c >= 'a' && c <= 'f') {
return c - 'a' + 10;
}
return 0;
}
return nil;
}
continue;
}
uint8_t c = 0;
}
return ret;
}
return nil;
}
return nil;
}
return nil;
}
}
static struct {
const char *name;
} algomap[] = {
{ "md5", kCCHmacAlgMD5 },
{ "sha1", kCCHmacAlgSHA1 },
{ "sha256", kCCHmacAlgSHA256 },
{ "sha512", kCCHmacAlgSHA512 },
};
return kCCHmacAlgSHA1;
}
return kCCHmacAlgSHA1;
}
}
}
return kCCHmacAlgSHA1;
}
return 6;
}
return 6;
}
return val;
}
@end