Merge branch 'feature/remove_freebee' into 'develop'

remove freebee

See merge request BPHV_MIPS/mvm_core!103
This commit is contained in:
Pfeil, Scott Robert 2020-09-09 12:25:42 -04:00
commit 27660dc8fe
16 changed files with 0 additions and 1282 deletions

View File

@ -92,16 +92,6 @@
AFBB96351FBA34310008D868 /* MVMCoreErrorConstants.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96331FBA34310008D868 /* MVMCoreErrorConstants.m */; };
AFBB96381FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96371FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB96531FBA3A570008D868 /* MVMCoreLoadHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96391FBA3A550008D868 /* MVMCoreLoadHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB96561FBA3A570008D868 /* freebee.json in Resources */ = {isa = PBXBuildFile; fileRef = AFBB963D1FBA3A550008D868 /* freebee.json */; };
AFBB96571FBA3A570008D868 /* FreeBeeAuthObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB963E1FBA3A560008D868 /* FreeBeeAuthObject.h */; };
AFBB96581FBA3A570008D868 /* FreeBeeAuthObject.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB963F1FBA3A560008D868 /* FreeBeeAuthObject.m */; };
AFBB96591FBA3A570008D868 /* freebeelaunchApp.json in Resources */ = {isa = PBXBuildFile; fileRef = AFBB96401FBA3A560008D868 /* freebeelaunchApp.json */; };
AFBB965A1FBA3A570008D868 /* FreeBeeUrlObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96411FBA3A560008D868 /* FreeBeeUrlObject.h */; };
AFBB965B1FBA3A570008D868 /* FreeBeeUrlObject.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96421FBA3A560008D868 /* FreeBeeUrlObject.m */; };
AFBB965C1FBA3A570008D868 /* MFFreebeeHandler.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96431FBA3A560008D868 /* MFFreebeeHandler.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB965D1FBA3A570008D868 /* MFFreebeeHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96441FBA3A560008D868 /* MFFreebeeHandler.m */; };
AFBB965E1FBA3A570008D868 /* MFFreebeeOperation.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96451FBA3A560008D868 /* MFFreebeeOperation.h */; };
AFBB965F1FBA3A570008D868 /* MFFreebeeOperation.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96461FBA3A560008D868 /* MFFreebeeOperation.m */; };
AFBB96601FBA3A570008D868 /* MVMCoreLoadObject.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96471FBA3A560008D868 /* MVMCoreLoadObject.h */; settings = {ATTRIBUTES = (Public, ); }; };
AFBB96611FBA3A570008D868 /* MVMCoreLoadObject.m in Sources */ = {isa = PBXBuildFile; fileRef = AFBB96481FBA3A560008D868 /* MVMCoreLoadObject.m */; };
AFBB96621FBA3A570008D868 /* MVMCoreRequestParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = AFBB96491FBA3A560008D868 /* MVMCoreRequestParameters.h */; settings = {ATTRIBUTES = (Public, ); }; };
@ -252,16 +242,6 @@
AFBB96331FBA34310008D868 /* MVMCoreErrorConstants.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MVMCoreErrorConstants.m; sourceTree = "<group>"; };
AFBB96371FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreLoadDelegateProtocol.h; sourceTree = "<group>"; };
AFBB96391FBA3A550008D868 /* MVMCoreLoadHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreLoadHandler.h; sourceTree = "<group>"; };
AFBB963D1FBA3A550008D868 /* freebee.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = freebee.json; sourceTree = "<group>"; };
AFBB963E1FBA3A560008D868 /* FreeBeeAuthObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FreeBeeAuthObject.h; sourceTree = "<group>"; };
AFBB963F1FBA3A560008D868 /* FreeBeeAuthObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FreeBeeAuthObject.m; sourceTree = "<group>"; };
AFBB96401FBA3A560008D868 /* freebeelaunchApp.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = freebeelaunchApp.json; sourceTree = "<group>"; };
AFBB96411FBA3A560008D868 /* FreeBeeUrlObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FreeBeeUrlObject.h; sourceTree = "<group>"; };
AFBB96421FBA3A560008D868 /* FreeBeeUrlObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FreeBeeUrlObject.m; sourceTree = "<group>"; };
AFBB96431FBA3A560008D868 /* MFFreebeeHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFFreebeeHandler.h; sourceTree = "<group>"; };
AFBB96441FBA3A560008D868 /* MFFreebeeHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFFreebeeHandler.m; sourceTree = "<group>"; };
AFBB96451FBA3A560008D868 /* MFFreebeeOperation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MFFreebeeOperation.h; sourceTree = "<group>"; };
AFBB96461FBA3A560008D868 /* MFFreebeeOperation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MFFreebeeOperation.m; sourceTree = "<group>"; };
AFBB96471FBA3A560008D868 /* MVMCoreLoadObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreLoadObject.h; sourceTree = "<group>"; };
AFBB96481FBA3A560008D868 /* MVMCoreLoadObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MVMCoreLoadObject.m; sourceTree = "<group>"; };
AFBB96491FBA3A560008D868 /* MVMCoreRequestParameters.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MVMCoreRequestParameters.h; sourceTree = "<group>"; };
@ -570,7 +550,6 @@
isa = PBXGroup;
children = (
AFFCFA601FCCC0D600FD0730 /* LoadingOverlay */,
AFBB963C1FBA3A550008D868 /* FreeBee */,
AFBB96371FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h */,
AFBB96391FBA3A550008D868 /* MVMCoreLoadHandler.h */,
AFBB964B1FBA3A560008D868 /* MVMCoreLoadHandler.m */,
@ -584,23 +563,6 @@
path = LoadHandling;
sourceTree = "<group>";
};
AFBB963C1FBA3A550008D868 /* FreeBee */ = {
isa = PBXGroup;
children = (
AFBB963D1FBA3A550008D868 /* freebee.json */,
AFBB963E1FBA3A560008D868 /* FreeBeeAuthObject.h */,
AFBB963F1FBA3A560008D868 /* FreeBeeAuthObject.m */,
AFBB96401FBA3A560008D868 /* freebeelaunchApp.json */,
AFBB96411FBA3A560008D868 /* FreeBeeUrlObject.h */,
AFBB96421FBA3A560008D868 /* FreeBeeUrlObject.m */,
AFBB96431FBA3A560008D868 /* MFFreebeeHandler.h */,
AFBB96441FBA3A560008D868 /* MFFreebeeHandler.m */,
AFBB96451FBA3A560008D868 /* MFFreebeeOperation.h */,
AFBB96461FBA3A560008D868 /* MFFreebeeOperation.m */,
);
path = FreeBee;
sourceTree = "<group>";
};
AFBB966B1FBA3A9A0008D868 /* PresentationHandling */ = {
isa = PBXGroup;
children = (
@ -772,9 +734,7 @@
AF43A7061FC4D7A2008E9347 /* MVMCoreObject.h in Headers */,
AFED77A11FCCA29400BAE689 /* MVMCoreViewControllerNibMappingObject.h in Headers */,
AFBB969F1FBA3A9A0008D868 /* MVMCoreAlertOperation.h in Headers */,
AFBB965A1FBA3A570008D868 /* FreeBeeUrlObject.h in Headers */,
AF43A71B1FC5BEBB008E9347 /* MVMCoreViewControllerProtocol.h in Headers */,
AFBB96571FBA3A570008D868 /* FreeBeeAuthObject.h in Headers */,
AFC5FA161FFC2E2A00C244CF /* MVMCoreGlobalTopAlertDelegateProtocol.h in Headers */,
AFBB96381FBA39E70008D868 /* MVMCoreLoadDelegateProtocol.h in Headers */,
AFBB96B01FBA3B590008D868 /* MVMCoreDispatchUtility.h in Headers */,
@ -788,12 +748,10 @@
AFC5FA1D1FFC39C700C244CF /* MVMCoreTopAlertViewProtocol.h in Headers */,
AFBB969D1FBA3A9A0008D868 /* MVMCoreAlertObject.h in Headers */,
8876D5CE1FB50A9E00EB2E3D /* MVMCore.h in Headers */,
AFBB965E1FBA3A570008D868 /* MFFreebeeOperation.h in Headers */,
AF43A57B1FBA5E6A008E9347 /* MVMCoreHardcodedStringsConstants.h in Headers */,
AFBB96B81FBA3CEC0008D868 /* MVMCoreActionDelegateProtocol.h in Headers */,
AFBB968B1FBA3A9A0008D868 /* MVMCoreDismissViewControllerOperation.h in Headers */,
AF43A70B1FC4F415008E9347 /* MVMCoreCache.h in Headers */,
AFBB965C1FBA3A570008D868 /* MFFreebeeHandler.h in Headers */,
AFEA17A8209B6A1C00BC6740 /* MVMCoreBlockOperation.h in Headers */,
AF43A5831FBB66DE008E9347 /* MVMCoreConstants.h in Headers */,
AFBB969A1FBA3A9A0008D868 /* MVMCoreAlertDelegateProtocol.h in Headers */,
@ -877,8 +835,6 @@
buildActionMask = 2147483647;
files = (
AF26DDAE1FCE6A37004E8F65 /* Localizable.strings in Resources */,
AFBB96561FBA3A570008D868 /* freebee.json in Resources */,
AFBB96591FBA3A570008D868 /* freebeelaunchApp.json in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
@ -926,7 +882,6 @@
AF43A74D1FC6109F008E9347 /* MVMCoreSessionObject.m in Sources */,
0184D3E324B8D0C600A05369 /* MVMCoreAlertObject+Swift.swift in Sources */,
D282AAB62240085300C46919 /* MVMCoreGetterUtility+Extension.swift in Sources */,
AFBB965F1FBA3A570008D868 /* MFFreebeeOperation.m in Sources */,
AFBB96901FBA3A9A0008D868 /* MVMCoreNavigationObject.m in Sources */,
946EE1AB237B5C940036751F /* Decoder.swift in Sources */,
946EE1BC237B691A0036751F /* ActionOpenPageModel.swift in Sources */,
@ -942,7 +897,6 @@
8876D5E91FB50AB000EB2E3D /* NSArray+MFConvenience.m in Sources */,
946EE1B2237B5F260036751F /* JSONValue.swift in Sources */,
AFBB96971FBA3A9A0008D868 /* MVMCorePresentViewControllerOperation.m in Sources */,
AFBB96581FBA3A570008D868 /* FreeBeeAuthObject.m in Sources */,
01F2A04E23A82CF500D954D8 /* ActionPopupModel.swift in Sources */,
0A62624824C1DFDC00C316B9 /* UIAlertControllerStyle+Extension.swift in Sources */,
AF43A5781FBA5B7C008E9347 /* MVMCoreJSONConstants.m in Sources */,
@ -957,7 +911,6 @@
AF43A5881FBB67D6008E9347 /* MVMCoreActionUtility.m in Sources */,
AFED77A61FCCA29400BAE689 /* MVMCoreViewControllerStoryBoardMappingObject.m in Sources */,
AF43A57C1FBA5E6A008E9347 /* MVMCoreHardcodedStringsConstants.m in Sources */,
AFBB965D1FBA3A570008D868 /* MFFreebeeHandler.m in Sources */,
0AFF597A23FC6E60005C24E8 /* ActionShareModel.swift in Sources */,
AFEEE81F1FCDF3CA00B5EDD0 /* MVMCoreLoggingHandler.m in Sources */,
01F2A05223A8325100D954D8 /* ModelMapping.swift in Sources */,
@ -970,7 +923,6 @@
01DF561421F90ADC00CC099B /* Dictionary+MFConvenience.swift in Sources */,
AFBB96B11FBA3B590008D868 /* MVMCoreDispatchUtility.m in Sources */,
946EE1A3237B59C30036751F /* ModelProtocol.swift in Sources */,
AFBB965B1FBA3A570008D868 /* FreeBeeUrlObject.m in Sources */,
AFEA17A9209B6A1C00BC6740 /* MVMCoreBlockOperation.m in Sources */,
AF43A70A1FC4F415008E9347 /* MVMCoreCache.m in Sources */,
AF43A6FF1FBE3252008E9347 /* Reachability.m in Sources */,

View File

@ -14,7 +14,6 @@
#import "MVMCoreSessionTimeHandler.h"
#import "MVMCoreLoadHandler.h"
#import "MVMCoreNavigationHandler.h"
#import "MFFreebeeHandler.h"
#import "MVMCoreDispatchUtility.h"
#import "NSDictionary+MFConvenience.h"
#import "MVMCoreGetterUtility.h"
@ -122,22 +121,6 @@ NSString * const KeyActionTypeOpen = @"openPage";
// Loads the given page type.
NSString *pageType = [actionInformation stringForKey:KeyPageType];
if (pageType.length > 0) {
//if freebee enabled for account,and state isNotDetermined or is expired
//launchFreebee auth request
//else if invalid or valid or busy do nothing
#warning i'd like to move this out of here.
MFFreebeeHandler *freebeeHandler = [MFFreebeeHandler sharedHandler];
if (YES == [freebeeHandler canProceedWithFreebeeAuthRequest]) {
MVMCoreLog(@"Processing Freebee Auth request");
[freebeeHandler processFreeBeeAuthRequestWithCompletionHandler:^(MVMCoreOperation* _Nullable freebeeOperation, BOOL isValid) {
MVMCoreLog(@"Processing Freebee Auth request Initiated");
}];
}
MVMCoreLog(@"Continuing operation after freebee request");
MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionInformation];
[self updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) {
@ -515,22 +498,6 @@ NSString * const KeyActionTypeOpen = @"openPage";
// Loads the given page type.
NSString *pageType = [actionInformation stringForKey:KeyPageType];
if (pageType.length > 0) {
//if freebee enabled for account,and state isNotDetermined or is expired
//launchFreebee auth request
//else if invalid or valid or busy do nothing
#warning i'd like to move this out of here.
MFFreebeeHandler *freebeeHandler = [MFFreebeeHandler sharedHandler];
if (YES == [freebeeHandler canProceedWithFreebeeAuthRequest]) {
MVMCoreLog(@"Processing Freebee Auth request");
[freebeeHandler processFreeBeeAuthRequestWithCompletionHandler:^(MVMCoreOperation* _Nullable freebeeOperation, BOOL isValid) {
MVMCoreLog(@"Processing Freebee Auth request Initiated");
}];
}
MVMCoreLog(@"Continuing operation after freebee request");
MVMCoreRequestParameters *requestParameters = [[MVMCoreRequestParameters alloc] initWithActionMap:actionInformation];
[self updateRequestParametersBeforeHandleOpenPageAction:requestParameters callBack:^(MVMCoreRequestParameters * _Nonnull requestParameters) {

View File

@ -1,23 +0,0 @@
//
// FreeBeeAuthObject.h
// mobilefirst
//
// Created by Bansal, Tapan on 20/01/17.
// Copyright © 2017 Verizon Wireless. All rights reserved.
//
#import <Foundation/Foundation.h>
@class FreeBeeUrlObject;
@interface FreeBeeAuthObject : NSObject
- (BOOL)isValidFreeBeeSessionAuthObject;
- (void)updateWithDictionary:(nullable NSDictionary*)inDict;
- (nullable NSDictionary*)proxyDictionaryForUrl:(nullable NSURL*)url;
- (nullable NSDictionary*)campaignHeaderForUrl:(nullable NSURL*)url;
- (nullable FreeBeeUrlObject*)freebeeUrlObjectForUrl:(nullable NSURL *)url;
- (BOOL)isExpired ;
@end

View File

@ -1,117 +0,0 @@
//
// FreeBeeAuthObject.m
// mobilefirst
//
// Created by Bansal, Tapan on 20/01/17.
// Copyright © 2017 Verizon Wireless. All rights reserved.
//
#import "FreeBeeAuthObject.h"
#import <MVMCore/NSDictionary+MFConvenience.h>
#import "MFFreebeeHandler.h"
#import "FreeBeeUrlObject.h"
@interface FreeBeeAuthObject ()
@property(nullable,strong,nonatomic) NSString *vidToken;
@property(nullable,strong,nonatomic) NSMutableArray *freeBeeUrlObjects;
- (FreeBeeUrlObject*)freebeeUrlObjectForUrl:(NSURL*)url;
@end
@implementation FreeBeeAuthObject
#pragma mark -
#pragma mark Public Methods
- (BOOL)isValidFreeBeeSessionAuthObject {
if (self.vidToken.length && self.freeBeeUrlObjects.count)
return YES;
return NO;
}
- (void)updateWithDictionary:(nullable NSDictionary*)inDict {
//Remove Previously Existing Expired Ones
[self.freeBeeUrlObjects removeAllObjects];
if (inDict && [inDict isKindOfClass:[NSDictionary class]]) {
self.vidToken = [inDict objectForKey:@"vidToken"];
if (self.vidToken && self.vidToken.length) {
NSArray* sdAuthResp = [inDict objectChainOfKeysOrIndexes:@[@"sdAuthResp"] ofType:[NSArray class]];
__block FreeBeeUrlObject* freeBeeUrlObject = nil;
for (NSDictionary* inDict in sdAuthResp) {
freeBeeUrlObject = [[FreeBeeUrlObject alloc] init];
[freeBeeUrlObject updateWithDictionary:inDict];
if (!self.freeBeeUrlObjects)
self.freeBeeUrlObjects = [NSMutableArray array];
//Assigning the requested url to have a mapping b/w sdurl and request url
freeBeeUrlObject.requestUrl = [[MFFreebeeHandler sharedHandler] urlForidFromConfigDict:freeBeeUrlObject.urlId];
//Adding Only Valid Objects to Array
if (freeBeeUrlObject.sdUrl.length && NO == [freeBeeUrlObject isExpired])
[self.freeBeeUrlObjects addObject:freeBeeUrlObject];
freeBeeUrlObject = nil;
}
}
}
}
- (nullable NSDictionary*)proxyDictionaryForUrl:(nullable NSURL*)url; {
FreeBeeUrlObject* urlObject = [self freebeeUrlObjectForUrl:url];
if (urlObject)
return [urlObject proxyDictionary];
return nil;
}
- (NSDictionary*)campaignHeaderForUrl:(nullable NSURL*)url {
if (self.vidToken.length) {
FreeBeeUrlObject* urlObject = [self freebeeUrlObjectForUrl:url];
if (urlObject)
return [urlObject campaignHeader];
}
return nil;
}
//http://mobile.vzw.com/abc.png
- (nullable FreeBeeUrlObject*)freebeeUrlObjectForUrl:(NSURL*)url {
if (url) {
NSString *host = [url host];
//if freebeeobjects has url as part of
if (host) {
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"requestUrl contains %@", host];
NSArray* freeBeeUrlObject = [self.freeBeeUrlObjects filteredArrayUsingPredicate:predicate];
if (freeBeeUrlObject.count)
return freeBeeUrlObject[0];
}
}
return nil;
}
- (BOOL)isExpired {
if (self.freeBeeUrlObjects.count) {
return [(( FreeBeeUrlObject*)self.freeBeeUrlObjects[0]) isExpired];
}
return YES;
}
@end

View File

@ -1,28 +0,0 @@
//
// FreeBeeUrlObject.h
// mobilefirst
//
// Created by Bansal, Tapan on 08/02/17.
// Copyright © 2017 Verizon Wireless. All rights reserved.
//
#import <Foundation/Foundation.h>
@interface FreeBeeUrlObject : NSObject
@property(nullable,strong,nonatomic) NSString *urlId;
@property(nullable,strong,nonatomic) NSNumber *httpsProxyIP;
@property(nullable,strong,nonatomic) NSString *sdUrl;
@property(nullable,strong,nonatomic) NSNumber *sdConfExpiry;
@property(nullable,strong,nonatomic) NSNumber *sdPort;
@property(nullable,strong,nonatomic) NSString *requestUrl;
@property(assign,nonatomic) NSInteger authStatus;
- (void)updateWithDictionary:(nullable NSDictionary*)inDict;
- (nullable NSDictionary*)proxyDictionary;
- (nullable NSDictionary*)campaignHeader;
- (BOOL)isValidFreeBeeObj;
- (BOOL)isExpired;
@end

View File

@ -1,100 +0,0 @@
//
// FreeBeeUrlObject.m
// mobilefirst
//
// Created by Bansal, Tapan on 08/02/17.
// Copyright © 2017 Verizon Wireless. All rights reserved.
//
#import "FreeBeeUrlObject.h"
static NSUInteger const kHTTPSProxyAuthorized = 1200;
@interface FreeBeeUrlObject()
@property(nonatomic) NSDictionary* proxyDictionary;
@property(nonatomic) NSDictionary* campaignHeaderDictionary;
// The time that we started the last session timer.
@property(nullable,strong,nonatomic) NSDate* expirationDate;
@end
@implementation FreeBeeUrlObject
- (void)updateWithDictionary:(nullable NSDictionary*)inDict {
if (inDict && [inDict isKindOfClass:[NSDictionary class]]) {
NSNumber* authCode = [inDict objectForKey:@"authRespCode"];
if ([authCode intValue] == kHTTPSProxyAuthorized) {
self.urlId = [inDict objectForKey:@"urlId"];
self.httpsProxyIP = [inDict objectForKey:@"httpsProxyIP"];
self.sdUrl = [inDict objectForKey:@"sdUrl"];
self.sdPort = [inDict objectForKey:@"sdPort"];
self.authStatus = kHTTPSProxyAuthorized;
self.sdConfExpiry = [inDict objectForKey:@"sdConfExpiry"];
self.expirationDate = [NSDate dateWithTimeIntervalSince1970:[self.sdConfExpiry doubleValue]];
}
else {
self.authStatus = [authCode intValue];
self.expirationDate = [NSDate distantPast];
}
}
}
- (nullable NSDictionary*)proxyDictionary {
if (nil != _proxyDictionary)
return _proxyDictionary;
NSMutableDictionary *proxyDict = [[NSMutableDictionary alloc]init];
// depricated constants with HTTPS
[proxyDict setObject:@1 forKey:@"HTTPSEnable"];
[proxyDict setObject:self.httpsProxyIP forKey:(NSString *)kCFStreamPropertyHTTPSProxyHost];
[proxyDict setObject:self.sdPort forKey:(NSString *)kCFStreamPropertyHTTPSProxyPort];
self.proxyDictionary = [proxyDict copy];
return self.proxyDictionary;
}
- (nullable NSDictionary*)campaignHeader {
if (YES == [self isValidFreeBeeObj]) {
if (self.campaignHeaderDictionary)
return self.campaignHeaderDictionary;
NSArray *urlPieces = [self.sdUrl componentsSeparatedByString:@"?"];
NSMutableString *pass = [[NSMutableString alloc]init];
pass = urlPieces[1];
NSData *plainData = [[NSString stringWithFormat:@"vzServices:%@", pass] dataUsingEncoding:NSUTF8StringEncoding];
NSString *base64string = [@"Basic " stringByAppendingString:[plainData base64EncodedStringWithOptions:0]];
if (base64string.length) {
self.campaignHeaderDictionary = @{@"Proxy-Authorization":base64string};
return self.campaignHeaderDictionary;
}
}
return nil;
}
- (BOOL)isValidFreeBeeObj {
if (self.sdUrl)
return YES;
return NO;
}
- (BOOL)isExpired {
return [[NSDate date] compare:self.expirationDate] == NSOrderedDescending ? YES : NO;
}
@end

View File

@ -1,52 +0,0 @@
//
// MFFreebeeHandler.h
// mobilefirst
//
// Created by Patrick Sommer on 1/3/17.
// Copyright © 2017 Verizon Wireless. All rights reserved.
//
#import <Foundation/Foundation.h>
@class FreeBeeAuthObject;
@class MVMCoreOperation;
@class MFFreebeeOperation;
typedef void(^FreebeeLoadFinishedHandler)(MVMCoreOperation* _Nullable freebeeOperation, BOOL isValid);
@interface MFFreebeeHandler : NSObject
@property(nullable, nonatomic, strong, readonly) FreeBeeAuthObject* freeBeeAuthObj;
@property(nonatomic, readonly) BOOL isValidCampaign;
@property(nonatomic, readonly) MFFreebeeOperation* _Nullable freebeeOperation;
+ (nullable instancetype)sharedHandler;
- (void)activateFreeBeeIfServerEnabled;
- (void)invalidateFreeBeeState;
- (void)processFreeBeeAuthRequestWithCompletionHandler:(nullable FreebeeLoadFinishedHandler)completionHandler;
- (BOOL)canProceedWithFreebeeAuthRequest;
- (BOOL)isFreeBeeEnabled;
- (BOOL)isExpired;
- (void)enableFreeBeeForCurrentModule:(BOOL)enable;
- (BOOL)isFreeBeeEnabledForCurrentModule;
- (BOOL)isExcludedModule:(nullable NSString*)parentPageType;
- (BOOL)isAllowedPage:(nullable NSString*)pageType;
- (void)printStatusDescription;
- (nullable NSDictionary*)proxyDictionaryforUrl:(nullable NSURL*)url;
- (nullable NSDictionary*)campaignHeaderforUrl:(nullable NSURL*)url;
- (BOOL)isFreeBeeAuthorizedValidUrl:(nullable NSURL*)url;
- (nullable NSString*)urlForidFromConfigDict:(nonnull NSString*)urlId;
// Tries to get the data using freebee. If freebee is not enabled, gets the data without freebee.
- (nullable NSData*)freebee_dataWithContentsOfURL:(NSURL *_Nullable)url;
- (nullable NSCachedURLResponse*)freebee_dataWithImageURL:(NSURL *_Nullable)imageURL;
- (void)configureFreeBeeWithDict:(nullable NSDictionary*)configDict withSessionReset:(BOOL)isReset;
@end

View File

@ -1,654 +0,0 @@
//
// MFFreebeeHandler.m
// mobilefirst
//
// Created by Patrick Sommer on 1/3/17.
// Copyright © 2017 Verizon Wireless. All rights reserved.
//
#import "MFFreebeeHandler.h"
#import <MVMCore/NSDictionary+MFConvenience.h>
#import "FreeBeeAuthObject.h"
#import "FreeBeeUrlObject.h"
#import "Reachability.h"
#import "MFFreebeeOperation.h"
#import "MVMCoreConstants.h"
#import "MVMCoreSessionObject.h"
#import "MVMCoreJSONConstants.h"
#import "MVMCoreLoadHandler.h"
#import "MVMCoreLoggingHandler.h"
typedef NS_ENUM(NSUInteger, FreeBeeCampaignState) {
FreeBeeCampaignStateNotDetermined,
FreeBeeCampaignStateBusy,
FreeBeeCampaignStateInvalid,
FreeBeeCampaignStateValid,
FreeBeeCampaignStateExpired,
};
#define ENABLE_FREEBEE_LOCAL_TEST 0
@interface MFFreebeeHandler()<FreeBeeTaskFinished>
@property(nonatomic, strong) NSString* authString;
@property(nonatomic, strong) FreeBeeAuthObject* freeBeeAuthObj;
@property(nonatomic, assign) NSTimeInterval requestTimeoutInterval;
@property(nonatomic, assign) FreeBeeCampaignState currentFreeBeeCampaignState;
@property(nonatomic, strong) NSMutableArray* freeBeeUrls;
@property(nonatomic, strong) NSArray* excludedModulesForFreeBee;
@property(nonatomic, strong) NSArray* enabledRootPagesForFreebee;
@property(nonatomic, strong) NSMutableDictionary* configDictionary;
@property(nonatomic) BOOL freeBeeEnabled;
@property(nonatomic) BOOL freeBeeEnabledForCurrentModule;
@property(nonatomic) BOOL isFreeBeeServerEnabled;
@property(nonatomic) Reachability* reachability;
@property(nonatomic) MFFreebeeOperation* freebeeOperation;
@property(nonatomic) FreebeeLoadFinishedHandler completionHandler;
// An operation queue for top alerts
@property (nonnull, strong, nonatomic) NSOperationQueue *freebeeOperationQueue;
- (void)processFreeBeeState:(nullable FreebeeLoadFinishedHandler)completionHandler;
- (void)processAuthRequest:(nullable FreebeeLoadFinishedHandler)completionHandler;
- (void)updateWithConfigDictionary:(nullable NSDictionary*)configDict;
- (NSURLRequest*)authRequestWithConfigDict:(NSDictionary*)configDict;
- (BOOL)isCampaignStateNotDetermined;
- (FreeBeeCampaignState)processResponse:(NSData*)data withExtraParams:(NSDictionary*)extraParams;
- (void)configureMFFreeBeeSession;
- (NSData *)sendSynchronousRequest:(NSURL *)url
returningResponse:(__autoreleasing NSURLResponse **)response
error:(__autoreleasing NSError **)error;
@end
@implementation MFFreebeeHandler
+ (nullable instancetype)sharedHandler {
static dispatch_once_t once;
static MFFreebeeHandler* sharedHandler;
dispatch_once(&once, ^ {
sharedHandler = [[self alloc] init];
sharedHandler.authString = nil;
sharedHandler.freeBeeAuthObj = nil;
sharedHandler.currentFreeBeeCampaignState = FreeBeeCampaignStateNotDetermined;
sharedHandler.excludedModulesForFreeBee = nil;
sharedHandler.freeBeeEnabledForCurrentModule = NO;
sharedHandler.requestTimeoutInterval = 1;
sharedHandler.isFreeBeeServerEnabled = NO;
[[NSNotificationCenter defaultCenter] addObserver:sharedHandler selector:@selector(responseJSONUpdated:) name:NotificationResponseLoaded object:nil];
sharedHandler.freebeeOperationQueue = [[NSOperationQueue alloc] init];
sharedHandler.freebeeOperationQueue.maxConcurrentOperationCount = 1;
});
return sharedHandler;
}
#pragma mark -
#pragma mark Public Methods
//Activate FreeBee Feature at certain point
- (void)activateFreeBeeIfServerEnabled {
if (self.isFreeBeeServerEnabled)
self.freeBeeEnabled = YES;
else
self.freeBeeEnabled = NO;
MVMCoreLog(@"FreeBee status is %d", [[MFFreebeeHandler sharedHandler] isFreeBeeEnabled]);
}
- (void)invalidateFreeBeeState {
MVMCoreLog(@"FreeBee State Invalidated");
if (self.currentFreeBeeCampaignState != FreeBeeCampaignStateBusy) {
self.currentFreeBeeCampaignState = FreeBeeCampaignStateNotDetermined;
[[MVMCoreSessionObject sharedGlobal].freeBeeSession invalidateAndCancel];
[MVMCoreSessionObject sharedGlobal].freeBeeSession = nil;
}
}
- (void)processFreeBeeAuthRequestWithCompletionHandler:(nullable FreebeeLoadFinishedHandler)completionHandler {
if ([self isExpired]) {
[self invalidateFreeBeeState];
}
[self processFreeBeeState:completionHandler];
}
- (BOOL)canProceedWithFreebeeAuthRequest {
if ([self isFreeBeeEnabled] && ([self isCampaignStateNotDetermined] || [self isExpired]))
return YES;
return NO;
}
- (BOOL)isFreeBeeEnabled {
return self.freeBeeEnabled;
}
- (BOOL)isValidCampaign {
if (self.currentFreeBeeCampaignState == FreeBeeCampaignStateValid ) {
return YES;
}
return NO;
}
- (BOOL)isExpired {
return [self.freeBeeAuthObj isExpired];
}
- (void)enableFreeBeeForCurrentModule:(BOOL)enable {
if (self.isFreeBeeEnabled)
self.freeBeeEnabledForCurrentModule = enable;
}
- (BOOL)isFreeBeeEnabledForCurrentModule {
return self.freeBeeEnabledForCurrentModule;
}
- (BOOL)isExcludedModule:(nullable NSString*)parentPageType {
if (self.excludedModulesForFreeBee.count == 0)
return NO;
if (parentPageType.length) {
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"%@ =[cd] SELF", parentPageType];
NSArray* subArray = [self.excludedModulesForFreeBee filteredArrayUsingPredicate:predicate];
if (subArray.count)
return YES;
else
return NO;
}
return YES;
}
- (BOOL)isAllowedPage:(nullable NSString*)pageType {
if (!self.enabledRootPagesForFreebee.count) {
return NO;
}
if (pageType.length) {
return [self.enabledRootPagesForFreebee containsObject:pageType];
}
return NO;
}
- (void)printStatusDescription {
if ([[MFFreebeeHandler sharedHandler] isValidCampaign]) {
MVMCoreLog(@"FreeBee Valid Campaign");
} else {
MVMCoreLog(@"FreeBee Invalid Campaign");
}
}
- (nullable NSDictionary*)proxyDictionaryforUrl:(nullable NSURL*)url {
return [self.freeBeeAuthObj proxyDictionaryForUrl:url];
}
- (nullable NSDictionary*)campaignHeaderforUrl:(nullable NSURL*)url {
return [self.freeBeeAuthObj campaignHeaderForUrl:url];
}
//make it protocol dependent
- (BOOL)isFreeBeeAuthorizedValidUrl:(nullable NSURL*)url {
//if validated url has prefix, then return YES
FreeBeeUrlObject* urlObject = [self.freeBeeAuthObj freebeeUrlObjectForUrl:url];
if (urlObject)
return YES;
return NO;
}
- (nullable NSString*)urlForidFromConfigDict:(nonnull NSString*)urlId {
NSArray* authUrls = [self.configDictionary arrayForKey:@"authUrls"];
NSPredicate* predicate = [NSPredicate predicateWithFormat:@"urlId = %@",urlId];
NSArray* matchedUrl = [authUrls filteredArrayUsingPredicate:predicate];
if (matchedUrl.count) {
NSDictionary* authUrl = matchedUrl[0];
return authUrl[@"authUrl"];
}
return nil;
}
#pragma mark FreeBee Helper for NSData
- (nullable NSData *)freebeeDataWithURL:(NSURL *)url response:(NSURLResponse **)response {
NSData *data = nil;
NSDictionary *proxyDict = [self proxyDictionaryforUrl:url];
if ([self isFreeBeeEnabled] &&
[self isValidCampaign] && proxyDict &&
![self isExpired] && [self isFreeBeeEnabledForCurrentModule]) {
MVMCoreLog(@"Free Data Url, %@", url);
NSError *error = nil;
data = [self sendSynchronousRequest:url returningResponse:response error:&error];
if (error) {
data = nil;
}
MVMCoreLog(@"freebee_dataWithContentsOfURL:Free Data, %lu", (unsigned long)data.length);
}
return data;
}
- (nullable NSData*)freebee_dataWithContentsOfURL:(NSURL *)url {
NSData *data = [self freebeeDataWithURL:url response:nil];
if (!data) {
data = [NSData dataWithContentsOfURL:url];
}
return data;
}
- (nullable NSCachedURLResponse*)freebee_dataWithImageURL:(NSURL *)imageURL {
NSURLResponse *response = nil;
NSData *data = [self freebeeDataWithURL:imageURL response:&response];
if (data) {
NSCachedURLResponse *cachedResponse = [[NSCachedURLResponse alloc] initWithResponse:response data:data];
return cachedResponse;
}
return nil;
}
#pragma mark - FreeBee Registration
- (void)responseJSONUpdated:(nonnull NSNotification *)notification {
#if !ENABLE_FREEBEE_LOCAL_TEST
NSDictionary *module = [notification.userInfo dictWithChainOfKeysOrIndexes:@[KeyModuleMap, @"FreeBeeRollout"]];
#else
NSDictionary *module = [notification.userInfo dictWithChainOfKeysOrIndexes:@[KeyModuleMap, @"DeepLinkMapping"]];
#endif
if (module) {
// Enable for testing hardcoded response
#if ENABLE_FREEBEE_LOCAL_TEST
NSString *plistPath = [[MVMCoreUtility bundleForMVMCore] pathForResource:@"freebeelaunchApp" ofType:@"json"];
NSData* data = [NSData dataWithContentsOfFile:plistPath];
NSDictionary* freeBeeConfigDictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:nil];
module = [freeBeeConfigDictionary dictionaryForKey:@"FreeBeeRollout"];
#endif
MVMCoreLog(@"*********************************FreeBee Logs Start**********************************");
MVMCoreLog(@"FreeBee launch App Json is %@", module);
MVMCoreLog(@"*********************************FreeBee Logs End**********************************");
NSString* freeBeeEnabledFlag = [module stringForKey:@"freeBeeEnabled"];
[MVMCoreLoggingHandler logWithDelegateWithObject:nil withName:@"freeBeeData" withExtraInfo:module];
if ([freeBeeEnabledFlag isEqualToString:@"Y"]) {
self.isFreeBeeServerEnabled = YES;
self.authString = [module stringForKey:@"proxyServerUrl"];
if (self.authString) {
NSDictionary* configDict = [module dictionaryForKey:@"freeBeeData"];
[self configureFreeBeeWithDict:configDict withSessionReset:NO];
self.excludedModulesForFreeBee = [module arrayForKey:@"disabledModules"];
self.enabledRootPagesForFreebee = [module arrayForKey:@"enabledPages"];
NSString* timeOut = [module stringForKey:@"authRequestTimeOut"];
NSTimeInterval time = [timeOut doubleValue];
if (time > 0.f)
self.requestTimeoutInterval = time;
} else {
[self configureFreeBeeWithDict:nil withSessionReset:NO];
}
} else {
[self configureFreeBeeWithDict:nil withSessionReset:NO];
}
}
}
- (void)configureFreeBeeWithDict:(nullable NSDictionary*)configDict withSessionReset:(BOOL)isReset {
if (configDict) {
[self updateWithConfigDictionary:configDict];
[self enableReachability:YES];
} else {
[self invalidateFreeBeeState];
[self updateWithConfigDictionary:nil];
if (isReset) {
[self enableReachability:NO];
[[MVMCoreSessionObject sharedGlobal].freeBeeSession invalidateAndCancel];
[MVMCoreSessionObject sharedGlobal].freeBeeSession = nil;
}
}
}
#pragma mark - FreeBee State Machine SetUp
- (void)processFreeBeeState:(nullable FreebeeLoadFinishedHandler)completionHandler {
switch (self.currentFreeBeeCampaignState) {
case FreeBeeCampaignStateBusy:
[self processBusyState];
break;
case FreeBeeCampaignStateNotDetermined:
[self processAuthRequest:completionHandler];
break;
case FreeBeeCampaignStateValid:
[self enableReachability:YES];
self.completionHandler(nil, YES);
self.completionHandler = nil;
//start a timer request
break;
case FreeBeeCampaignStateInvalid:
[self enableReachability:YES];
self.completionHandler(nil, YES);
self.completionHandler = nil;
break;
default:
break;
}
}
- (void)processBusyState {
if (!self.configDictionary) {
MVMCoreLog(@"FreeBee Response failed with error configDictionary:Empty");
self.freeBeeAuthObj = nil;
self.currentFreeBeeCampaignState = FreeBeeCampaignStateInvalid;
}
self.completionHandler(self.freebeeOperation, YES);
}
#pragma mark - Auth Request Handler
- (void)processAuthRequest:(nullable FreebeeLoadFinishedHandler)completionHandler {
if (self.freebeeOperation) {
self.currentFreeBeeCampaignState = FreeBeeCampaignStateBusy;
[self processBusyState];
return;
}
[self enableReachability:NO];
[[MVMCoreLoadHandler sharedGlobal] registerLoadQueue:self.freebeeOperationQueue];
self.completionHandler = completionHandler;
MVMCoreLog(@"Initializing Freebee Auth Session Call");
__weak MFFreebeeHandler* wSelf = self;
self.currentFreeBeeCampaignState = FreeBeeCampaignStateBusy;
NSURLRequest* request = [self authRequestWithConfigDict:self.configDictionary];
if (!request) {
[MVMCoreLoggingHandler logWithDelegateWithObject:nil withName:@"freeBeeError" withExtraInfo:nil];
wSelf.currentFreeBeeCampaignState = FreeBeeCampaignStateInvalid;
[self processFreeBeeState:nil];
return;
}
//add operation to queue
self.freebeeOperation = [[MFFreebeeOperation alloc] initWithConfigDict:request Delegate:wSelf];
[self.freebeeOperationQueue addOperation:self.freebeeOperation];
}
- (void)updateWithConfigDictionary:(nullable NSDictionary*)configDict {
if (configDict && configDict.count) {
self.configDictionary = [NSMutableDictionary dictionaryWithDictionary:configDict];
} else {
[self.configDictionary removeAllObjects];
self.isFreeBeeServerEnabled = NO;
self.freeBeeEnabled = NO;
self.freeBeeEnabledForCurrentModule = NO;
self.enabledRootPagesForFreebee = nil;
self.excludedModulesForFreeBee = nil;
}
}
//warning:this needs to be modified for actual dictionary
- (NSURLRequest*)authRequestWithConfigDict:(NSDictionary*)configDict {
//Need to modify this code with config dictionary
if (self.authString.length == 0)
return nil;
NSURL *url = [NSURL URLWithString:self.authString];
//warning: For Initial testing we are putting
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:self.requestTimeoutInterval];
//Update headers
[request setHTTPMethod:@"POST"];
[request setValue:@"no-cache, no-store" forHTTPHeaderField:@"Cache-Control"];
[request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[request setValue:@"application/json" forHTTPHeaderField:@"Accept"];
NSMutableDictionary *parameters = [NSMutableDictionary dictionary];
[parameters setObject:@[configDict] forKey:@"sdAuthReq"];
MVMCoreLog(@"Freebee AuthRequest Params = %@",parameters);
NSError *error = nil;
NSData *data = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:&error];
[request setHTTPBody:data];
return [request copy];
}
#pragma mark - Helper Functions
- (BOOL)isCampaignStateNotDetermined {
if (self.currentFreeBeeCampaignState == FreeBeeCampaignStateNotDetermined)
return YES;
return NO;
}
#pragma mark - FreeBeeTaskFinished Protocol
- (void)updateWithResponse:(NSData*)data Error:(NSError*)error ExtraParams:(NSDictionary*) extraParams {
if (data.length > 0) {
self.currentFreeBeeCampaignState = [self processResponse:data withExtraParams:extraParams];
[self processFreeBeeState:nil];
} else {
// Empty response.
MVMCoreLog(@"FreeBee Auth Request failed with empty response");
self.currentFreeBeeCampaignState = FreeBeeCampaignStateInvalid;
if (error.description) {
[MVMCoreLoggingHandler logWithDelegateWithObject:nil withName:@"freeBeeError" withExtraInfo:@{@"description":error.description}];
} else {
[MVMCoreLoggingHandler logWithDelegateWithObject:nil withName:@"freeBeeError" withExtraInfo:extraParams];
}
[self processFreeBeeState:nil];
}
self.freebeeOperation = nil;
}
- (FreeBeeCampaignState)processResponse:(NSData*)data withExtraParams:(NSDictionary*)extraParams {
__weak MFFreebeeHandler* wSelf = self;
NSDictionary *jsonDictionary = nil;
NSString *responseString = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
MVMCoreLog(@"FreeBee Response is %@",responseString);
// Serialize the downloaded data to json object.
NSError *error = nil;
jsonDictionary = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
MVMCoreLog(@"FreeBee init success with response %@", jsonDictionary);
if ([jsonDictionary isKindOfClass:[NSDictionary class]]) {
if (!self.freeBeeAuthObj) {
//warning:this needs to be modified for multiple urls
wSelf.freeBeeAuthObj = [[FreeBeeAuthObject alloc] init];
[wSelf.freeBeeAuthObj updateWithDictionary:jsonDictionary];
} else {
[wSelf.freeBeeAuthObj updateWithDictionary:jsonDictionary];
}
NSMutableDictionary* logDict = [NSMutableDictionary dictionary];
if (jsonDictionary)
[logDict addEntriesFromDictionary:jsonDictionary];
if (extraParams)
[logDict addEntriesFromDictionary:extraParams];
if ([self.freeBeeAuthObj isValidFreeBeeSessionAuthObject]) {
[MVMCoreLoggingHandler logWithDelegateWithObject:nil withName:@"freeBeeSuccess" withExtraInfo:logDict];
MVMCoreLog(@"FreeBee Response Validated");
[self configureMFFreeBeeSession];
return FreeBeeCampaignStateValid;
}
[MVMCoreLoggingHandler logWithDelegateWithObject:nil withName:@"freeBeeError" withExtraInfo:logDict];
MVMCoreLog(@"FreeBee Response failed with error");
wSelf.freeBeeAuthObj = nil;
return FreeBeeCampaignStateInvalid;
}
if (error.description) {
[MVMCoreLoggingHandler logWithDelegateWithObject:nil withName:@"freeBeeError" withExtraInfo:@{@"description":error.description}];
} else {
[MVMCoreLoggingHandler logWithDelegateWithObject:nil withName:@"freeBeeError" withExtraInfo:nil];
}
return FreeBeeCampaignStateInvalid;
}
- (void)configureMFFreeBeeSession {
MVMCoreLog(@"FreeBee Configure Session");
//Assign The new Session Configuration sice its not possible to modify the existing session, we need to
MVMCoreSessionObject *sessionSingleton = [MVMCoreSessionObject sharedGlobal];
NSURLSession* session = sessionSingleton.session;
NSURLSessionConfiguration *configuration = session.configuration;
NSURL* baseUrl = sessionSingleton.baseURL;
configuration.connectionProxyDictionary = [[MFFreebeeHandler sharedHandler] proxyDictionaryforUrl:baseUrl];
if (configuration.connectionProxyDictionary) {
MVMCoreLog("Creating New MFSSeeion object with configuration dict %@",configuration.connectionProxyDictionary);
MVMCoreLog("Creating New MFSSeeion object with Delegate %@, Op Queue %@",session.delegate, session.delegateQueue);
sessionSingleton.freeBeeSession = [NSURLSession sessionWithConfiguration:configuration delegate:session.delegate delegateQueue:session.delegateQueue];
}
}
// A Syncchronous request to fetch NSData
- (NSData *)sendSynchronousRequest:(NSURL *)url
returningResponse:(__autoreleasing NSURLResponse **)response
error:(__autoreleasing NSError **)error {
dispatch_group_t group = dispatch_group_create();
dispatch_group_enter(group);
NSError __block *err = NULL;
NSData __block *data;
NSURLResponse __block *resp;
NSURLSession *session = nil;
NSOperationQueue* queue = [NSOperationQueue currentQueue];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url];
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
configuration.connectionProxyDictionary = [[MFFreebeeHandler sharedHandler] proxyDictionaryforUrl:url];
session = [NSURLSession sessionWithConfiguration:configuration delegate:session.delegate delegateQueue:queue];
NSDictionary* campaignDictionary = [[MFFreebeeHandler sharedHandler] campaignHeaderforUrl:url];
if (campaignDictionary) {
[request addValue:campaignDictionary[@"Proxy-Authorization"] forHTTPHeaderField:@"Proxy-Authorization"];
}
[[session dataTaskWithRequest:request
completionHandler:^(NSData* _data, NSURLResponse* _response, NSError* _error) {
resp = _response;
err = _error;
data = _data;
dispatch_group_leave(group);
}] resume];
dispatch_group_wait(group, DISPATCH_TIME_FOREVER);
if (response) {
*response = resp;
}
if (error) {
*error = err;
}
return data;
}
#pragma mark - Reachibility Integration
- (void)enableReachability:(BOOL)enable {
dispatch_async(dispatch_get_main_queue(), ^{
if (enable) {
self->_reachability = [Reachability reachabilityForInternetConnection];
// Observe the kNetworkReachabilityChangedNotification. When that notification is posted, the method reachabilityChanged will be called.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(reachabilityDidChange:) name:kReachabilityChangedNotification object:nil];
[self->_reachability startNotifier];
} else if (self->_reachability) {
[[NSNotificationCenter defaultCenter] removeObserver:self name:kReachabilityChangedNotification object:nil];
[self->_reachability stopNotifier];
self->_reachability = nil;
}
});
}
- (void)reachabilityDidChange:(NSNotification *)notification {
MVMCoreLog(@"Device Reachability Changed");
Reachability *reachability = (Reachability *)[notification object];
switch (reachability.currentReachabilityStatus) {
case NotReachable: {
MVMCoreLog(@"Unreachable");
[self invalidateFreeBeeState];
break;
}
case ReachableViaWWAN: {
MVMCoreLog(@"Reachable via wlan");
[self invalidateFreeBeeState];
break;
}
case ReachableViaWiFi: {
MVMCoreLog(@"Reachable via wifi");
[self invalidateFreeBeeState];
break;
}
}
}
#pragma mark - NSObject Methods
- (void)dealloc {
[[NSNotificationCenter defaultCenter] removeObserver:self name:NotificationResponseLoaded object:nil];
}
@end

View File

@ -1,22 +0,0 @@
//
// MFFreebeeOperation.h
// mobilefirst
//
// Created by Bansal, Tapan on 07/09/17.
// Copyright © 2017 Verizon Wireless. All rights reserved.
//
#import <UIKit/UIKit.h>
#import "MVMCoreOperation.h"
@protocol FreeBeeTaskFinished<NSObject>
-(void)updateWithResponse:(NSData*)data Error:(NSError*)error ExtraParams:(NSDictionary*) extraParams;
@end
@interface MFFreebeeOperation : MVMCoreOperation
-(instancetype)initWithConfigDict:(NSURLRequest*)freeBeeAuthRequest Delegate:(id<FreeBeeTaskFinished>)delegate;
@end

View File

@ -1,106 +0,0 @@
//
// MFFreebeeOperation.m
// mobilefirst
//
// Created by Bansal, Tapan on 07/09/17.
// Copyright © 2017 Verizon Wireless. All rights reserved.
//
#import "MFFreebeeOperation.h"
#import "MVMCoreLoggingHandler.h"
@interface MFFreebeeOperation()
@property(nonatomic, strong) NSURLRequest *freeBeeAuthRequest;
@property(weak) id<FreeBeeTaskFinished> delegate;
@property(nonatomic) dispatch_semaphore_t semaphore;
@end
@implementation MFFreebeeOperation
-(instancetype)initWithConfigDict:(NSURLRequest*)freeBeeAuthRequest Delegate:(id<FreeBeeTaskFinished>)delegate {
if(self = [super init]) {
self.freeBeeAuthRequest = freeBeeAuthRequest;
self.delegate = delegate;
_semaphore = dispatch_semaphore_create(0);
}
return self;
}
-(void)main {
[super main];
if ([self checkAndHandleForCancellation]){
[self markAsFinished];
return;
}
[self processAuthRequest];
[self markAsFinished];
}
-(void)unlock {
dispatch_semaphore_signal(_semaphore);
}
-(void)processAuthRequest {
NSURLRequest *request = self.freeBeeAuthRequest;
if (request == nil) {
[self.delegate updateWithResponse:nil Error:nil ExtraParams:nil];
return;
}
MVMCoreLog(@"*********************************FreeBee Auth Call Start**********************************");
NSURLResponse *response = nil;
NSError *error = nil;
NSDate *date = [NSDate date];
NSData *data = [self sendSynchronousRequest:request returningResponse:&response error:&error];
NSTimeInterval interval = [[NSDate date] timeIntervalSinceDate:date];
MVMCoreLog(@"Freebee Auth Call Request Time response for freebee is %f", interval);
NSDictionary *extraParams = @{@"ResponseTime":@(interval)};
[self.delegate updateWithResponse:[data copy] Error:error ExtraParams:extraParams];
}
- (NSData *)sendSynchronousRequest:(NSURLRequest *)request returningResponse:(NSURLResponse **)response
error:(NSError **)error {
NSError __block *err = NULL;
NSData __block *data;
NSURLResponse __block *resp;
[[[NSURLSession sharedSession] dataTaskWithRequest:request
completionHandler:^(NSData* _data, NSURLResponse* _response, NSError* _error) {
resp = _response;
err = _error;
data = _data;
// this is for local testing
#if 0
NSString *plistPath = [[MVMCoreUtility bundleForMVMCore] pathForResource:@"freebee" ofType:@"json"];
data = [NSData dataWithContentsOfFile:plistPath];
err = nil;
#endif
[self unlock];
}] resume];
dispatch_semaphore_wait(_semaphore, DISPATCH_TIME_FOREVER);
if (response) {
*response = resp;
}
if (error) {
*error = err;
}
return data;
}
@end

View File

@ -1,15 +0,0 @@
{
"statusCode": 200,
"message": "Success",
"vidToken": "OAlTpG0WFQ_qKHdnjBQueUB_SjZk46rjTGxxSGppKd8=",
"sdAuthResp": [
{
"urlId": "1",
"authRespCode": 1200,
"httpsProxyIP": "152.198.7.159",
"sdPort": 22779,
"sdUrl": "mobile-eqa6.vzw.com:443?vzSvc=OAlTpG0WFQ_qKHdnjBQueUB_SjZk46rjTGxxSGppKd8=&vispVzKey=44595039&vispIconFg=1&vispUsr=44595039:sNNHcJP2nYGtcuiCaVZcHQ==&vispAuthSid=CIAAACAKJwE&vispExpTime=1511370770&vispAuthKey=25858536&vispAuthSign=0.19._y9flLw7123TMhTcHUe7IVUmzJZK4MhC5kC3A6FTvXw",
"sdConfExpiry": 1512370770
}
]
}

View File

@ -1,28 +0,0 @@
{
"FreeBeeRollout": {
"ResponseInfo": {
"locale": "EN",
"type": "Success",
"code": "00000",
"message": "0",
"userMessage": "0"
},
"authRequestTimeOut": "1",
"freeBeeEnabled": "Y",
"freeBeeData": {
"campaignToken": "CIAAIYAKqAE",
"authUrls": [
{
"urlId": "1",
"authUrl": "mobile-eqa6.vzw.com:443"
}
]
},
"disabledModules": ["gridwall"
],
"enabledPages": ["billOverview","myData","accountLanding", "deviceLanding"
],
"proxyServerUrl": "https://auth.svcs.verizon.com:22790/sd/v2/sdAuthorization/httpsProxy"
}
}

View File

@ -12,7 +12,6 @@
#import "MVMCoreLoadRequestOperation.h"
#import "MVMCoreCache.h"
#import "MFHardCodedServerResponse.h"
#import "MFFreebeeHandler.h"
#import "MVMCoreNavigationHandler.h"
#import "MVMCoreLoadObject.h"
#import "MVMCoreSessionObject.h"
@ -161,25 +160,6 @@
return nil;
}
//adding Free Bee header
if ([[MFFreebeeHandler sharedHandler] isFreeBeeEnabled]
&& [[MFFreebeeHandler sharedHandler] isValidCampaign]) {
BOOL isAllowedPage = [[MFFreebeeHandler sharedHandler] isAllowedPage:requestParameters.pageType];
if (requestParameters.parentPageType.length) {
BOOL isExcluded = [[MFFreebeeHandler sharedHandler] isExcludedModule:requestParameters.parentPageType];
[[MFFreebeeHandler sharedHandler] enableFreeBeeForCurrentModule:!isExcluded];
}
if (isAllowedPage || (!isAllowedPage && [[MFFreebeeHandler sharedHandler] isFreeBeeEnabledForCurrentModule])) {
NSDictionary* campaignDictionary = [[MFFreebeeHandler sharedHandler] campaignHeaderforUrl:request.URL];
if (campaignDictionary) {
MVMCoreLog(@"Freebee Request Campaign Dictionary : %@", campaignDictionary);
[request addValue:campaignDictionary[@"Proxy-Authorization"] forHTTPHeaderField:@"Proxy-Authorization"];
}
}
}
NSError *bodyError;
NSData *body = jsonData;
if (requestParameters.imageData) {
@ -331,20 +311,6 @@
requestFinished(nil,error);
}
if ([[MFFreebeeHandler sharedHandler] isFreeBeeEnabled]
&& [[MFFreebeeHandler sharedHandler] isValidCampaign]) {
BOOL isAllowedPage = [[MFFreebeeHandler sharedHandler] isAllowedPage:requestParameters.pageType];
//In case of error for time out, we need to revert to normal session object
if (isAllowedPage || (!isAllowedPage && [[MFFreebeeHandler sharedHandler] isFreeBeeEnabledForCurrentModule])) {
// to enable only for self server module
if ([MVMCoreSessionObject sharedGlobal].freeBeeSession) {
session = [MVMCoreSessionObject sharedGlobal].freeBeeSession;
MVMCoreLog(@"*********************************FreeBee Sponsored Request Start**********************************");
}
}
}
MVMCoreLog(@"********************************* Cookie Sent *********************************");
[[[NSHTTPCookieStorage sharedHTTPCookieStorage] cookies] enumerateObjectsUsingBlock:^(NSHTTPCookie * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
MVMCoreLog(@"Cookie Name: %@, Cookie Value: %@",obj.name, obj.value);

View File

@ -95,9 +95,3 @@ FOUNDATION_EXPORT const unsigned char MVMCoreVersionString[];
#import <MVMCore/MVMCoreCache.h>
#import <MVMCore/MVMCoreSessionTimeHandler.h>
#import <MVMCore/MVMCoreSessionObject.h>
// Main Views
//Freebee
#import <MVMCore/MFFreebeeHandler.h>

View File

@ -10,7 +10,6 @@
#import <MVMCore/NSDictionary+MFConvenience.h>
#import "MVMCoreErrorObject.h"
#import "MVMCoreLoggingHandler.h"
#import "MFFreebeeHandler.h"
#import "MVMCoreGetterUtility.h"
#import "MVMCoreObject.h"
#import "MVMCoreConstants.h"
@ -575,18 +574,6 @@ static NSString * const STATIC_CACHE_COMPONENT = @"StaticCache.txt";
NSURLSession *session = [MVMCoreSessionObject sharedGlobal].session;
NSURLCache *sharedCache = session.configuration.URLCache;
NSURLRequest *request = [NSURLRequest requestWithURL:s7URL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:ImageTimeOut];
//use Freebee to download image first if it is not already in the cache, then store image to cache
NSCachedURLResponse *cachedResponse = [sharedCache cachedResponseForRequest:request];
if (!cachedResponse.data) {
cachedResponse = [[MFFreebeeHandler sharedHandler] freebee_dataWithImageURL:s7URL];
if (cachedResponse) {
//system stores cache based datatask and check cache based on response,
//need to manually store cache for response
[sharedCache storeCachedResponse:cachedResponse forRequest:request];
}
}
//call nsurlsession again, if image is cached by Freebee, the second session will grab image data from cache instead of making another server call
NSURLSessionDownloadTask *downloadImageTask = [session downloadTaskWithRequest:request completionHandler:^(NSURL * _Nullable location, NSURLResponse * _Nullable response, NSError * _Nullable error) {
NSData *data = [NSData dataWithContentsOfURL:location];
//check data and response first, since they are nullable

View File

@ -13,9 +13,6 @@
/// the session used for all requests.
@property (nullable, strong, nonatomic) NSURLSession *session;
/// the session used for all Freebee requests.
@property (nullable, strong, nonatomic) NSURLSession *freeBeeSession;
/// The server base url (Until prepay is native, this will always be postpay).
@property (nullable, strong, nonatomic) NSURL *baseURL;