FRAPushMechanism.m revision 721bb987c406979bcfe705fa1ca8d54497d40fcb
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell/*
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * The contents of this file are subject to the terms of the Common Development and
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * Distribution License (the License). You may not use this file except in compliance with the
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * License.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell *
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * You can obtain a copy of the License at legal/CDDLv1.0.txt. See the License for the
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * specific language governing permission and limitations under the License.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell *
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * When distributing Covered Software, include this CDDL Header Notice in each file and include
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * the License file at legal/CDDLv1.0.txt. If applicable, add the following below the CDDL
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * Header, with the fields enclosed by brackets [] replaced by your own identifying
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * information: "Portions copyright [year] [name of copyright owner]".
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell *
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell * Copyright 2016 ForgeRock AS.
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell */
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell#import "FRAPushMechanism.h"
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell@implementation FRAPushMechanism
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark -
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell#pragma mark Lifecyle
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott// Testing only?
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database {
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott return [self initWithDatabase:database authEndpoint:nil secret:nil version:1];
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings}
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database authEndpoint:(NSString *)authEndPoint secret:(NSString *)secret {
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott return [self initWithDatabase:database authEndpoint:authEndPoint secret:secret version:1];
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott}
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott- (instancetype)initWithDatabase:(FRAIdentityDatabase *)database authEndpoint:(NSString *)authEndPoint secret:(NSString *)secret version:(NSInteger)version {
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell self = [super initWithDatabase:database];
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell if (self) {
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott _version = version;
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott _authEndpoint = authEndPoint;
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott _secret = secret;
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott _type = @"push";
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott _mechanismUID = [NSUUID UUID].UUIDString;
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell }
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell return self;
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell}
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott// Testing only?
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell+ (instancetype)pushMechanismWithDatabase:(FRAIdentityDatabase *)database {
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell return [[FRAPushMechanism alloc] initWithDatabase:database];
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell}
415243fbc81341293a852ff6aa14e9608d08685cCraig McDonnell
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott+ (instancetype)pushMechanismWithDatabase:(FRAIdentityDatabase *)database authEndpoint:(NSString *)authEndPoint secret:(NSString *)secret version:(NSInteger)version {
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott return [[FRAPushMechanism alloc] initWithDatabase:database authEndpoint:authEndPoint secret:secret version:version];
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott}
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott+ (instancetype)pushMechanismWithDatabase:(FRAIdentityDatabase *)database authEndpoint:(NSString *)authEndPoint secret:(NSString *)secret {
721bb987c406979bcfe705fa1ca8d54497d40fcbRobert Wapshott return [[FRAPushMechanism alloc] initWithDatabase:database authEndpoint:authEndPoint secret:secret];
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings}
9ebd9a731316dfd624ce3bcc4ea6519d10899936Ken Stubbings
6c1420dd55f69d09f39dd213ee6c97ba901b8d92Craig McDonnell@end