From 719b6553b1017b472ce7815e479e570b63216f9a Mon Sep 17 00:00:00 2001 From: James Go Date: Tue, 16 Apr 2019 17:03:55 -0700 Subject: [PATCH 1/3] US584914 : iOS - Decoupling the BLE into separate module --- MASFoundation.xcodeproj/project.pbxproj | 78 +- MASFoundation/Classes/MAS.m | 5 +- MASFoundation/Classes/MASError.h | 28 - .../Classes/MASProximityLoginDelegate.h | 135 --- .../Classes/_private_/MASConstantsPrivate.h | 9 - .../categories/CBCentralManager+MASPrivate.h | 56 -- .../categories/CBCentralManager+MASPrivate.m | 141 --- .../CBPeripheralManager+MASPrivate.h | 80 -- .../CBPeripheralManager+MASPrivate.m | 162 ---- .../_private_/categories/NSError+MASPrivate.h | 18 - .../_private_/categories/NSError+MASPrivate.m | 41 +- .../MASProximityLoginQRCode+MASPrivate.h | 49 - .../MASProximityLoginQRCode+MASPrivate.m | 279 ------ .../_private_/services/MASServiceRegistry.m | 1 - .../services/bluetooth/MASBluetoothCentral.h | 63 -- .../services/bluetooth/MASBluetoothCentral.m | 867 ------------------ .../bluetooth/MASBluetoothPeripheral.h | 52 -- .../bluetooth/MASBluetoothPeripheral.m | 539 ----------- .../services/bluetooth/MASBluetoothService.h | 41 - .../services/bluetooth/MASBluetoothService.m | 135 --- .../models/MASAuthenticationProviders.h | 5 + .../models/MASAuthenticationProviders.m | 9 + MASFoundation/Classes/models/MASDevice.h | 66 -- MASFoundation/Classes/models/MASDevice.m | 53 -- .../Classes/models/MASProximityLogin.h | 15 - .../Classes/models/MASProximityLogin.m | 29 - .../Classes/models/MASProximityLoginQRCode.h | 128 --- .../Classes/models/MASProximityLoginQRCode.m | 225 ----- MASFoundation/MASFoundation.h | 3 - 29 files changed, 17 insertions(+), 3295 deletions(-) delete mode 100644 MASFoundation/Classes/MASProximityLoginDelegate.h delete mode 100644 MASFoundation/Classes/_private_/categories/CBCentralManager+MASPrivate.h delete mode 100644 MASFoundation/Classes/_private_/categories/CBCentralManager+MASPrivate.m delete mode 100644 MASFoundation/Classes/_private_/categories/CBPeripheralManager+MASPrivate.h delete mode 100644 MASFoundation/Classes/_private_/categories/CBPeripheralManager+MASPrivate.m delete mode 100644 MASFoundation/Classes/_private_/models/MASProximityLoginQRCode+MASPrivate.h delete mode 100644 MASFoundation/Classes/_private_/models/MASProximityLoginQRCode+MASPrivate.m delete mode 100644 MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothCentral.h delete mode 100644 MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothCentral.m delete mode 100644 MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothPeripheral.h delete mode 100644 MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothPeripheral.m delete mode 100644 MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothService.h delete mode 100644 MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothService.m delete mode 100644 MASFoundation/Classes/models/MASProximityLogin.h delete mode 100644 MASFoundation/Classes/models/MASProximityLogin.m delete mode 100644 MASFoundation/Classes/models/MASProximityLoginQRCode.h delete mode 100644 MASFoundation/Classes/models/MASProximityLoginQRCode.m diff --git a/MASFoundation.xcodeproj/project.pbxproj b/MASFoundation.xcodeproj/project.pbxproj index 29f7e848..d65b015c 100644 --- a/MASFoundation.xcodeproj/project.pbxproj +++ b/MASFoundation.xcodeproj/project.pbxproj @@ -64,8 +64,6 @@ A4150ED51BF16D9A00037E27 /* MASNetworkingService.m in Sources */ = {isa = PBXBuildFile; fileRef = A4150EC91BF16D9A00037E27 /* MASNetworkingService.m */; }; A4150ED91BF16DBE00037E27 /* MASLocationService.h in Headers */ = {isa = PBXBuildFile; fileRef = A4150ED71BF16DBE00037E27 /* MASLocationService.h */; }; A4150EDA1BF16DBE00037E27 /* MASLocationService.m in Sources */ = {isa = PBXBuildFile; fileRef = A4150ED81BF16DBE00037E27 /* MASLocationService.m */; }; - A4150EE01BF16E0F00037E27 /* MASBluetoothService.h in Headers */ = {isa = PBXBuildFile; fileRef = A4150EDC1BF16E0F00037E27 /* MASBluetoothService.h */; }; - A4150EE11BF16E0F00037E27 /* MASBluetoothService.m in Sources */ = {isa = PBXBuildFile; fileRef = A4150EDD1BF16E0F00037E27 /* MASBluetoothService.m */; }; A4150EE71BF16E5B00037E27 /* MASFileService.h in Headers */ = {isa = PBXBuildFile; fileRef = A4150EE51BF16E5B00037E27 /* MASFileService.h */; }; A4150EE81BF16E5B00037E27 /* MASFileService.m in Sources */ = {isa = PBXBuildFile; fileRef = A4150EE61BF16E5B00037E27 /* MASFileService.m */; }; A4150EFB1BF16EE200037E27 /* MASKeyChainService.h in Headers */ = {isa = PBXBuildFile; fileRef = A4150EF71BF16EE200037E27 /* MASKeyChainService.h */; }; @@ -141,10 +139,6 @@ A47332D01BBC61F50002A492 /* NSData+MASPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = A47332CE1BBC61F50002A492 /* NSData+MASPrivate.m */; }; A47F126C1C1D6B4B0008E3F2 /* MASURLRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = A47F126A1C1D6B4B0008E3F2 /* MASURLRequest.h */; }; A47F126D1C1D6B4B0008E3F2 /* MASURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = A47F126B1C1D6B4B0008E3F2 /* MASURLRequest.m */; }; - A47F127E1C1D73530008E3F2 /* MASBluetoothCentral.h in Headers */ = {isa = PBXBuildFile; fileRef = A47F127A1C1D73530008E3F2 /* MASBluetoothCentral.h */; }; - A47F127F1C1D73530008E3F2 /* MASBluetoothCentral.m in Sources */ = {isa = PBXBuildFile; fileRef = A47F127B1C1D73530008E3F2 /* MASBluetoothCentral.m */; }; - A47F12801C1D73530008E3F2 /* MASBluetoothPeripheral.h in Headers */ = {isa = PBXBuildFile; fileRef = A47F127C1C1D73530008E3F2 /* MASBluetoothPeripheral.h */; }; - A47F12811C1D73530008E3F2 /* MASBluetoothPeripheral.m in Sources */ = {isa = PBXBuildFile; fileRef = A47F127D1C1D73530008E3F2 /* MASBluetoothPeripheral.m */; }; A4831AA91BD1A551007B4AE6 /* MASApplication.h in Headers */ = {isa = PBXBuildFile; fileRef = A4831A9B1BD1A551007B4AE6 /* MASApplication.h */; settings = {ATTRIBUTES = (Public, ); }; }; A4831AAA1BD1A551007B4AE6 /* MASApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = A4831A9C1BD1A551007B4AE6 /* MASApplication.m */; }; A4831AAB1BD1A551007B4AE6 /* MASAuthenticationProvider.h in Headers */ = {isa = PBXBuildFile; fileRef = A4831A9D1BD1A551007B4AE6 /* MASAuthenticationProvider.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -171,10 +165,6 @@ A4831AFB1BD1A8E8007B4AE6 /* MASFile+MASPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = A4831AF91BD1A8E8007B4AE6 /* MASFile+MASPrivate.m */; }; A4831AFD1BD1A917007B4AE6 /* MASUser+MASPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A4831AFC1BD1A917007B4AE6 /* MASUser+MASPrivate.h */; }; A4831AFF1BD1A922007B4AE6 /* MASUser+MASPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = A4831AFE1BD1A922007B4AE6 /* MASUser+MASPrivate.m */; }; - A483C1A31BE56BAF007572CE /* CBPeripheralManager+MASPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A483C1A11BE56BAF007572CE /* CBPeripheralManager+MASPrivate.h */; }; - A483C1A41BE56BAF007572CE /* CBPeripheralManager+MASPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = A483C1A21BE56BAF007572CE /* CBPeripheralManager+MASPrivate.m */; }; - A483C2011BE6D0C5007572CE /* CBCentralManager+MASPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A483C1FF1BE6D0C5007572CE /* CBCentralManager+MASPrivate.h */; }; - A483C2021BE6D0C5007572CE /* CBCentralManager+MASPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = A483C2001BE6D0C5007572CE /* CBCentralManager+MASPrivate.m */; }; A488CE751C0B97FD00B8B961 /* MASService.h in Headers */ = {isa = PBXBuildFile; fileRef = A488CE731C0B97FD00B8B961 /* MASService.h */; settings = {ATTRIBUTES = (Public, ); }; }; A488CE761C0B97FD00B8B961 /* MASService.m in Sources */ = {isa = PBXBuildFile; fileRef = A488CE741C0B97FD00B8B961 /* MASService.m */; }; A4E340EB1B9E9F2000883AD3 /* MASConstantsPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = A4E340BE1B9E9F2000883AD3 /* MASConstantsPrivate.h */; }; @@ -195,15 +185,8 @@ C81CC3CD1FC2EA190058718E /* MASBrowserBasedAuthentication.m in Sources */ = {isa = PBXBuildFile; fileRef = C81CC3CB1FC2EA190058718E /* MASBrowserBasedAuthentication.m */; }; C81CC3D01FC2EFBB0058718E /* UIAlertController+MAS.h in Headers */ = {isa = PBXBuildFile; fileRef = C81CC3CE1FC2EFBB0058718E /* UIAlertController+MAS.h */; }; C81CC3D11FC2EFBB0058718E /* UIAlertController+MAS.m in Sources */ = {isa = PBXBuildFile; fileRef = C81CC3CF1FC2EFBB0058718E /* UIAlertController+MAS.m */; }; - CB0A8ADF1D01F64F00B1DCCC /* MASProximityLogin.h in Headers */ = {isa = PBXBuildFile; fileRef = CB0A8ADD1D01F64F00B1DCCC /* MASProximityLogin.h */; settings = {ATTRIBUTES = (Public, ); }; }; - CB0A8AE01D01F64F00B1DCCC /* MASProximityLogin.m in Sources */ = {isa = PBXBuildFile; fileRef = CB0A8ADE1D01F64F00B1DCCC /* MASProximityLogin.m */; }; CB0B58591E258C2A00BC0163 /* MASAuthorizationResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = CB0B58571E258C2A00BC0163 /* MASAuthorizationResponse.h */; settings = {ATTRIBUTES = (Public, ); }; }; CB0B585A1E258C2A00BC0163 /* MASAuthorizationResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = CB0B58581E258C2A00BC0163 /* MASAuthorizationResponse.m */; }; - CB14D2191D02266D004F772E /* MASProximityLoginQRCode.h in Headers */ = {isa = PBXBuildFile; fileRef = CB14D2171D02266D004F772E /* MASProximityLoginQRCode.h */; settings = {ATTRIBUTES = (Public, ); }; }; - CB14D21A1D02266D004F772E /* MASProximityLoginQRCode.m in Sources */ = {isa = PBXBuildFile; fileRef = CB14D2181D02266D004F772E /* MASProximityLoginQRCode.m */; }; - CB14D21C1D02293B004F772E /* MASProximityLoginDelegate.h in Headers */ = {isa = PBXBuildFile; fileRef = CB14D21B1D0228DB004F772E /* MASProximityLoginDelegate.h */; settings = {ATTRIBUTES = (Public, ); }; }; - CB14D2231D02328C004F772E /* MASProximityLoginQRCode+MASPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = CB14D2211D02328C004F772E /* MASProximityLoginQRCode+MASPrivate.h */; }; - CB14D2241D02328C004F772E /* MASProximityLoginQRCode+MASPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = CB14D2221D02328C004F772E /* MASProximityLoginQRCode+MASPrivate.m */; }; CB1907EF1C1794F400A5EF16 /* MASIKeyChainStore+MASPrivate.h in Headers */ = {isa = PBXBuildFile; fileRef = CB1907ED1C1794F400A5EF16 /* MASIKeyChainStore+MASPrivate.h */; }; CB1907F01C1794F400A5EF16 /* MASIKeyChainStore+MASPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = CB1907EE1C1794F400A5EF16 /* MASIKeyChainStore+MASPrivate.m */; }; CB1907F31C1794FC00A5EF16 /* MASAccess.h in Headers */ = {isa = PBXBuildFile; fileRef = CB1907F11C1794FC00A5EF16 /* MASAccess.h */; }; @@ -450,8 +433,6 @@ A4150EC91BF16D9A00037E27 /* MASNetworkingService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASNetworkingService.m; sourceTree = ""; }; A4150ED71BF16DBE00037E27 /* MASLocationService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASLocationService.h; sourceTree = ""; }; A4150ED81BF16DBE00037E27 /* MASLocationService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASLocationService.m; sourceTree = ""; }; - A4150EDC1BF16E0F00037E27 /* MASBluetoothService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASBluetoothService.h; sourceTree = ""; }; - A4150EDD1BF16E0F00037E27 /* MASBluetoothService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASBluetoothService.m; sourceTree = ""; }; A4150EE51BF16E5B00037E27 /* MASFileService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASFileService.h; sourceTree = ""; }; A4150EE61BF16E5B00037E27 /* MASFileService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASFileService.m; sourceTree = ""; }; A4150EF71BF16EE200037E27 /* MASKeyChainService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASKeyChainService.h; sourceTree = ""; }; @@ -531,10 +512,6 @@ A47332CE1BBC61F50002A492 /* NSData+MASPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+MASPrivate.m"; sourceTree = ""; }; A47F126A1C1D6B4B0008E3F2 /* MASURLRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASURLRequest.h; sourceTree = ""; }; A47F126B1C1D6B4B0008E3F2 /* MASURLRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASURLRequest.m; sourceTree = ""; }; - A47F127A1C1D73530008E3F2 /* MASBluetoothCentral.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASBluetoothCentral.h; sourceTree = ""; }; - A47F127B1C1D73530008E3F2 /* MASBluetoothCentral.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASBluetoothCentral.m; sourceTree = ""; }; - A47F127C1C1D73530008E3F2 /* MASBluetoothPeripheral.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASBluetoothPeripheral.h; sourceTree = ""; }; - A47F127D1C1D73530008E3F2 /* MASBluetoothPeripheral.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASBluetoothPeripheral.m; sourceTree = ""; }; A4831A9B1BD1A551007B4AE6 /* MASApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASApplication.h; sourceTree = ""; }; A4831A9C1BD1A551007B4AE6 /* MASApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASApplication.m; sourceTree = ""; }; A4831A9D1BD1A551007B4AE6 /* MASAuthenticationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASAuthenticationProvider.h; sourceTree = ""; }; @@ -561,10 +538,6 @@ A4831AF91BD1A8E8007B4AE6 /* MASFile+MASPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MASFile+MASPrivate.m"; sourceTree = ""; }; A4831AFC1BD1A917007B4AE6 /* MASUser+MASPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MASUser+MASPrivate.h"; sourceTree = ""; }; A4831AFE1BD1A922007B4AE6 /* MASUser+MASPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MASUser+MASPrivate.m"; sourceTree = ""; }; - A483C1A11BE56BAF007572CE /* CBPeripheralManager+MASPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CBPeripheralManager+MASPrivate.h"; sourceTree = ""; }; - A483C1A21BE56BAF007572CE /* CBPeripheralManager+MASPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CBPeripheralManager+MASPrivate.m"; sourceTree = ""; }; - A483C1FF1BE6D0C5007572CE /* CBCentralManager+MASPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "CBCentralManager+MASPrivate.h"; sourceTree = ""; }; - A483C2001BE6D0C5007572CE /* CBCentralManager+MASPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "CBCentralManager+MASPrivate.m"; sourceTree = ""; }; A488CE731C0B97FD00B8B961 /* MASService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASService.h; sourceTree = ""; }; A488CE741C0B97FD00B8B961 /* MASService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASService.m; sourceTree = ""; }; A48CDD381B7D1FDD00ADABC6 /* MASFoundation_PrefixHeader.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MASFoundation_PrefixHeader.pch; sourceTree = ""; }; @@ -587,15 +560,8 @@ C81CC3CB1FC2EA190058718E /* MASBrowserBasedAuthentication.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MASBrowserBasedAuthentication.m; sourceTree = ""; }; C81CC3CE1FC2EFBB0058718E /* UIAlertController+MAS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIAlertController+MAS.h"; sourceTree = ""; }; C81CC3CF1FC2EFBB0058718E /* UIAlertController+MAS.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIAlertController+MAS.m"; sourceTree = ""; }; - CB0A8ADD1D01F64F00B1DCCC /* MASProximityLogin.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASProximityLogin.h; sourceTree = ""; }; - CB0A8ADE1D01F64F00B1DCCC /* MASProximityLogin.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASProximityLogin.m; sourceTree = ""; }; CB0B58571E258C2A00BC0163 /* MASAuthorizationResponse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASAuthorizationResponse.h; sourceTree = ""; }; CB0B58581E258C2A00BC0163 /* MASAuthorizationResponse.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASAuthorizationResponse.m; sourceTree = ""; }; - CB14D2171D02266D004F772E /* MASProximityLoginQRCode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASProximityLoginQRCode.h; sourceTree = ""; }; - CB14D2181D02266D004F772E /* MASProximityLoginQRCode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASProximityLoginQRCode.m; sourceTree = ""; }; - CB14D21B1D0228DB004F772E /* MASProximityLoginDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MASProximityLoginDelegate.h; sourceTree = ""; }; - CB14D2211D02328C004F772E /* MASProximityLoginQRCode+MASPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MASProximityLoginQRCode+MASPrivate.h"; sourceTree = ""; }; - CB14D2221D02328C004F772E /* MASProximityLoginQRCode+MASPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MASProximityLoginQRCode+MASPrivate.m"; sourceTree = ""; }; CB1907ED1C1794F400A5EF16 /* MASIKeyChainStore+MASPrivate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "MASIKeyChainStore+MASPrivate.h"; sourceTree = ""; }; CB1907EE1C1794F400A5EF16 /* MASIKeyChainStore+MASPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "MASIKeyChainStore+MASPrivate.m"; sourceTree = ""; }; CB1907F11C1794FC00A5EF16 /* MASAccess.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASAccess.h; sourceTree = ""; }; @@ -886,19 +852,6 @@ path = location; sourceTree = ""; }; - A4150EDB1BF16E0F00037E27 /* bluetooth */ = { - isa = PBXGroup; - children = ( - A4150EDC1BF16E0F00037E27 /* MASBluetoothService.h */, - A4150EDD1BF16E0F00037E27 /* MASBluetoothService.m */, - A47F127A1C1D73530008E3F2 /* MASBluetoothCentral.h */, - A47F127B1C1D73530008E3F2 /* MASBluetoothCentral.m */, - A47F127C1C1D73530008E3F2 /* MASBluetoothPeripheral.h */, - A47F127D1C1D73530008E3F2 /* MASBluetoothPeripheral.m */, - ); - path = bluetooth; - sourceTree = ""; - }; A4150EE41BF16E5B00037E27 /* file */ = { isa = PBXGroup; children = ( @@ -1102,10 +1055,6 @@ 1046618D1C0ABDDE00A2A03C /* MASGroup.m */, CBAFD24A1F2BD46C0034DF02 /* MASSecurityConfiguration.h */, CBAFD24B1F2BD46C0034DF02 /* MASSecurityConfiguration.m */, - CB0A8ADD1D01F64F00B1DCCC /* MASProximityLogin.h */, - CB0A8ADE1D01F64F00B1DCCC /* MASProximityLogin.m */, - CB14D2171D02266D004F772E /* MASProximityLoginQRCode.h */, - CB14D2181D02266D004F772E /* MASProximityLoginQRCode.m */, CBA3EB2C1E945F2400E64D9D /* MASClaims.h */, CBA3EB2D1E945F2400E64D9D /* MASClaims.m */, CB1FD1491FB23701000AFA25 /* MASSharedStorage.h */, @@ -1122,7 +1071,6 @@ A42157171BF863480034BDC9 /* MASServiceRegistry.h */, A42157181BF863480034BDC9 /* MASServiceRegistry.m */, CB1907F51C17950700A5EF16 /* access */, - A4150EDB1BF16E0F00037E27 /* bluetooth */, A42157231BF864590034BDC9 /* configuration */, A4150EE41BF16E5B00037E27 /* file */, A898EF602182D30900CF291B /* jwt */, @@ -1148,7 +1096,6 @@ 699570E52062FF1300017244 /* MASError.m */, 699570E02060650400017244 /* MASNotifications.h */, 699570E12060650400017244 /* MASNotifications.m */, - CB14D21B1D0228DB004F772E /* MASProximityLoginDelegate.h */, 107389F21C7118F800B7E87E /* MQTT */, A419B39A1C17622E008DC88C /* categories */, A4831A9A1BD1A551007B4AE6 /* models */, @@ -1179,10 +1126,6 @@ C81CC3CF1FC2EFBB0058718E /* UIAlertController+MAS.m */, CB1907ED1C1794F400A5EF16 /* MASIKeyChainStore+MASPrivate.h */, CB1907EE1C1794F400A5EF16 /* MASIKeyChainStore+MASPrivate.m */, - A483C1FF1BE6D0C5007572CE /* CBCentralManager+MASPrivate.h */, - A483C2001BE6D0C5007572CE /* CBCentralManager+MASPrivate.m */, - A483C1A11BE56BAF007572CE /* CBPeripheralManager+MASPrivate.h */, - A483C1A21BE56BAF007572CE /* CBPeripheralManager+MASPrivate.m */, A417BA4F1BF033C300EC9BCB /* CLLocation+MASPrivate.h */, A417BA501BF033C300EC9BCB /* CLLocation+MASPrivate.m */, A43BEBB01BE34D7700842522 /* CLLocationManager+MASPrivate.h */, @@ -1235,8 +1178,6 @@ 10D2D49D1C1686ED00DF8AC4 /* MASGroup+MASPrivate.m */, A898EF652182D35700CF291B /* MASJWKSet.h */, A898EF662182D35700CF291B /* MASJWKSet.m */, - CB14D2211D02328C004F772E /* MASProximityLoginQRCode+MASPrivate.h */, - CB14D2221D02328C004F772E /* MASProximityLoginQRCode+MASPrivate.m */, CBA3EB301E94634C00E64D9D /* MASClaims+MASPrivate.h */, CBA3EB311E94634C00E64D9D /* MASClaims+MASPrivate.m */, ); @@ -1601,12 +1542,9 @@ CB9B1207210949D5008A2075 /* NSMutableData+MASASN1Helper.h in Headers */, CBA3EB2E1E945F2400E64D9D /* MASClaims.h in Headers */, CB0B58591E258C2A00BC0163 /* MASAuthorizationResponse.h in Headers */, - CB14D21C1D02293B004F772E /* MASProximityLoginDelegate.h in Headers */, CBA3EB321E94634C00E64D9D /* MASClaims+MASPrivate.h in Headers */, CBD25AFF1E78C47C00DFB47F /* JWTClaimsSetVerifier.h in Headers */, - CB14D2191D02266D004F772E /* MASProximityLoginQRCode.h in Headers */, CBD25AF21E78C47C00DFB47F /* JWTRSAlgorithm.h in Headers */, - CB0A8ADF1D01F64F00B1DCCC /* MASProximityLogin.h in Headers */, CB6491F01FE9DAF300281288 /* MQTTPersistence.h in Headers */, 10E027A11F72B10100EAB103 /* RNCryptor+Private.h in Headers */, CBD25B0C1E78C47C00DFB47F /* JWTBase64Coder.h in Headers */, @@ -1660,7 +1598,6 @@ 10E0279E1F72B10100EAB103 /* RNCryptor-Prefix.pch in Headers */, CB6492051FE9DAF300281288 /* MQTTTransport.h in Headers */, CB6491E21FE9DAF300281288 /* MQTTCFSocketTransport.h in Headers */, - A47F127E1C1D73530008E3F2 /* MASBluetoothCentral.h in Headers */, CBD25AE41E78C47C00DFB47F /* JWTAlgorithmFactory.h in Headers */, CB1C151E1E450109002B31A5 /* NSURL+MASPrivate.h in Headers */, CB6491FD1FE9DAF300281288 /* MQTTSSLSecurityPolicyDecoder.h in Headers */, @@ -1679,14 +1616,12 @@ CB23579A1F100EC400D4C420 /* MASSessionDataTaskOperation.h in Headers */, A4831AB31BD1A551007B4AE6 /* MASObject.h in Headers */, CBD25AF71E78C47C00DFB47F /* JWTCryptoSecurity.h in Headers */, - CB14D2231D02328C004F772E /* MASProximityLoginQRCode+MASPrivate.h in Headers */, CB58986B1F183E0A005C1E82 /* MASAuthValidationOperation.h in Headers */, A4831AB51BD1A551007B4AE6 /* MASUser.h in Headers */, A46F49F31C2F5FC500A4C370 /* MASIOrderedDictionary.h in Headers */, A42D02E41C0E240800AA1F11 /* MASAuthenticationProviders+MASPrivate.h in Headers */, A46F49E11C2F5FC500A4C370 /* UIImage+MASINetworking.h in Headers */, CB3173E01F1FFF2C00C85E47 /* MASNetworkMonitor.h in Headers */, - A47F12801C1D73530008E3F2 /* MASBluetoothPeripheral.h in Headers */, A4150EE71BF16E5B00037E27 /* MASFileService.h in Headers */, A46F49C41C2F5FC500A4C370 /* MASIHTTPRequestOperation.h in Headers */, A46F49E51C2F5FC500A4C370 /* UIProgressView+MASINetworking.h in Headers */, @@ -1694,7 +1629,6 @@ A46F49BC1C2F5FC500A4C370 /* fmemopen.h in Headers */, A4831AF21BD1A8AA007B4AE6 /* MASConfiguration+MASPrivate.h in Headers */, CBD25AE61E78C47C00DFB47F /* JWTAlgorithmNone.h in Headers */, - A483C2011BE6D0C5007572CE /* CBCentralManager+MASPrivate.h in Headers */, A4150EFB1BF16EE200037E27 /* MASKeyChainService.h in Headers */, A46F49C61C2F5FC500A4C370 /* MASIHTTPRequestOperationManager.h in Headers */, CB1EE31C2009895A0056F24A /* MASMQTTForegroundReconnection.h in Headers */, @@ -1728,7 +1662,6 @@ A46F49CF1C2F5FC500A4C370 /* MASISecurityPolicy.h in Headers */, A4831AEE1BD1A87C007B4AE6 /* MASAuthenticationProvider+MASPrivate.h in Headers */, A4831AEC1BD1A87C007B4AE6 /* MASApplication+MASPrivate.h in Headers */, - A4150EE01BF16E0F00037E27 /* MASBluetoothService.h in Headers */, CB5E4C741C1D26BA001B3B8A /* MASPatchURLRequest.h in Headers */, A42157261BF864590034BDC9 /* MASConfigurationService.h in Headers */, CB5E4C701C1D250D001B3B8A /* MASPutURLRequest.h in Headers */, @@ -1757,7 +1690,6 @@ CBD25B031E78C47C00DFB47F /* JWTCoding+VersionOne.h in Headers */, CBD25B051E78C47C00DFB47F /* JWTCoding+VersionThree.h in Headers */, CB9975561EDF5986006CEBB1 /* MASAuthCredentialsClientCredentials.h in Headers */, - A483C1A31BE56BAF007572CE /* CBPeripheralManager+MASPrivate.h in Headers */, A4150ED91BF16DBE00037E27 /* MASLocationService.h in Headers */, 10E027A61F72B10100EAB103 /* RNEncryptor.h in Headers */, CB6491E01FE9DAF300281288 /* MQTTCFSocketEncoder.h in Headers */, @@ -1900,7 +1832,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/bash; - shellScript = export; + shellScript = "export\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -1911,12 +1843,9 @@ files = ( CB5E4C711C1D250D001B3B8A /* MASPutURLRequest.m in Sources */, CB2A4056209B9DA600F988AA /* MASMultiFactorHandler+MASPrivate.m in Sources */, - CB14D21A1D02266D004F772E /* MASProximityLoginQRCode.m in Sources */, A858C6661D0978A6001FB9AD /* MASOTPService.m in Sources */, CBD25AE71E78C47C00DFB47F /* JWTAlgorithmNone.m in Sources */, CB1C151F1E450109002B31A5 /* NSURL+MASPrivate.m in Sources */, - CB14D2241D02328C004F772E /* MASProximityLoginQRCode+MASPrivate.m in Sources */, - A4150EE11BF16E0F00037E27 /* MASBluetoothService.m in Sources */, 10D2D49F1C1686ED00DF8AC4 /* MASGroup+MASPrivate.m in Sources */, CB99754F1EDF5837006CEBB1 /* MASAuthCredentialsAuthorizationCode.m in Sources */, A488CE761C0B97FD00B8B961 /* MASService.m in Sources */, @@ -1947,7 +1876,6 @@ CB6492041FE9DAF300281288 /* MQTTStrict.m in Sources */, 699570E32060650400017244 /* MASNotifications.m in Sources */, A4150EFC1BF16EE200037E27 /* MASKeyChainService.m in Sources */, - A47F12811C1D73530008E3F2 /* MASBluetoothPeripheral.m in Sources */, CBD25B061E78C47C00DFB47F /* JWTCoding+VersionThree.m in Sources */, C81CC3D11FC2EFBB0058718E /* UIAlertController+MAS.m in Sources */, CBD25AED1E78C47C00DFB47F /* JWTAlgorithmDataHolderChain.m in Sources */, @@ -1979,7 +1907,6 @@ CBD25AF11E78C47C00DFB47F /* JWTAlgorithmRSBase.m in Sources */, CBD25AEF1E78C47C00DFB47F /* JWTAlgorithmHSBase.m in Sources */, CBD25AF81E78C47C00DFB47F /* JWTCryptoSecurity.m in Sources */, - A47F127F1C1D73530008E3F2 /* MASBluetoothCentral.m in Sources */, CB2A4052209A732500F988AA /* MASOTPMultiFactorAuthenticator.m in Sources */, A4831AB41BD1A551007B4AE6 /* MASObject.m in Sources */, CB6491F41FE9DAF300281288 /* MQTTSession.m in Sources */, @@ -2003,7 +1930,6 @@ CB9975531EDF591C006CEBB1 /* MASAuthCredentialsJWT.m in Sources */, CBD25B041E78C47C00DFB47F /* JWTCoding+VersionOne.m in Sources */, CB9B1208210949D5008A2075 /* NSMutableData+MASASN1Helper.m in Sources */, - CB0A8AE01D01F64F00B1DCCC /* MASProximityLogin.m in Sources */, CB99754B1EDF57D6006CEBB1 /* MASAuthCredentialsPassword.m in Sources */, A42D02E11C0E223600AA1F11 /* MASAuthenticationProviders.m in Sources */, CB5E4C691C1D21FB001B3B8A /* MASPostURLRequest.m in Sources */, @@ -2049,7 +1975,6 @@ 69B7DF691F9675600056DD3A /* MASRequest.m in Sources */, CB6492021FE9DAF300281288 /* MQTTSSLSecurityPolicyTransport.m in Sources */, CBD25B081E78C47C00DFB47F /* JWTCoding+VersionTwo.m in Sources */, - A483C2021BE6D0C5007572CE /* CBCentralManager+MASPrivate.m in Sources */, CBD25AFA1E78C47C00DFB47F /* JWTClaim.m in Sources */, A4831AFF1BD1A922007B4AE6 /* MASUser+MASPrivate.m in Sources */, CBA3EB331E94634C00E64D9D /* MASClaims+MASPrivate.m in Sources */, @@ -2071,7 +1996,6 @@ A46F49E81C2F5FC500A4C370 /* UIRefreshControl+MASINetworking.m in Sources */, CB6491DD1FE9DAF300281288 /* ForegroundReconnection.m in Sources */, CB1EE31D2009895A0056F24A /* MASMQTTForegroundReconnection.m in Sources */, - A483C1A41BE56BAF007572CE /* CBPeripheralManager+MASPrivate.m in Sources */, CB6491F21FE9DAF300281288 /* MQTTProperties.m in Sources */, 107389FE1C7119E800B7E87E /* MASMQTTHelper.m in Sources */, ); diff --git a/MASFoundation/Classes/MAS.m b/MASFoundation/Classes/MAS.m index 367c873a..3cdaa1a4 100644 --- a/MASFoundation/Classes/MAS.m +++ b/MASFoundation/Classes/MAS.m @@ -12,7 +12,6 @@ #import "MASJWTService.h" #import "MASAccessService.h" -#import "MASBluetoothService.h" #import "MASConfigurationService.h" #import "MASConstantsPrivate.h" #import "MASClaims+MASPrivate.h" @@ -1518,19 +1517,17 @@ + (void)currentStatusToConsole { MASServiceRegistry *registry = [MASServiceRegistry sharedRegistry]; MASConfigurationService *configurationService = [MASConfigurationService sharedService]; - MASBluetoothService *bluetoothService = [MASBluetoothService sharedService]; MASFileService *fileService = [MASFileService sharedService]; MASLocationService *locationService = [MASLocationService sharedService]; MASModelService *modelService = [MASModelService sharedService]; MASNetworkingService *networkingService = [MASNetworkingService sharedService]; DLog(@"\n\n\n%@\n\n ****************************** Services Summary ******************************\n\n\n" - " %@\n\n\n %@\n\n\n %@\n\n\n %@\n\n\n %@\n\n\n %@\n\n\n %@\n\n\n", + " %@\n\n\n %@\n\n\n %@\n\n\n %@\n\n\n %@\n\n\n %@\n\n\n", (registry ? [registry debugDescription] : @"(Service Registry Not Initialized"), (configurationService ? [configurationService debugDescription] : @"(Configuration Service Not Initialized)\n\n"), (networkingService ? [networkingService debugDescription] : @"(Networking Service Not Initialized)\n\n"), (locationService ? [locationService debugDescription] : @"(Location Service Not Initialized)\n\n"), - (bluetoothService ? [bluetoothService debugDescription] : @"(Bluetooth Service Not Initialized)\n\n"), (modelService ? [modelService debugDescription] : @"(Model Service Not Initialized)\n\n"), (fileService ? [fileService debugDescription] : @"(File Service Not Initialized)\n\n"), [[MASAccessService sharedService] debugSecuredDescription]); diff --git a/MASFoundation/Classes/MASError.h b/MASFoundation/Classes/MASError.h index 4ec5fe19..2b26156d 100644 --- a/MASFoundation/Classes/MASError.h +++ b/MASFoundation/Classes/MASError.h @@ -162,34 +162,6 @@ typedef NS_ENUM(NSInteger, MASFoundationErrorCode) MASFoundationErrorCodeEnterpriseBrowserNativeAppCannotOpen = 140003, MASFoundationErrorCodeEnterpriseBrowserAppDoesNotExist = 140004, - // - // BLE - // - MASFoundationErrorCodeBLEUnknownState = 150001, - MASFoundationErrorCodeBLEAuthorizationFailed = 150002, - MASFoundationErrorCodeBLEAuthorizationPollingFailed = 150003, - MASFoundationErrorCodeBLECentralDeviceNotFound = 150004, - MASFoundationErrorCodeBLEDelegateNotDefined = 150005, - MASFoundationErrorCodeBLEInvalidAuthenticationProvider = 150006, - MASFoundationErrorCodeBLEPoweredOff = 150007, - MASFoundationErrorCodeBLEResetting = 150008, - MASFoundationErrorCodeBLERSSINotInRange = 150009, - MASFoundationErrorCodeBLEUnSupported = 150010, - MASFoundationErrorCodeBLEUnauthorized = 150011, - MASFoundationErrorCodeBLEUserDeclined = 150012, - MASFoundationErrorCodeBLECentral = 150013, - MASFoundationErrorCodeBLEPeripheral = 150014, - MASFoundationErrorCodeBLEPeripheralServices = 150015, - MASFoundationErrorCodeBLEPeripheralCharacteristics = 150016, - - // - // Proximity Login - // - MASFoundationErrorCodeProximityLoginAuthorizationInProgress = 150101, - MASFoundationErrorCodeProximityLoginInvalidAuthenticationURL = 150102, - MASFoundationErrorCodeQRCodeProximityLoginAuthorizationPollingFailed = 150103, - MASFoundationErrorCodeProximityLoginInvalidAuthorizeURL = 150104, - // // OTP // diff --git a/MASFoundation/Classes/MASProximityLoginDelegate.h b/MASFoundation/Classes/MASProximityLoginDelegate.h deleted file mode 100644 index 2a71e400..00000000 --- a/MASFoundation/Classes/MASProximityLoginDelegate.h +++ /dev/null @@ -1,135 +0,0 @@ -// -// MASProximityLoginDelegate.h -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -@import Foundation; - -#import "MASConstants.h" - -/** - * The enumerated MASBLEServiceState that can indicate what is current status of Device BLE - */ -typedef NS_ENUM(NSInteger, MASBLEServiceState) { - /** - * Unknown - */ - MASBLEServiceStateUnknown = -1, - /** - * BLE Central started - */ - MASBLEServiceStateCentralStarted, - /** - * BLE Central stopped - */ - MASBLEServiceStateCentralStopped, - /** - * BLE Central a device detected - */ - MASBLEServiceStateCentralDeviceDetected, - /** - * BLE Central a device connected - */ - MASBLEServiceStateCentralDeviceConnected, - /** - * BLE Central a device disconnected - */ - MASBLEServiceStateCentralDeviceDisconnected, - /** - * BLE Central service discovered - */ - MASBLEServiceStateCentralServiceDiscovered, - /** - * BLE Central characteristic discovered - */ - MASBLEServiceStateCentralCharacteristicDiscovered, - /** - * BLE Central characteristic written - */ - MASBLEServiceStateCentralCharacteristicWritten, - /** - * BLE Central authorization succeeded - */ - MASBLEServiceStateCentralAuthorizationSucceeded, - /** - * BLE Central authorization failed - */ - MASBLEServiceStateCentralAuthorizationFailed, - /** - * BLE Peripheral subscribed - */ - MASBLEServiceStatePeripheralSubscribed, - /** - * BLE Peripheral unsubscribed - */ - MASBLEServiceStatePeripheralUnsubscribed, - /** - * BLE Peripheral started - */ - MASBLEServiceStatePeripheralStarted, - /** - * BLE Peripheral stopped - */ - MASBLEServiceStatePeripheralStopped, - /** - * BLE Peripheral session authorized - */ - MASBLEServiceStatePeripheralSessionAuthorized, - /** - * BLE Peripheral session notified - */ - MASBLEServiceStatePeripheralSessionNotified -}; - - -@protocol MASProximityLoginDelegate - - -@required - -/** - * SDK callback to this method for user consent to authorize proximity login. - * - * @param completion MASCompletionErrorBlock returns boolean of consent state and error if there is any - * @param deviceName NSString of device name - */ -- (void)handleBLEProximityLoginUserConsent:(MASCompletionErrorBlock _Nullable)completion deviceName:(NSString *_Nonnull)deviceName; - - - -@optional - - - -/** - * Notify the host application that the authorization code has been received from other device. - * Alternatively, developers can subscribe notification, MASDeviceDidReceiveAuthorizationCodeFromProximityLoginNotification, to receive the authorization code. - * - * @param authorizationCode NSString of authorization code - */ -- (void)didReceiveAuthorizationCode:(NSString *_Nonnull)authorizationCode; - - - -/** - * Notify the host application on the state of the BLE proximity login. - * - * @param state enumeration of MASBLEServiceState - */ -- (void)didReceiveBLEProximityLoginStateUpdate:(MASBLEServiceState)state; - - - -/** - * Notify the host application on any error occured while proximity login - * - * @param error NSError of BLE proximity login error - */ -- (void)didReceiveProximityLoginError:(NSError *_Nonnull)error; - -@end diff --git a/MASFoundation/Classes/_private_/MASConstantsPrivate.h b/MASFoundation/Classes/_private_/MASConstantsPrivate.h index 48bd9a4a..f2c10ce0 100644 --- a/MASFoundation/Classes/_private_/MASConstantsPrivate.h +++ b/MASFoundation/Classes/_private_/MASConstantsPrivate.h @@ -15,8 +15,6 @@ #import "MASNetworkingService.h" #import "MASIOrderedDictionary.h" -#import "CBCentralManager+MASPrivate.h" -#import "CBPeripheralManager+MASPrivate.h" #import "CLLocation+MASPrivate.h" #import "CLLocationManager+MASPrivate.h" #import "MASApplication+MASPrivate.h" @@ -37,7 +35,6 @@ // Known internal MASFoundation service UUIDs static NSString *_Nonnull const MASAccessServiceUUID = @"46987e7b-a694-4b44-b02d-694c90ae6952"; -static NSString *_Nonnull const MASBluetoothServiceUUID = @"e1c58e79-3df9-4dcc-b32d-f947762450c8"; static NSString *_Nonnull const MASConfigurationServiceUUID = @"277a5b4a-b665-4ace-b23b-237c80bd7083"; static NSString *_Nonnull const MASConnectaServiceUUID = @"ce68de11-609c-42cb-9fb1-96d661e9ff17"; static NSString *_Nonnull const MASLocationServiceUUID = @"83c5830a-019f-4415-a46c-41470bc28219"; @@ -334,12 +331,6 @@ typedef void (^MASLocationMonitorBlock)(CLLocation *_Nonnull location, MASLocati typedef void (^MASSessionDataTaskCompletionBlock)(NSURLResponse *_Nonnull response, id _Nonnull responseObject, NSError *_Nonnull error); -/** - * Void code block. - */ -typedef void (^MASVoidCodeBlock)(void); - - // // MAS Notification - private // diff --git a/MASFoundation/Classes/_private_/categories/CBCentralManager+MASPrivate.h b/MASFoundation/Classes/_private_/categories/CBCentralManager+MASPrivate.h deleted file mode 100644 index 8ed23525..00000000 --- a/MASFoundation/Classes/_private_/categories/CBCentralManager+MASPrivate.h +++ /dev/null @@ -1,56 +0,0 @@ -// -// CBCentralManager+MASPrivate.h -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import - - -@interface CBCentralManager (MASPrivate) - - - -///-------------------------------------- -/// @name CBCentralManagerState -///-------------------------------------- - -# pragma mark - CBCentralManagerState - - -/** - * Simple, convenient method to determine if the peripheral is in the state 'CBCentralManagerStatePoweredOn'. - * - * This is equivalent to the code 'self.centralManager.state == CBCentralManagerStatePoweredOn'. - * - * @returns YES if powered on, NO if in any other state. - */ -- (BOOL)isPoweredOn; - - -/** - * Retrieve a human readable string value for the current CBCentralManagerState enumeration. - */ -- (NSString *)centralManagerStateAsString; - - -/** - * Retrieve a human readable string value for a CBCentralManagerState enumeration. - * - * @param status The CBCentralManagerState value. - */ -+ (NSString *)centralManagerStateToString:(CBCentralManagerState)state; - - -/** - * Retrieve a MASFoundation NSError object with MASFoundationErrorDomainLocal for its CBCentralManagerState enumeration. - * - * @return NSError object of bluetooth state error; if there no error, the method will return nil. - */ -- (NSError *)centralManagerStateToMASFoundationError; - -@end diff --git a/MASFoundation/Classes/_private_/categories/CBCentralManager+MASPrivate.m b/MASFoundation/Classes/_private_/categories/CBCentralManager+MASPrivate.m deleted file mode 100644 index 8ebcf501..00000000 --- a/MASFoundation/Classes/_private_/categories/CBCentralManager+MASPrivate.m +++ /dev/null @@ -1,141 +0,0 @@ -// -// CBCentralManager+MASPrivate.m -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import "CBCentralManager+MASPrivate.h" - -#import "NSError+MASPrivate.h" -#import "MASConstants.h" - -@implementation CBCentralManager (MASPrivate) - - -# pragma mark - CBCentralManagerState - - -/** - * Simple, convenient method to determine if the peripheral is in the state 'CBCentralManagerStatePoweredOn'. - * - * This is equivalent to the code 'self.centralManager.state == CBCentralManagerStatePoweredOn'. - * - * @returns YES if powered on, NO if in any other state. - */ -- (BOOL)isPoweredOn -{ - return (self.state == CBCentralManagerStatePoweredOn); -} - - -/** - * Retrieve a human readable string value for the current CBCentralManagerState enumeration. - */ -- (NSString *)centralManagerStateAsString -{ - return [CBCentralManager centralManagerStateToString:self.state]; -} - - -/** - * Retrieve a human readable string value for a CBCentralManagerState enumeration. - * - * @param status The CBCentralManagerState value. - */ -+ (NSString *)centralManagerStateToString:(CBCentralManagerState)state -{ - // - // Detect state and respond appropriately - // - switch(state) - { - // - // Resetting - // - case CBCentralManagerStateResetting: return @"Resetting"; - - // - // Unsupported - // - case CBCentralManagerStateUnsupported: return @"Unsupported"; - - // - // Unauthorized - // - case CBCentralManagerStateUnauthorized: return @"Unauthorized"; - - // - // Powered Off - // - case CBCentralManagerStatePoweredOff: return @"Powered Off"; - - // - // Powered On - // - case CBCentralManagerStatePoweredOn: return @"Powered On"; - - // - // Default - // - default: return @"Unknown"; - } -} - - -- (NSError *)centralManagerStateToMASFoundationError -{ - // - // Detect state and respond appropriately - // - switch (self.state) { - - // - // Resetting - // - case CBCentralManagerStateResetting: - return [NSError errorForFoundationCode:MASFoundationErrorCodeBLEResetting errorDomain:MASFoundationErrorDomainLocal]; - break; - - // - // Unsupported - // - case CBCentralManagerStateUnsupported: - return [NSError errorForFoundationCode:MASFoundationErrorCodeBLEUnSupported errorDomain:MASFoundationErrorDomainLocal]; - break; - - // - // Unauthorized - // - case CBCentralManagerStateUnauthorized: - return [NSError errorForFoundationCode:MASFoundationErrorCodeBLEUnauthorized errorDomain:MASFoundationErrorDomainLocal]; - break; - - // - // Powered Off - // - case CBCentralManagerStatePoweredOff: - return [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPoweredOff errorDomain:MASFoundationErrorDomainLocal]; - break; - - // - // Powered On - // If the BLE power is on which means no error, return nil. - // - case CBCentralManagerStatePoweredOn: - break; - - // - // Default - // - default: - break; - } - - return nil; -} - -@end diff --git a/MASFoundation/Classes/_private_/categories/CBPeripheralManager+MASPrivate.h b/MASFoundation/Classes/_private_/categories/CBPeripheralManager+MASPrivate.h deleted file mode 100644 index bc1ee6e7..00000000 --- a/MASFoundation/Classes/_private_/categories/CBPeripheralManager+MASPrivate.h +++ /dev/null @@ -1,80 +0,0 @@ -// -// CBPeripheralManager+MASPrivate.h -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import - - -@interface CBPeripheralManager (MASPrivate) - - - -///-------------------------------------- -/// @name CBPeripheralAuthorizationStatus -///-------------------------------------- - -# pragma mark - CBPeripheralAuthorizationStatus - -/** - * Simple, convenient method to determine if the peripheral's application background authorization status is - * 'CBPeripheralManagerAuthorizationStatusAuthorized'. - * - * This is equivalent to the code '[CBPeripheralManager authorizationStatus] == CBPeripheralManagerAuthorizationStatusAuthorized'. - * - * @returns YES if authorized, NO if in any other status. - */ -+ (BOOL)isAuthorizedForBackground; - - -/** - * Retrieve a human readable string value for the current CBPeripheralManagerAuthorizationStatus enumeration. - */ -+ (NSString *)peripheralManagerAuthorizationStatusAsString; - - - -///-------------------------------------- -/// @name CBPeripheralManagerState -///-------------------------------------- - -# pragma mark - CBPeripheralManagerState - - -/** - * Simple, convenient method to determine if the peripheral is in the state 'CBPeripheralManagerStatePoweredOn'. - * - * This is equivalent to the code 'self.peripheralManager.state == CBPeripheralManagerStatePoweredOn'. - * - * @returns YES if powered on, NO if in any other state. - */ -- (BOOL)isPoweredOn; - - -/** - * Retrieve a human readable string value for the current CBPeripheralManagerState enumeration. - */ -- (NSString *)peripheralManagerStateAsString; - - -/** - * Retrieve a human readable string value for a CBPeripheralManagerState enumeration. - * - * @param status The CBPeripheralManagerState value. - */ -+ (NSString *)peripheralManagerStateToString:(CBPeripheralManagerState)state; - - -/** - * Retrieve a MASFoundation NSError object with MASFoundationErrorDomainLocal for its CBPeripheralManagerState enumeration. - * - * @return NSError object of bluetooth state error; if there no error, the method will return nil. - */ -- (NSError *)peripheralManagerStateToMASFoundationError; - -@end diff --git a/MASFoundation/Classes/_private_/categories/CBPeripheralManager+MASPrivate.m b/MASFoundation/Classes/_private_/categories/CBPeripheralManager+MASPrivate.m deleted file mode 100644 index 7b3c4525..00000000 --- a/MASFoundation/Classes/_private_/categories/CBPeripheralManager+MASPrivate.m +++ /dev/null @@ -1,162 +0,0 @@ -// -// CBPeripheralManager+MASPrivate.m -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import "CBPeripheralManager+MASPrivate.h" - -#import "NSError+MASPrivate.h" - -@implementation CBPeripheralManager (MASPrivate) - - -# pragma mark - CBPeripheralAuthorizationStatus - -+ (BOOL)isAuthorizedForBackground -{ - return ([CBPeripheralManager authorizationStatus] == CBPeripheralManagerAuthorizationStatusAuthorized); -} - - -+ (NSString *)peripheralManagerAuthorizationStatusAsString -{ - // - // Detect status and respond appropriately - // - switch([CBPeripheralManager authorizationStatus]) - { - // - // Authorized - // - case CBPeripheralManagerAuthorizationStatusAuthorized: return @"Authorized"; - - // - // Denied - // - case CBPeripheralManagerAuthorizationStatusDenied: return @"Denied"; - - // - // Restricted - // - case CBPeripheralManagerAuthorizationStatusRestricted: return @"Restricted"; - - // - // Default (not determined) - // - default: return @"Not Determined"; - } -} - - -# pragma mark - CBPeripheralManagerState - -- (BOOL)isPoweredOn -{ - return (self.state == CBPeripheralManagerStatePoweredOn); -} - - -- (NSString *)peripheralManagerStateAsString -{ - return [CBPeripheralManager peripheralManagerStateToString:self.state]; -} - - -+ (NSString *)peripheralManagerStateToString:(CBPeripheralManagerState)state -{ - // - // Detect state and respond appropriately - // - switch(state) - { - // - // Resetting - // - case CBPeripheralManagerStateResetting: return @"Resetting"; - - // - // Unsupported - // - case CBPeripheralManagerStateUnsupported: return @"Unsupported"; - - // - // Unauthorized - // - case CBPeripheralManagerStateUnauthorized: return @"Unauthorized"; - - // - // Powered Off - // - case CBPeripheralManagerStatePoweredOff: return @"Powered Off"; - - // - // Powered On - // - case CBPeripheralManagerStatePoweredOn: return @"Powered On"; - - // - // Default - // - default: return @"Unknown"; - } -} - - -- (NSError *)peripheralManagerStateToMASFoundationError -{ - // - // Detect state and respond appropriately - // - switch (self.state) { - - // - // Resetting - // - case CBCentralManagerStateResetting: - return [NSError errorForFoundationCode:MASFoundationErrorCodeBLEResetting errorDomain:MASFoundationErrorDomainLocal]; - break; - - // - // Unsupported - // - case CBCentralManagerStateUnsupported: - return [NSError errorForFoundationCode:MASFoundationErrorCodeBLEUnSupported errorDomain:MASFoundationErrorDomainLocal]; - break; - - // - // Unauthorized - // - case CBCentralManagerStateUnauthorized: - return [NSError errorForFoundationCode:MASFoundationErrorCodeBLEUnauthorized errorDomain:MASFoundationErrorDomainLocal]; - break; - - // - // Powered Off - // - case CBCentralManagerStatePoweredOff: - return [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPoweredOff errorDomain:MASFoundationErrorDomainLocal]; - break; - - // - // Powered On - // If the BLE power is on which means no error, return nil. - // - case CBCentralManagerStatePoweredOn: - break; - - // - // Default - // - default: - break; - } - - return nil; -} - -@end diff --git a/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.h b/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.h index cc1b760e..91029b35 100644 --- a/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.h +++ b/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.h @@ -639,24 +639,6 @@ + (NSError *)errorInvalidEndpoint; -/** - * Create MASFoundationErrorDomainLocal NSError for MASFoundationErrorCodeProximityLoginAuthorizationInProgress. - * - * @return Returns an NSError instance with the domain MASFoundationErrorDomainLocal and - * error MASFoundationErrorCodeProximityLoginAuthorizationInProgress. - */ -+ (NSError *)errorProximityLoginAuthorizationInProgress; - - -/** - * Create MASFoundationErrorDomainLocal NSError for MASFoundationErrorCodeProximityLoginInvalidAuthorizeURL. - * - * @return Returns an NSError instance with the domain MASFoundationErrorDomainLocal and - * error MASFoundationErrorCodeProximityLoginInvalidAuthorizeURL - */ -+ (NSError *)errorProximityLoginInvalidAuthroizeURL; - - /** * Create MASFoundationErrorDomainLocal NSError for MASFoundationErrorCodeBBANotEnabled. * diff --git a/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.m b/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.m index a1733719..3219ff6d 100644 --- a/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.m +++ b/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.m @@ -828,18 +828,6 @@ + (NSError *)errorInvalidEndpoint } -+ (NSError *)errorProximityLoginAuthorizationInProgress -{ - return [self errorForFoundationCode:MASFoundationErrorCodeProximityLoginAuthorizationInProgress errorDomain:MASFoundationErrorDomainLocal]; -} - - -+ (NSError *)errorProximityLoginInvalidAuthroizeURL -{ - return [self errorForFoundationCode:MASFoundationErrorCodeProximityLoginInvalidAuthorizeURL errorDomain:MASFoundationErrorDomainLocal]; -} - - + (NSError *)errorBrowserBasedAuthenticaionNotEnabled { return [self errorForFoundationCode:MASFoundationErrorCodeBBANotEnabled errorDomain:MASFoundationErrorDomainLocal]; @@ -1086,34 +1074,7 @@ + (NSString *)descriptionForFoundationErrorCode:(MASFoundationErrorCode)errorCod case MASFoundationErrorCodeEnterpriseBrowserNativeAppDoesNotExist: return @"Native app does not exist"; case MASFoundationErrorCodeEnterpriseBrowserNativeAppCannotOpen: return @"Error loading the native app"; case MASFoundationErrorCodeEnterpriseBrowserAppDoesNotExist: return @"Enterprise Browser App does not exist"; - - // - // BLE - // - case MASFoundationErrorCodeBLEUnknownState: return @"Unknown error occurred while enabling BLE Central"; - case MASFoundationErrorCodeBLEPoweredOff: return @"Bluetooth is currently off"; - case MASFoundationErrorCodeBLEResetting: return @"Bluetooth connection is momentarily lost; resetting the connection"; - case MASFoundationErrorCodeBLEUnauthorized: return @"Bluetooth feature is not authorized for this application"; - case MASFoundationErrorCodeBLEUnSupported: return @"Bluetooth feature is not supported"; - case MASFoundationErrorCodeBLEDelegateNotDefined: return @"MASDevice's BLE delegate is not defined. Delegate is mandatory to acquire permission from the user."; - case MASFoundationErrorCodeBLEAuthorizationFailed: return @"BLE authorization failed due to invalid or expired authorization request."; - case MASFoundationErrorCodeBLECentralDeviceNotFound: return @"BLE authorization failed due to no subscribed central device."; - case MASFoundationErrorCodeBLERSSINotInRange: return @"BLE RSSI is not in range. Please refer to msso_config.json for BLE RSSI configuration."; - case MASFoundationErrorCodeBLEAuthorizationPollingFailed: return @"BLE authorization failed while polling authorization code from gateway."; - case MASFoundationErrorCodeBLEInvalidAuthenticationProvider: return @"BLE authorization failed due to invalid authentication provider."; - case MASFoundationErrorCodeBLECentral: return @"BLE Central error encountered in CBCentral with specific reason in userInfo."; - case MASFoundationErrorCodeBLEPeripheral: return @"BLE Peripheral error encountered while discovering, or connecting central device with specific reason in userInfo."; - case MASFoundationErrorCodeBLEPeripheralServices: return @"BLE Peripheral error encountered while discovering or connecting peripheral services with specific reason in userInfo."; - case MASFoundationErrorCodeBLEPeripheralCharacteristics: return @"BLE Peripheral error encountered while discovering, connecting, or writing peripheral service's characteristics with specific reason in userInfo."; - - // - // Session Sharing - // - case MASFoundationErrorCodeProximityLoginAuthorizationInProgress: return @"Authorization is currently in progress through proximity login."; - case MASFoundationErrorCodeQRCodeProximityLoginAuthorizationPollingFailed: return @"QR Code proximity login authentication failed with specific information on userInfo."; - case MASFoundationErrorCodeProximityLoginInvalidAuthenticationURL: return @"Invalid authentication URL is provided for proximity login."; - case MASFoundationErrorCodeProximityLoginInvalidAuthorizeURL: return @"Invalid authorization url."; - + // // JWT // diff --git a/MASFoundation/Classes/_private_/models/MASProximityLoginQRCode+MASPrivate.h b/MASFoundation/Classes/_private_/models/MASProximityLoginQRCode+MASPrivate.h deleted file mode 100644 index ddefb24f..00000000 --- a/MASFoundation/Classes/_private_/models/MASProximityLoginQRCode+MASPrivate.h +++ /dev/null @@ -1,49 +0,0 @@ -// -// MASProximityLoginQRCode+MASPrivate.h -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import - -@interface MASProximityLoginQRCode (MASPrivate) - -# pragma mark - Lifecycle - -/** - * Init the object with given values. - * Property values cannot be changed once it is initialized. - * - * @param provider MASAuthenticationProvider object with authorizationURL and pollingURL for QR Code. - * @param initDelay NSNumber of initial delay in seconds to start making a request to poll for authorization. - * @param pollingInterval NSNumber of interval for polling requests. - * @param pollingLimit NSNumber of limit counter for number of polling requests. - * - * @return MASProximityLoginQRCode object - */ -- (instancetype)initPrivateWithAuthenticationUrl:(NSString *)authUrl pollingUrl:(NSString *)pollingUrl initialDelay:(NSNumber *)initDelay pollingInterval:(NSNumber *)pollingInterval pollingLimit:(NSNumber *)pollingLimit; - - -# pragma mark - Start/Stop displaying QR Code image : Private - -/** - * Generates QR Code image for proximity login based on provided authentication provider and starts polling request for authorization. - * Upon successful start display, NSNotification with notification name, MASProximityLoginQRCodeDidStartDisplayingQRCodeImage, will be sent. - * - * @return UIImage of QR Code. - */ -- (UIImage *)startPrivateDisplayingQRCodeImageForProximityLogin; - - -/** - * Stops displaying QR Code image for proximity login based on provided polling configuration. - * Upon successful stop display, NSNotification with notification name, MASProximityLoginQRCodeDidStopDisplayingQRCodeImage, will be sent. - */ -- (void)stopPrivateDisplayingQRCodeImageForProximityLogin; - - -@end diff --git a/MASFoundation/Classes/_private_/models/MASProximityLoginQRCode+MASPrivate.m b/MASFoundation/Classes/_private_/models/MASProximityLoginQRCode+MASPrivate.m deleted file mode 100644 index 3a746975..00000000 --- a/MASFoundation/Classes/_private_/models/MASProximityLoginQRCode+MASPrivate.m +++ /dev/null @@ -1,279 +0,0 @@ -// -// MASProximityLoginQRCode+MASPrivate.m -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import "MASProximityLoginQRCode+MASPrivate.h" - -#import -#import "MASAccessService.h" -#import "MASNetworkingService.h" -#import "NSError+MASPrivate.h" - -@implementation MASProximityLoginQRCode (MASPrivate) - - -# pragma mark - Lifecycle - -- (instancetype)initPrivateWithAuthenticationUrl:(NSString *)authUrl pollingUrl:(NSString *)pollingUrl initialDelay:(NSNumber *)initDelay pollingInterval:(NSNumber *)pollingInterval pollingLimit:(NSNumber *)pollingLimit -{ - self = [super init]; - - if (!self) { - - return nil; - } - - [self setValue:authUrl forKey:@"authenticationUrl"]; - [self setValue:pollingUrl forKey:@"pollUrl"]; - [self setValue:initDelay forKey:@"pollingDelay"]; - [self setValue:pollingInterval forKey:@"pollingInterval"]; - [self setValue:pollingLimit forKey:@"pollingLimit"]; - - return self; -} - - -# pragma mark - Start/Stop displaying QR Code image : Private - -- (UIImage *)startPrivateDisplayingQRCodeImageForProximityLogin -{ - // Convert NSString to NSData - NSData *stringData = [self.authenticationUrl dataUsingEncoding:NSUTF8StringEncoding]; - - UIImage *qrCodeImage = nil; - - @try { - CIFilter *qrFilter = [CIFilter filterWithName:@"CIQRCodeGenerator"]; - [qrFilter setValue:stringData forKey:@"inputMessage"]; - [qrFilter setValue:@"H" forKey:@"inputCorrectionLevel"]; - - CGImageRef cgImage = [[CIContext contextWithOptions:nil] createCGImage:qrFilter.outputImage fromRect:qrFilter.outputImage.extent]; - - UIGraphicsBeginImageContext(CGSizeMake(qrFilter.outputImage.extent.size.width * [[UIScreen mainScreen] scale], qrFilter.outputImage.extent.size.width * [[UIScreen mainScreen] scale])); - CGContextRef context = UIGraphicsGetCurrentContext(); - CGContextSetInterpolationQuality(context, kCGInterpolationNone); - CGContextDrawImage(context, CGContextGetClipBoundingBox(context), cgImage); - // Get the image out - qrCodeImage = UIGraphicsGetImageFromCurrentImageContext(); - // Tidy up - UIGraphicsEndImageContext(); - CGImageRelease(cgImage); - - [self setValue:[NSNumber numberWithBool:YES] forKey:@"isPolling"]; - - // - // Start polling - // - dispatch_time_t pollTimer = dispatch_time(DISPATCH_TIME_NOW, [self.pollingDelay intValue] * NSEC_PER_SEC); - dispatch_after(pollTimer, dispatch_get_main_queue(), ^{ - - // - // Call polling method - // - [self makePollingRequest]; - - // - // Send notification - // - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:MASProximityLoginQRCodeDidStartDisplayingQRCodeImage object:nil userInfo:nil]; - }); - }); - - } - @catch (NSException *exception) { - NSLog(@"exception : %@",exception); - } - - return qrCodeImage; -} - - -- (void)stopPrivateDisplayingQRCodeImageForProximityLogin -{ - [self setValue:[NSNumber numberWithBool:NO] forKey:@"isPolling"]; - - // - // Send notification that polling stopped - // - dispatch_async(dispatch_get_main_queue(), ^{ - [[NSNotificationCenter defaultCenter] postNotificationName:MASProximityLoginQRCodeDidStopDisplayingQRCodeImage object:nil userInfo:nil]; - }); -} - - -# pragma mark - Private - -- (void)makePollingRequest -{ - - // - // If stop request was made - // - if (!self.isPolling) - { - return; - } - - // - // If authenticationUrl is being used with other session sharing (BLE), ignore it - // - if ([MASDevice currentDevice].isBeingAuthorized) - { - return; - } - - // - // Increment the polling counter - // - [self setValue:[NSNumber numberWithInt:self.currentPollingCounter+1] forKey:@"currentPollingCounter"]; - - NSString *pollPath = [self.pollUrl stringByReplacingOccurrencesOfString:[MASConfiguration currentConfiguration].gatewayUrl.absoluteString withString:@""]; - - __block MASProximityLoginQRCode *blockSelf = self; - - // - // Instead of making a request through [MAS getFrom:..] public interface, call directly the networking service to bypass validation process - // - [[MASNetworkingService sharedService] getFrom:pollPath - withParameters:nil - andHeaders:nil - requestType:MASRequestResponseTypeWwwFormUrlEncoded - responseType:MASRequestResponseTypeJson - completion:^(NSDictionary *responseInfo, NSError *error) { - - if (error) - { - NSError * pollError = [NSError errorForFoundationCode:MASFoundationErrorCodeQRCodeProximityLoginAuthorizationPollingFailed info:error.userInfo errorDomain:MASFoundationErrorDomain]; - // - // Stop polling and displaying the QR Code image - // - [blockSelf stopPrivateDisplayingQRCodeImageForProximityLogin]; - - // - // If MASDevice's BLE delegate is set, and method is implemented, notify the delegate - // - if ([MASDevice proximityLoginDelegate] && [[MASDevice proximityLoginDelegate] respondsToSelector:@selector(didReceiveProximityLoginError:)]) - { - [[MASDevice proximityLoginDelegate] didReceiveProximityLoginError:pollError]; - } - - // - // Send the notification with authorization code - // - [[NSNotificationCenter defaultCenter] postNotificationName:MASDeviceDidReceiveErrorFromProximityLoginNotification object:pollError]; - } - else { - - // - // Validate PKCE state value - // Only validates state when it is returned from the server for Proximity Login - // - if ([responseInfo objectForKey:MASPKCEStateRequestResponseKey]) - { - NSString *responseState = [responseInfo objectForKey:MASPKCEStateRequestResponseKey]; - NSString *requestState = [[MASAccessService sharedService].currentAccessObj retrievePKCEState]; - - NSError *pkceError = nil; - - // - // If response or request state is nil, invalid request and/or response - // - if (responseState == nil || requestState == nil) - { - pkceError = [NSError errorInvalidAuthorization]; - } - // - // verify that the state in the response is the same as the state sent in the request - // - else if (![[responseInfo objectForKey:MASPKCEStateRequestResponseKey] isEqualToString:[[MASAccessService sharedService].currentAccessObj retrievePKCEState]]) - { - pkceError = [NSError errorInvalidAuthorization]; - } - - // - // If the validation fail, notify - // - if (pkceError) - { - // - // Stop polling and displaying the QR Code image - // - [blockSelf stopPrivateDisplayingQRCodeImageForProximityLogin]; - - // - // If MASDevice's BLE delegate is set, and method is implemented, notify the delegate - // - if ([MASDevice proximityLoginDelegate] && [[MASDevice proximityLoginDelegate] respondsToSelector:@selector(didReceiveProximityLoginError:)]) - { - [[MASDevice proximityLoginDelegate] didReceiveProximityLoginError:pkceError]; - } - - // - // Send the notification with authorization code - // - [[NSNotificationCenter defaultCenter] postNotificationName:MASDeviceDidReceiveErrorFromProximityLoginNotification object:pkceError]; - - return; - } - } - - // - // Retrieve authorization code - // - NSString *code = [responseInfo[MASResponseInfoBodyInfoKey] valueForKey:@"code"]; - - if (code == nil || [code length] == 0) - { - - // - // re trigger polling if no authorization code is found; if the counter did not exceed the limit - // - - if (blockSelf.currentPollingCounter < [blockSelf.pollingLimit intValue]) - { - dispatch_time_t pollTimer = dispatch_time(DISPATCH_TIME_NOW, [self.pollingDelay intValue] * NSEC_PER_SEC); - dispatch_after(pollTimer, dispatch_get_main_queue(), ^{ - - [blockSelf makePollingRequest]; - }); - } - } - else { - - // - // If the delegate is set, send the authorization code to delegation method - // - if ([MASDevice proximityLoginDelegate] && [[MASDevice proximityLoginDelegate] respondsToSelector:@selector(didReceiveAuthorizationCode:)]) - { - [[MASDevice proximityLoginDelegate] didReceiveAuthorizationCode:code]; - } - - // - // Send the notification with authoriation code - // - [[NSNotificationCenter defaultCenter] postNotificationName:MASDeviceDidReceiveAuthorizationCodeFromProximityLoginNotification object:@{@"code" : code}]; - - } - - // - // If the current polling count exceeds pollLimit - // - if (blockSelf.currentPollingCounter >= [blockSelf.pollingLimit intValue]) - { - // - // Stop polling and displaying the QR Code image - // - [blockSelf stopPrivateDisplayingQRCodeImageForProximityLogin]; - } - } - }]; -} - -@end diff --git a/MASFoundation/Classes/_private_/services/MASServiceRegistry.m b/MASFoundation/Classes/_private_/services/MASServiceRegistry.m index 9530b98a..c34ce61b 100644 --- a/MASFoundation/Classes/_private_/services/MASServiceRegistry.m +++ b/MASFoundation/Classes/_private_/services/MASServiceRegistry.m @@ -105,7 +105,6 @@ + (void)initialize [ MASAccessServiceUUID, MASConfigurationServiceUUID, - MASBluetoothServiceUUID, MASLocationServiceUUID, MASFileServiceUUID, MASModelServiceUUID, diff --git a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothCentral.h b/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothCentral.h deleted file mode 100644 index 9f9f5231..00000000 --- a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothCentral.h +++ /dev/null @@ -1,63 +0,0 @@ -// -// MASBluetoothCentral.h -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import - - -@interface MASBluetoothCentral : MASObject - - - -///-------------------------------------- -/// @name Lifecycle -///-------------------------------------- - -# pragma mark - Lifecycle - -/** - * Create a bluetooth central. - * - * @param serviceUUID The peripheral's service UUID. - * @param characteristicUUI The peripheral's characteristic UUID. - * @param sessionId The session identifier. - * @return Returns the newly initialized 'MASBluetoothCentral'. - */ -+ (id)centralWithServiceUUID:(NSString *)serviceUUID characteristicUUID:(NSString *)characteristicUUID; - - - -///-------------------------------------- -/// @name Starting & Stopping -///-------------------------------------- - -# pragma mark - Starting and Stopping - -/** - * Start the central scanning for peripherals. - */ -- (void)startScanning; - - - -/** - * Start the central scanning for peripherals with specific authentication provider - * - * @param provider MASAuthneticationProvider to scan - */ -- (void)startScanningWithAuthenticationProvider:(MASAuthenticationProvider *)provider; - - - -/** - * Stop the central from scanning for peripherals. - */ -- (void)stopScanning; - -@end diff --git a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothCentral.m b/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothCentral.m deleted file mode 100644 index 36d7fded..00000000 --- a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothCentral.m +++ /dev/null @@ -1,867 +0,0 @@ -// -// MASBluetoothCentral.m -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import "MASBluetoothCentral.h" - -#import -#import "MASAccessService.h" -#import "MASBluetoothService.h" -#import "MASConstantsPrivate.h" -#import "MASNetworkingService.h" - -@interface MASBluetoothCentral () - - -# pragma mark - Properties - -@property (nonatomic, strong, readonly) CBCentralManager *centralManager; -@property (nonatomic, strong, readonly) NSMutableArray *peripherals; - -@property (nonatomic, copy, readonly) NSString *serviceUUID; -@property (nonatomic, copy, readonly) NSString *characteristicUUID; -@property (nonatomic, copy, readonly) MASAuthenticationProvider *provider; - -@property (nonatomic, strong) NSRecursiveLock *lock; - -@property (nonatomic, strong) MASVoidCodeBlock initializeCodeBlock; - -@end - - -@implementation MASBluetoothCentral - - -# pragma mark - Central - -+ (id)centralWithServiceUUID:(NSString *)serviceUUID characteristicUUID:(NSString *)characteristicUUID -{ - // todo: validate the UUIDs??? - - MASBluetoothCentral *central = [[MASBluetoothCentral alloc] initWithServiceUUID:serviceUUID characteristicUUID:characteristicUUID]; - - return central; -} - - -# pragma mark - Private - -- (void)updateBLEState:(MASBLEServiceState)state -{ - // - // If MASDevice's BLE delegate is set, and method is implemented, notify the delegate - // - if ([MASDevice proximityLoginDelegate] && [[MASDevice proximityLoginDelegate] respondsToSelector:@selector(didReceiveBLEProximityLoginStateUpdate:)]) - { - [[MASDevice proximityLoginDelegate] didReceiveBLEProximityLoginStateUpdate:state]; - } -} - - -- (void)notifyErrorForBLEState:(NSError *)error -{ - // - // If MASDevice's BLE delegate is set, and method is implemented, notify the delegate - // - if ([MASDevice proximityLoginDelegate] && [[MASDevice proximityLoginDelegate] respondsToSelector:@selector(didReceiveProximityLoginError:)]) - { - [[MASDevice proximityLoginDelegate] didReceiveProximityLoginError:error]; - } -} - - -- (void)sendAuthURLWithAuthenticationProvider:(MASAuthenticationProvider *)authProvider characteristic:(CBCharacteristic *)characteristic -{ - // - // Notify that the device is being authorized to avoid duplicate calls - // - [[MASDevice currentDevice] setIsBeingAuthorized:YES]; - - // - // Prepare auth data request to transfer with given auth provider url and discovered characteristic - // - NSDictionary *authDictionary = @{@"provider_url" : authProvider.authenticationUrl.absoluteString , @"device_name" : [[UIDevice currentDevice] name]}; - NSData *authData = [NSJSONSerialization dataWithJSONObject:authDictionary options:NSJSONWritingPrettyPrinted error:nil]; - - NSData *authRequest = [[[NSString alloc] initWithBytes:[authData bytes] length:[authData length] encoding:NSUTF8StringEncoding] dataUsingEncoding:NSUTF8StringEncoding]; - - NSInteger sendDataIndex = 0; - - BOOL isSending = YES; - - while (isSending) - { - CBPeripheral *discoveredPeripheral = [self.peripherals objectAtIndex:0]; - - NSInteger sendDataAmount = authRequest.length - sendDataIndex; - - // - // BLE transfer data limit to 20 byes - // - if (sendDataAmount > 20) - { - sendDataAmount = 20; - } - - // - // Data for for specific amount - // - NSData *chunk = [NSData dataWithBytes:authRequest.bytes+sendDataIndex length:sendDataAmount]; - - // - // Send value to disvered peripheral's characteristic - // - [discoveredPeripheral writeValue:chunk forCharacteristic:characteristic type:CBCharacteristicWriteWithoutResponse]; - - sendDataIndex += sendDataAmount; - - // - // If all data was sent, notify EOM - // - if (sendDataIndex >= authRequest.length) - { - [discoveredPeripheral writeValue:[@"EOM" dataUsingEncoding:NSUTF8StringEncoding] forCharacteristic:characteristic type:CBCharacteristicWriteWithoutResponse]; - - // - // Notify delegate - // - [self updateBLEState:MASBLEServiceStateCentralCharacteristicWritten]; - - isSending = NO; - } - } -} - - -- (void)pollAuthorizationCode -{ - - - NSString *pollURL = _provider.pollUrl.absoluteString; - - if ([pollURL isEmpty]) - { - NSError *invalidURLError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEAuthorizationFailed errorDomain:MASFoundationErrorDomainLocal]; - [self notifyErrorForBLEState:invalidURLError]; - - return; - } - - NSString *pollPath = [pollURL stringByReplacingOccurrencesOfString:[MASConfiguration currentConfiguration].gatewayUrl.absoluteString - withString:@""]; - - // - // Instead of making a request through [MAS getFrom:..] public interface, call directly the networking service to bypass validation process - // - [[MASNetworkingService sharedService] getFrom:pollPath - withParameters:nil - andHeaders:nil - requestType:MASRequestResponseTypeWwwFormUrlEncoded - responseType:MASRequestResponseTypeJson - completion:^(NSDictionary *responseInfo, NSError *error) { - // - // Notify that the device is done with authorization - // - [[MASDevice currentDevice] setIsBeingAuthorized:NO]; - - if (error) - { - NSError * pollError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEAuthorizationPollingFailed info:responseInfo errorDomain:MASFoundationErrorDomain]; - [self notifyErrorForBLEState:pollError]; - - // - // Send the notification with authorization code - // - [[NSNotificationCenter defaultCenter] postNotificationName:MASDeviceDidReceiveErrorFromProximityLoginNotification object:pollError]; - } - else { - - // - // Validate PKCE state value - // Only validates state when it is returned from the server for Proximity Login - // - if ([responseInfo objectForKey:MASPKCEStateRequestResponseKey]) - { - NSString *responseState = [responseInfo objectForKey:MASPKCEStateRequestResponseKey]; - NSString *requestState = [[MASAccessService sharedService].currentAccessObj retrievePKCEState]; - - NSError *pkceError = nil; - - // - // If response or request state is nil, invalid request and/or response - // - if (responseState == nil || requestState == nil) - { - pkceError = [NSError errorInvalidAuthorization]; - } - // - // verify that the state in the response is the same as the state sent in the request - // - else if (![[responseInfo objectForKey:MASPKCEStateRequestResponseKey] isEqualToString:[[MASAccessService sharedService].currentAccessObj retrievePKCEState]]) - { - pkceError = [NSError errorInvalidAuthorization]; - } - - // - // If the validation fail, notify - // - if (pkceError) - { - - // - // If MASDevice's BLE delegate is set, and method is implemented, notify the delegate - // - if ([MASDevice proximityLoginDelegate] && [[MASDevice proximityLoginDelegate] respondsToSelector:@selector(didReceiveProximityLoginError:)]) - { - [[MASDevice proximityLoginDelegate] didReceiveProximityLoginError:pkceError]; - } - - // - // Send the notification with authorization code - // - [[NSNotificationCenter defaultCenter] postNotificationName:MASDeviceDidReceiveErrorFromProximityLoginNotification object:pkceError]; - - return; - } - } - - // - // Retrieve authorization code - // - NSString *code = [responseInfo[MASResponseInfoBodyInfoKey] valueForKey:@"code"]; - - // - // If the delegate is set, send the authorization code to delegation method - // - if ([MASDevice proximityLoginDelegate] && [[MASDevice proximityLoginDelegate] respondsToSelector:@selector(didReceiveAuthorizationCode:)]) - { - [[MASDevice proximityLoginDelegate] didReceiveAuthorizationCode:code]; - } - - // - // Send the notification with authoriation code - // - [[NSNotificationCenter defaultCenter] postNotificationName:MASDeviceDidReceiveAuthorizationCodeFromProximityLoginNotification object:@{@"code" : code}]; - - } - }]; -} - - -# pragma mark - Creating a new peripheral - -- (id)init -{ - @throw [NSException exceptionWithName:NSInternalInconsistencyException - reason:@"init is not a valid initializer, please use a factory method" - userInfo:nil]; - return nil; -} - - -- (id)initWithServiceUUID:(NSString *)serviceUUID characteristicUUID:(NSString *)characteristicUUID -{ - self = [super init]; - if(self) - { - - _serviceUUID = serviceUUID; - _characteristicUUID = characteristicUUID; - - _peripherals = [NSMutableArray new]; - - _lock = [[NSRecursiveLock alloc] init]; - } - - return self; -} - - -- (NSString *)debugDescription -{ - return [NSString stringWithFormat:@"(%@) central manager state is: %@\n\n known peripheral count: %ld", - [self class], [self.centralManager centralManagerStateAsString], (unsigned long)self.peripherals.count]; -} - - -# pragma mark - Starting and Stopping - -/** - * Start the central scanning for peripherals. - */ -- (void)startScanning -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); - - __block MASBluetoothCentral *blockSelf = self; - - MASVoidCodeBlock initializeCodeBlock = ^{ - - // - // If the central manager exists, and is not scanning - // - if (blockSelf.centralManager && ![blockSelf.centralManager isScanning]) - { - // - // If the central manager is not powered on and/or is in a state it can't search - // - if (![blockSelf.centralManager isPoweredOn]) - { - NSError *bleError = [blockSelf.centralManager centralManagerStateToMASFoundationError]; - - // - // Notify delegate - // - [blockSelf notifyErrorForBLEState:bleError]; - } - else { - @try { - // - // Start central scanning for peripherals - // - [blockSelf.centralManager scanForPeripheralsWithServices:@[ - [ - CBUUID UUIDWithString:_serviceUUID] - ] - options:@ - { - CBCentralManagerScanOptionAllowDuplicatesKey : @NO - }]; - - [blockSelf updateBLEState:MASBLEServiceStateCentralStarted]; - } - @catch (NSException *exception) { - - // - // Catech an exception - // - NSDictionary *exceptionInfo = @{@"reason" : exception.reason , @"name" : exception.name}; - - // - // Conver the exception with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheral info:exceptionInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [blockSelf notifyErrorForBLEState:masError]; - } - } - } - - blockSelf.initializeCodeBlock = nil; - }; - - // - // If there is no central manager instantiated, so initialize the central manager - // - if (!_centralManager) - { - //DLog(@"\n\nError: no central manager detected!!\n\n"); - _centralManager = [[CBCentralManager alloc] initWithDelegate:self queue:nil]; - _centralManager.delegate = self; - _initializeCodeBlock = initializeCodeBlock; - } - else { - - initializeCodeBlock(); - } -} - - -- (void)startScanningWithAuthenticationProvider:(MASAuthenticationProvider *)provider -{ - - // - // If no auth provider is set, notify delegate - // Authentication provider should have both auth url and poll url - // - if (!provider && !provider.authenticationUrl && !provider.pollUrl) - { - NSError *invalidAuthError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEInvalidAuthenticationProvider errorDomain:MASFoundationErrorDomainLocal]; - [self notifyErrorForBLEState:invalidAuthError]; - - return; - } - - _provider = provider; - - [self startScanning]; -} - - -/** - * Stop the central from scanning for peripherals. - */ -- (void)stopScanning -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); - - // - // If there is no central manager instantiated stop here - // - if(!self.centralManager) - { - //DLog(@"\n\nError: no central manager detected!!\n\n"); - - return; - } - - // - // For connected peripherals, search for characteristics that are currently subscribing - // - for (CBPeripheral *peripheral in self.peripherals) - { - // - // Loop through services - // - for (CBService *service in peripheral.services) - { - // - // Loop through characteristics - // - for (CBCharacteristic *characteristic in service.characteristics) - { - // - // If characteristics UUID matches with our UUID and it is currently notifying, stop - // - if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:_characteristicUUID]] && characteristic.isNotifying) - { - // - // Unsubscribe characteristics - // - [peripheral setNotifyValue:NO forCharacteristic:characteristic]; - } - } - } - - // - // Cancel peripheral connection - // - [self.centralManager cancelPeripheralConnection:peripheral]; - } - - // - // set being authroized status to false - // - [[MASDevice currentDevice] setIsBeingAuthorized:NO]; - - // - // Stop central scanning for peripherals - // - [self.centralManager stopScan]; - - // - // Notify delegate - // - [self updateBLEState:MASBLEServiceStateCentralDeviceDisconnected]; -} - - -# pragma mark - CBCentralManagerDelegate - -- (void)centralManager:(CBCentralManager *)central didDiscoverPeripheral:(CBPeripheral *)peripheral advertisementData:(NSDictionary *)advertisementData RSSI:(NSNumber *)RSSI -{ - //DLog(@"\n\ndiscovered peripheral: %@ for central:\n\n%@\n\n", peripheral.name, [self debugDescription]); - - // - // If RSSI is not in reasonable range defined in msso_config.json, reject it - // - if (RSSI.integerValue < [[MASConfiguration currentConfiguration] bluetoothRssi]) - { - NSError *error = [NSError errorForFoundationCode:MASFoundationErrorCodeBLERSSINotInRange errorDomain:MASFoundationErrorDomainLocal]; - [self notifyErrorForBLEState:error]; - - return; - } - - // - // Detect a duplicate and ignore if found - // - if([self.peripherals containsObject:peripheral]) - { - //DLog(@"\n\nDetected duplicate peripheral: %@\n\n", peripheral.name); - - // - // Search only for services that match our UUID - // - [peripheral discoverServices:@[[CBUUID UUIDWithString: _serviceUUID]]]; - - return; - } - - // - // Stop scanning once peripheral discovered - // - [self.centralManager stopScan]; - - // - // Device detected - // - [self updateBLEState:MASBLEServiceStateCentralDeviceDetected]; - - // - // Stop scanning - // - [self updateBLEState:MASBLEServiceStateCentralStopped]; - - // - // Add the discovered peripheral - // - [peripheral setDelegate:self]; - [self.peripherals addObject:peripheral]; - - // - // Connect the peripheral - // - [central connectPeripheral:peripheral options:nil]; -} - - -- (void)centralManager:(CBCentralManager *)central didConnectPeripheral:(CBPeripheral *)peripheral -{ - //DLog(@"\n\nconnected to peripheral: %@ for central:\n\n%@\n\n", peripheral.name, [self debugDescription]); - - [self updateBLEState:MASBLEServiceStateCentralDeviceConnected]; - - // - // Search only for services that match our UUID - // - [peripheral discoverServices:@[[CBUUID UUIDWithString: _serviceUUID]]]; -} - - -- (void)centralManager:(CBCentralManager *)central didFailToConnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error -{ - //DLog(@"\n\nfailed to connect to peripheral: %@ for central:\n\n%@ with error:\n\n%@\n\n", peripheral.name, [self debugDescription], [error localizedDescription]); - - if (error) - { - // - // Re-create an error with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheral info:error.userInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [self notifyErrorForBLEState:masError]; - } - - // - // Remove the peripheral - // - [self.peripherals removeObject:peripheral]; -} - - -- (void)centralManager:(CBCentralManager *)central didDisconnectPeripheral:(CBPeripheral *)peripheral error:(NSError *)error -{ - //DLog(@"\n\ndisconnected from peripheral: %@ for central:\n\n%@\n\n with error:\n\n%@\n\n", peripheral.name, [self debugDescription], [error localizedDescription]); - - if (error) - { - // - // Re-create an error with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheral info:error.userInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [self notifyErrorForBLEState:masError]; - } - - // - // Remove the peripheral - // - [self.peripherals removeObject:peripheral]; - - // - // Notify delegate - // - [self updateBLEState:MASBLEServiceStateCentralDeviceDisconnected]; -} - - -- (void)centralManagerDidUpdateState:(CBCentralManager *)central -{ -// DLog(@"\n%@\n\n", [self debugDescription]); - if (_initializeCodeBlock) - { - _initializeCodeBlock(); - } -} - - -- (void)centralManager:(CBCentralManager *)central willRestoreState:(NSDictionary *)stateInfo -{ - //DLog(@"\n\ncalled with restored state: %@\n\n", stateInfo); -} - - -# pragma mark - CBPeripheralDelegate -/* -- (void)peripheralDidUpdateName:(CBPeripheral *)peripheral -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); -} -*/ - -# pragma mark - CBPeripheralDelegate (Services) - -- (void)peripheral:(CBPeripheral *)peripheral didDiscoverServices:(NSError *)error -{ - //DLog(@"\n\ncalled with peripheral: %@, services: %@ with error:\n\n%@\n\n", peripheral.name, peripheral.services, [error localizedDescription]); - - // - // Error - // - if(error) - { - //DLog(@"\n\nError discovering services:\n\n%@\n\n", [error localizedDescription]); - - // - // Re-create an error with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLECentral info:error.userInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [self notifyErrorForBLEState:masError]; - - return; - } - - // - // Iterate the newly filled peripheral.services array, just in case there's more than one. - // - for (CBService *service in peripheral.services) - { - //DLog(@"\n\n found service: %@\n\n", [service debugDescription]); - - [self updateBLEState:MASBLEServiceStateCentralServiceDiscovered]; - - [peripheral discoverCharacteristics:@[[CBUUID UUIDWithString:_characteristicUUID]] forService:service]; - } -} - - -- (void)peripheral:(CBPeripheral *)peripheral didDiscoverIncludedServicesForService:(CBService *)service error:(NSError *)error -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); - - if (error) - { - // - // Re-create an error with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheralServices info:error.userInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [self notifyErrorForBLEState:masError]; - } -} - -/* -- (void)peripheral:(CBPeripheral *)peripheral didModifyServices:(NSArray *)invalidatedServices -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); -} -*/ - -# pragma mark - CBPeripheralDelegate (Characteristics) - -- (void)peripheral:(CBPeripheral *)peripheral didDiscoverCharacteristicsForService:(CBService *)service error:(NSError *)error -{ - //DLog(@"called with peripheral: %@\n\n%@\n\n with error:\n\n%@\n\n", peripheral.name, [self debugDescription], [error localizedDescription]); - - // - // Error - // - if(error) - { - //DLog(@"\n\nError when discovering service from peripheral: %@ characteristics:\n\n%@\n\n", service.peripheral.name, [error localizedDescription]); - - // - // Re-create an error with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheralCharacteristics info:error.userInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [self notifyErrorForBLEState:masError]; - - return; - } - - // - // Lock the thread for one request at a given time - // - [_lock lock]; - - // - // Again, we loop through the array, just in case. - // - for (CBCharacteristic *characteristic in service.characteristics) - { - // - // Detect the one we are looking for - // - if ([characteristic.UUID isEqual:[CBUUID UUIDWithString:_characteristicUUID]]) - { - [peripheral setNotifyValue:YES forCharacteristic:characteristic]; - - // - // Notify - // - [self updateBLEState:MASBLEServiceStateCentralCharacteristicDiscovered]; - - // - // Call method to send data to peripheral with given auth provider and characteristic if authentication provider is provided - // - if (_provider) - { - [self sendAuthURLWithAuthenticationProvider:_provider characteristic:characteristic]; - } - } - } - - // - // Unlock the thread after it's done - // - [_lock unlock]; -} - - -- (void)peripheral:(CBPeripheral *)peripheral didDiscoverDescriptorsForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); - - if (error) - { - // - // Re-create an error with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheralCharacteristics info:error.userInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [self notifyErrorForBLEState:masError]; - } -} - - -- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); - if (error) - { - // - // Re-create an error with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheralCharacteristics info:error.userInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [self notifyErrorForBLEState:masError]; - } -} - - -- (void)peripheral:(CBPeripheral *)peripheral didWriteValueForDescriptor:(CBDescriptor *)descriptor error:(NSError *)error -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); - - if (error) - { - // - // Re-create an error with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheralCharacteristics info:error.userInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [self notifyErrorForBLEState:masError]; - } -} - - -- (void)peripheral:(CBPeripheral *)peripheral didUpdateValueForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); - - // - // Error - // - if(error) - { - NSError *errorDetail = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheralCharacteristics info:error.userInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [self notifyErrorForBLEState:errorDetail]; - - return; - } - - NSString *stringFromData = [[NSString alloc] initWithData:characteristic.value encoding:NSUTF8StringEncoding]; - - if ([stringFromData isEqualToString:@"0"]) - { - [self updateBLEState:MASBLEServiceStateCentralAuthorizationSucceeded]; - - // - // Pull URL, if authentication provider is provided - // - if (_provider) - { - [self pollAuthorizationCode]; - } - } - else { - [self updateBLEState:MASBLEServiceStateCentralAuthorizationFailed]; - } - - // - // Stop - // - [self stopScanning]; -} - - -- (void)peripheral:(CBPeripheral *)peripheral didUpdateNotificationStateForCharacteristic:(CBCharacteristic *)characteristic error:(NSError *)error -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); - - if (error) - { - // - // Re-create an error with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheralCharacteristics info:error.userInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [self notifyErrorForBLEState:masError]; - } -} - - -@end diff --git a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothPeripheral.h b/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothPeripheral.h deleted file mode 100644 index 0f1ce2b6..00000000 --- a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothPeripheral.h +++ /dev/null @@ -1,52 +0,0 @@ -// -// MASBluetoothPeripheral.h -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import - - -@interface MASBluetoothPeripheral : MASObject - - - -///-------------------------------------- -/// @name Lifecycle -///-------------------------------------- - -# pragma mark - Lifecycle - -/** - * Create a bluetooth peripheral. - * - * @param serviceUUID The peripheral's service UUID. - @ @param characteristicUUI The peripheral's characteristic UUID. - * @return Returns the newly initialized 'MASBluetoothPeripheral'. - */ -+ (id)peripheralWithServiceUUID:(NSString *)serviceUUID characteristicUUID:(NSString *)characteristicUUID; - - - -///-------------------------------------- -/// @name Starting & Stopping -///-------------------------------------- - -# pragma mark - Starting and Stopping - -/** - * Start the peripheral advertising it's presence. - */ -- (void)startAdvertising; - - -/** - * Stop the peripheral advertising it's presence. - */ -- (void)stopAdvertising; - -@end diff --git a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothPeripheral.m b/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothPeripheral.m deleted file mode 100644 index 643b36d5..00000000 --- a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothPeripheral.m +++ /dev/null @@ -1,539 +0,0 @@ -// -// MASBluetoothPeripheral.m -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import "MASBluetoothPeripheral.h" - -#import -#import "MASConstantsPrivate.h" - - -@interface MASBluetoothPeripheral () - - -# pragma mark - Properties - -@property (nonatomic, strong, readonly) CBPeripheralManager *peripheralManager; -@property (nonatomic, strong, readwrite) CBMutableCharacteristic *transferCharacteristic; - -@property (nonatomic, copy, readonly) NSString *serviceUUID; -@property (nonatomic, copy, readonly) NSString *characteristicUUID; -@property (nonatomic, copy, readonly) NSMutableData *sessionURLData; - -@property (nonatomic, strong) MASVoidCodeBlock initializeCodeBlock; - -@property (assign) BOOL isSubscribed; - -@end - - -@implementation MASBluetoothPeripheral - - -# pragma mark - Current Peripheral - -+ (id)peripheralWithServiceUUID:(NSString *)serviceUUID characteristicUUID:(NSString *)characteristicUUID; -{ - // - // These are required - // - NSParameterAssert(serviceUUID); - NSParameterAssert(characteristicUUID); - - // todo: validate the UUIDs??? - - MASBluetoothPeripheral *peripheral = [[MASBluetoothPeripheral alloc] initWithServiceUUID:serviceUUID characteristicUUID:characteristicUUID]; - - return peripheral; -} - - -# pragma mark - Private - -- (void)updateBLEState:(MASBLEServiceState)state -{ - // - // If MASDevice's BLE delegate is set, and method is implemented, notify the delegate - // - if ([MASDevice proximityLoginDelegate] && [[MASDevice proximityLoginDelegate] respondsToSelector:@selector(didReceiveBLEProximityLoginStateUpdate:)]) - { - [[MASDevice proximityLoginDelegate] didReceiveBLEProximityLoginStateUpdate:state]; - } -} - - -- (void)notifyErrorForBLEState:(NSError *)error -{ - // - // If MASDevice's BLE delegate is set, and method is implemented, notify the delegate - // - if ([MASDevice proximityLoginDelegate] && [[MASDevice proximityLoginDelegate] respondsToSelector:@selector(didReceiveProximityLoginError:)]) - { - [[MASDevice proximityLoginDelegate] didReceiveProximityLoginError:error]; - } -} - - -- (void)requestUserPermissionOnBLEForDeviceName:(NSString *)deviceName completion:(MASCompletionErrorBlock)completion -{ - // - // If MASDevice's BLE delegate is set, and method is implemented, notify the delegate - // - if ([MASDevice proximityLoginDelegate] && [[MASDevice proximityLoginDelegate] respondsToSelector:@selector(handleBLEProximityLoginUserConsent:deviceName:)]) - { - [[MASDevice proximityLoginDelegate] handleBLEProximityLoginUserConsent:completion deviceName:deviceName]; - } - // - // Otherwise, return an error for delegate undefine - // - else { - completion(NO, [NSError errorForFoundationCode:MASFoundationErrorCodeBLEDelegateNotDefined errorDomain:MASFoundationErrorDomainLocal]); - } -} - - -# pragma mark - Creating a new peripheral - -- (id)init -{ - @throw [NSException exceptionWithName:NSInternalInconsistencyException - reason:@"init is not a valid initializer, please use a factory method" - userInfo:nil]; - return nil; -} - - -- (id)initWithServiceUUID:(NSString *)serviceUUID characteristicUUID:(NSString *)characteristicUUID -{ - self = [super init]; - if(self) - { - - _serviceUUID = serviceUUID; - _characteristicUUID = characteristicUUID; - _sessionURLData = [[NSMutableData alloc] init]; - } - - return self; -} - - -- (NSString *)debugDescription -{ - return [NSString stringWithFormat:@"(%@) peripheral manager state is: %@ and is advertising: %@\n\n" - " background authorization status: %@\n serviceUUID: %@\n characteristicUUID: %@", - [self class], [self.peripheralManager peripheralManagerStateAsString], ([self.peripheralManager isAdvertising] ? @"Yes" : @"No"), - [CBPeripheralManager peripheralManagerAuthorizationStatusAsString], - self.serviceUUID, self.characteristicUUID]; -} - - -# pragma mark - Starting and Stopping - -- (void)startAdvertising -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); - - __block MASBluetoothPeripheral *blockSelf = self; - - MASVoidCodeBlock initializeCodeBlock = ^{ - - // - // If the peripheral manager exists, and is not advertising - // - if (blockSelf.peripheralManager && ![blockSelf.peripheralManager isAdvertising]) - { - // - // Check BLE state, and return proper error if the state is invalid. - // - if (![blockSelf.peripheralManager isPoweredOn]) - { - NSError *bleError = [blockSelf.peripheralManager peripheralManagerStateToMASFoundationError]; - - // - // Notify delegate - // - [blockSelf notifyErrorForBLEState:bleError]; - } - else { - - // - // Notify delegatepo - // - [blockSelf updateBLEState:MASBLEServiceStatePeripheralStarted]; - - // - // If characteristic service is not created - // - if (!blockSelf.transferCharacteristic) - { - @try { - - // - // Create characteristic - // - blockSelf.transferCharacteristic = [[CBMutableCharacteristic alloc] initWithType:[CBUUID UUIDWithString:_characteristicUUID] - properties:CBCharacteristicPropertyWriteWithoutResponse + CBCharacteristicPropertyNotify - value:nil - permissions:CBAttributePermissionsReadable|CBAttributePermissionsWriteable]; - - // - // Create service - // - CBMutableService *transferService = [[CBMutableService alloc] initWithType:[CBUUID UUIDWithString:_serviceUUID] - primary:YES]; - transferService.characteristics = @[blockSelf.transferCharacteristic]; - - // - // Add service - // - [blockSelf.peripheralManager addService:transferService]; - - // - // Start peripheral advertising - // - [blockSelf.peripheralManager startAdvertising:@ - { - CBAdvertisementDataServiceUUIDsKey : @[[CBUUID UUIDWithString:_serviceUUID]] - }]; - } - @catch (NSException *exception) { - - // - // Nullify the transferCharacteristic, otherwise on the second attempt to startPeripheral it will throw an uncaught exception. - // - blockSelf.transferCharacteristic = nil; - - NSDictionary *exceptionInfo = @{@"reason" : exception.reason , @"name" : exception.name}; - - // - // Conver the exception with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheral info:exceptionInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [blockSelf notifyErrorForBLEState:masError]; - } - } - else { - - // - // Start peripheral advertising - // - [blockSelf.peripheralManager startAdvertising:@ - { - CBAdvertisementDataServiceUUIDsKey : @[[CBUUID UUIDWithString:_serviceUUID]] - }]; - } - } - } - - blockSelf.initializeCodeBlock = nil; - }; - - // - // If there is no peripheral manager instantiated stop here - // - if (!_peripheralManager) - { - //DLog(@"\n\nError: no peripheral manager detected!!\n\n"); - _peripheralManager = [[CBPeripheralManager alloc] initWithDelegate:self queue:nil]; - _peripheralManager.delegate = self; - _initializeCodeBlock = initializeCodeBlock; - } - else { - - initializeCodeBlock(); - } -} - - -- (void)stopAdvertising -{ - //DLog(@"\n\n%@\n\n", [self debugDescription]); - - // - // If there is no peripheral manager instantiated stop here - // - if(!self.peripheralManager) - { - //DLog(@"\n\nError: no peripheral manager detected!!\n\n"); - - return; - } - - // - // If it is already NOT advertising stop here - // - if(![self.peripheralManager isAdvertising]) - { - //DLog(@"\n\nThe peripheral is already NOT advertising:\n%@\n\n", [self debugDescription]); - - return; - } - - // - // Stop peripheral advertising - // - [self.peripheralManager stopAdvertising]; - - // - // Notify delegate - // - [self updateBLEState:MASBLEServiceStatePeripheralStopped]; -} - - -# pragma mark - CBPeripheralManagerDelegate - -- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didSubscribeToCharacteristic:(CBCharacteristic *)characteristic -{ - //DLog(@"\n\ncalled with characteristic: %@\n\n", [characteristic debugDescription]); - - _isSubscribed = YES; - - // - // Notify delegate - // - [self updateBLEState:MASBLEServiceStatePeripheralSubscribed]; -} - - -- (void)peripheralManager:(CBPeripheralManager *)peripheral central:(CBCentral *)central didUnsubscribeFromCharacteristic:(CBCharacteristic *)characteristic -{ - //DLog(@"\ncalled with characteristic: %@\n\n", [characteristic debugDescription]); - - _isSubscribed = NO; - - // - // Notify delegate - // - [self updateBLEState:MASBLEServiceStatePeripheralUnsubscribed]; -} - - -- (void)peripheralManagerIsReadyToUpdateSubscribers:(CBPeripheralManager *)peripheral -{ - //DLog(@"\n%@\n\n", [self debugDescription]); -} - -/* -- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveReadRequest:(CBATTRequest *)request -{ - //DLog(@"\n\ncalled with request: %@\n\n", [request debugDescription]); -} -*/ - -- (void)peripheralManager:(CBPeripheralManager *)peripheral didReceiveWriteRequests:(NSArray *)requests -{ - //DLog(@"\n\ncalled with requests: %@\n\n", [requests debugDescription]); - - if([requests count] > 0) - { - CBATTRequest *request = requests[0]; - NSString *sessionURLFragment = [[NSString alloc] initWithData:request.value encoding:NSUTF8StringEncoding]; - - //DLog(@"\n\nsessionURLFragment: %@\n\n", sessionURLFragment); - - // - // We rely on EOM to signal the end of the message - // - if([sessionURLFragment isEqualToString:@"EOM"]) - { - //DLog(@"\n\nreceived EOM indicating the end of the authorization request\n\n"); - - NSError *error = nil; - NSDictionary *authorizationRequest = [NSJSONSerialization JSONObjectWithData:self.sessionURLData - options:kNilOptions - error:&error]; - if(error != nil) - { - //DLog(@"\n\nFailed to load authorization request with error: %@\n\n", error); - - NSError *authorizationError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEAuthorizationFailed - info:error.userInfo - errorDomain:MASFoundationErrorDomainLocal]; - [self notifyErrorForBLEState:authorizationError]; - - return; - } - - //DLog(@"\n\nsessionURL: %@\n\n", authorizationRequest); - - // - // Reset the sessionData - // - _sessionURLData = [[NSMutableData alloc] init]; - - [self requestUserPermissionOnBLEForDeviceName:[authorizationRequest objectForKey:@"device_name"] completion:^(BOOL completed, NSError *error) { - - // - // If error was returned, notify delegate and stop processing - // - if (error) - { - [self notifyErrorForBLEState:error]; - - return; - } - else { - - // - // If user accepts the consent - // - if (completed) - { - NSString *providerURL = [authorizationRequest objectForKey:@"provider_url"]; - - if ([providerURL isEmpty]) - { - NSError *invalidURLError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEAuthorizationFailed errorDomain:MASFoundationErrorDomainLocal]; - [self notifyErrorForBLEState:invalidURLError]; - - return; - } - - // - // Retrieve the absolute URL of the authorizing device's gateway URL - // Due to TLS Caching issue, if the authenticating device is on iOS 8, the auth url may come with trailing dot. - // Make sure to handle both of them. - // - NSString *absoluteURL = [NSString stringWithFormat:@"https://%@:%@",[MASConfiguration currentConfiguration].gatewayHostName, [MASConfiguration currentConfiguration].gatewayPort]; - NSString *absoluteURLWithTrailingDot = [NSString stringWithFormat:@"https://%@.:%@",[MASConfiguration currentConfiguration].gatewayHostName, [MASConfiguration currentConfiguration].gatewayPort]; - - if ([MASConfiguration currentConfiguration].gatewayPrefix) - { - absoluteURL = [NSString stringWithFormat:@"%@/%@", absoluteURL, [MASConfiguration currentConfiguration].gatewayPrefix]; - absoluteURLWithTrailingDot = [NSString stringWithFormat:@"%@/%@", absoluteURLWithTrailingDot, [MASConfiguration currentConfiguration].gatewayPrefix]; - } - - NSString *authPath = @""; - - if ([providerURL rangeOfString:absoluteURL].location != NSNotFound || [providerURL rangeOfString:absoluteURLWithTrailingDot].location != NSNotFound) - { - // - // Extract the path of the authorization URL - // - authPath = [providerURL stringByReplacingOccurrencesOfString:absoluteURL withString:@""]; - authPath = [authPath stringByReplacingOccurrencesOfString:absoluteURLWithTrailingDot withString:@""]; - } - else { - - [self notifyErrorForBLEState:[NSError errorProximityLoginInvalidAuthroizeURL]]; - return; - } - - @try { - - [MAS postTo:authPath - withParameters:nil - andHeaders:nil - requestType:MASRequestResponseTypeWwwFormUrlEncoded - responseType:MASRequestResponseTypeTextPlain - completion:^(NSDictionary *responseInfo, NSError *error) { - - if (error) - { - - NSError * invalidURLError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEAuthorizationFailed info:responseInfo errorDomain:MASFoundationErrorDomain]; - [self notifyErrorForBLEState:invalidURLError]; - - NSString *statusCode = @"1"; - [self.peripheralManager updateValue:[statusCode dataUsingEncoding:NSUTF8StringEncoding] forCharacteristic:self.transferCharacteristic onSubscribedCentrals:nil]; - - return; - } - else { - - [self updateBLEState:MASBLEServiceStatePeripheralSessionAuthorized]; - - if (!_isSubscribed) - { - NSError *noSubscribedDeviceError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLECentralDeviceNotFound errorDomain:MASFoundationErrorDomainLocal]; - [self notifyErrorForBLEState:noSubscribedDeviceError]; - - return; - } - - - NSString *statusCode = @"0"; - [self.peripheralManager updateValue:[statusCode dataUsingEncoding:NSUTF8StringEncoding] forCharacteristic:self.transferCharacteristic onSubscribedCentrals:nil]; - - [self updateBLEState:MASBLEServiceStatePeripheralSessionNotified]; - } - }]; - } - @catch(NSException* exception) - { - NSError *invalidURLError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEAuthorizationFailed errorDomain:MASFoundationErrorDomainLocal]; - [self notifyErrorForBLEState:invalidURLError]; - - return; - } - } - // - // If user does not authroize - // - else { - - NSString *statusCode = @"2"; - [self.peripheralManager updateValue:[statusCode dataUsingEncoding:NSUTF8StringEncoding] forCharacteristic:self.transferCharacteristic onSubscribedCentrals:nil]; - } - } - }]; - } - - // - // Append the data to what we already have - // - else - { - [self.sessionURLData appendData:request.value]; - } - } -} - - -- (void)peripheralManagerDidStartAdvertising:(CBPeripheralManager *)peripheral error:(NSError *)error -{ - //DLog(@"\n%@\n error: %@\n\n", [self debugDescription], [error localizedDescription]); - - if (error) - { - // - // Re-create an error with proper framework error domain and error code. - // - NSError *masError = [NSError errorForFoundationCode:MASFoundationErrorCodeBLEPeripheral info:error.userInfo errorDomain:MASFoundationErrorDomainLocal]; - - // - // Notify delegate - // - [self notifyErrorForBLEState:masError]; - } -} - - -- (void)peripheralManagerDidUpdateState:(CBPeripheralManager *)peripheral -{ - //DLog(@"\n%@\n\n", [self debugDescription]); - if (_initializeCodeBlock) - { - _initializeCodeBlock(); - } -} - - -- (void)peripheralManager:(CBPeripheralManager *)peripheral willRestoreState:(NSDictionary *)stateInfo -{ - //DLog(@"\n\ncalled with restored state: %@\n\n", stateInfo); -} - -@end diff --git a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothService.h b/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothService.h deleted file mode 100644 index 2fd7803d..00000000 --- a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothService.h +++ /dev/null @@ -1,41 +0,0 @@ -// -// MASBluetoothService.h -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import "MASService.h" - -#import "MASConstantsPrivate.h" - - -@class MASBluetoothCentral; -@class MASBluetoothPeripheral; - - -@interface MASBluetoothService : MASService - - - -///-------------------------------------- -/// @name Properties -///-------------------------------------- - -# pragma mark - Properties - -/** - * The BLE central. - */ -@property (nonatomic, strong, readonly) MASBluetoothCentral *central; - - -/** - * The BLE peripheral. - */ -@property (nonatomic, strong, readonly) MASBluetoothPeripheral *peripheral; - -@end diff --git a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothService.m b/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothService.m deleted file mode 100644 index c4e098b7..00000000 --- a/MASFoundation/Classes/_private_/services/bluetooth/MASBluetoothService.m +++ /dev/null @@ -1,135 +0,0 @@ -// -// MASBluetoothService.m -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import "MASBluetoothService.h" - -#import -#import "MASBluetoothCentral.h" -#import "MASBluetoothPeripheral.h" - - -@implementation MASBluetoothService - - -# pragma mark - Shared Service - -+ (instancetype)sharedService -{ - static id sharedInstance = nil; - static dispatch_once_t onceToken; - dispatch_once(&onceToken, ^ - { - sharedInstance = [[MASBluetoothService alloc] initProtected]; - }); - - return sharedInstance; -} - - -# pragma mark - Lifecycle - -+ (void)load -{ - [MASService registerSubclass:[self class] serviceUUID:MASBluetoothServiceUUID]; -} - - -+ (NSString *)serviceUUID -{ - return MASBluetoothServiceUUID; -} - - -- (void)serviceDidLoad -{ - - [super serviceDidLoad]; -} - - -- (void)serviceWillStart -{ - // - // Retrieve the configuation for UUID values - // - MASConfiguration *configuration = [MASConfiguration currentConfiguration]; - - // - // Create the central - // - _central = [MASBluetoothCentral centralWithServiceUUID:configuration.bluetoothServiceUuid - characteristicUUID:configuration.bluetoothCharacteristicUuid]; - - // - // Create the peripheral - // - _peripheral = [MASBluetoothPeripheral peripheralWithServiceUUID:configuration.bluetoothServiceUuid - characteristicUUID:configuration.bluetoothCharacteristicUuid]; - - [super serviceWillStart]; -} - - -- (void)serviceWillStop -{ - // - // If the central exists - // - if(self.central) - { - [self.central stopScanning]; - } - - // - // If the peripheral exists - // - if(self.peripheral) - { - [self.peripheral stopAdvertising]; - } - - [super serviceWillStop]; -} - - -- (void)serviceDidReset -{ - // - // If the central exists - // - if(self.central) - { - [self.central stopScanning]; - _central = nil; - } - - // - // If the peripheral exists - // - if(self.peripheral) - { - [self.peripheral stopAdvertising]; - _peripheral = nil; - } - - [super serviceDidReset]; -} - - -# pragma mark - Public - -- (NSString *)debugDescription -{ - return [NSString stringWithFormat:@"%@\n\n central: %@\n\n peripheral: %@", - [super debugDescription], - [self.central debugDescription], [self.peripheral debugDescription]]; -} - -@end diff --git a/MASFoundation/Classes/models/MASAuthenticationProviders.h b/MASFoundation/Classes/models/MASAuthenticationProviders.h index c3855dc7..9e04f5d3 100644 --- a/MASFoundation/Classes/models/MASAuthenticationProviders.h +++ b/MASFoundation/Classes/models/MASAuthenticationProviders.h @@ -38,6 +38,11 @@ @property (nonatomic, copy, readonly, nullable) NSString *idp; +/** + * PKCE state value being used for current authentication providers + */ +@property (nonatomic, copy, readonly, nullable) NSString *PKCEstate; + ///-------------------------------------- /// @name Authentication Providers diff --git a/MASFoundation/Classes/models/MASAuthenticationProviders.m b/MASFoundation/Classes/models/MASAuthenticationProviders.m index cd913794..becbe85a 100644 --- a/MASFoundation/Classes/models/MASAuthenticationProviders.m +++ b/MASFoundation/Classes/models/MASAuthenticationProviders.m @@ -10,6 +10,7 @@ #import "MASAuthenticationProviders.h" +#import "MASAccessService.h" #import "MASConstantsPrivate.h" #import "MASModelService.h" @@ -20,6 +21,7 @@ @implementation MASAuthenticationProviders +@synthesize PKCEstate = _PKCEstate; - (id)init { @@ -58,6 +60,13 @@ - (NSString *)debugDescription } +# pragma mark - Properties + +- (NSString *)PKCEstate +{ + return [[MASAccessService sharedService].currentAccessObj retrievePKCEState]; +} + # pragma mark - Authentication Providers + (MASAuthenticationProviders *)currentProviders diff --git a/MASFoundation/Classes/models/MASDevice.h b/MASFoundation/Classes/models/MASDevice.h index bea9d2cb..39601d7a 100644 --- a/MASFoundation/Classes/models/MASDevice.h +++ b/MASFoundation/Classes/models/MASDevice.h @@ -11,11 +11,6 @@ #import "MASObject.h" -@class MASAuthenticationProvider; - -@protocol MASProximityLoginDelegate; - - /** * The `MASDevice` class is a local representation of device data. */ @@ -59,18 +54,6 @@ @property (assign) BOOL isBeingAuthorized; -/** - * The MASProximityLoginDelegate static property getter - */ -+ (id _Nullable)proximityLoginDelegate; - - -/** - * The MASProximityLoginDelegate static property setter - */ -+ (void)setProximityLoginDelegate:(id _Nonnull)delegate; - - ///-------------------------------------- /// @name Current Device ///-------------------------------------- @@ -144,55 +127,6 @@ -///-------------------------------------- -/// @name Bluetooth Peripheral -///-------------------------------------- - -# pragma mark - Bluetooth Peripheral - -/** - * Start the device acting as a bluetooth peripheral. - */ -- (void)startAsBluetoothPeripheral; - - - -/** - * Stop the device acting as a bluetooth peripheral. - */ -- (void)stopAsBluetoothPeripheral; - - - -///-------------------------------------- -/// @name Bluetooth Central -///-------------------------------------- - -# pragma mark - Bluetooth Central - -/** - * Start the device acting as a bluetooth central. - */ -- (void)startAsBluetoothCentral; - - - -/** - * Start the device acting as a bluetooth central with given authentication provider. - * - * @param provider MASAuthenticationProvider to pass authentication information to other devices - */ -- (void)startAsBluetoothCentralWithAuthenticationProvider:(MASAuthenticationProvider *_Nonnull)provider; - - - -/** - * Stop the device acting as a bluetooth central. - */ -- (void)stopAsBluetoothCentral; - - - ///-------------------------------------- /// @name Device Metadata ///-------------------------------------- diff --git a/MASFoundation/Classes/models/MASDevice.m b/MASFoundation/Classes/models/MASDevice.m index 553cb7df..03426a2a 100644 --- a/MASFoundation/Classes/models/MASDevice.m +++ b/MASFoundation/Classes/models/MASDevice.m @@ -11,9 +11,6 @@ #import "MASDevice.h" #import "MASAccessService.h" -#import "MASBluetoothCentral.h" -#import "MASBluetoothPeripheral.h" -#import "MASBluetoothService.h" #import "MASConstantsPrivate.h" #import "MASModelService.h" #import "MASSecurityService.h" @@ -29,22 +26,6 @@ @implementation MASDevice @synthesize isRegistered = _isRegistered; -static id _proximityLoginDelegate_; - - -# pragma mark - Property - -+ (id)proximityLoginDelegate -{ - return _proximityLoginDelegate_; -} - - -+ (void)setProximityLoginDelegate:(id)delegate -{ - _proximityLoginDelegate_ = delegate; -} - # pragma mark - Properties @@ -166,40 +147,6 @@ - (NSString *)debugDescription } -# pragma mark - Bluetooth Peripheral - -- (void)startAsBluetoothPeripheral -{ - [[MASBluetoothService sharedService].peripheral startAdvertising]; -} - - -- (void)stopAsBluetoothPeripheral -{ - [[MASBluetoothService sharedService].peripheral stopAdvertising]; -} - - -# pragma mark - Bluetooth Central - -- (void)startAsBluetoothCentral -{ - [[MASBluetoothService sharedService].central startScanning]; -} - - -- (void)startAsBluetoothCentralWithAuthenticationProvider:(MASAuthenticationProvider *)provider -{ - [[MASBluetoothService sharedService].central startScanningWithAuthenticationProvider:provider]; -} - - -- (void)stopAsBluetoothCentral -{ - [[MASBluetoothService sharedService].central stopScanning]; -} - - # pragma mark - Device Metadata - (void)addAttribute:(NSString *_Nonnull)name value:(NSString *)value completion:(MASObjectResponseErrorBlock)completion diff --git a/MASFoundation/Classes/models/MASProximityLogin.h b/MASFoundation/Classes/models/MASProximityLogin.h deleted file mode 100644 index dcfed259..00000000 --- a/MASFoundation/Classes/models/MASProximityLogin.h +++ /dev/null @@ -1,15 +0,0 @@ -// -// MASProximityLogin.h -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import "MASObject.h" - -@interface MASProximityLogin : MASObject - -@end diff --git a/MASFoundation/Classes/models/MASProximityLogin.m b/MASFoundation/Classes/models/MASProximityLogin.m deleted file mode 100644 index 5df24bc9..00000000 --- a/MASFoundation/Classes/models/MASProximityLogin.m +++ /dev/null @@ -1,29 +0,0 @@ -// -// MASProximityLogin.m -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import "MASProximityLogin.h" - -@implementation MASProximityLogin - -- (void)start -{ - @throw [NSException exceptionWithName:NSInternalInconsistencyException - reason:@"not a valid method, please use a factory method" - userInfo:nil]; -} - -- (void)stop -{ - @throw [NSException exceptionWithName:NSInternalInconsistencyException - reason:@"not a valid method, please use a factory method" - userInfo:nil]; -} - -@end diff --git a/MASFoundation/Classes/models/MASProximityLoginQRCode.h b/MASFoundation/Classes/models/MASProximityLoginQRCode.h deleted file mode 100644 index 73930283..00000000 --- a/MASFoundation/Classes/models/MASProximityLoginQRCode.h +++ /dev/null @@ -1,128 +0,0 @@ -// -// MASProximityLoginQRCode.h -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import -#import "MASProximityLogin.h" - -@class MASAuthenticationProvider; - -/** - * The `MASProximityLoginQRCode` class is a local representation of QR Code authentication provider data and handle necessary logic. - */ -@interface MASProximityLoginQRCode : MASProximityLogin - -///-------------------------------------- -/// @name Properties -///-------------------------------------- - -# pragma mark - Properties - -/** - * Polling interval in seconds for QR Code proximity login - */ -@property (nonatomic, assign, readonly, nonnull) NSNumber *pollingInterval; - - -/** - * Initial delay in seconds to make polling request for QR Code authorization - */ -@property (nonatomic, assign, readonly, nonnull) NSNumber *pollingDelay; - - -/** - * Limit for number of polling requests for QR Code authorization - */ -@property (nonatomic, assign, readonly, nonnull) NSNumber *pollingLimit; - - -/** - * Counter for current number of polling reuqests made. - */ -@property (nonatomic, assign, readonly) int currentPollingCounter; - - -/** - * Boolean indicator of polling request is in progress or not. - */ -@property (nonatomic, assign, readonly) BOOL isPolling; - - -/** - * NSString of authentication URL - */ -@property (nonatomic, copy, readonly, nonnull) NSString *authenticationUrl; - - -/** - * NSString of polling URL - */ -@property (nonatomic, copy, readonly, nonnull) NSString *pollUrl; - - -# pragma mark - Lifecycle - -/** - * Init the object with given values. - * Property values cannot be changed once it is initialized. - * - * @param provider MASAuthenticationProvider object with authenticationUrl and pollUrl for QR Code. - * @param initDelay NSNumber of initial delay in seconds to start making a request to poll for authorization. - * @param pollingInterval NSNumber of interval for polling requests. - * @param pollingLimit NSNumber of limit counter for number of polling requests. - * - * @return MASProximityLoginQRCode object - */ -- (instancetype _Nullable)initWithAuthenticationProvider:(MASAuthenticationProvider *_Nonnull)provider initialDelay:(NSNumber *_Nonnull)initDelay pollingInterval:(NSNumber *_Nonnull)pollingInterval pollingLimit:(NSNumber *_Nonnull)pollingLimit; - - -/** - * Init the object with authentication provider and default values for polling configurations - * Default values for the objects are - * - * pollingDelay : 10 seconds - * pollingInterval : 5 seconds - * pollingLimit : 6 times - * - * @param provider MASAuthenticationProvider object with authenticationUrl and pollUrl for QR Code. - * - * @return MASProximityLoginQRCode object - */ -- (instancetype _Nullable)initWithAuthenticationProvider:(MASAuthenticationProvider *_Nonnull)provider; - - -# pragma mark - Start/Stop displaying QR Code image - -/** - * Generates QR Code image for proximity login based on provided authentication provider and starts polling request for authorization. - * Upon successful start display, NSNotification with notification name, MASProximityLoginQRCodeDidStartDisplayingQRCodeImage, will be sent. - * - * @return UIImage of QR Code. - */ -- (UIImage *_Nullable)startDisplayingQRCodeImageForProximityLogin; - - -/** - * Stops displaying QR Code image for proximity login based on provided polling configuration. - * Upon successful stop display, NSNotification with notification name, MASProxityLoginQRCodeDidStopDisplayingQRCodeImage, will be sent. - */ -- (void)stopDisplayingQRCodeImageForProximityLogin; - - -# pragma mark - Authorize authenticateUrl for proximity login - -/** - * Authorize given authenticateUrl with gateway. Method will validate authenticateUrl, and send it over to gateway to authorize. - * - * @param authenticateUrl NSString of authenticateUrl. - * @param completion MASCompletionErrorBlock to notify caller for the result. - */ -+ (void)authorizeAuthenticateUrl:(NSString *_Nonnull)authenticateUrl completion:(MASCompletionErrorBlock _Nullable)completion; - -@end diff --git a/MASFoundation/Classes/models/MASProximityLoginQRCode.m b/MASFoundation/Classes/models/MASProximityLoginQRCode.m deleted file mode 100644 index 74e8bb62..00000000 --- a/MASFoundation/Classes/models/MASProximityLoginQRCode.m +++ /dev/null @@ -1,225 +0,0 @@ -// -// MASProximityLoginQRCode.m -// MASFoundation -// -// Copyright (c) 2016 CA. All rights reserved. -// -// This software may be modified and distributed under the terms -// of the MIT license. See the LICENSE file for details. -// - -#import "MASProximityLoginQRCode.h" - -#import "MASProximityLoginQRCode+MASPrivate.h" -#import "NSString+MASPrivate.h" -#import "NSError+MASPrivate.h" - -# pragma mark - Property Constants - -static NSString *const kMASProximityLoginQRCodeAuthenticationUrlKey = @"authenticationUrl"; // string -static NSString *const kMASProximityLoginQRCodePollUrlKey = @"pollUrl"; // string -static NSString *const kMASProximityLoginQRCodePollingDelayKey = @"pollingDelay"; // string -static NSString *const kMASProximityLoginQRCodePollingIntervalKey = @"pollingInterval"; // string -static NSString *const kMASProximityLoginQRCodePollingLimitKey = @"pollingLimit"; // string -static NSString *const kMASProximityLoginQRCodeCurrentPollingCounterKey = @"currentPollingCounter"; // string -static NSString *const kMASProximityLoginQRCodeIsPollingKey = @"isPolling"; // string - -@interface MASProximityLoginQRCode () - -@property (nonatomic, strong) UIImage *qrCodeImage; - -@property (assign) BOOL isStop; - -@property (assign) int pollCount; - -@end - -@implementation MASProximityLoginQRCode - -# pragma mark - Lifecycle - -- (id)init -{ - @throw [NSException exceptionWithName:NSInternalInconsistencyException - reason:@"init is not a valid initializer, please use a factory method" - userInfo:nil]; - return nil; -} - - -- (instancetype)initWithAuthenticationProvider:(MASAuthenticationProvider *)provider initialDelay:(NSNumber *)initDelay pollingInterval:(NSNumber *)pollingInterval pollingLimit:(NSNumber *)pollingLimit -{ - NSParameterAssert(provider); - NSParameterAssert(provider.authenticationUrl); - NSParameterAssert(provider.pollUrl); - NSParameterAssert([initDelay intValue] > 0); - NSParameterAssert([pollingInterval intValue] > 0); - NSParameterAssert([pollingLimit intValue] > 0); - - return [self initPrivateWithAuthenticationUrl:provider.authenticationUrl.absoluteString pollingUrl:provider.pollUrl.absoluteString initialDelay:initDelay pollingInterval:pollingInterval pollingLimit:pollingLimit]; -} - - -- (instancetype)initWithAuthenticationProvider:(MASAuthenticationProvider *)provider -{ - return [self initWithAuthenticationProvider:provider initialDelay:[NSNumber numberWithInt:10] pollingInterval:[NSNumber numberWithInt:5] pollingLimit:[NSNumber numberWithInt:6]]; -} - - -# pragma mark - Start/Stop displaying QR Code image - -- (UIImage *)startDisplayingQRCodeImageForProximityLogin -{ - // - // Generate image only once - // - if (_qrCodeImage == nil) - { - _qrCodeImage = [self startPrivateDisplayingQRCodeImageForProximityLogin]; - } - - return _qrCodeImage; -} - - -- (void)stopDisplayingQRCodeImageForProximityLogin -{ - [self stopPrivateDisplayingQRCodeImageForProximityLogin]; -} - - - -# pragma mark - Authorize authenticateUrl for proximity login - -+ (void)authorizeAuthenticateUrl:(NSString *)authenticateUrl completion:(MASCompletionErrorBlock)completion -{ - NSError *invalidURLError = nil; - - // - // If url is empty - // - if ([authenticateUrl isEmpty]) - { - invalidURLError = [NSError errorForFoundationCode:MASFoundationErrorCodeProximityLoginInvalidAuthenticationURL errorDomain:MASFoundationErrorDomainLocal]; - } - - if (invalidURLError) - { - if (completion) - { - completion(NO, invalidURLError); - } - - return; - } - - - // - // Retrieve the absolute URL of the authorizing device's gateway URL - // Due to TLS Caching issue, if the authenticating device is on iOS 8, the auth url may come with trailing dot. - // Make sure to handle both of them. - // - NSString *absoluteURL = [NSString stringWithFormat:@"https://%@:%@",[MASConfiguration currentConfiguration].gatewayHostName, [MASConfiguration currentConfiguration].gatewayPort]; - NSString *absoluteURLWithTrailingDot = [NSString stringWithFormat:@"https://%@.:%@",[MASConfiguration currentConfiguration].gatewayHostName, [MASConfiguration currentConfiguration].gatewayPort]; - - if ([MASConfiguration currentConfiguration].gatewayPrefix) - { - absoluteURL = [NSString stringWithFormat:@"%@/%@", absoluteURL, [MASConfiguration currentConfiguration].gatewayPrefix]; - absoluteURLWithTrailingDot = [NSString stringWithFormat:@"%@/%@", absoluteURLWithTrailingDot, [MASConfiguration currentConfiguration].gatewayPrefix]; - } - - NSString *authPath = @""; - - if ([authenticateUrl rangeOfString:absoluteURL].location != NSNotFound || [authenticateUrl rangeOfString:absoluteURLWithTrailingDot].location != NSNotFound) - { - // - // Extract the path of the authorization URL - // - authPath = [authenticateUrl stringByReplacingOccurrencesOfString:absoluteURL withString:@""]; - authPath = [authPath stringByReplacingOccurrencesOfString:absoluteURLWithTrailingDot withString:@""]; - } - else { - - if (completion) - { - completion(NO, [NSError errorProximityLoginInvalidAuthroizeURL]); - } - - return; - } - - - [MAS postTo:authPath withParameters:nil andHeaders:nil requestType:MASRequestResponseTypeWwwFormUrlEncoded responseType:MASRequestResponseTypeTextPlain completion:^(NSDictionary *responseInfo, NSError *error) { - - if (error) - { - if (completion) - { - completion(NO, error); - } - } - else { - if (completion) - { - completion(YES, nil); - } - } - }]; -} - - -#pragma mark - Debug methods - -- (NSString *)debugDescription -{ - return [NSString stringWithFormat:@"(%@)\n\n" - " objectId: %@\n auth url: %@\n poll url: %@\n polling delay: %@\n polling interval: %@\n polling limit: %@\n", - [self class], [self objectId], [self authenticationUrl], [self pollUrl], [self pollingDelay], [self pollingInterval], [self pollingLimit]]; -} - -#pragma mark - NSCopying - -- (id)copyWithZone:(NSZone *)zone -{ - MASProximityLoginQRCode *qrCode = [super copyWithZone:zone]; - - [qrCode setValue:self.authenticationUrl forKey:@"authenticationUrl"]; - [qrCode setValue:self.pollUrl forKey:@"pollUrl"]; - [qrCode setValue:self.pollingDelay forKey:@"pollingDelay"]; - [qrCode setValue:self.pollingInterval forKey:@"pollingInterval"]; - [qrCode setValue:self.pollingLimit forKey:@"pollingLimit"]; - - return qrCode; -} - - -# pragma mark - NSCoding - -- (void)encodeWithCoder:(NSCoder *)aCoder -{ - [super encodeWithCoder:aCoder]; //ObjectID is encoded in the super class MASObject - - if (self.authenticationUrl) [aCoder encodeObject:self.authenticationUrl forKey:kMASProximityLoginQRCodeAuthenticationUrlKey]; - if (self.pollUrl) [aCoder encodeObject:self.pollUrl forKey:kMASProximityLoginQRCodePollUrlKey]; - if (self.pollingDelay) [aCoder encodeObject:self.pollingDelay forKey:kMASProximityLoginQRCodePollingDelayKey]; - if (self.pollingInterval) [aCoder encodeObject:self.pollingInterval forKey:kMASProximityLoginQRCodePollingIntervalKey]; - if (self.pollingLimit) [aCoder encodeObject:self.pollingLimit forKey:kMASProximityLoginQRCodePollingLimitKey]; -} - - -- (id)initWithCoder:(NSCoder *)aDecoder -{ - if(self = [super initWithCoder:aDecoder]) //ObjectID is decoded in the super class MASObject - { - [self setValue:[aDecoder decodeObjectForKey:kMASProximityLoginQRCodeAuthenticationUrlKey] forKey:@"authenticationUrl"]; - [self setValue:[aDecoder decodeObjectForKey:kMASProximityLoginQRCodePollUrlKey] forKey:@"pollUrl"]; - [self setValue:[aDecoder decodeObjectForKey:kMASProximityLoginQRCodePollingDelayKey] forKey:@"pollingDelay"]; - [self setValue:[aDecoder decodeObjectForKey:kMASProximityLoginQRCodePollingIntervalKey] forKey:@"pollingInterval"]; - [self setValue:[aDecoder decodeObjectForKey:kMASProximityLoginQRCodePollingLimitKey] forKey:@"pollingLimit"]; - } - - return self; -} - - -@end diff --git a/MASFoundation/MASFoundation.h b/MASFoundation/MASFoundation.h index 5fcf1e1a..9cd5edca 100644 --- a/MASFoundation/MASFoundation.h +++ b/MASFoundation/MASFoundation.h @@ -23,7 +23,6 @@ FOUNDATION_EXPORT const unsigned char MASFoundationVersionString[]; // #import #import -#import #import #import #import @@ -49,8 +48,6 @@ FOUNDATION_EXPORT const unsigned char MASFoundationVersionString[]; #import #import #import -#import -#import #import #import #import From 69dcf2c900b3687fa60cffd31a6bab358c2ce50b Mon Sep 17 00:00:00 2001 From: James Go Date: Mon, 22 Apr 2019 15:26:52 -0700 Subject: [PATCH 2/3] US584914 : iOS - Decoupling the BLE into separate module - correcting the signing profile, and removing podspec --- MASFoundation.podspec | 27 ------------------------- MASFoundation.xcodeproj/project.pbxproj | 7 ++++++- 2 files changed, 6 insertions(+), 28 deletions(-) delete mode 100644 MASFoundation.podspec diff --git a/MASFoundation.podspec b/MASFoundation.podspec deleted file mode 100644 index d6461b2c..00000000 --- a/MASFoundation.podspec +++ /dev/null @@ -1,27 +0,0 @@ -Pod::Spec.new do |s| - - s.version = '1.2.02' - s.summary = 'The MASFoundation framework is the core iOS framework upon which Mobile App Service is built.' - s.homepage = "http://mas.ca.com" - s.authors = {'Luis Sanches' => 'luis.sanches@ca.com'} - s.license = {:type => 'MIT', :file => 'LICENSE'} - s.platform = :ios, '8.0' - s.requires_arc = true - s.source = { :git => 'https://github.com/CAAPIM/iOS-MAS-Foundation.git', :tag => s.version.to_s } - - s.subspec 'Classes' do |classes| - classes.public_header_files = 'MASFoundation/Classes/**/*.h' - classes.source_files = 'MASFoundation/Classes/**/*' - end - - s.subspec 'Vendor' do |vendor| - vendor.subspec 'OpenSSL' do |openssl| - openssl.public_header_files = 'MASFoundation/Vendor/**/*.h' - openssl.source_files = 'MASFoundation/Vendor/**/*' - openssl.preserve_paths = 'MASFoundation/Vendor/OpenSSL/include/openssl/*.h' - openssl.vendored_libraries = 'MASFoundation/Vendor/OpenSSL/include/lib/libcrypto_iOS.a', 'MASFoundation/Vendor/OpenSSL/include/lib/libssl_iOS.a' - openssl.libraries = 'ssl_iOS', 'crypto_iOS' - openssl.xcconfig = { 'HEADER_SEARCH_PATHS' => "${PODS_ROOT}/#{s.name}/MASFoundation/Vendor/OpenSSL/include/**" } - end - end -end diff --git a/MASFoundation.xcodeproj/project.pbxproj b/MASFoundation.xcodeproj/project.pbxproj index d65b015c..418edc6a 100644 --- a/MASFoundation.xcodeproj/project.pbxproj +++ b/MASFoundation.xcodeproj/project.pbxproj @@ -1758,7 +1758,7 @@ TargetAttributes = { 1059D36F1B61AA3700223267 = { CreatedOnToolsVersion = 6.4; - ProvisioningStyle = Automatic; + ProvisioningStyle = Manual; }; 1059D37A1B61AA3800223267 = { CreatedOnToolsVersion = 6.4; @@ -1774,6 +1774,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 1059D3661B61AA3700223267; @@ -2116,6 +2117,7 @@ buildSettings = { CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1.9.10; DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; @@ -2151,6 +2153,7 @@ ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.ca.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_OBJC_BRIDGING_HEADER = ""; }; @@ -2161,6 +2164,7 @@ buildSettings = { CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; + CODE_SIGN_STYLE = Manual; CURRENT_PROJECT_VERSION = 1.9.10; DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; @@ -2196,6 +2200,7 @@ ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.ca.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; SWIFT_OBJC_BRIDGING_HEADER = ""; }; From 35dbd52145ec7d18b9cdc4ac90e9e5b89b641b56 Mon Sep 17 00:00:00 2001 From: James Go Date: Thu, 25 Apr 2019 14:54:56 -0700 Subject: [PATCH 3/3] US584914 : iOS - Decoupling the BLE into separate module - Updating README.md and CHANGELOG.md --- CHANGELOG.md | 7 ++++++- README.md | 5 +++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index e0b51af1..871ff128 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,8 @@ +# Version 1.9.20 + +### New features +- Proximity Login feature (BLE and QR Code) is now moved to [MASProximity][MASProximity] framework. No code change is required, and no functionality change was made. In order to use Proxmity Login feature, please include [MASProximity][MASProximity] framework into a project. [US584914] + # Version 1.9.10 ### Bug fixes @@ -228,7 +233,7 @@ None. - . - + [MASProximity]: https://github.com/CAAPIM/iOS-MAS-Proximity [mag]: https://docops.ca.com/mag [mas.ca.com]: http://mas.ca.com/ [docs]: http://mas.ca.com/docs/ diff --git a/README.md b/README.md index 81fc427a..54891da4 100644 --- a/README.md +++ b/README.md @@ -7,9 +7,9 @@ The MASFoundation framework has the following features: - Authentication + OAuth + OIDC - OpenID Connect - + BLE + + BLE (in [MASProximity][MASProximity] SDK) + Dynamic Client ID & Client Secret - + QR Code + + QR Code (in [MASProximity][MASProximity] SDK) + Social Login + Single Sign On + OTP - One Time Password @@ -144,6 +144,7 @@ Copyright (c) 2016 CA. All rights reserved. This software may be modified and distributed under the terms of the MIT license. See the [LICENSE][license-link] file for details. + [MASProximity]: https://github.com/CAAPIM/iOS-MAS-Proximity [mag]: https://docops.ca.com/mag [mas.ca.com]: http://mas.ca.com/ [get-started]: http://mas.ca.com/get-started/