diff --git a/CHANGELOG.md b/CHANGELOG.md index e0b51af1..fe592cb8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,25 @@ +# Version 2.0.00 + +### Bug fixes +- None + +### 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] +- Intermediate Certificate Pinning-Implementation Cordova-iOS [US579432] +- Multipart Form data support (Usage: File Upload) [US605851] +- Ability to specify Timeout parameter for HTTP(S) Requests [US609984] + +### Deprecated methods +- None + +### Removed methods +- None + +# Version 1.9.20 + +### Bug fixes +- ASN.1 Bit String Null Range Handled. [US604884] + # Version 1.9.10 ### Bug fixes @@ -228,11 +250,10 @@ 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/ - [blog]: http://mas.ca.com/blog/ + [techdocs.broadcom.com]: http://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/layer7-api-management/mobile-sdk-for-ca-mobile-api-gateway/2-0.html + [docs]: http://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/layer7-api-management/mobile-sdk-for-ca-mobile-api-gateway/2-0.html [releases]: ../../releases [contributing]: /CONTRIBUTING.md diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3b8d6f13..1951d855 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -21,13 +21,13 @@ Follow these steps for pull requests: 6. If you haven't already, complete the [Contributor License Agreement ("CLA")][cla]. ### Contributor License Agreement ("CLA") -To accept pull requests, submit a CLA. (Submitting a single CLA lets you work on any open source projects from CA, Inc.) +To accept pull requests, submit a CLA. (Submitting a single CLA lets you work on any open source projects from Broadcom, Inc.) Complete your CLA here: ## Bugs -We work hard to avoid them, but they still happen. If you're a CA customer, open an issue in our [Support Page][casupport], otherwise use GitHub issues. -To share ideas or ask product-related questions go to [CA Communities][community]. +We work hard to avoid them, but they still happen. If you're a Broadcom customer, open an issue in our [Support Page][casupport], otherwise use GitHub issues. +To share ideas or ask product-related questions go to [Broadcom Communities][community]. ### Known Issues We also use GitHub issues for updates to known issues, including alerts when fixes are in progress. @@ -48,8 +48,8 @@ By contributing to iOS Mobile SDK, you agree that your contributions will be lic [guidelines]: /GUIDELINES.md -[community]: https://communities.ca.com/community/ca-api-management-community/content?filterID=contentstatus%5Bpublished%5D~category%5Bca-mobile-api-gateway%5D +[community]: https://community.broadcom.com/enterprisesoftware/communities/communityhomeblogs?CommunityKey=0f580f5f-30a4-41de-a75c-e5f433325a18 [license-link]: /LICENSE [cla]: https://www.clahub.com/agreements/CAAPIM/iOS-MAS-Foundation -[casupport]: https://support.ca.com/irj/portal/implsvcnewcase +[casupport]: https://casupport.broadcom.com diff --git a/GUIDELINES.md b/GUIDELINES.md index 28972890..b7b08bb8 100644 --- a/GUIDELINES.md +++ b/GUIDELINES.md @@ -1,4 +1,4 @@ -# CA Technologies Objective-C Style Guide +# Broadcom Objective-C Style Guide This document describes the Objective-C coding style of the iOS Mobile SDK team. This guideline is recommended to comply with all Objective-C implementations of our products. diff --git a/LICENSE b/LICENSE index 56dbc620..a0a95c1a 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,7 @@ The MIT License (MIT) -Copyright (c) 2016 CA. All rights reserved. +Copyright (c) 2019 Broadcom. All Rights Reserved. +The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/LICENSE.md b/LICENSE.md index a54c3d26..d49a6b40 100755 --- a/LICENSE.md +++ b/LICENSE.md @@ -1,7 +1,8 @@ The MIT License (MIT) ===================== -Copyright (c) 2016 CA. All rights reserved. +Copyright (c) 2019 Broadcom. All Rights Reserved. +The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation 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 29f7e848..f77cc0e4 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 */; }; @@ -185,6 +175,8 @@ A4F671331BAFC345000E2223 /* NSString+MASPrivate.m in Sources */ = {isa = PBXBuildFile; fileRef = A4F671311BAFC345000E2223 /* NSString+MASPrivate.m */; }; A858C6651D0978A6001FB9AD /* MASOTPService.h in Headers */ = {isa = PBXBuildFile; fileRef = A858C6631D0978A6001FB9AD /* MASOTPService.h */; }; A858C6661D0978A6001FB9AD /* MASOTPService.m in Sources */ = {isa = PBXBuildFile; fileRef = A858C6641D0978A6001FB9AD /* MASOTPService.m */; }; + A888437E2327858D0005F502 /* MASNetworkConfiguration.h in Headers */ = {isa = PBXBuildFile; fileRef = A888437C2327858C0005F502 /* MASNetworkConfiguration.h */; settings = {ATTRIBUTES = (Public, ); }; }; + A888437F2327858D0005F502 /* MASNetworkConfiguration.m in Sources */ = {isa = PBXBuildFile; fileRef = A888437D2327858C0005F502 /* MASNetworkConfiguration.m */; }; A898EF632182D30A00CF291B /* MASJWTService.m in Sources */ = {isa = PBXBuildFile; fileRef = A898EF612182D30900CF291B /* MASJWTService.m */; }; A898EF642182D30A00CF291B /* MASJWTService.h in Headers */ = {isa = PBXBuildFile; fileRef = A898EF622182D30900CF291B /* MASJWTService.h */; }; A898EF672182D35700CF291B /* MASJWKSet.h in Headers */ = {isa = PBXBuildFile; fileRef = A898EF652182D35700CF291B /* MASJWKSet.h */; }; @@ -195,15 +187,13 @@ 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 */; }; + C8C32B0D22D706B900D64DF0 /* MASMultiPartFormData.h in Headers */ = {isa = PBXBuildFile; fileRef = C8C32B0C22D706B900D64DF0 /* MASMultiPartFormData.h */; settings = {ATTRIBUTES = (Public, ); }; }; + C8C32B1022D7163100D64DF0 /* MASMultiPartRequestSerializer.h in Headers */ = {isa = PBXBuildFile; fileRef = C8C32B0E22D7163100D64DF0 /* MASMultiPartRequestSerializer.h */; }; + C8C32B1122D7163100D64DF0 /* MASMultiPartRequestSerializer.m in Sources */ = {isa = PBXBuildFile; fileRef = C8C32B0F22D7163100D64DF0 /* MASMultiPartRequestSerializer.m */; }; + C8C32B1822D88BF100D64DF0 /* MASPostFormURLRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = C8C32B1622D88BF100D64DF0 /* MASPostFormURLRequest.h */; }; + C8C32B1922D88BF100D64DF0 /* MASPostFormURLRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = C8C32B1722D88BF100D64DF0 /* MASPostFormURLRequest.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 +440,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 +519,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 +545,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 = ""; }; @@ -577,6 +557,8 @@ A4F671311BAFC345000E2223 /* NSString+MASPrivate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+MASPrivate.m"; sourceTree = ""; }; A858C6631D0978A6001FB9AD /* MASOTPService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASOTPService.h; sourceTree = ""; }; A858C6641D0978A6001FB9AD /* MASOTPService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASOTPService.m; sourceTree = ""; }; + A888437C2327858C0005F502 /* MASNetworkConfiguration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASNetworkConfiguration.h; sourceTree = ""; }; + A888437D2327858C0005F502 /* MASNetworkConfiguration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASNetworkConfiguration.m; sourceTree = ""; }; A898EF612182D30900CF291B /* MASJWTService.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MASJWTService.m; sourceTree = ""; }; A898EF622182D30900CF291B /* MASJWTService.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASJWTService.h; sourceTree = ""; }; A898EF652182D35700CF291B /* MASJWKSet.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MASJWKSet.h; sourceTree = ""; }; @@ -587,15 +569,13 @@ 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 = ""; }; + C8C32B0C22D706B900D64DF0 /* MASMultiPartFormData.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MASMultiPartFormData.h; sourceTree = ""; }; + C8C32B0E22D7163100D64DF0 /* MASMultiPartRequestSerializer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MASMultiPartRequestSerializer.h; sourceTree = ""; }; + C8C32B0F22D7163100D64DF0 /* MASMultiPartRequestSerializer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MASMultiPartRequestSerializer.m; sourceTree = ""; }; + C8C32B1622D88BF100D64DF0 /* MASPostFormURLRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MASPostFormURLRequest.h; sourceTree = ""; }; + C8C32B1722D88BF100D64DF0 /* MASPostFormURLRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MASPostFormURLRequest.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 +866,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 = ( @@ -944,6 +911,8 @@ CB5E4C671C1D21FB001B3B8A /* MASPostURLRequest.m */, CB5E4C6E1C1D250D001B3B8A /* MASPutURLRequest.h */, CB5E4C6F1C1D250D001B3B8A /* MASPutURLRequest.m */, + C8C32B1622D88BF100D64DF0 /* MASPostFormURLRequest.h */, + C8C32B1722D88BF100D64DF0 /* MASPostFormURLRequest.m */, ); path = requests; sourceTree = ""; @@ -1102,10 +1071,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 +1087,6 @@ A42157171BF863480034BDC9 /* MASServiceRegistry.h */, A42157181BF863480034BDC9 /* MASServiceRegistry.m */, CB1907F51C17950700A5EF16 /* access */, - A4150EDB1BF16E0F00037E27 /* bluetooth */, A42157231BF864590034BDC9 /* configuration */, A4150EE41BF16E5B00037E27 /* file */, A898EF602182D30900CF291B /* jwt */, @@ -1148,7 +1112,6 @@ 699570E52062FF1300017244 /* MASError.m */, 699570E02060650400017244 /* MASNotifications.h */, 699570E12060650400017244 /* MASNotifications.m */, - CB14D21B1D0228DB004F772E /* MASProximityLoginDelegate.h */, 107389F21C7118F800B7E87E /* MQTT */, A419B39A1C17622E008DC88C /* categories */, A4831A9A1BD1A551007B4AE6 /* models */, @@ -1179,10 +1142,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 +1194,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 */, ); @@ -1286,6 +1243,11 @@ 699C17901F9585BC008C1B11 /* MASRequest.m */, 699C17921F9585BC008C1B11 /* MASRequestBuilder.h */, 699C17931F9585BD008C1B11 /* MASRequestBuilder.m */, + C8C32B0C22D706B900D64DF0 /* MASMultiPartFormData.h */, + C8C32B0E22D7163100D64DF0 /* MASMultiPartRequestSerializer.h */, + C8C32B0F22D7163100D64DF0 /* MASMultiPartRequestSerializer.m */, + A888437C2327858C0005F502 /* MASNetworkConfiguration.h */, + A888437D2327858C0005F502 /* MASNetworkConfiguration.m */, ); path = Network; sourceTree = ""; @@ -1589,6 +1551,7 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( + C8C32B0D22D706B900D64DF0 /* MASMultiPartFormData.h in Headers */, CB2A4048209A341A00F988AA /* MASMultiFactorHandler.h in Headers */, CB1FD14B1FB23701000AFA25 /* MASSharedStorage.h in Headers */, 69B7DF6A1F9675600056DD3A /* MASRequestBuilder.h in Headers */, @@ -1601,12 +1564,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 +1620,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,22 +1638,20 @@ 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 */, + C8C32B1822D88BF100D64DF0 /* MASPostFormURLRequest.h in Headers */, A46F49E51C2F5FC500A4C370 /* UIProgressView+MASINetworking.h in Headers */, A4150E711BF1643900037E27 /* NSMutableURLRequest+MASPrivate.h in Headers */, 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,9 +1685,9 @@ 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 */, + A888437E2327858D0005F502 /* MASNetworkConfiguration.h in Headers */, CB5E4C701C1D250D001B3B8A /* MASPutURLRequest.h in Headers */, CB6491DE1FE9DAF300281288 /* MQTTCFSocketDecoder.h in Headers */, CB9975461EDF5799006CEBB1 /* MASAuthCredentials+MASPrivate.h in Headers */, @@ -1742,6 +1699,7 @@ A47F126C1C1D6B4B0008E3F2 /* MASURLRequest.h in Headers */, CB9B1211210949E1008A2075 /* MASASN1Decoder.h in Headers */, 10D2D49E1C1686ED00DF8AC4 /* MASGroup+MASPrivate.h in Headers */, + C8C32B1022D7163100D64DF0 /* MASMultiPartRequestSerializer.h in Headers */, CB5E4C681C1D21FB001B3B8A /* MASPostURLRequest.h in Headers */, A4150ED41BF16D9A00037E27 /* MASNetworkingService.h in Headers */, CB2357961F0EFDEA00D4C420 /* MASSessionTaskOperation.h in Headers */, @@ -1757,7 +1715,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 */, @@ -1826,7 +1783,7 @@ TargetAttributes = { 1059D36F1B61AA3700223267 = { CreatedOnToolsVersion = 6.4; - ProvisioningStyle = Automatic; + ProvisioningStyle = Manual; }; 1059D37A1B61AA3800223267 = { CreatedOnToolsVersion = 6.4; @@ -1842,6 +1799,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, ); mainGroup = 1059D3661B61AA3700223267; @@ -1886,7 +1844,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "set -e\n\n#---------------\n#Framework Name\n#---------------\n\nFRAMEWORK_NAME=MASFoundation\n\n\n#---------------\n#SDK Directory\n#---------------\n\nSDK_DIR=../iOS_SDK\n\n\n#-----------------------\n#CleanUp Build Cache\n#-----------------------\n\nxcodebuild -project $PROJECT_NAME.xcodeproj -configuration Debug -alltargets clean\nxcodebuild -project $PROJECT_NAME.xcodeproj -configuration Release -alltargets clean\n\n\n#-----------------------\n#CleanUp Previous Builds\n#-----------------------\n\n# Remove the framework from the Project Folder\nrm -Rf \"${PROJECT_DIR}/${FRAMEWORK_NAME}.framework\"\n\n# Remove Build folder from DerivedData\nrm -Rf \"${BUILD_DIR}\"\n\n\n#-----------------------\n#Creating New Builds\n#-----------------------\n\n# define output folder environment variable\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal\nARCHIVE_OUTPUTFOLDER=${OBJROOT}/ArchiveIntermediates/$PROJECT_NAME/IntermediateBuildFilesPath/UninstalledProducts/iphoneos\n\n# Archive framework for iPhoneOS with BitCode enabled\n#xcodebuild -scheme $PROJECT_NAME -configuration Release archive\n\nxcodebuild OTHER_CFLAGS=\"-fembed-bitcode\" -scheme $PROJECT_NAME -configuration Release archive CODE_SIGN_IDENTITY=\"iPhone Distribution: CA, Inc (RAKRWMN9VH)\" -archivePath \"${BUILD_DIR}\"\n\n# Build framework for iPhoneOS\n#xcodebuild -target ${FRAMEWORK_NAME} ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\" CODE_SIGN_IDENTITY=\"iPhone Distribution: CA, Inc (RAKRWMN9VH)\"\n\n# Build framework for iPhoneSimulator\nxcodebuild -target ${FRAMEWORK_NAME} -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\" CODE_SIGN_IDENTITY=\"iPhone Distribution: CA, Inc (RAKRWMN9VH)\"\n\n\n#-----------------------\n#Creating Universal Framework\n#-----------------------\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\nmkdir -p \"${SDK_DIR}\"\n\n\n# Build the universal library\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}\" \"${ARCHIVE_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}\" \"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}\"\n\n# Copy the .framework folder of iphoneos\ncp -R \"${ARCHIVE_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework\" \"${UNIVERSAL_OUTPUTFOLDER}/\"\n\n# Delete the library for iphoneos\nrm \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}\"\n\n# Move the Universal Library into our framework\nmv \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework/\"\n\n# Remove the _CodeSignature from the UniversalFramework\nrm -Rf \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework/_CodeSignature\"\n\n# Copy the framework\ncp -R \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework\" \"${SDK_DIR}\"\n\n#-----------------------\n#Deleting Build Folder\n#-----------------------\n\n# Remove build folder from the Project Folder\nrm -Rf \"${PROJECT_DIR}/build\"\n\n"; + shellScript = "set -e\n\n#---------------\n#Framework Name\n#---------------\n\nFRAMEWORK_NAME=MASFoundation\n\n\n#---------------\n#SDK Directory\n#---------------\n\nSDK_DIR=../iOS_SDK\n\n\n#-----------------------\n#CleanUp Build Cache\n#-----------------------\n\nxcodebuild -project $PROJECT_NAME.xcodeproj -configuration Debug -alltargets clean\nxcodebuild -project $PROJECT_NAME.xcodeproj -configuration Release -alltargets clean\n\n\n#-----------------------\n#CleanUp Previous Builds\n#-----------------------\n\n# Remove the framework from the Project Folder\nrm -Rf \"${PROJECT_DIR}/${FRAMEWORK_NAME}.framework\"\n\n# Remove Build folder from DerivedData\nrm -Rf \"${BUILD_DIR}\"\n\n\n#-----------------------\n#Creating New Builds\n#-----------------------\n\n# define output folder environment variable\nUNIVERSAL_OUTPUTFOLDER=${BUILD_DIR}/${CONFIGURATION}-universal\nARCHIVE_OUTPUTFOLDER=${OBJROOT}/ArchiveIntermediates/$PROJECT_NAME/IntermediateBuildFilesPath/UninstalledProducts/iphoneos\n\n# Archive framework for iPhoneOS with BitCode enabled\n#xcodebuild -scheme $PROJECT_NAME -configuration Release archive\n\nxcodebuild OTHER_CFLAGS=\"-fembed-bitcode\" -scheme $PROJECT_NAME -configuration Release archive CODE_SIGN_IDENTITY=\"iPhone Distribution: CA, Inc\" -archivePath \"${BUILD_DIR}\"\n\n# Build framework for iPhoneOS\n#xcodebuild -target ${FRAMEWORK_NAME} ONLY_ACTIVE_ARCH=NO -configuration ${CONFIGURATION} -sdk iphoneos BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\" CODE_SIGN_IDENTITY=\"iPhone Distribution: CA, Inc (RAKRWMN9VH)\"\n\n# Build framework for iPhoneSimulator\nxcodebuild -target ${FRAMEWORK_NAME} -configuration ${CONFIGURATION} -sdk iphonesimulator BUILD_DIR=\"${BUILD_DIR}\" BUILD_ROOT=\"${BUILD_ROOT}\" CODE_SIGN_IDENTITY=\"iPhone Distribution: CA, Inc (RAKRWMN9VH)\"\n\n\n#-----------------------\n#Creating Universal Framework\n#-----------------------\n\nmkdir -p \"${UNIVERSAL_OUTPUTFOLDER}\"\nmkdir -p \"${SDK_DIR}\"\n\n\n# Build the universal library\nlipo -create -output \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}\" \"${ARCHIVE_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}\" \"${BUILD_DIR}/${CONFIGURATION}-iphonesimulator/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}\"\n\n# Copy the .framework folder of iphoneos\ncp -R \"${ARCHIVE_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework\" \"${UNIVERSAL_OUTPUTFOLDER}/\"\n\n# Delete the library for iphoneos\nrm \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework/${FRAMEWORK_NAME}\"\n\n# Move the Universal Library into our framework\nmv \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}\" \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework/\"\n\n# Remove the _CodeSignature from the UniversalFramework\nrm -Rf \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework/_CodeSignature\"\n\n# Copy the framework\ncp -R \"${UNIVERSAL_OUTPUTFOLDER}/${FRAMEWORK_NAME}.framework\" \"${SDK_DIR}\"\n\n#-----------------------\n#Deleting Build Folder\n#-----------------------\n\n# Remove build folder from the Project Folder\nrm -Rf \"${PROJECT_DIR}/build\"\n\n"; }; 69DE19DB1F8E8A2300F4C7FE /* Log Build Settings */ = { isa = PBXShellScriptBuildPhase; @@ -1900,7 +1858,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/bash; - shellScript = export; + shellScript = "export\n"; }; /* End PBXShellScriptBuildPhase section */ @@ -1911,12 +1869,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 +1902,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 */, @@ -1976,10 +1930,10 @@ 107389F81C7118F800B7E87E /* MASMQTTClient.m in Sources */, 10E027A31F72B10100EAB103 /* RNCryptorEngine.m in Sources */, CBD25AFC1E78C47C00DFB47F /* JWTClaimsSet.m in Sources */, + C8C32B1122D7163100D64DF0 /* MASMultiPartRequestSerializer.m in Sources */, 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 +1957,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 */, @@ -2022,6 +1975,7 @@ A4831AB21BD1A551007B4AE6 /* MASFile.m in Sources */, CB0B585A1E258C2A00BC0163 /* MASAuthorizationResponse.m in Sources */, CB5E4C651C1D1B56001B3B8A /* MASGetURLRequest.m in Sources */, + C8C32B1922D88BF100D64DF0 /* MASPostFormURLRequest.m in Sources */, CB6491FA1FE9DAF300281288 /* MQTTSessionSynchron.m in Sources */, A4831AB01BD1A551007B4AE6 /* MASDevice.m in Sources */, CBD25B001E78C47C00DFB47F /* JWTClaimsSetVerifier.m in Sources */, @@ -2049,7 +2003,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 */, @@ -2065,13 +2018,13 @@ CB1907F91C17950700A5EF16 /* MASAccessService.m in Sources */, CBD25B0A1E78C47C00DFB47F /* JWTCoding.m in Sources */, CBD25B101E78C47C00DFB47F /* JWTErrorDescription.m in Sources */, + A888437F2327858D0005F502 /* MASNetworkConfiguration.m in Sources */, CB5E4C6D1C1D2467001B3B8A /* MASDeleteURLRequest.m in Sources */, A46F49CE1C2F5FC500A4C370 /* MASINetworkReachabilityManager.m in Sources */, A4831AEF1BD1A87C007B4AE6 /* MASAuthenticationProvider+MASPrivate.m in Sources */, 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 */, ); @@ -2192,7 +2145,8 @@ buildSettings = { CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 1.9.10; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 2.0.00; DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; @@ -2227,7 +2181,9 @@ ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.ca.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_OBJC_BRIDGING_HEADER = ""; }; name = Debug; @@ -2237,7 +2193,8 @@ buildSettings = { CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - CURRENT_PROJECT_VERSION = 1.9.10; + CODE_SIGN_STYLE = Manual; + CURRENT_PROJECT_VERSION = 2.0.00; DEAD_CODE_STRIPPING = YES; DEFINES_MODULE = YES; DEVELOPMENT_TEAM = ""; @@ -2272,7 +2229,9 @@ ONLY_ACTIVE_ARCH = NO; PRODUCT_BUNDLE_IDENTIFIER = "com.ca.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + PROVISIONING_PROFILE_SPECIFIER = ""; SKIP_INSTALL = YES; + SUPPORTS_MACCATALYST = NO; SWIFT_OBJC_BRIDGING_HEADER = ""; }; name = Release; @@ -2296,6 +2255,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.ca.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTS_MACCATALYST = NO; }; name = Debug; }; @@ -2314,6 +2274,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "com.ca.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTS_MACCATALYST = NO; }; name = Release; }; @@ -2325,6 +2286,7 @@ ENABLE_BITCODE = YES; MACH_O_TYPE = staticlib; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTS_MACCATALYST = NO; }; name = Debug; }; @@ -2336,6 +2298,7 @@ ENABLE_BITCODE = YES; MACH_O_TYPE = staticlib; PRODUCT_NAME = "$(TARGET_NAME)"; + SUPPORTS_MACCATALYST = NO; }; name = Release; }; diff --git a/MASFoundation/Classes/MAS.h b/MASFoundation/Classes/MAS.h index cf7c56b0..1c4e6e3c 100644 --- a/MASFoundation/Classes/MAS.h +++ b/MASFoundation/Classes/MAS.h @@ -14,6 +14,7 @@ #import "MASClaims.h" #import "MASRequest.h" #import "MASMultiFactorAuthenticator.h" +#import "MASMultiPartFormData.h" /** * The top level MAS object represents the Mobile App Services SDK in it's entirety. It @@ -1059,6 +1060,34 @@ withParameters:(NSDictionary *_Nullable)parameterInfo +# pragma mark - FILE Requests + +/** + * Post a multi-part form with the parameters defined in the MASRequest object + * + * If endPointPath is full URL format (including port number and http protocol), SDK will validate the server from the client side through SSL pinning (authentication challenge) with + * provided subjectKeyHash (also known as public key hash) in configuration in mag.mobile_sdk.trusted_cert_pinned_public_key_hashes and mag.mobile_sdk.enable_public_key_pinning. + * ALL of servers' public key hashes in certificate chain must be defined in the list. This means when it is configured to use public key hash pinning for SSL pinning, + * subjectKeyHash (public key hash) of the gateway must be also present within the list. The list can contain multiple hash values in array for multiple servers. + * + * When SDK fails to validate SSL with certificate or subjectKeyHash pinning for communication to HTTPs, SDK will cancel the request. + * + * If endPointPath is full URL format, upon successful SSL pinning validation, SDK will also validate the user session against primary gateway regardless the request is being made + * to the primary gateway or not. To ensure bypass the user session validation for public API, use [MAS deleteFrom:withParameters:requestType:responseType:isPublic:completion:] method + * with isPublic being YES. + * + * The API appends the file data and any other parameters to the body and follows the standards defined for Content-Type = multipart/form-data + * + * @param request MASRequest An object containing all parameters to call the endpoint + * When the value is set to true, all automatically injected credentials in SDK will be excluded in the request. + * @param formDataBlock This is a block that gets called while constructing the body of the multi-part form request. Typically files can be added to the body by calling various APIs available in MASMultiPartFormData + * @see MASMultiPartFormData + * @param progressBlock Block which gives back the NSProgress of the task that is going on. Different values can be read from the progress object to present a meaningful progress updates in the UI. Recommend to use progress.fractioncompleted for progress bar updates. + * @param completion An MASResponseObjectErrorBlock (NSHTTPURLResponse *response, id responseObject, NSError *error) that will + * receive the NSHTTPURLResponse object, response object which needs to perform type casting based on the object type, and NSError object when error occurs. + */ ++ (void)postMultiPartForm:(nonnull MASRequest *)request constructingBodyWithBlock:(nonnull MASMultiPartFormDataBlock)formDataBlock progress:( MASFileRequestProgressBlock _Nullable )progressBlock completion:(nullable MASResponseObjectErrorBlock)completion; + ///-------------------------------------- /// @name JWT Signing ///-------------------------------------- diff --git a/MASFoundation/Classes/MAS.m b/MASFoundation/Classes/MAS.m index 367c873a..0521c675 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" @@ -642,7 +641,7 @@ + (void)startWithURL:(NSURL *)url completion:(MASCompletionErrorBlock)completion withParameters:urlParameters andHeaders:nil requestType:MASRequestResponseTypeJson - responseType:MASRequestResponseTypeJson isPublic:YES]; + responseType:MASRequestResponseTypeJson isPublic:YES timeoutInterval:MASDefaultNetworkTimeoutConfiguration]; MASSessionDataTaskOperation *dataTaskOperation = [urlSessionManager dataOperationWithRequest:request completionHandler:^(NSURLResponse * _Nonnull response, id _Nonnull responseObject, NSError * _Nonnull error) { if (error) @@ -927,7 +926,8 @@ + (void)deleteFrom:(NSString *)endPoint isPublic:(BOOL)isPublic completion:(MASResponseInfoErrorBlock)completion { - [MAS httpMethod:@"DELETE" endPoint:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:requestType responseType:responseType isPublic:isPublic completion:[MAS parseToEjectURLResponseForCompletionBlock:completion]]; + [MAS httpMethod:@"DELETE" endPoint:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:[self timeoutIntervalForEndpoint:endPoint] + completion:[MAS parseToEjectURLResponseForCompletionBlock:completion]]; } @@ -972,7 +972,8 @@ + (void)getFrom:(NSString *)endPoint isPublic:(BOOL)isPublic completion:(MASResponseInfoErrorBlock)completion { - [MAS httpMethod:@"GET" endPoint:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:requestType responseType:responseType isPublic:isPublic completion:[MAS parseToEjectURLResponseForCompletionBlock:completion]]; + [MAS httpMethod:@"GET" endPoint:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:[self timeoutIntervalForEndpoint:endPoint] + completion:[MAS parseToEjectURLResponseForCompletionBlock:completion]]; } @@ -1016,7 +1017,8 @@ + (void)patchTo:(NSString *)endPoint isPublic:(BOOL)isPublic completion:(MASResponseInfoErrorBlock)completion { - [MAS httpMethod:@"PATCH" endPoint:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:requestType responseType:responseType isPublic:isPublic completion:[MAS parseToEjectURLResponseForCompletionBlock:completion]]; + [MAS httpMethod:@"PATCH" endPoint:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:[self timeoutIntervalForEndpoint:endPoint] + completion:[MAS parseToEjectURLResponseForCompletionBlock:completion]]; } @@ -1060,7 +1062,8 @@ + (void)postTo:(NSString *)endPoint isPublic:(BOOL)isPublic completion:(MASResponseInfoErrorBlock)completion { - [MAS httpMethod:@"POST" endPoint:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:requestType responseType:responseType isPublic:isPublic completion:[MAS parseToEjectURLResponseForCompletionBlock:completion]]; + [MAS httpMethod:@"POST" endPoint:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:[self timeoutIntervalForEndpoint:endPoint] + completion:[MAS parseToEjectURLResponseForCompletionBlock:completion]]; } @@ -1104,7 +1107,8 @@ + (void)putTo:(nonnull NSString *)endPoint isPublic:(BOOL)isPublic completion:(nullable MASResponseInfoErrorBlock)completion { - [MAS httpMethod:@"PUT" endPoint:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:requestType responseType:responseType isPublic:isPublic completion:[MAS parseToEjectURLResponseForCompletionBlock:completion]]; + [MAS httpMethod:@"PUT" endPoint:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:[self timeoutIntervalForEndpoint:endPoint] + completion:[MAS parseToEjectURLResponseForCompletionBlock:completion]]; } @@ -1112,6 +1116,11 @@ + (void)invoke:(nonnull MASRequest *)request completion:(nullable MASResponseObj { __block MASResponseObjectErrorBlock blockCompletion = completion; + // If default timeoutInterval override to NetworkConfiguration timeoutInterval. + NSTimeInterval timeoutInterval = + (request.timeoutInterval == MASDefaultNetworkTimeoutConfiguration) ? + [self timeoutIntervalForEndpoint:request.endPoint] : request.timeoutInterval; + [MAS httpMethod:request.httpMethod endPoint:request.endPoint withParameters:request.body @@ -1119,6 +1128,7 @@ + (void)invoke:(nonnull MASRequest *)request completion:(nullable MASResponseObj requestType:request.requestType responseType:request.responseType isPublic:request.isPublic + timeoutInterval:request.timeoutInterval completion:^(NSDictionary * _Nullable responseInfo, NSError * _Nullable error) { if (blockCompletion) @@ -1129,8 +1139,71 @@ + (void)invoke:(nonnull MASRequest *)request completion:(nullable MASResponseObj } ++ (void)postMultiPartForm:(nonnull MASRequest *)request constructingBodyWithBlock:(nonnull MASMultiPartFormDataBlock)formDataBlock progress:( MASFileRequestProgressBlock _Nullable )progressBlock completion:(nullable MASResponseObjectErrorBlock)completion +{ + if(![request.httpMethod isEqualToString:@"POST"] || request.requestType != MASRequestResponseTypeFormData) + { + NSError* error = [NSError errorInvalidRequestForFileUpload]; + completion(nil,nil,error); + return; + } + + [MAS checkAndValidateRequestScope:request.endPoint headerInfo:request.header isPublic:request.isPublic completion:^(BOOL completed, NSError *error) { + + if(!completed){ + completion(nil,nil,error); + return; + } + + // If default timeoutInterval override to NetworkConfiguration timeoutInterval. + NSTimeInterval timeoutInterval = + (request.timeoutInterval == MASDefaultNetworkTimeoutConfiguration) ? + [self timeoutIntervalForEndpoint:request.endPoint] : request.timeoutInterval; + + [[MASNetworkingService sharedService] postMultiPartForm:request.endPoint withParameters:request.body andHeaders:request.header requestType:request.requestType responseType:request.responseType isPublic:request.isPublic timeoutInterval:timeoutInterval constructingBodyBlock:formDataBlock progress:progressBlock completion:completion]; + + }]; +} + + # pragma mark - Private ++ (void)checkAndValidateRequestScope:(NSString*)endPoint headerInfo:(NSDictionary *)headerInfo isPublic:(BOOL)isPublic completion:(MASCompletionErrorBlock)completion +{ + // + // Check for endpoint + // + if (!endPoint) + { + if (completion) + { + completion(NO, [NSError errorInvalidEndpoint]); + + return; + } + } + + // + // Check if MAS has been started. + // + if ([MAS MASState] != MASStateDidStart) + { + if (completion) + { + completion(NO, [NSError errorMASIsNotStarted]); + + return; + } + } + + // + // Validate if new scope has been requested in header + // Validation will be ignored if the request is being made as public + // + [MAS validateScopeForRequest:headerInfo isPublic:isPublic completion:completion]; + +} + + (void)httpMethod:(NSString *)httpMethod endPoint:(NSString *)endPoint withParameters:(NSDictionary *)parameterInfo @@ -1138,6 +1211,7 @@ + (void)httpMethod:(NSString *)httpMethod requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval completion:(MASResponseInfoErrorBlock)completion { // @@ -1174,6 +1248,7 @@ + (void)httpMethod:(NSString *)httpMethod __block MASRequestResponseType blockRequestType = requestType; __block MASRequestResponseType blockResponseType = responseType; __block BOOL blockIsPublic = isPublic; + __block NSTimeInterval blockTimeoutInterval = timeoutInterval; // // Validate if new scope has been requested in header @@ -1192,6 +1267,7 @@ + (void)httpMethod:(NSString *)httpMethod requestType:blockRequestType responseType:blockResponseType isPublic:blockIsPublic + timeoutInterval:blockTimeoutInterval completion:[MAS parseTargetAPIErrorForCompletionBlock:blockCompletion]]; } else if ([blockHttpMethod isEqualToString:@"GET"]) @@ -1202,6 +1278,7 @@ + (void)httpMethod:(NSString *)httpMethod requestType:blockRequestType responseType:blockResponseType isPublic:blockIsPublic + timeoutInterval:blockTimeoutInterval completion:[MAS parseTargetAPIErrorForCompletionBlock:blockCompletion]]; } else if ([blockHttpMethod isEqualToString:@"PATCH"]) @@ -1212,6 +1289,7 @@ + (void)httpMethod:(NSString *)httpMethod requestType:blockRequestType responseType:blockResponseType isPublic:blockIsPublic + timeoutInterval:blockTimeoutInterval completion:[MAS parseTargetAPIErrorForCompletionBlock:blockCompletion]]; } else if ([blockHttpMethod isEqualToString:@"POST"]) @@ -1222,6 +1300,7 @@ + (void)httpMethod:(NSString *)httpMethod requestType:blockRequestType responseType:blockResponseType isPublic:blockIsPublic + timeoutInterval:blockTimeoutInterval completion:[MAS parseTargetAPIErrorForCompletionBlock:blockCompletion]]; } else if ([blockHttpMethod isEqualToString:@"PUT"]) @@ -1232,6 +1311,7 @@ + (void)httpMethod:(NSString *)httpMethod requestType:blockRequestType responseType:blockResponseType isPublic:blockIsPublic + timeoutInterval:blockTimeoutInterval completion:[MAS parseTargetAPIErrorForCompletionBlock:blockCompletion]]; } }]; @@ -1404,6 +1484,27 @@ + (BOOL)isPublicForEndpoint:(NSString *)endPoint } ++ (NSTimeInterval)timeoutIntervalForEndpoint:(NSString *)endPoint +{ + NSTimeInterval timeoutInterval = MASDefaultNetworkTimeoutConfiguration; + + NSURL *endpointURL = [NSURL URLWithString:endPoint]; + if (endpointURL.scheme && endpointURL.host) + { + MASNetworkConfiguration *networkConfiguration = [MASConfiguration networkConfigurationForDomain:[NSURL URLWithString:[NSString stringWithFormat:@"%@://%@:%@", endpointURL.scheme, endpointURL.host, endpointURL.port]]]; + timeoutInterval = networkConfiguration.timeoutInterval; + } + else if ([MASConfiguration currentConfiguration]) + { + NSURL *gatewayURL = [MASConfiguration currentConfiguration].gatewayUrl; + MASNetworkConfiguration *networkConfiguration = [MASConfiguration networkConfigurationForDomain:[NSURL URLWithString:[NSString stringWithFormat:@"%@://%@:%@", gatewayURL.scheme, gatewayURL.host, gatewayURL.port]]]; + timeoutInterval = networkConfiguration.timeoutInterval; + } + + return timeoutInterval; +} + + # pragma mark - JWT Signing + (NSString * _Nullable)signWithClaims:(MASClaims *_Nonnull)claims error:(NSError *__nullable __autoreleasing *__nullable)error @@ -1518,19 +1619,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/MASConstants.h b/MASFoundation/Classes/MASConstants.h index 92b994ed..1dcec58f 100644 --- a/MASFoundation/Classes/MASConstants.h +++ b/MASFoundation/Classes/MASConstants.h @@ -13,6 +13,7 @@ @class CLLocation; @class MASAuthCredentials; @class MASUser; +@protocol MASMultiPartFormData; /** @@ -113,6 +114,16 @@ typedef void (^MASResponseObjectErrorBlock)(NSHTTPURLResponse *_Nullable respons */ typedef void (^MASUserResponseErrorBlock)(MASUser *_Nullable user, NSError *_Nullable error); +/** + * Progress block for File requests + */ +typedef void (^MASFileRequestProgressBlock) (NSProgress* _Nullable progress); + + +/** + * Multi Part body data that needs to be supplied + */ +typedef void (^MASMultiPartFormDataBlock)(id _Nonnull formData); /** * The MASAuthCredentialsBlcok to provide auth credentials for device registration and/or user authentication. @@ -240,6 +251,11 @@ typedef NS_ENUM(NSInteger, MASRequestResponseType) */ MASRequestResponseTypeXml, + /** + * Standard Multi-part form data + */ + MASRequestResponseTypeFormData, + /** * The total number of supported types. */ diff --git a/MASFoundation/Classes/MASError.h b/MASFoundation/Classes/MASError.h index 4ec5fe19..ea6bfe60 100644 --- a/MASFoundation/Classes/MASError.h +++ b/MASFoundation/Classes/MASError.h @@ -99,6 +99,11 @@ typedef NS_ENUM(NSInteger, MASFoundationErrorCode) MASFoundationErrorCodeResponseSerializationFailedToParseResponse = 100407, MASFoundationErrorCodeNetworkSSLAuthenticationChallengeFailure = 100408, + // + // Network Configuration + // + MASFoundationErrorCodeConfigurationInvalidHostForNetworkConfiguration = 100501, + // // Application // @@ -162,34 +167,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 // @@ -226,6 +203,11 @@ typedef NS_ENUM(NSInteger, MASFoundationErrorCode) MASFoundationErrorCodeMultiFactorAuthenticationCancelled = 180002, MASFoundationErrorCodeMultiFactorAuthenticationInvalidRequest = 180003, + // + // File Request Errors + // + MASFoundationErrorCodeInvalidRequestForFileUpload = 180100, + MASFoundationErrorCodeCount = -999999 }; 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..931bbb17 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"; @@ -207,6 +204,9 @@ static NSString *_Nonnull const MASUserPhoneRequestResponseKey = @"phone_number" static NSString *_Nonnull const MASUserPictureRequestResponseKey = @"picture"; // string static NSString *_Nonnull const MASUserRefreshTokenRequestResponseKey = @"refresh_token"; // string +// Default network timeout configuration. +static int const MASDefaultNetworkTimeoutConfiguration = 60; + # pragma mark - GrantType Constants @@ -334,12 +334,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..dc59163f 100644 --- a/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.h +++ b/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.h @@ -640,29 +640,20 @@ /** - * Create MASFoundationErrorDomainLocal NSError for MASFoundationErrorCodeProximityLoginAuthorizationInProgress. - * - * @return Returns an NSError instance with the domain MASFoundationErrorDomainLocal and - * error MASFoundationErrorCodeProximityLoginAuthorizationInProgress. - */ -+ (NSError *)errorProximityLoginAuthorizationInProgress; - - -/** - * Create MASFoundationErrorDomainLocal NSError for MASFoundationErrorCodeProximityLoginInvalidAuthorizeURL. + * Create MASFoundationErrorDomainLocal NSError for MASFoundationErrorCodeBBANotEnabled. * - * @return Returns an NSError instance with the domain MASFoundationErrorDomainLocal and - * error MASFoundationErrorCodeProximityLoginInvalidAuthorizeURL + * @return Returns an NSError instance with the domain MASFoundationErrorDomainLocal and + * error MASFoundationErrorCodeBBANotEnabled */ -+ (NSError *)errorProximityLoginInvalidAuthroizeURL; ++ (NSError *)errorBrowserBasedAuthenticaionNotEnabled; /** - * Create MASFoundationErrorDomainLocal NSError for MASFoundationErrorCodeBBANotEnabled. + * Create MASFoundationErrorDomainLocal NSError for MASFoundationErrorCodeInvalidRequestForFileUpload. * * @return Returns an NSError instance with the domain MASFoundationErrorDomainLocal and - * error MASFoundationErrorCodeBBANotEnabled + * error MASFoundationErrorCodeInvalidRequestForFileUpload */ -+ (NSError *)errorBrowserBasedAuthenticaionNotEnabled; ++ (NSError *)errorInvalidRequestForFileUpload; @end diff --git a/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.m b/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.m index a1733719..173bdbcc 100644 --- a/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.m +++ b/MASFoundation/Classes/_private_/categories/NSError+MASPrivate.m @@ -828,21 +828,14 @@ + (NSError *)errorInvalidEndpoint } -+ (NSError *)errorProximityLoginAuthorizationInProgress ++ (NSError *)errorBrowserBasedAuthenticaionNotEnabled { - return [self errorForFoundationCode:MASFoundationErrorCodeProximityLoginAuthorizationInProgress errorDomain:MASFoundationErrorDomainLocal]; + return [self errorForFoundationCode:MASFoundationErrorCodeBBANotEnabled errorDomain:MASFoundationErrorDomainLocal]; } - -+ (NSError *)errorProximityLoginInvalidAuthroizeURL ++ (NSError *)errorInvalidRequestForFileUpload { - return [self errorForFoundationCode:MASFoundationErrorCodeProximityLoginInvalidAuthorizeURL errorDomain:MASFoundationErrorDomainLocal]; -} - - -+ (NSError *)errorBrowserBasedAuthenticaionNotEnabled -{ - return [self errorForFoundationCode:MASFoundationErrorCodeBBANotEnabled errorDomain:MASFoundationErrorDomainLocal]; + return [self errorForFoundationCode:MASFoundationErrorCodeInvalidRequestForFileUpload errorDomain:MASFoundationErrorDomainLocal]; } @@ -1001,6 +994,11 @@ + (NSString *)descriptionForFoundationErrorCode:(MASFoundationErrorCode)errorCod case MASFoundationErrorCodeConfigurationInvalidHostForSecurityConfiguration: return @"Invalid host information for security configuration. NSURL host or port cannot be nil."; case MASFoundationErrorCodeConfigurationInvalidPinningInfoForSecurityConfiguration: return @"Invalid pinning information for security configuration. At least one pinning information should be provided or public PKI should be trusted."; + // + // Network Configuration + // + case MASFoundationErrorCodeConfigurationInvalidHostForNetworkConfiguration: return @"Invalid host information for network configuration. NSURL host or port cannot be nil."; + // // Device // @@ -1086,34 +1084,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 // @@ -1137,6 +1108,12 @@ + (NSString *)descriptionForFoundationErrorCode:(MASFoundationErrorCode)errorCod case MASFoundationErrorCodeMultiFactorAuthenticationCancelled : return @"Multi factor authentication process has been cancelled."; case MASFoundationErrorCodeMultiFactorAuthenticationInvalidRequest : return @"Invalid request for multi factor authentication."; + // + // File Request Errors + // + + case MASFoundationErrorCodeInvalidRequestForFileUpload : return @"the MASRequest is not valid for multi-part file upload. Please check if the request is of method POST and the request type is MASRequestResponseTypeFormData."; + // // Default // diff --git a/MASFoundation/Classes/_private_/categories/NSMutableURLRequest+MASPrivate.h b/MASFoundation/Classes/_private_/categories/NSMutableURLRequest+MASPrivate.h index 043e0991..20af507a 100644 --- a/MASFoundation/Classes/_private_/categories/NSMutableURLRequest+MASPrivate.h +++ b/MASFoundation/Classes/_private_/categories/NSMutableURLRequest+MASPrivate.h @@ -17,6 +17,7 @@ extern NSString * const MASRequestResponseTypeScimJsonValue; extern NSString * const MASRequestResponseTypeTextPlainValue; extern NSString * const MASRequestResponseTypeWwwFormUrlEncodedValue; extern NSString * const MASRequestResponseTypeXmlValue; +extern NSString * const MASRequestResponseTypeFormDataValue; @interface NSMutableURLRequest (MASPrivate) diff --git a/MASFoundation/Classes/_private_/categories/NSMutableURLRequest+MASPrivate.m b/MASFoundation/Classes/_private_/categories/NSMutableURLRequest+MASPrivate.m index 468212b9..c1f646f1 100644 --- a/MASFoundation/Classes/_private_/categories/NSMutableURLRequest+MASPrivate.m +++ b/MASFoundation/Classes/_private_/categories/NSMutableURLRequest+MASPrivate.m @@ -69,6 +69,8 @@ - (NSString *)requestResponseTypeAsMimeTypeString:(MASRequestResponseType)type // XML // case MASRequestResponseTypeXml: return MASRequestResponseTypeXmlValue; + + case MASRequestResponseTypeFormData : return MASRequestResponseTypeFormDataValue; // // Default @@ -100,6 +102,8 @@ - (MASRequestResponseType)requestResponseTypeFromMimeTypeString:(NSString *)mime // else if([mimeType isEqualToString:MASRequestResponseTypeXmlValue]) return MASRequestResponseTypeXml; + + else if([mimeType isEqualToString:MASRequestResponseTypeFormDataValue]) return MASRequestResponseTypeFormData; // // Default to text/plain // 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_/models/MASSecurityConfiguration+MASPrivate.h b/MASFoundation/Classes/_private_/models/MASSecurityConfiguration+MASPrivate.h index f2acfdb0..27a27150 100644 --- a/MASFoundation/Classes/_private_/models/MASSecurityConfiguration+MASPrivate.h +++ b/MASFoundation/Classes/_private_/models/MASSecurityConfiguration+MASPrivate.h @@ -18,7 +18,6 @@ - (NSArray *)convertCertificatesToData; - /** Converts MASSecurityConfiguration's array of certificate array into array of SecCertificateRef diff --git a/MASFoundation/Classes/_private_/models/MASSecurityConfiguration+MASPrivate.m b/MASFoundation/Classes/_private_/models/MASSecurityConfiguration+MASPrivate.m index a7a49e2f..f73bccae 100644 --- a/MASFoundation/Classes/_private_/models/MASSecurityConfiguration+MASPrivate.m +++ b/MASFoundation/Classes/_private_/models/MASSecurityConfiguration+MASPrivate.m @@ -23,7 +23,7 @@ - (NSArray *)convertCertificatesToData { NSData *certificateAsData = [NSData pemDataFromCertificateArray:certificate]; - if (certificateAsData) + if (certificateAsData && [certificateAsData length]) { [certsAsData addObject:certificateAsData]; } @@ -32,12 +32,12 @@ - (NSArray *)convertCertificatesToData { NSData *certificateAsData = [NSData dataFromPEMBase64String:certificate]; - if (certificateAsData) + if (certificateAsData && [certificateAsData length]) { [certsAsData addObject:certificateAsData]; } } - else if ([certificate isKindOfClass:[NSData class]]) + else if ([certificate isKindOfClass:[NSData class]] && [certificate length]) { [certsAsData addObject:certificate]; } @@ -47,6 +47,7 @@ - (NSArray *)convertCertificatesToData } + - (NSArray *)convertCertificatesToSecCertificateRef { NSMutableArray *certAsData = [[self convertCertificatesToData] mutableCopy]; diff --git a/MASFoundation/Classes/_private_/models/Network/MASRequest+MASPrivate.m b/MASFoundation/Classes/_private_/models/Network/MASRequest+MASPrivate.m index 746cadce..80289881 100644 --- a/MASFoundation/Classes/_private_/models/Network/MASRequest+MASPrivate.m +++ b/MASFoundation/Classes/_private_/models/Network/MASRequest+MASPrivate.m @@ -23,6 +23,7 @@ @interface MASRequest () @property (assign, readwrite) BOOL sign; @property (assign, readwrite) MASRequestResponseType requestType; @property (assign, readwrite) MASRequestResponseType responseType; +@property (assign, readwrite) NSTimeInterval timeoutInterval; @end @@ -48,6 +49,7 @@ - (instancetype)initWithBuilder:(MASRequestBuilder *)builder self.header = builder.header; self.body = builder.body; self.query = builder.query; + self.timeoutInterval = builder.timeoutInterval; // 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/_private_/services/configuration/MASConfigurationService.h b/MASFoundation/Classes/_private_/services/configuration/MASConfigurationService.h index 31e42df9..a6156105 100644 --- a/MASFoundation/Classes/_private_/services/configuration/MASConfigurationService.h +++ b/MASFoundation/Classes/_private_/services/configuration/MASConfigurationService.h @@ -17,6 +17,51 @@ @interface MASConfigurationService : MASService + +///-------------------------------------- +/// @name Network Configuration +///-------------------------------------- + +# pragma mark - Network Configuration + +/** +Sets network timeout for specified host in MASNetworkConfiguration object + +@warning Upon SDK initialization, [MASConfiguration currentConfiguration].gatewayUrl's MASNetworkConfiguration object will be overwritten. If primary gateway's network configuration has to be modified, ensure to set network configuration after SDK initialization. +@param networkConfiguration MASNetworkConfiguration object with host, and network configuration values. +*/ ++ (void)setNetworkConfiguration:(MASNetworkConfiguration *)networkConfiguration; + + + +/** + Removes network configuration object based on the domain. + + @param domain NSURL of the domain to delete network configuration. + */ ++ (void)removeNetworkConfigurationForDomain:(NSURL *)domain; + + + +/** + Returns an array of MASNetworkConfiguration objects for each host. + + @return Returns an array of currently active MASNetworkConfigurations. + */ ++ (NSArray *)networkConfigurations; + + + +/** + Returns MASNetworkConfiguration object for a specific domain. + + @param domain NSURL of the domain for the MASNetworkConfiguration object. + @return Returns a MASNetworkConfiguration object for the domain. + */ ++ (MASNetworkConfiguration *)networkConfigurationForDomain:(NSURL *)domain; + + + ///-------------------------------------- /// @name Security Configuration ///-------------------------------------- diff --git a/MASFoundation/Classes/_private_/services/configuration/MASConfigurationService.m b/MASFoundation/Classes/_private_/services/configuration/MASConfigurationService.m index 42a67cf9..0f0aa643 100644 --- a/MASFoundation/Classes/_private_/services/configuration/MASConfigurationService.m +++ b/MASFoundation/Classes/_private_/services/configuration/MASConfigurationService.m @@ -18,6 +18,7 @@ @implementation MASConfigurationService static NSString *_configurationFileType_ = @"json"; static NSDictionary *_newConfigurationObject_ = nil; static BOOL _newConfigurationDetected_ = NO; +static NSMutableDictionary *_networkConfigurations_; static NSMutableDictionary *_securityConfigurations_; static BOOL _enableIdTokenValidation_ = YES; @@ -80,6 +81,42 @@ + (NSDictionary *)getDefaultConfigurationAsDictionary } +# pragma mark - Network Configuration + ++ (void)setNetworkConfiguration:(MASNetworkConfiguration *)networkConfiguration +{ + if (!_networkConfigurations_) + { + _networkConfigurations_ = [NSMutableDictionary dictionary]; + } + + if ([networkConfiguration.host absoluteString]) + { + [_networkConfigurations_ setObject:networkConfiguration forKey:[networkConfiguration.host absoluteString]]; + } +} + + ++ (void)removeNetworkConfigurationForDomain:(NSURL *)domain +{ + NSURL *thisDomain = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@:%@", domain.scheme, domain.host, domain.port]]; + [_networkConfigurations_ removeObjectForKey:[thisDomain absoluteString]]; +} + + ++ (NSArray *)networkConfigurations +{ + return _networkConfigurations_ ? [_networkConfigurations_ allValues] : nil; +} + + ++ (MASNetworkConfiguration *)networkConfigurationForDomain:(NSURL *)domain +{ + NSURL *thisDomain = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@:%@", domain.scheme, domain.host, domain.port]]; + return thisDomain ? [_networkConfigurations_ objectForKey:[thisDomain absoluteString]] : nil; +} + + # pragma mark - Security Configuration + (void)setSecurityConfiguration:(MASSecurityConfiguration *)securityConfiguration @@ -281,10 +318,18 @@ - (void)serviceWillStart } } + + NSURL *currentURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@:%@", _currentConfiguration.gatewayUrl.scheme, _currentConfiguration.gatewayHostName, _currentConfiguration.gatewayPort]]; + + // + // Construct and set MASNetworkConfiguration for the primary gateway + // + MASNetworkConfiguration *defaultNetworkConfiguration = [[MASNetworkConfiguration alloc] initWithURL:currentURL]; + [MASConfiguration setNetworkConfiguration:defaultNetworkConfiguration error:nil]; + // // Construct and set MASSecurityConfiguration for the primary gateway // - NSURL *currentURL = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@:%@", _currentConfiguration.gatewayUrl.scheme, _currentConfiguration.gatewayHostName, _currentConfiguration.gatewayPort]]; MASSecurityConfiguration *defaultSecurityConfiguration = [[MASSecurityConfiguration alloc] initWithURL:currentURL]; defaultSecurityConfiguration.trustPublicPKI = _currentConfiguration.enabledTrustedPublicPKI; defaultSecurityConfiguration.publicKeyHashes = _currentConfiguration.trustedCertPinnedPublicKeyHashes; diff --git a/MASFoundation/Classes/_private_/services/jwt/MASJWTService.m b/MASFoundation/Classes/_private_/services/jwt/MASJWTService.m index 32e66603..c4769655 100644 --- a/MASFoundation/Classes/_private_/services/jwt/MASJWTService.m +++ b/MASFoundation/Classes/_private_/services/jwt/MASJWTService.m @@ -167,6 +167,7 @@ - (void)loadJWKSAsynchronously:(BOOL)async completion:(MASCompletionErrorBlock)c requestType:MASRequestResponseTypeJson responseType:MASRequestResponseTypeJson isPublic:YES + timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion: ^(NSDictionary * _Nullable responseInfo, NSError * _Nullable error) { @@ -191,6 +192,7 @@ - (void)loadJWKSAsynchronously:(BOOL)async completion:(MASCompletionErrorBlock)c requestType:MASRequestResponseTypeJson responseType:MASRequestResponseTypeJson isPublic:YES + timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion: ^(NSDictionary * _Nullable responseInfo, NSError * _Nullable error) { diff --git a/MASFoundation/Classes/_private_/services/network/MASNetworkingService.h b/MASFoundation/Classes/_private_/services/network/MASNetworkingService.h index c9da95d5..ecca1591 100644 --- a/MASFoundation/Classes/_private_/services/network/MASNetworkingService.h +++ b/MASFoundation/Classes/_private_/services/network/MASNetworkingService.h @@ -276,6 +276,40 @@ typedef NSURLRequest* (^MASSessionDataTaskHTTPRedirectBlock)(NSURLSession *sessi completion:(MASResponseInfoErrorBlock)completion; +/** +* Request method for an HTTP DELETE call from the Gateway. This type of HTTP Method type +* places it's parameters within the NSURL itself as an HTTP query extension as so: +* +* https://:/ +* +* @param endPointPath The specific end point path fragment NSString to append to the base +* Gateway URL. +* @param parameterInfo An NSDictionary of key/value parameter values that will go into the +* query portion of the URL. +* @param headerInfo An NSDictionary of key/value header values that will go into the HTTP +* header. +* @param requestType The expected content type encoding for the parameter values. +* @param responseType The expected content type encoding for any response data. +* @param isPublic Represents whether to include or exclude necessary credentials of MAG to inject in the header of the request. +* @param timeoutInterval Represents the request's timeout interval, in seconds. +* @param completion An MASResponseInfoErrorBlock type (NSDictionary *responseInfo, NSError *error) that will +* receive the NSDictionary responseInfo and an NSError object if there is a failure. +* +* The responseInfo can have two keys: +* +* MASResponseInfoHeaderInfoKey: the value will be an NSDictionary of key/value pairs from the HTTP header. +* MASResponseInfoBodyInfoKey: the value will be an NSObject of some kind that is expected in the body of +* the particular request (optional) +*/ +- (void)deleteFrom:(NSString *)endPoint +withParameters:(NSDictionary *)parameterInfo + andHeaders:(NSDictionary *)headerInfo + requestType:(MASRequestResponseType)requestType + responseType:(MASRequestResponseType)responseType + isPublic:(BOOL)isPublic +timeoutInterval:(NSTimeInterval)timeoutInterval + completion:(MASResponseInfoErrorBlock)completion; + /** * Request method for an HTTP GET call from the Gateway. This type of HTTP Method type * places it's parameters within the NSURL itself as an HTTP query extension as so: @@ -369,6 +403,41 @@ typedef NSURLRequest* (^MASSessionDataTaskHTTPRedirectBlock)(NSURLSession *sessi completion:(MASResponseInfoErrorBlock)completion; +/** +* Request method for an HTTP GET call from the Gateway. This type of HTTP Method type +* places it's parameters within the NSURL itself as an HTTP query extension as so: +* +* https://:/ +* +* @param endPointPath The specific end point path fragment NSString to append to the base +* Gateway URL. +* @param parameterInfo An NSDictionary of key/value parameter values that will go into the +* query portion of the URL. +* @param headerInfo An NSDictionary of key/value header values that will go into the HTTP +* header. +* @param requestType The expected content type encoding for the parameter values. +* @param responseType The expected content type encoding for any response data. +* @param isPublic Represents whether to include or exclude necessary credentials of MAG to inject in the header of the request. +* @param timeoutInterval Represents the request's timeout interval, in seconds. +* @param completion An MASResponseInfoErrorBlock type (NSDictionary *responseInfo, NSError *error) that will +* receive the NSDictionary responseInfo and an NSError object if there is a failure. +* +* The responseInfo can have two keys: +* +* MASResponseInfoHeaderInfoKey: the value will be an NSDictionary of key/value pairs from the HTTP header. +* MASResponseInfoBodyInfoKey: the value will be an NSObject of some kind that is expected in the body of +* the particular request (optional) +*/ +- (void)getFrom:(NSString *)endPoint + withParameters:(NSDictionary *)parameterInfo + andHeaders:(NSDictionary *)headerInfo + requestType:(MASRequestResponseType)requestType + responseType:(MASRequestResponseType)responseType + isPublic:(BOOL)isPublic +timeoutInterval:(NSTimeInterval)timeoutInterval + completion:(MASResponseInfoErrorBlock)completion; + + /** * Request method for an HTTP PATCH call to the Gateway. This type of HTTP Method type * places it's parameters within the HTTP body in www-form-urlencoded format: @@ -468,6 +537,42 @@ typedef NSURLRequest* (^MASSessionDataTaskHTTPRedirectBlock)(NSURLSession *sessi completion:(MASResponseInfoErrorBlock)completion; +/** +* Request method for an HTTP PATCH call to the Gateway. This type of HTTP Method type +* places it's parameters within the HTTP body in www-form-urlencoded format: +* +* +* +* +* +* @param endPointPath The specific end point path fragment NSString to append to the base +* Gateway URL. +* @param parameterInfo An NSDictionary of key/value parameter values that will go into the +* query portion of the URL. +* @param headerInfo An NSDictionary of key/value header values that will go into the HTTP +* header. +* @param requestType The expected content type encoding for the parameter values. +* @param responseType The expected content type encoding for any response data. +* @param isPublic Represents whether to include or exclude necessary credentials of MAG to inject in the header of the request. +* @param timeoutInterval Represents the request's timeout interval, in seconds. +* @param completion An MASResponseInfoErrorBlock type (NSDictionary *responseInfo, NSError *error) that will +* receive the NSDictionary responseInfo and an NSError object if there is a failure. +* +* The responseInfo can have two keys: +* +* MASResponseInfoHeaderInfoKey: the value will be an NSDictionary of key/value pairs from the HTTP header. +* MASResponseInfoBodyInfoKey: the value will be an NSObject of some kind that is expected in the body of +* the particular request (optional) +*/ +- (void)patchTo:(NSString *)endPoint +withParameters:(NSDictionary *)parameterInfo + andHeaders:(NSDictionary *)headerInfo + requestType:(MASRequestResponseType)requestType + responseType:(MASRequestResponseType)responseType + isPublic:(BOOL)isPublic +timeoutInterval:(NSTimeInterval)timeoutInterval + completion:(MASResponseInfoErrorBlock)completion; + /** * Request method for an HTTP POST call to the Gateway. This type of HTTP Method type * places it's parameters within the HTTP body in www-form-urlencoded format: @@ -569,6 +674,42 @@ withParameters:(NSDictionary *)parameterInfo completion:(MASResponseInfoErrorBlock)completion; +/** +* Request method for an HTTP POST call to the Gateway. This type of HTTP Method type +* places it's parameters within the HTTP body in www-form-urlencoded format: +* +* +* +* +* +* @param endPointPath The specific end point path fragment NSString to append to the base +* Gateway URL. +* @param parameterInfo An NSDictionary of key/value parameter values that will go into the +* query portion of the URL. +* @param headerInfo An NSDictionary of key/value header values that will go into the HTTP +* header. +* @param requestType The expected content type encoding for the parameter values. +* @param responseType The expected content type encoding for any response data. +* @param isPublic Represents whether to include or exclude necessary credentials of MAG to inject in the header of the request. +* @param timeoutInterval Represents the request's timeout interval, in seconds. +* @param completion An MASResponseInfoErrorBlock type (NSDictionary *responseInfo, NSError *error) that will +* receive the NSDictionary responseInfo and an NSError object if there is a failure. +* +* The responseInfo can have two keys: +* +* MASResponseInfoHeaderInfoKey: the value will be an NSDictionary of key/value pairs from the HTTP header. +* MASResponseInfoBodyInfoKey: the value will be an NSObject of some kind that is expected in the body of +* the particular request (optional) +*/ +- (void)postTo:(NSString *)endPoint +withParameters:(NSDictionary *)parameterInfo + andHeaders:(NSDictionary *)headerInfo + requestType:(MASRequestResponseType)requestType + responseType:(MASRequestResponseType)responseType + isPublic:(BOOL)isPublic +timeoutInterval:(NSTimeInterval)timeoutInterval + completion:(MASResponseInfoErrorBlock)completion; + /** * Request method for an HTTP PUT call to the Gateway. This type of HTTP Method type * places it's parameters within the HTTP body in www-form-urlencoded format: @@ -667,5 +808,48 @@ withParameters:(NSDictionary *)parameterInfo isPublic:(BOOL)isPublic completion:(MASResponseInfoErrorBlock)completion; + +/** +* Request method for an HTTP PUT call to the Gateway. This type of HTTP Method type +* places it's parameters within the HTTP body in www-form-urlencoded format: +* +* +* +* +* +* @param endPointPath The specific end point path fragment NSString to append to the base +* Gateway URL. +* @param parameterInfo An NSDictionary of key/value parameter values that will go into the +* query portion of the URL. +* @param headerInfo An NSDictionary of key/value header values that will go into the HTTP +* header. +* @param requestType The expected content type encoding for the parameter values. +* @param responseType The expected content type encoding for any response data. +* @param isPublic Represents whether to include or exclude necessary credentials of MAG to inject in the header of the request. +* @param timeoutInterval Represents the request's timeout interval, in seconds. +* @param completion An MASResponseInfoErrorBlock type (NSDictionary *responseInfo, NSError *error) that will +* receive the NSDictionary responseInfo and an NSError object if there is a failure. +* +* The responseInfo can have two keys: +* +* MASResponseInfoHeaderInfoKey: the value will be an NSDictionary of key/value pairs from the HTTP header. +* MASResponseInfoBodyInfoKey: the value will be an NSObject of some kind that is expected in the body of +* the particular request (optional) +*/ +- (void)putTo:(NSString *)endPoint +withParameters:(NSDictionary *)parameterInfo + andHeaders:(NSDictionary *)headerInfo + requestType:(MASRequestResponseType)requestType + responseType:(MASRequestResponseType)responseType + isPublic:(BOOL)isPublic +timeoutInterval:(NSTimeInterval)timeoutInterval + completion:(MASResponseInfoErrorBlock)completion; + + + +# pragma mark - HTTP File Requests + +- (void)postMultiPartForm:(NSString*)endPoint withParameters:(NSDictionary *)parameterInfo andHeaders:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic timeoutInterval:(NSTimeInterval)timeoutInterval constructingBodyBlock:(nonnull MASMultiPartFormDataBlock)formDataBlock progress:(MASFileRequestProgressBlock)progress completion:(MASResponseObjectErrorBlock)completion; + @end diff --git a/MASFoundation/Classes/_private_/services/network/MASNetworkingService.m b/MASFoundation/Classes/_private_/services/network/MASNetworkingService.m index e25f0ae5..d3e6ffc8 100644 --- a/MASFoundation/Classes/_private_/services/network/MASNetworkingService.m +++ b/MASFoundation/Classes/_private_/services/network/MASNetworkingService.m @@ -29,6 +29,7 @@ #import "MASSecurityPolicy.h" #import "MASNetworkReachability.h" #import "MASMultiFactorHandler+MASPrivate.h" +#import "MASMultiPartRequestSerializer.h" # pragma mark - Configuration Constants @@ -975,6 +976,7 @@ - (void)deleteFrom:(NSString *)endPoint requestType:MASRequestResponseTypeJson responseType:MASRequestResponseTypeJson isPublic:NO + timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion:completion]; } @@ -995,6 +997,7 @@ - (void)deleteFrom:(NSString *)endPoint requestType:requestType responseType:responseType isPublic:NO + timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion:completion]; } @@ -1016,6 +1019,30 @@ - (void)deleteFrom:(NSString *)endPoint requestType:requestType responseType:responseType isPublic:isPublic + timeoutInterval:MASDefaultNetworkTimeoutConfiguration + completion:completion]; +} + + +- (void)deleteFrom:(NSString *)endPoint + withParameters:(NSDictionary *)parameterInfo + andHeaders:(NSDictionary *)headerInfo + requestType:(MASRequestResponseType)requestType + responseType:(MASRequestResponseType)responseType + isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval + completion:(MASResponseInfoErrorBlock)completion +{ + // + // Just passthrough + // + [self httpDeleteFrom:endPoint + withParameters:parameterInfo + andHeaders:headerInfo + requestType:requestType + responseType:responseType + isPublic:isPublic + timeoutInterval:timeoutInterval completion:completion]; } @@ -1026,6 +1053,7 @@ - (void)httpDeleteFrom:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval completion:(MASResponseInfoErrorBlock)completion { //DLog(@"called"); @@ -1043,7 +1071,7 @@ - (void)httpDeleteFrom:(NSString *)endPoint return; } - [self httpRequest:@"DELETE" endPoint:endPoint parameters:parameterInfo headers:headerInfo requestType:requestType responseType:responseType isPublic:isPublic completion:completion]; + [self httpRequest:@"DELETE" endPoint:endPoint parameters:parameterInfo headers:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval completion:completion]; } @@ -1061,6 +1089,7 @@ - (void)getFrom:(NSString *)endPoint requestType:MASRequestResponseTypeJson responseType:MASRequestResponseTypeJson isPublic:NO + timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion:completion]; } @@ -1081,9 +1110,30 @@ - (void)getFrom:(NSString *)endPoint requestType:requestType responseType:responseType isPublic:NO + timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion:completion]; } +- (void)getFrom:(NSString *)endPoint + withParameters:(NSDictionary *)parameterInfo + andHeaders:(NSDictionary *)headerInfo + requestType:(MASRequestResponseType)requestType + responseType:(MASRequestResponseType)responseType + isPublic:(BOOL)isPublic + completion:(MASResponseInfoErrorBlock)completion +{ + // + // Just passthrough + // + [self getFrom:endPoint + withParameters:parameterInfo + andHeaders:headerInfo + requestType:requestType + responseType:responseType + isPublic:isPublic + timeoutInterval:MASDefaultNetworkTimeoutConfiguration + completion:completion]; +} - (void)getFrom:(NSString *)endPoint withParameters:(NSDictionary *)parameterInfo @@ -1091,6 +1141,7 @@ - (void)getFrom:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic +timeoutInterval:(NSTimeInterval)timeoutInterval completion:(MASResponseInfoErrorBlock)completion { // @@ -1102,6 +1153,7 @@ - (void)getFrom:(NSString *)endPoint requestType:requestType responseType:responseType isPublic:isPublic + timeoutInterval:timeoutInterval completion:completion]; } @@ -1112,6 +1164,7 @@ - (void)httpGetFrom:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval completion:(MASResponseInfoErrorBlock)completion { //DLog(@"called"); @@ -1129,7 +1182,7 @@ - (void)httpGetFrom:(NSString *)endPoint return; } - [self httpRequest:@"GET" endPoint:endPoint parameters:parameterInfo headers:headerInfo requestType:requestType responseType:responseType isPublic:isPublic completion:completion]; + [self httpRequest:@"GET" endPoint:endPoint parameters:parameterInfo headers:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval completion:completion]; } @@ -1147,6 +1200,7 @@ - (void)patchTo:(NSString *)endPoint requestType:MASRequestResponseTypeJson responseType:MASRequestResponseTypeJson isPublic:NO + timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion:completion]; } @@ -1167,6 +1221,7 @@ - (void)patchTo:(NSString *)endPoint requestType:requestType responseType:responseType isPublic:NO + timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion:completion]; } @@ -1188,6 +1243,29 @@ - (void)patchTo:(NSString *)endPoint requestType:requestType responseType:responseType isPublic:isPublic + timeoutInterval:MASDefaultNetworkTimeoutConfiguration + completion:completion]; +} + +- (void)patchTo:(NSString *)endPoint + withParameters:(NSDictionary *)parameterInfo + andHeaders:(NSDictionary *)headerInfo + requestType:(MASRequestResponseType)requestType + responseType:(MASRequestResponseType)responseType + isPublic:(BOOL)isPublic +timeoutInterval:(NSTimeInterval)timeoutInterval + completion:(MASResponseInfoErrorBlock)completion +{ + // + // Just passthrough + // + [self httpPatchTo:endPoint + withParameters:parameterInfo + andHeaders:headerInfo + requestType:requestType + responseType:responseType + isPublic:isPublic + timeoutInterval:timeoutInterval completion:completion]; } @@ -1198,6 +1276,7 @@ - (void)httpPatchTo:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval completion:(MASResponseInfoErrorBlock)completion { // @@ -1213,7 +1292,7 @@ - (void)httpPatchTo:(NSString *)endPoint return; } - [self httpRequest:@"PATCH" endPoint:endPoint parameters:parameterInfo headers:headerInfo requestType:requestType responseType:responseType isPublic:isPublic completion:completion]; + [self httpRequest:@"PATCH" endPoint:endPoint parameters:parameterInfo headers:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval completion:completion]; } @@ -1231,6 +1310,7 @@ - (void)postTo:(NSString *)endPoint requestType:MASRequestResponseTypeJson responseType:MASRequestResponseTypeJson isPublic:NO + timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion:completion]; } @@ -1251,6 +1331,7 @@ - (void)postTo:(NSString *)endPoint requestType:requestType responseType:responseType isPublic:NO + timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion:completion]; } @@ -1262,6 +1343,29 @@ - (void)postTo:(NSString *)endPoint responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic completion:(MASResponseInfoErrorBlock)completion +{ + //DLog(@"called"); + // + // Just passthrough + // + [self postTo:endPoint + withParameters:parameterInfo + andHeaders:headerInfo + requestType:requestType + responseType:responseType + isPublic:isPublic + timeoutInterval:MASDefaultNetworkTimeoutConfiguration + completion:completion]; +} + +- (void)postTo:(NSString *)endPoint +withParameters:(NSDictionary *)parameterInfo + andHeaders:(NSDictionary *)headerInfo + requestType:(MASRequestResponseType)requestType + responseType:(MASRequestResponseType)responseType + isPublic:(BOOL)isPublic +timeoutInterval:(NSTimeInterval)timeoutInterval + completion:(MASResponseInfoErrorBlock)completion { //DLog(@"called"); // @@ -1273,6 +1377,7 @@ - (void)postTo:(NSString *)endPoint requestType:requestType responseType:responseType isPublic:isPublic + timeoutInterval:timeoutInterval completion:completion]; } @@ -1283,6 +1388,7 @@ - (void)httpPostTo:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval completion:(MASResponseInfoErrorBlock)completion { //DLog(@"called"); @@ -1300,7 +1406,7 @@ - (void)httpPostTo:(NSString *)endPoint return; } - [self httpRequest:@"POST" endPoint:endPoint parameters:parameterInfo headers:headerInfo requestType:requestType responseType:responseType isPublic:isPublic completion:completion]; + [self httpRequest:@"POST" endPoint:endPoint parameters:parameterInfo headers:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval completion:completion]; } @@ -1318,6 +1424,7 @@ - (void)putTo:(NSString *)endPoint requestType:MASRequestResponseTypeJson responseType:MASRequestResponseTypeJson isPublic:NO +timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion:completion]; } @@ -1338,9 +1445,30 @@ - (void)putTo:(NSString *)endPoint requestType:requestType responseType:responseType isPublic:NO +timeoutInterval:MASDefaultNetworkTimeoutConfiguration completion:completion]; } +- (void)putTo:(NSString *)endPoint +withParameters:(NSDictionary *)parameterInfo + andHeaders:(NSDictionary *)headerInfo + requestType:(MASRequestResponseType)requestType + responseType:(MASRequestResponseType)responseType + isPublic:(BOOL)isPublic + completion:(MASResponseInfoErrorBlock)completion +{ + // + // Just passthrough + // + [self putTo:endPoint + withParameters:parameterInfo + andHeaders:headerInfo + requestType:requestType + responseType:responseType + isPublic:isPublic + timeoutInterval:MASDefaultNetworkTimeoutConfiguration + completion:completion]; +} - (void)putTo:(NSString *)endPoint withParameters:(NSDictionary *)parameterInfo @@ -1348,6 +1476,7 @@ - (void)putTo:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic +timeoutInterval:(NSTimeInterval)timeoutInterval completion:(MASResponseInfoErrorBlock)completion { // @@ -1359,6 +1488,7 @@ - (void)putTo:(NSString *)endPoint requestType:requestType responseType:responseType isPublic:isPublic + timeoutInterval:timeoutInterval completion:completion]; } @@ -1369,6 +1499,7 @@ - (void)httpPutTo:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval completion:(MASResponseInfoErrorBlock)completion { // @@ -1384,11 +1515,102 @@ - (void)httpPutTo:(NSString *)endPoint return; } - [self httpRequest:@"PUT" endPoint:endPoint parameters:parameterInfo headers:headerInfo requestType:requestType responseType:responseType isPublic:isPublic completion:completion]; + [self httpRequest:@"PUT" endPoint:endPoint parameters:parameterInfo headers:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval completion:completion]; +} + + +- (void)postMultiPartForm:(NSString*)endPoint withParameters:(NSDictionary *)parameterInfo andHeaders:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic timeoutInterval:(NSTimeInterval)timeoutInterval constructingBodyBlock:(nonnull MASMultiPartFormDataBlock)formDataBlock progress:(MASFileRequestProgressBlock)progress completion:(MASResponseObjectErrorBlock)completion +{ + // + // endPoint cannot be nil + // + if (!endPoint) + { + // + // Notify + // + if(completion) completion(nil, nil,[NSError errorInvalidEndpoint]); + + return; + } + + [self httpFileUploadRequest:endPoint parameters:parameterInfo headers:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval constructingBodyBlock:formDataBlock progress:progress completion:completion]; +} + + +- (void)httpFileUploadRequest:(NSString *)endPoint parameters:(NSDictionary *)parameterInfo headers:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic timeoutInterval:(NSTimeInterval)timeoutInterval constructingBodyBlock:(nonnull MASMultiPartFormDataBlock)formDataBlock progress:(MASFileRequestProgressBlock)progress completion:(MASResponseObjectErrorBlock)completion +{ + NSMutableDictionary *mutableHeaderInfo = [headerInfo mutableCopy]; + + MASURLRequest *request = nil; + + // + // if location was successfully retrieved + // + if ([MASLocationService sharedService].lastKnownLocation != nil) + { + mutableHeaderInfo[MASGeoLocationRequestResponseKey] = [[MASLocationService sharedService].lastKnownLocation locationAsGeoCoordinates]; + } + + request = [MASPostFormURLRequest requestForEndpoint:endPoint withParameters:parameterInfo andHeaders:headerInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval constructingBodyBlock:formDataBlock]; + + // + // Construct MASSessionDataTaskOperation with request, and completion block to handle any responsive re-authentication or re-registration. + // + if(self.httpRedirectionBlock) + { + [_sessionManager setSessionDidReceiveHTTPRedirectBlock:self.httpRedirectionBlock]; + } + + MASSessionDataTaskOperation *operation = [self.sessionManager fileUploadOperation:request progress:progress completionHandler:[self sessionDataTaskCompletionBlockWithEndPoint:endPoint parameters:parameterInfo headers:headerInfo httpMethod:request.HTTPMethod requestType:requestType responseType:responseType isPublic:isPublic completionBlock:^(NSDictionary * _Nullable responseInfo, NSError * _Nullable error) { + if (completion) + { + completion([responseInfo objectForKey:MASNSHTTPURLResponseObjectKey], responseInfo[MASResponseInfoBodyInfoKey], error); + } + }]]; + + if (![self isMAGEndpoint:endPoint]) + { + // + // if the request is being made to system endpoint, and is not a public request which requires user credentials (tokens) + // then, add dependency on shared validation operation which will validate current session + // sharedOperation will only exist one at any given time as long as sharedOperation is being executed + // + if (!isPublic) + { + // + // add dependency + // + [operation addDependency:self.sharedOperation]; + + // + // to make sure SDK to not enqueue sharedOperation that is already enqueue and being executed + // + if (!self.sharedOperation.isFinished && !self.sharedOperation.isExecuting && ![_sessionManager.internalOperationQueue.operations containsObject:self.sharedOperation]) + { + // + // add sharedOperation into internal operation queue + // + [_sessionManager.internalOperationQueue addOperation:self.sharedOperation]; + } + } + + // + // add current request into normal operation queue + // + [_sessionManager.operationQueue addOperation:operation]; + } + else { + // + // if the request is being made to any one of system endpoints (registration, and/or authentication), then, add the operation into internal operation queue + // + [_sessionManager.internalOperationQueue addOperation:operation]; + } } -- (void)httpRequest:(NSString *)httpMethod endPoint:(NSString *)endPoint parameters:(NSDictionary *)parameterInfo headers:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic completion:(MASResponseInfoErrorBlock)completion +- (void)httpRequest:(NSString *)httpMethod endPoint:(NSString *)endPoint parameters:(NSDictionary *)parameterInfo headers:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval completion:(MASResponseInfoErrorBlock)completion { // // Update the header @@ -1410,23 +1632,23 @@ - (void)httpRequest:(NSString *)httpMethod endPoint:(NSString *)endPoint paramet // if ([httpMethod isEqualToString:@"DELETE"]) { - request = [MASDeleteURLRequest requestForEndpoint:endPoint withParameters:parameterInfo andHeaders:mutableHeaderInfo requestType:requestType responseType:responseType isPublic:isPublic]; + request = [MASDeleteURLRequest requestForEndpoint:endPoint withParameters:parameterInfo andHeaders:mutableHeaderInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval]; } else if ([httpMethod isEqualToString:@"GET"]) { - request = [MASGetURLRequest requestForEndpoint:endPoint withParameters:parameterInfo andHeaders:mutableHeaderInfo requestType:requestType responseType:responseType isPublic:isPublic]; + request = [MASGetURLRequest requestForEndpoint:endPoint withParameters:parameterInfo andHeaders:mutableHeaderInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval]; } else if ([httpMethod isEqualToString:@"PATCH"]) { - request = [MASPatchURLRequest requestForEndpoint:endPoint withParameters:parameterInfo andHeaders:mutableHeaderInfo requestType:requestType responseType:responseType isPublic:isPublic]; + request = [MASPatchURLRequest requestForEndpoint:endPoint withParameters:parameterInfo andHeaders:mutableHeaderInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval]; } else if ([httpMethod isEqualToString:@"POST"]) { - request = [MASPostURLRequest requestForEndpoint:endPoint withParameters:parameterInfo andHeaders:mutableHeaderInfo requestType:requestType responseType:responseType isPublic:isPublic]; + request = [MASPostURLRequest requestForEndpoint:endPoint withParameters:parameterInfo andHeaders:mutableHeaderInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval]; } else if ([httpMethod isEqualToString:@"PUT"]) { - request = [MASPutURLRequest requestForEndpoint:endPoint withParameters:parameterInfo andHeaders:mutableHeaderInfo requestType:requestType responseType:responseType isPublic:isPublic]; + request = [MASPutURLRequest requestForEndpoint:endPoint withParameters:parameterInfo andHeaders:mutableHeaderInfo requestType:requestType responseType:responseType isPublic:isPublic timeoutInterval:timeoutInterval]; } // diff --git a/MASFoundation/Classes/_private_/services/network/internal/MASSecurityPolicy.m b/MASFoundation/Classes/_private_/services/network/internal/MASSecurityPolicy.m index cb64f6c6..d64e879b 100644 --- a/MASFoundation/Classes/_private_/services/network/internal/MASSecurityPolicy.m +++ b/MASFoundation/Classes/_private_/services/network/internal/MASSecurityPolicy.m @@ -77,7 +77,7 @@ - (BOOL)evaluateSecurityConfigurationsForServerTrust:(SecTrustRef)serverTrust fo // // If trustPublicPKI is set to NO, and there is no pinning information defined, reject connection // - else if (!securityConfiguration.trustPublicPKI && ((([securityConfiguration.certificates isKindOfClass:[NSArray class]] && [securityConfiguration.certificates count] == 0) || securityConfiguration.certificates == nil) && (([securityConfiguration.publicKeyHashes isKindOfClass:[NSArray class]] && [securityConfiguration.publicKeyHashes count] == 0) || securityConfiguration.publicKeyHashes == nil))) + else if (!securityConfiguration.trustPublicPKI && (((([securityConfiguration.certificates isKindOfClass:[NSArray class]] && [securityConfiguration.certificates count] == 0) || securityConfiguration.certificates == nil) && (([securityConfiguration.publicKeyHashes isKindOfClass:[NSArray class]] && [securityConfiguration.publicKeyHashes count] == 0) || securityConfiguration.publicKeyHashes == nil)))) { return NO; } @@ -88,34 +88,65 @@ - (BOOL)evaluateSecurityConfigurationsForServerTrust:(SecTrustRef)serverTrust fo BOOL isPinningVerified = YES; NSArray *certificateChain = [self extractCertificateDataFromServerTrust:serverTrust]; + switch (securityConfiguration.pinningMode) { + //Tricky case where the default behaviour is still the same as older release. If certificate is set check it or check if atleast public key hash is set, if yes verify public key hash. Not setting both would have errored out in the code above + case MASSecuritySSLPinningModeCertificate: + { + BOOL isPublicKeyHashVerified = NO; + + if (securityConfiguration.publicKeyHashes != nil && [securityConfiguration.publicKeyHashes isKindOfClass:[NSArray class]] && [securityConfiguration.publicKeyHashes count] > 0) + { + isPublicKeyHashVerified = [self validatePublicKeyHash:serverTrust configuration:securityConfiguration]; + } + else + { + isPublicKeyHashVerified = YES; + } + + if(securityConfiguration.certificates != nil && [securityConfiguration.certificates isKindOfClass:[NSArray class]] && [securityConfiguration.certificates count] > 0) + { + isPinningVerified = ([self validateCertPinning:serverTrust configuration:securityConfiguration certChain:certificateChain]) && isPublicKeyHashVerified; + } + + } + break; + + case MASSecuritySSLPinningModeIntermediateCertifcate: + { + isPinningVerified = [self validateIntermediateCertPinning:serverTrust configuration:securityConfiguration certChain:certificateChain]; + } + break; + case MASSecuritySSLPinningModePublicKeyHash: + { + isPinningVerified = [self validatePublicKeyHash:serverTrust configuration:securityConfiguration]; + } + break; + + } + + return isPinningVerified; +} + + +- (BOOL)validateCertPinning:(SecTrustRef)serverTrust configuration:(MASSecurityConfiguration *)securityConfiguration certChain:(NSArray *)certificateChain +{ // // pinning with certificates // if (securityConfiguration.certificates != nil && [securityConfiguration.certificates isKindOfClass:[NSArray class]] && [securityConfiguration.certificates count] > 0) { - // - // Set anchor cert with pinned certificates - // - NSMutableArray *pinnedCertificates = [NSMutableArray array]; NSMutableArray *pinnedCertificatesData = [[securityConfiguration convertCertificatesToData] mutableCopy]; - for (NSData *certificateData in pinnedCertificatesData) - { - [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; - } - SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); - - // - // Stop proceeding if validation of server trust against anchor (pinned) certificates - // - if (![self validateServerTrust:serverTrust]) + if(![self validateAnchorTrust:serverTrust pinnedCerts:pinnedCertificatesData]) { return NO; } + // // As of this point, if the configuration forces to validate the entire chain, validate entire chain of certificates // - if ([securityConfiguration validateCertificateChain]) + + if (![securityConfiguration validateCertificateChain]) { int matchingCertificatesCount = 0; @@ -134,9 +165,74 @@ - (BOOL)evaluateSecurityConfigurationsForServerTrust:(SecTrustRef)serverTrust fo { return NO; } + + return YES; } } + return NO; +} + + +//Validate the intermediate certificate pinning + +- (BOOL)validateIntermediateCertPinning:(SecTrustRef)serverTrust configuration:(MASSecurityConfiguration *)securityConfiguration certChain:(NSArray *)certificateChain +{ + if (securityConfiguration.certificates != nil && [securityConfiguration.certificates isKindOfClass:[NSArray class]] && [securityConfiguration.certificates count] > 0) + { + NSMutableArray *pinnedCertificatesData = [[securityConfiguration convertCertificatesToData] mutableCopy]; + if(![self validateAnchorTrust:serverTrust pinnedCerts:pinnedCertificatesData]) + { + return NO; + } + + // + // Since this part is only pinning intermediate certificates no need to validate the entire chain. Only make sure if the intermediate certs are part of the CertificateChain that server presented + // + for (NSData *pinnedCertData in pinnedCertificatesData) + { + if (![certificateChain containsObject:pinnedCertData]) + { + return NO; + } + } + + return YES; + + } + + return NO; +} + + +//Validate server anchor trust based on the certificates that are pinned +- (BOOL)validateAnchorTrust:(SecTrustRef)serverTrust pinnedCerts:(NSArray *)pinnedCertificatesData +{ + // + // Set anchor cert with pinned certificates + // + NSMutableArray *pinnedCertificates = [NSMutableArray array]; + + for (NSData *certificateData in pinnedCertificatesData) + { + [pinnedCertificates addObject:(__bridge_transfer id)SecCertificateCreateWithData(NULL, (__bridge CFDataRef)certificateData)]; + } + SecTrustSetAnchorCertificates(serverTrust, (__bridge CFArrayRef)pinnedCertificates); + + // + // Stop proceeding if validation of server trust against anchor (pinned) certificates + // + if (![self validateServerTrust:serverTrust]) + { + return NO; + } + + return YES; +} + +//Pinning based on public key hash +- (BOOL)validatePublicKeyHash:(SecTrustRef)serverTrust configuration:(MASSecurityConfiguration *)securityConfiguration +{ // // pinning with public key hashes // @@ -199,23 +295,34 @@ - (BOOL)evaluateSecurityConfigurationsForServerTrust:(SecTrustRef)serverTrust fo { return NO; } + + return YES; } - return isPinningVerified; + return NO; } + + - (BOOL)validateServerTrust:(SecTrustRef)serverTrust { BOOL isValid = YES; SecTrustResultType result = 0; + CFErrorRef trustErrorRef = NULL; - if (SecTrustEvaluate(serverTrust, &result) != errSecSuccess) - { - isValid = NO; + if ([NSProcessInfo.processInfo isOperatingSystemAtLeastVersion:(NSOperatingSystemVersion){13,0,0}]) { + + isValid = SecTrustEvaluateWithError(serverTrust, &trustErrorRef); } else { - isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); + if (SecTrustEvaluate(serverTrust, &result) != errSecSuccess) + { + isValid = NO; + } + else { + isValid = (result == kSecTrustResultUnspecified || result == kSecTrustResultProceed); + } } return isValid; diff --git a/MASFoundation/Classes/_private_/services/network/internal/MASSessionDataTaskOperation.h b/MASFoundation/Classes/_private_/services/network/internal/MASSessionDataTaskOperation.h index e5268bdd..37b832fc 100644 --- a/MASFoundation/Classes/_private_/services/network/internal/MASSessionDataTaskOperation.h +++ b/MASFoundation/Classes/_private_/services/network/internal/MASSessionDataTaskOperation.h @@ -23,4 +23,6 @@ @property (nonatomic, copy) MASNetworkDataTaskWillCacheResponseBlock willCacheResponseBlock; @property (nonatomic, copy) MASNetworkDataTaskDidReceiveResponseBlock didReceiveResponseBlock; +- (instancetype)initWithSession:(NSURLSession *)session request:(NSURLRequest *)request progress:(MASFileRequestProgressBlock)progress; + @end diff --git a/MASFoundation/Classes/_private_/services/network/internal/MASSessionDataTaskOperation.m b/MASFoundation/Classes/_private_/services/network/internal/MASSessionDataTaskOperation.m index 0329c917..7889c12a 100644 --- a/MASFoundation/Classes/_private_/services/network/internal/MASSessionDataTaskOperation.m +++ b/MASFoundation/Classes/_private_/services/network/internal/MASSessionDataTaskOperation.m @@ -30,6 +30,8 @@ @interface MASSessionDataTaskOperation () @property (nonatomic, readwrite, strong) MASURLRequest *request; @property (nonatomic, readwrite, strong) NSURLSession *session; +@property (nonatomic)MASFileRequestProgressBlock fileProgressblock; + @end @@ -41,6 +43,7 @@ @implementation MASSessionDataTaskOperation - (instancetype)initWithSession:(NSURLSession *)session request:(NSURLRequest *)request { + self = [super initWithSession:session request:request]; if (self) { @@ -51,6 +54,20 @@ - (instancetype)initWithSession:(NSURLSession *)session request:(NSURLRequest *) return self; } +- (instancetype)initWithSession:(NSURLSession *)session request:(NSURLRequest *)request progress:(MASFileRequestProgressBlock)progress +{ + self = [super initWithSession:session request:request]; + if(self) + { + self.request = (MASURLRequest *)request; + [self setResponseType:self.request.responseType]; + self.fileProgressblock = progress; + } + + return self; + +} + # pragma mark - Public - (void)updateSession:(NSURLSession *)session @@ -279,4 +296,17 @@ - (void)URLSessionDidFinishEventsForBackgroundURLSession:(NSURLSession *)session } + +- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didSendBodyData:(int64_t)bytesSent totalBytesSent:(int64_t)totalBytesSent totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend +{ + + NSLog(@"total bytes sent - %lld total bytes expected %lld",totalBytesSent,totalBytesExpectedToSend); + if(self.fileProgressblock){ + //NSProgress* progress = [NSProgress progressWithTotalUnitCount:totalBytesExpectedToSend]; + //[progress set] + self.fileProgressblock(task.progress); + } + + [super URLSession:session task:task didSendBodyData:bytesSent totalBytesSent:totalBytesSent totalBytesExpectedToSend:totalBytesExpectedToSend]; +} @end diff --git a/MASFoundation/Classes/_private_/services/network/internal/MASSessionTaskOperation.m b/MASFoundation/Classes/_private_/services/network/internal/MASSessionTaskOperation.m index 9b488a77..db685612 100644 --- a/MASFoundation/Classes/_private_/services/network/internal/MASSessionTaskOperation.m +++ b/MASFoundation/Classes/_private_/services/network/internal/MASSessionTaskOperation.m @@ -54,6 +54,8 @@ - (instancetype)initWithSession:(NSURLSession *)session request:(NSURLRequest *) } + + # pragma mark - Public - (void)updateSession:(NSURLSession *)session @@ -218,6 +220,7 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didSend self.didSendBodyDataBlock(session, task, bytesSent, totalBytesSent, totalBytesExpectedToSend); }); } + } @@ -232,4 +235,5 @@ - (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didComp } } + @end diff --git a/MASFoundation/Classes/_private_/services/network/internal/MASURLSessionManager.h b/MASFoundation/Classes/_private_/services/network/internal/MASURLSessionManager.h index aee49747..317f6fce 100644 --- a/MASFoundation/Classes/_private_/services/network/internal/MASURLSessionManager.h +++ b/MASFoundation/Classes/_private_/services/network/internal/MASURLSessionManager.h @@ -14,6 +14,7 @@ #import "MASSecurityPolicy.h" #import "MASSessionDataTaskOperation.h" #import "MASURLRequest.h" +#import "MASPostFormURLRequest.h" // // NSURLSessionDelegate @@ -81,6 +82,7 @@ typedef void (^MASNetworkSessionDidFinishEventsForBackgroundURLSessionBlock)(NSU - (MASSessionDataTaskOperation *)dataOperationWithRequest:(MASURLRequest *)request completionHandler:(MASSessionDataTaskCompletionBlock)completionHandler; +-(MASSessionDataTaskOperation *)fileUploadOperation:(MASURLRequest *)request progress:(MASFileRequestProgressBlock)progress completionHandler:(MASSessionDataTaskCompletionBlock)completionHandler; ///-------------------------------------- /// @name Public diff --git a/MASFoundation/Classes/_private_/services/network/internal/MASURLSessionManager.m b/MASFoundation/Classes/_private_/services/network/internal/MASURLSessionManager.m index e96ff1dc..e3181367 100644 --- a/MASFoundation/Classes/_private_/services/network/internal/MASURLSessionManager.m +++ b/MASFoundation/Classes/_private_/services/network/internal/MASURLSessionManager.m @@ -12,6 +12,8 @@ #import "MASSecurityService.h" +#import "MASPostFormURLRequest.h" + @interface MASURLSessionManager () @property (readwrite, nonatomic, strong) NSURLSession *session; @@ -168,6 +170,23 @@ - (MASSessionDataTaskOperation *)dataOperationWithRequest:(MASURLRequest *)reque return dataTask; } +-(MASSessionDataTaskOperation *)fileUploadOperation:(MASURLRequest *)request progress:(MASFileRequestProgressBlock)progress completionHandler:(MASSessionDataTaskCompletionBlock)completionHandler +{ + MASSessionDataTaskOperation *dataTask = [[MASSessionDataTaskOperation alloc] initWithSession:_session request:request progress:progress]; + + [self.operations addObject:dataTask]; + + dataTask.didCompleteWithDataErrorBlock = ^(NSURLSession *session, NSURLSessionTask *task, NSData *data, NSError *error) { + + if (completionHandler) + { + completionHandler(task.response, data, error); + } + }; + + return dataTask; +} + # pragma mark - NSOperationQueue diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASDeleteURLRequest.h b/MASFoundation/Classes/_private_/services/network/requests/MASDeleteURLRequest.h index 96f9ef4c..1ee38b57 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASDeleteURLRequest.h +++ b/MASFoundation/Classes/_private_/services/network/requests/MASDeleteURLRequest.h @@ -33,6 +33,7 @@ * @param requestType Represents the expected encoding of the request contents. * @param responseType Represents the excepted encoding of the response contents. * @param isPublic Represents whether to include or exclude necessary credentials of MAG to inject in the header of the request. + * @param timeoutInterval Represents the request's timeout interval, in seconds. * @return MASDeleteURLRequest which could be used to create NSURLSessionDataTask. */ + (MASDeleteURLRequest *)requestForEndpoint:(NSString *)endPoint @@ -40,6 +41,7 @@ andHeaders:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType - isPublic:(BOOL)isPublic; + isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval; @end diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASDeleteURLRequest.m b/MASFoundation/Classes/_private_/services/network/requests/MASDeleteURLRequest.m index 3e91aa41..eace3350 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASDeleteURLRequest.m +++ b/MASFoundation/Classes/_private_/services/network/requests/MASDeleteURLRequest.m @@ -26,6 +26,7 @@ + (MASDeleteURLRequest *)requestForEndpoint:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval { // // Adding prefix to the endpoint path @@ -50,7 +51,7 @@ + (MASDeleteURLRequest *)requestForEndpoint:(NSString *)endPoint // // Create the request // - MASDeleteURLRequest *request = [MASDeleteURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60]; + MASDeleteURLRequest *request = [MASDeleteURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:timeoutInterval]; // // Method @@ -66,6 +67,7 @@ + (MASDeleteURLRequest *)requestForEndpoint:(NSString *)endPoint // capture request // request.isPublic = isPublic; + request.timeoutInterval = timeoutInterval; request.requestType = requestType; request.responseType = responseType; request.headerInfo = headerInfo; diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASGetURLRequest.h b/MASFoundation/Classes/_private_/services/network/requests/MASGetURLRequest.h index 62ce7a0e..c72260c7 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASGetURLRequest.h +++ b/MASFoundation/Classes/_private_/services/network/requests/MASGetURLRequest.h @@ -33,6 +33,7 @@ * @param requestType Represents the expected encoding of the request contents. * @param responseType Represents the excepted encoding of the response contents. * @param isPublic Represents whether to include or exclude necessary credentials of MAG to inject in the header of the request. + * @param timeoutInterval Represents the request's timeout interval, in seconds. * @return MASGetURLRequest which could be used to create NSURLSessionDataTask. */ + (MASGetURLRequest *)requestForEndpoint:(NSString *)endPoint @@ -40,6 +41,7 @@ andHeaders:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType - isPublic:(BOOL)isPublic; + isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval; @end diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASGetURLRequest.m b/MASFoundation/Classes/_private_/services/network/requests/MASGetURLRequest.m index 74b1d3fb..f262bcb6 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASGetURLRequest.m +++ b/MASFoundation/Classes/_private_/services/network/requests/MASGetURLRequest.m @@ -26,6 +26,7 @@ + (MASGetURLRequest *)requestForEndpoint:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval { // // Adding prefix to the endpoint path @@ -50,7 +51,7 @@ + (MASGetURLRequest *)requestForEndpoint:(NSString *)endPoint // // Create the request // - MASGetURLRequest *request = [MASGetURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60]; + MASGetURLRequest *request = [MASGetURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:timeoutInterval]; // // Method @@ -66,6 +67,7 @@ + (MASGetURLRequest *)requestForEndpoint:(NSString *)endPoint // capture request // request.isPublic = isPublic; + request.timeoutInterval = timeoutInterval; request.requestType = requestType; request.responseType = responseType; request.headerInfo = headerInfo; diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASPatchURLRequest.h b/MASFoundation/Classes/_private_/services/network/requests/MASPatchURLRequest.h index 00370698..3c03b416 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASPatchURLRequest.h +++ b/MASFoundation/Classes/_private_/services/network/requests/MASPatchURLRequest.h @@ -33,6 +33,7 @@ * @param requestType Represents the expected encoding of the request contents. * @param responseType Represents the excepted encoding of the response contents. * @param isPublic Represents whether to include or exclude necessary credentials of MAG to inject in the header of the request. + * @param timeoutInterval Represents the request's timeout interval, in seconds. * @return MASPatchURLRequest which could be used to create NSURLSessionDataTask. */ + (MASPatchURLRequest *)requestForEndpoint:(NSString *)endPoint @@ -40,6 +41,7 @@ andHeaders:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType - isPublic:(BOOL)isPublic; + isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval; @end diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASPatchURLRequest.m b/MASFoundation/Classes/_private_/services/network/requests/MASPatchURLRequest.m index 3ab2d9ff..134ba8f4 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASPatchURLRequest.m +++ b/MASFoundation/Classes/_private_/services/network/requests/MASPatchURLRequest.m @@ -26,6 +26,7 @@ + (MASPatchURLRequest *)requestForEndpoint:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval { // // Adding prefix to the endpoint path @@ -45,7 +46,7 @@ + (MASPatchURLRequest *)requestForEndpoint:(NSString *)endPoint // // Create the request // - MASPatchURLRequest *request = [MASPatchURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60]; + MASPatchURLRequest *request = [MASPatchURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:timeoutInterval]; // // Method @@ -61,6 +62,7 @@ + (MASPatchURLRequest *)requestForEndpoint:(NSString *)endPoint // capture request // request.isPublic = isPublic; + request.timeoutInterval = timeoutInterval; request.requestType = requestType; request.responseType = responseType; request.headerInfo = headerInfo; diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASPostFormURLRequest.h b/MASFoundation/Classes/_private_/services/network/requests/MASPostFormURLRequest.h new file mode 100644 index 00000000..c9f2d8b7 --- /dev/null +++ b/MASFoundation/Classes/_private_/services/network/requests/MASPostFormURLRequest.h @@ -0,0 +1,23 @@ +// +// MASPostFormURLRequest.h +// MASFoundation +// +// Copyright © 2019 CA Technologies. All rights reserved. +// +// This software may be modified and distributed under the terms +// of the MIT license. See the LICENSE file for details. +// + + +#import "MASURLRequest.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MASPostFormURLRequest : MASURLRequest + + ++ (MASPostFormURLRequest *)requestForEndpoint:(NSString *)endPoint withParameters:(NSDictionary *)parameterInfo andHeaders:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic timeoutInterval:(NSTimeInterval)timeoutInterval constructingBodyBlock:(nonnull MASMultiPartFormDataBlock)formDataBlock; + +@end + +NS_ASSUME_NONNULL_END diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASPostFormURLRequest.m b/MASFoundation/Classes/_private_/services/network/requests/MASPostFormURLRequest.m new file mode 100644 index 00000000..c35596cf --- /dev/null +++ b/MASFoundation/Classes/_private_/services/network/requests/MASPostFormURLRequest.m @@ -0,0 +1,139 @@ +// +// MASPostFormURLRequest.m +// MASFoundation +// +// Created by nimma01 on 12/07/19. +// Copyright © 2019 CA Technologies. All rights reserved. +// + +#import "MASPostFormURLRequest.h" +#import "MASMultiPartRequestSerializer.h" + + +#define kMASHTTPPostRequestMethod @"POST" + +@implementation MASPostFormURLRequest + + ++ (MASPostFormURLRequest *)requestForEndpoint:(NSString *)endPoint withParameters:(NSDictionary *)parameterInfo andHeaders:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic timeoutInterval:(NSTimeInterval)timeoutInterval constructingBodyBlock:(nonnull MASMultiPartFormDataBlock)formDataBlock +{ + // + // Adding prefix to the endpoint path + // + if ([MASConfiguration currentConfiguration].gatewayPrefix && ![endPoint hasPrefix:@"http://"] && ![endPoint hasPrefix:@"https://"]) + { + endPoint = [NSString stringWithFormat:@"%@%@",[MASConfiguration currentConfiguration].gatewayPrefix, endPoint]; + } + + // + // Full URL path (no query parameters go here) + // + NSURL *url = [NSURL URLWithString:endPoint relativeToURL:[MASConfiguration currentConfiguration].gatewayUrl]; + + NSAssert(url, @"URL cannot be nil"); + + // + // Create the request + // + MASPostFormURLRequest *request = [MASPostFormURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:timeoutInterval]; + + // + // Method + // + [request setHTTPMethod:kMASHTTPPostRequestMethod]; + + [request setHeaderInfo:headerInfo forRequestType:requestType andResponseType:responseType]; + + // + // capture request + // + request.isPublic = isPublic; + request.timeoutInterval = timeoutInterval; + request.requestType = requestType; + request.responseType = responseType; + request.headerInfo = headerInfo; + request.parameterInfo = parameterInfo; + request.endPoint = endPoint; + + __block MASMultiPartRequestSerializer* formData = [[MASMultiPartRequestSerializer alloc] initWithURLRequest:request]; + + if(formDataBlock){ + formDataBlock(formData); + } + + return [formData requestByFinalizingMultipartFormData]; + + +} + +- (MASURLRequest *)rebuildRequest +{ + [self setHeaderInfo:self.headerInfo forRequestType:self.requestType andResponseType:self.responseType]; + + return self; +} + + +//overriding the behavior for this class as the super class does not know about boundary string + +- (void)setHeaderInfo:(NSDictionary *)headerInfo forRequestType:(MASRequestResponseType)requestType andResponseType:(MASRequestResponseType)responseType +{ + + //don't set the request type as we don't want to disturb the boundary string + + // + // Accept based on MASRequestResponseType + // + [self setValue:[self requestResponseTypeAsMimeTypeString:responseType] forHTTPHeaderField:MASAcceptRequestResponseKey]; + + NSString *lowerKey; + NSString *value; + for(NSString *key in [headerInfo allKeys]) + { + lowerKey = [key lowercaseString]; + value = [headerInfo objectForKey:key]; + [self setValue:value forHTTPHeaderField:key]; + } +} + +//overriding the behavior for this class as the super class does not know about boundary string +- (NSString *)requestResponseTypeAsMimeTypeString:(MASRequestResponseType)type +{ + // + // Detect type and respond approriately + // + switch(type) + { + // + // JSON + // + case MASRequestResponseTypeJson: return MASRequestResponseTypeJsonValue; + + // + // SCIM variant JSON + // + case MASRequestResponseTypeScimJson: return MASRequestResponseTypeScimJsonValue; + + // + // Form URL Encoded + // + case MASRequestResponseTypeWwwFormUrlEncoded: return MASRequestResponseTypeWwwFormUrlEncodedValue; + + // + // XML + // + case MASRequestResponseTypeXml: return MASRequestResponseTypeXmlValue; + + case MASRequestResponseTypeFormData : return MASRequestResponseTypeFormDataValue; + + // + // Default + // + default: return MASRequestResponseTypeTextPlainValue; + } +} + + + + +@end diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASPostURLRequest.h b/MASFoundation/Classes/_private_/services/network/requests/MASPostURLRequest.h index ec4a129e..acefeeb4 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASPostURLRequest.h +++ b/MASFoundation/Classes/_private_/services/network/requests/MASPostURLRequest.h @@ -33,6 +33,7 @@ * @param requestType Represents the expected encoding of the request contents. * @param responseType Represents the excepted encoding of the response contents. * @param isPublic Represents whether to include or exclude necessary credentials of MAG to inject in the header of the request. + * @param timeoutInterval Represents the request's timeout interval, in seconds. * @return MASPostURLRequest which could be used to create NSURLSessionDataTask. */ + (MASPostURLRequest *)requestForEndpoint:(NSString *)endPoint @@ -40,6 +41,7 @@ andHeaders:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType - isPublic:(BOOL)isPublic; + isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval; @end diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASPostURLRequest.m b/MASFoundation/Classes/_private_/services/network/requests/MASPostURLRequest.m index 06f16d11..e96cb087 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASPostURLRequest.m +++ b/MASFoundation/Classes/_private_/services/network/requests/MASPostURLRequest.m @@ -26,6 +26,7 @@ + (MASPostURLRequest *)requestForEndpoint:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval { // // Adding prefix to the endpoint path @@ -45,7 +46,7 @@ + (MASPostURLRequest *)requestForEndpoint:(NSString *)endPoint // // Create the request // - MASPostURLRequest *request = [MASPostURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60]; + MASPostURLRequest *request = [MASPostURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:timeoutInterval]; // // Method @@ -60,6 +61,7 @@ + (MASPostURLRequest *)requestForEndpoint:(NSString *)endPoint // capture request // request.isPublic = isPublic; + request.timeoutInterval = timeoutInterval; request.requestType = requestType; request.responseType = responseType; request.headerInfo = headerInfo; diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASPutURLRequest.h b/MASFoundation/Classes/_private_/services/network/requests/MASPutURLRequest.h index abc7f459..f73d1a86 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASPutURLRequest.h +++ b/MASFoundation/Classes/_private_/services/network/requests/MASPutURLRequest.h @@ -33,6 +33,7 @@ * @param requestType Represents the expected encoding of the request contents. * @param responseType Represents the excepted encoding of the response contents. * @param isPublic Represents whether to include or exclude necessary credentials of MAG to inject in the header of the request. + * @param timeoutInterval Represents the request's timeout interval, in seconds. * @return MASPutURLRequest which could be used to create NSURLSessionDataTask. */ + (MASPutURLRequest *)requestForEndpoint:(NSString *)endPoint @@ -40,6 +41,7 @@ andHeaders:(NSDictionary *)headerInfo requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType - isPublic:(BOOL)isPublic; + isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval; @end diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASPutURLRequest.m b/MASFoundation/Classes/_private_/services/network/requests/MASPutURLRequest.m index f3ebba17..85766203 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASPutURLRequest.m +++ b/MASFoundation/Classes/_private_/services/network/requests/MASPutURLRequest.m @@ -26,6 +26,7 @@ + (MASPutURLRequest *)requestForEndpoint:(NSString *)endPoint requestType:(MASRequestResponseType)requestType responseType:(MASRequestResponseType)responseType isPublic:(BOOL)isPublic + timeoutInterval:(NSTimeInterval)timeoutInterval { // // Adding prefix to the endpoint path @@ -45,7 +46,7 @@ + (MASPutURLRequest *)requestForEndpoint:(NSString *)endPoint // // Create the request // - MASPutURLRequest *request = [MASPutURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:60]; + MASPutURLRequest *request = [MASPutURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringCacheData timeoutInterval:timeoutInterval]; // // Method @@ -61,6 +62,7 @@ + (MASPutURLRequest *)requestForEndpoint:(NSString *)endPoint // capture request // request.isPublic = isPublic; + request.timeoutInterval = timeoutInterval; request.requestType = requestType; request.responseType = responseType; request.headerInfo = headerInfo; diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASURLRequest.h b/MASFoundation/Classes/_private_/services/network/requests/MASURLRequest.h index 79407d8a..3297d7a3 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASURLRequest.h +++ b/MASFoundation/Classes/_private_/services/network/requests/MASURLRequest.h @@ -27,6 +27,7 @@ @property (assign) BOOL isPublic; @property (assign) MASRequestResponseType requestType; @property (assign) MASRequestResponseType responseType; +@property (assign) NSTimeInterval timeoutInterval; @property (nonatomic, strong) NSString *endPoint; @property (nonatomic, strong) NSDictionary *parameterInfo; @property (nonatomic, strong) NSDictionary *headerInfo; diff --git a/MASFoundation/Classes/_private_/services/network/requests/MASURLRequest.m b/MASFoundation/Classes/_private_/services/network/requests/MASURLRequest.m index cb982295..745234da 100644 --- a/MASFoundation/Classes/_private_/services/network/requests/MASURLRequest.m +++ b/MASFoundation/Classes/_private_/services/network/requests/MASURLRequest.m @@ -15,6 +15,7 @@ NSString * const MASRequestResponseTypeTextPlainValue = @"text/plain"; NSString * const MASRequestResponseTypeWwwFormUrlEncodedValue = @"application/x-www-form-urlencoded"; NSString * const MASRequestResponseTypeXmlValue = @"application/xml"; +NSString * const MASRequestResponseTypeFormDataValue = @"multipart/form-data"; @implementation MASURLRequest diff --git a/MASFoundation/Classes/_private_/services/security/ASN1CertificateParse/MASASN1Decoder.m b/MASFoundation/Classes/_private_/services/security/ASN1CertificateParse/MASASN1Decoder.m index 6cf1c60d..9a5c3134 100644 --- a/MASFoundation/Classes/_private_/services/security/ASN1CertificateParse/MASASN1Decoder.m +++ b/MASFoundation/Classes/_private_/services/security/ASN1CertificateParse/MASASN1Decoder.m @@ -194,7 +194,11 @@ - (NSMutableArray *)parseWithRange:(NSRange)range } case MASASN1TagBitStr: { - NSData *dataWithoutUnusedBit = [subContentData subdataWithRange:NSMakeRange(1, [subContentData length]-1)]; + NSData *dataWithoutUnusedBit = [NSData data]; + if (subContentData && [subContentData length]) { + + dataWithoutUnusedBit = [subContentData subdataWithRange:NSMakeRange(1, [subContentData length]-1)]; + } thisObject.value = dataWithoutUnusedBit; break; } 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/MASConfiguration.h b/MASFoundation/Classes/models/MASConfiguration.h index 84c07c32..5f694ead 100644 --- a/MASFoundation/Classes/models/MASConfiguration.h +++ b/MASFoundation/Classes/models/MASConfiguration.h @@ -9,6 +9,7 @@ // @import Foundation; +@class MASNetworkConfiguration; @class MASSecurityConfiguration; /** @@ -173,6 +174,50 @@ +///-------------------------------------- +/// @name Network Configuration +///-------------------------------------- + +# pragma mark - Network Configuration + +/** +Sets network timeout for specified host in MASNetworkConfiguration object + +@warning Upon SDK initialization, [MASConfiguration currentConfiguration].gatewayUrl's MASNetworkConfiguration object will be overwritten. If primary gateway's network configuration has to be modified, ensure to set network configuration after SDK initialization. +@param networkConfiguration MASNetworkConfiguration object with host, and network configuration values. +*/ ++ (BOOL)setNetworkConfiguration:(MASNetworkConfiguration *_Nonnull)networkConfiguration error:(NSError *__nullable __autoreleasing *__nullable)error; + + + +/** + Removes network configuration object based on the domain (host, and port number). + + @param domain NSURL object of domain to delete MASNetworkConfiguration. + */ ++ (void)removeNetworkConfigurationForDomain:(NSURL *_Nonnull)domain; + + + +/** + Returns an array of MASNetworkConfiguration objects for each host. + + @return Returns an array of currently active MASNetworkConfigurations. + */ ++ (NSArray *_Nullable)networkConfigurations; + + + +/** + Returns MASSecurityConfiguration object for a specific domain. + + @param domain NSURL of the domain for the MASSecurityConfiguration object. + @return Returns a MASSecurityConfiguration object for the domain. + */ ++ (MASNetworkConfiguration *_Nullable)networkConfigurationForDomain:(NSURL *_Nonnull)domain; + + + ///-------------------------------------- /// @name Security Configuration ///-------------------------------------- diff --git a/MASFoundation/Classes/models/MASConfiguration.m b/MASFoundation/Classes/models/MASConfiguration.m index 4c245d35..34226dba 100644 --- a/MASFoundation/Classes/models/MASConfiguration.m +++ b/MASFoundation/Classes/models/MASConfiguration.m @@ -419,6 +419,49 @@ - (id)initWithCoder:(NSCoder *)aDecoder } +# pragma mark - Network Configuration + ++ (BOOL)setNetworkConfiguration:(MASNetworkConfiguration *)networkConfiguration error:(NSError **)error +{ + // + // Validate the NSURL host for network configuration. + // + if (!networkConfiguration.host || !networkConfiguration.host.port) + { + if (error) + { + *error = [NSError errorForFoundationCode:MASFoundationErrorCodeConfigurationInvalidHostForNetworkConfiguration errorDomain:MASFoundationErrorDomainLocal]; + } + + return NO; + } + + [MASConfigurationService setNetworkConfiguration:networkConfiguration]; + + return YES; +} + + ++ (void)removeNetworkConfigurationForDomain:(NSURL *)domain +{ + [MASConfigurationService removeNetworkConfigurationForDomain:domain]; +} + + ++ (NSArray *)networkConfigurations +{ + return [MASConfigurationService networkConfigurations]; +} + + ++ (MASNetworkConfiguration *)networkConfigurationForDomain:(NSURL *)domain +{ + return [MASConfigurationService networkConfigurationForDomain:domain]; +} + + +# pragma mark - Security Configuration + + (BOOL)setSecurityConfiguration:(MASSecurityConfiguration *)securityConfiguration error:(NSError **)error { // 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/Classes/models/MASSecurityConfiguration.h b/MASFoundation/Classes/models/MASSecurityConfiguration.h index 5c7455f4..cd90c7cf 100644 --- a/MASFoundation/Classes/models/MASSecurityConfiguration.h +++ b/MASFoundation/Classes/models/MASSecurityConfiguration.h @@ -21,6 +21,27 @@ @interface MASSecurityConfiguration : MASObject +/** + * Different SSL pinning modes that can be opted. + */ +typedef NS_ENUM(NSUInteger, MASSecuritySSLPinningMode) { + /** + * SSL pinning based on Public Key Hash. + */ + MASSecuritySSLPinningModePublicKeyHash, + + /** + * SSL pinning based on Leaf Certificate. + */ + MASSecuritySSLPinningModeCertificate, + + /** + * SSL pinning based on Intermediate Certificate. + */ + MASSecuritySSLPinningModeIntermediateCertifcate, +}; + + ///-------------------------------------- /// @name Properties ///-------------------------------------- @@ -45,6 +66,12 @@ */ @property (assign) BOOL trustPublicPKI; +/** + enum value that determines the SSL pinning mode. The Certifcates array needs to be set accordingly with the certificates that needs to be pinned. If MASSecuritySSLPinningModeIntermediateCertifcate is chosen, then the certificates array should contain intermediate certificate. + @see certificates + */ +@property (assign) MASSecuritySSLPinningMode pinningMode; + /** NSArray value of pinned certificates. Certificates must be in PEM encoded CRT; each line should be an item of the certificate array. diff --git a/MASFoundation/Classes/models/MASSecurityConfiguration.m b/MASFoundation/Classes/models/MASSecurityConfiguration.m index f59f7d11..0b6db956 100644 --- a/MASFoundation/Classes/models/MASSecurityConfiguration.m +++ b/MASFoundation/Classes/models/MASSecurityConfiguration.m @@ -40,6 +40,7 @@ - (instancetype)initWithURL:(NSURL *)url self.trustPublicPKI = NO; self.validateCertificateChain = NO; self.validateDomainName = YES; + self.pinningMode = MASSecuritySSLPinningModeCertificate; } return self; @@ -99,6 +100,11 @@ - (void)setValuesWithConfiguration:(NSDictionary *)configuration self.trustPublicPKI = [[configuration objectForKey:@"trustPublicPKI"] boolValue]; } + if ([configuration.allKeys containsObject:@"pinningMode"]) + { + self.pinningMode = [MASSecurityConfiguration praseStringToPinningMode:[configuration objectForKey:@"pinningMode"]]; + } + if ([configuration.allKeys containsObject:@"certificates"] && [[configuration objectForKey:@"certificates"] isKindOfClass:[NSArray class]]) { self.certificates = [configuration objectForKey:@"certificates"]; @@ -111,6 +117,27 @@ - (void)setValuesWithConfiguration:(NSDictionary *)configuration } ++ (MASSecuritySSLPinningMode)praseStringToPinningMode:(NSString *)pinningMode +{ + MASSecuritySSLPinningMode pinningModeValue = MASSecuritySSLPinningModeCertificate; + + if ([pinningMode isEqualToString:MASSecurityConfigurationPinningModeCertificate]) + { + pinningModeValue = MASSecuritySSLPinningModeCertificate; + } +// else if ([pinningMode isEqualToString:MASSecurityConfigurationPinningModePublicKey]) +// { +// pinningModeValue = MASSecuritySSLPinningModePublicKey; +// } + else if ([pinningMode isEqualToString:MASSecurityConfigurationPinningModePublicKeyHash]) + { + pinningModeValue = MASSecuritySSLPinningModePublicKeyHash; + } + + return pinningModeValue; +} + + - (NSString *)debugDescription { return [NSString stringWithFormat:@"(%@) for %@\n\nisPublic: %@\nvalidateDomainName: %@\ntrustPublicPKI: %@\ncertificates: %@\npublicKeyHashes: %@\n", [self class], [[self host] absoluteString], self.isPublic ? @"YES":@"NO", self.validateDomainName ? @"YES":@"NO", self.trustPublicPKI ? @"YES":@"NO", self.certificates, self.publicKeyHashes]; diff --git a/MASFoundation/Classes/models/Network/MASMultiPartFormData.h b/MASFoundation/Classes/models/Network/MASMultiPartFormData.h new file mode 100644 index 00000000..8aa3f79b --- /dev/null +++ b/MASFoundation/Classes/models/Network/MASMultiPartFormData.h @@ -0,0 +1,55 @@ +// +// MASMultiPartFormData.h +// MASFoundation +// +// Copyright © 2019 CA Technologies. All rights reserved. +// +// This software may be modified and distributed under the terms +// of the MIT license. See the LICENSE file for details. +// + +#ifndef MASMultiPartFormData_h +#define MASMultiPartFormData_h + +@protocol MASMultiPartFormData + + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{generated filename}; name=#{name}"` and `Content-Type: #{generated mimeType}`, followed by the encoded file data and the multipart form boundary. + + The filename and MIME type for this data in the form will be automatically generated, using the last path component of the `fileURL` and system associated MIME type for the `fileURL` extension, respectively. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended, otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL * __nonnull)fileURL name:(NSString * __nonnull)name error:(NSError *_Nullable* _Nullable)error; + + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param fileURL The URL corresponding to the file whose content will be appended to the form. This parameter must not be `nil`. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The file name to be used in the `Content-Disposition` header. This parameter must not be `nil`. + @param mimeType The declared MIME type of the file data. This parameter must not be `nil`. + @param error If an error occurs, upon return contains an `NSError` object that describes the problem. + + @return `YES` if the file data was successfully appended otherwise `NO`. + */ +- (BOOL)appendPartWithFileURL:(NSURL * __nonnull)fileURL name:(NSString * __nonnull)name fileName:(NSString * __nonnull)fileName mimeType:(NSString * __nonnull)mimeType error:(NSError *_Nullable* _Nullable)error; + +/** + Appends the HTTP header `Content-Disposition: file; filename=#{filename}; name=#{name}"` and `Content-Type: #{mimeType}`, followed by the encoded file data and the multipart form boundary. + + @param data The data to be encoded and appended to the form data. + @param name The name to be associated with the specified data. This parameter must not be `nil`. + @param fileName The filename to be associated with the specified data. This parameter must not be `nil`. + @param mimeType The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be `nil`. + */ +-(BOOL)appendPartWithFileData:(NSData * __nonnull)data name:(NSString * __nonnull)name fileName:(NSString * __nonnull)fileName mimeType:(NSString * __nonnull)mimeType; + +@end +#endif /* MASMultiPartFormData_h */ diff --git a/MASFoundation/Classes/models/Network/MASMultiPartRequestSerializer.h b/MASFoundation/Classes/models/Network/MASMultiPartRequestSerializer.h new file mode 100644 index 00000000..939b30e5 --- /dev/null +++ b/MASFoundation/Classes/models/Network/MASMultiPartRequestSerializer.h @@ -0,0 +1,25 @@ +// +// MASMultiPartRequestSerializer.h +// MASFoundation +// +// Copyright © 2019 CA Technologies. 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 "MASMultiPartFormData.h" +#import "MASPostFormURLRequest.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MASMultiPartRequestSerializer : NSObject + +- (id)initWithURLRequest:(MASPostFormURLRequest *)request; + +- (MASPostFormURLRequest *)requestByFinalizingMultipartFormData; + +@end + +NS_ASSUME_NONNULL_END diff --git a/MASFoundation/Classes/models/Network/MASMultiPartRequestSerializer.m b/MASFoundation/Classes/models/Network/MASMultiPartRequestSerializer.m new file mode 100644 index 00000000..9ecb4204 --- /dev/null +++ b/MASFoundation/Classes/models/Network/MASMultiPartRequestSerializer.m @@ -0,0 +1,140 @@ +// +// MASMultiPartRequestSerializer.m +// MASFoundation +// +// Copyright © 2019 CA Technologies. All rights reserved. +// +// This software may be modified and distributed under the terms +// of the MIT license. See the LICENSE file for details. +// + +#import "MASMultiPartRequestSerializer.h" +#import + +@interface MASMultiPartRequestSerializer() +{ + +} + +@property(nonatomic) NSString* boundary; +@property(nonatomic) NSMutableData* body; +@property(nonatomic) MASURLRequest* request; + +@end + +static NSString * MASCreateMultipartFormBoundary() { + return [NSString stringWithFormat:@"Boundary+%08X%08X", arc4random(), arc4random()]; +} + + +static inline NSString * MASMultipartFormEncapsulationBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@%@", @"\r\n", boundary, @"\r\n"]; +} + + +static inline NSString * MASMultipartFormFinalBoundary(NSString *boundary) { + return [NSString stringWithFormat:@"%@--%@--%@", @"\r\n", boundary, @"\r\n"]; +} + +static inline NSString * MASContentTypeForPathExtension(NSString *extension) { +#ifdef __UTTYPE__ + NSString *UTI = (__bridge_transfer NSString *)UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, (__bridge CFStringRef)extension, NULL); + NSString *contentType = (__bridge_transfer NSString *)UTTypeCopyPreferredTagWithClass((__bridge CFStringRef)UTI, kUTTagClassMIMEType); + if (!contentType) { + return @"application/octet-stream"; + } else { + return contentType; + } +#else +#pragma unused (extension) + return @"application/octet-stream"; +#endif +} + +@implementation MASMultiPartRequestSerializer + + +- (id)initWithURLRequest:(MASPostFormURLRequest *)request +{ + if(self = [super init]) + { + self.request = request; + self.boundary = MASCreateMultipartFormBoundary(); + self.body = [NSMutableData data]; + [self setInitialHeadersforRequest]; + [self setBodyParameters]; + + } + + return self; +} + +-(void)setInitialHeadersforRequest +{ + NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary]; + [self.request addValue:contentType forHTTPHeaderField:@"Content-Type"]; +} + + +-(void)setBodyParameters +{ + [self.request.parameterInfo enumerateKeysAndObjectsUsingBlock:^(NSString *parameterKey, NSString *parameterValue, BOOL *stop) { + [self.body appendData:[[NSString stringWithFormat:@"%@", MASMultipartFormEncapsulationBoundary(self.boundary)] dataUsingEncoding:NSUTF8StringEncoding]]; + [self.body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"\r\n\r\n", parameterKey] dataUsingEncoding:NSUTF8StringEncoding]]; + [self.body appendData:[[NSString stringWithFormat:@"%@", parameterValue] dataUsingEncoding:NSUTF8StringEncoding]]; + }]; +} + + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL name:(NSString *)name error:(NSError *__autoreleasing _Nullable *)error +{ + return [self appendPartWithFileURL:fileURL name:name fileName:name mimeType:MASContentTypeForPathExtension([fileURL pathExtension]) error:error]; +} + +- (BOOL)appendPartWithFileURL:(NSURL *)fileURL name:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType error:(NSError *__autoreleasing _Nullable *)error +{ + if(!fileURL || !name) + { + return NO; + } + + [self.body appendData:[[NSString stringWithFormat:@"%@", MASMultipartFormEncapsulationBoundary(self.boundary)] dataUsingEncoding:NSUTF8StringEncoding]]; + [self.body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", name, fileName] dataUsingEncoding:NSUTF8StringEncoding]]; + [self.body appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", mimeType] dataUsingEncoding:NSUTF8StringEncoding]]; + NSData* data = [NSData dataWithContentsOfURL:fileURL]; + [self.body appendData:data]; + [self.body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; + + + return YES; +} + + +-(BOOL)appendPartWithFileData:(NSData *)data name:(NSString *)name fileName:(NSString *)fileName mimeType:(NSString *)mimeType +{ + [self.body appendData:[[NSString stringWithFormat:@"%@", MASMultipartFormEncapsulationBoundary(self.boundary)] dataUsingEncoding:NSUTF8StringEncoding]]; + [self.body appendData:[[NSString stringWithFormat:@"Content-Disposition: form-data; name=\"%@\"; filename=\"%@\"\r\n", name, fileName] dataUsingEncoding:NSUTF8StringEncoding]]; + [self.body appendData:[[NSString stringWithFormat:@"Content-Type: %@\r\n\r\n", mimeType] dataUsingEncoding:NSUTF8StringEncoding]]; + [self.body appendData:data]; + [self.body appendData:[@"\r\n" dataUsingEncoding:NSUTF8StringEncoding]]; + + return YES; +} + + +- (MASURLRequest *)requestByFinalizingMultipartFormData { + if (!self.body) { + return self.request; + } + + [self.body appendData:[[NSString stringWithFormat:@"%@", MASMultipartFormFinalBoundary(self.boundary)] dataUsingEncoding:NSUTF8StringEncoding]]; + + [self.request setValue:[NSString stringWithFormat:@"multipart/form-data; boundary=%@", self.boundary] forHTTPHeaderField:@"Content-Type"]; + [self.request setValue:[NSString stringWithFormat:@"%lu", (unsigned long)[self.body length]] forHTTPHeaderField:@"Content-Length"]; + // Reset the initial and final boundaries to ensure correct Content-Length + [self.request setHTTPBody:self.body]; + + return self.request; +} + +@end diff --git a/MASFoundation/Classes/models/Network/MASNetworkConfiguration.h b/MASFoundation/Classes/models/Network/MASNetworkConfiguration.h new file mode 100644 index 00000000..c99d9c16 --- /dev/null +++ b/MASFoundation/Classes/models/Network/MASNetworkConfiguration.h @@ -0,0 +1,54 @@ +// +// MASNetworkConfiguration.h +// MASFoundation +// +// Copyright © 2019 CA Technologies. 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 MASNetworkConfiguration : MASObject + + + +///-------------------------------------- +/// @name Properties +///-------------------------------------- + +# pragma mark - Properties + + +/** +The NSTimeInterval value that specifies the global timeInterval of all the requests. +*/ +@property (assign) NSTimeInterval timeoutInterval; + + + +/** + NSURL value of the target host. + */ +@property (nonatomic, strong, readonly, nonnull) NSURL *host; + + + +///-------------------------------------- +/// @name Lifecycle +///-------------------------------------- + +# pragma mark - Lifecycle + +/** + Designated initializer for MASNetworkConfiguration. + + @discussion default values for designated initializer are: timeoutInterval : 60. + @param url NSURL of the target domain + @return MASNetworkConfiguration object + */ +- (instancetype _Nonnull)initWithURL:(NSURL * _Nonnull)url NS_DESIGNATED_INITIALIZER; + +@end diff --git a/MASFoundation/Classes/models/Network/MASNetworkConfiguration.m b/MASFoundation/Classes/models/Network/MASNetworkConfiguration.m new file mode 100644 index 00000000..da2b71f2 --- /dev/null +++ b/MASFoundation/Classes/models/Network/MASNetworkConfiguration.m @@ -0,0 +1,40 @@ +// +// MASNetworkConfiguration.m +// MASFoundation +// +// Copyright © 2019 CA Technologies. All rights reserved. +// +// This software may be modified and distributed under the terms +// of the MIT license. See the LICENSE file for details. +// + +#import "MASNetworkConfiguration.h" + +#import "MASConstantsPrivate.h" + + +@interface MASNetworkConfiguration () + +@property (nonatomic, strong, readwrite) NSURL *host; + +@end + + +@implementation MASNetworkConfiguration + + +# pragma mark - Lifecycle + +- (instancetype)initWithURL:(NSURL *)url +{ + self = [super init]; + + if (self) { + self.host = [NSURL URLWithString:[NSString stringWithFormat:@"%@://%@:%@", url.scheme, url.host, url.port]]; + self.timeoutInterval = MASDefaultNetworkTimeoutConfiguration; + } + + return self; +} + +@end diff --git a/MASFoundation/Classes/models/Network/MASRequest.h b/MASFoundation/Classes/models/Network/MASRequest.h index 5b493627..67d17225 100644 --- a/MASFoundation/Classes/models/Network/MASRequest.h +++ b/MASFoundation/Classes/models/Network/MASRequest.h @@ -84,6 +84,12 @@ @property (assign, readonly) MASRequestResponseType responseType; +/** +The NSTimeInterval value that specifies the timeInterval of the request. +*/ +@property (assign, readonly) NSTimeInterval timeoutInterval; + + # pragma mark - Public diff --git a/MASFoundation/Classes/models/Network/MASRequest.m b/MASFoundation/Classes/models/Network/MASRequest.m index c63179d8..57f1f108 100644 --- a/MASFoundation/Classes/models/Network/MASRequest.m +++ b/MASFoundation/Classes/models/Network/MASRequest.m @@ -22,6 +22,7 @@ @interface MASRequest () @property (assign, readwrite) BOOL sign; @property (assign, readwrite) MASRequestResponseType requestType; @property (assign, readwrite) MASRequestResponseType responseType; +@property (assign, readwrite) NSTimeInterval timeoutInterval; @end diff --git a/MASFoundation/Classes/models/Network/MASRequestBuilder.h b/MASFoundation/Classes/models/Network/MASRequestBuilder.h index 1bdbb6cd..2d12f0cf 100644 --- a/MASFoundation/Classes/models/Network/MASRequestBuilder.h +++ b/MASFoundation/Classes/models/Network/MASRequestBuilder.h @@ -18,6 +18,7 @@ Default configuration value for designated initializer, [[MASRequestBuilder alloc] initWithHTTPMethod:], would be: isPublic: NO, + timeoutInterval: 60, sign: NO, requestType:MASRequestResponseTypeJson, responseType:MASRequestResponseTypeJson. @@ -98,6 +99,12 @@ @property (assign) MASRequestResponseType responseType; +/** +The NSTimeInterval value that specifies the timeInterval of the request. +*/ +@property (assign) NSTimeInterval timeoutInterval; + + ///-------------------------------------- /// @name Lifecycle ///-------------------------------------- diff --git a/MASFoundation/Classes/models/Network/MASRequestBuilder.m b/MASFoundation/Classes/models/Network/MASRequestBuilder.m index b04d6944..34bf0117 100644 --- a/MASFoundation/Classes/models/Network/MASRequestBuilder.m +++ b/MASFoundation/Classes/models/Network/MASRequestBuilder.m @@ -10,8 +10,10 @@ #import "MASRequestBuilder.h" +#import "MASConstantsPrivate.h" #import "MASRequest+MASPrivate.h" + @interface MASRequestBuilder () @property (nonatomic, strong, readwrite) NSString *httpMethod; @@ -36,6 +38,7 @@ - (instancetype)initWithHTTPMethod:(NSString *)method self.sign = NO; self.requestType = MASRequestResponseTypeJson; self.responseType = MASRequestResponseTypeJson; + self.timeoutInterval = MASDefaultNetworkTimeoutConfiguration; // default to 60 seconds. } return self; diff --git a/MASFoundation/Info.plist b/MASFoundation/Info.plist index a6cb2047..b6725b18 100644 --- a/MASFoundation/Info.plist +++ b/MASFoundation/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.9.10 + 2.0.00 CFBundleSignature ???? CFBundleVersion diff --git a/MASFoundation/MASFoundation.h b/MASFoundation/MASFoundation.h index 5fcf1e1a..7f36d17b 100644 --- a/MASFoundation/MASFoundation.h +++ b/MASFoundation/MASFoundation.h @@ -23,8 +23,8 @@ FOUNDATION_EXPORT const unsigned char MASFoundationVersionString[]; // #import #import -#import #import +#import #import #import #import @@ -49,8 +49,6 @@ FOUNDATION_EXPORT const unsigned char MASFoundationVersionString[]; #import #import #import -#import -#import #import #import #import diff --git a/README.md b/README.md index 81fc427a..3df2c3e9 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 @@ -72,7 +72,7 @@ For manual install, you add the Mobile SDK to your Xcode project. Note that you ## Set Up Project and Start the SDK -To start your project, see [developer site](https://mas.ca.com/docs) +To start your project, see [developer site](http://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/layer7-api-management/mobile-sdk-for-ca-mobile-api-gateway/2-0.html) After your project is properly configured, you must start the SDK to establish a secure connection with the backend services. The startup process includes: initialize necessary services for library (such as geo-location, BLE, and network services), and load configuration. @@ -139,17 +139,17 @@ For more documentation and API references, go to our [main website][docs] ## License -Copyright (c) 2016 CA. All rights reserved. +Copyright (c) 2019 Broadcom. All Rights Reserved. +The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. 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/ - [docs]: http://mas.ca.com/docs/ - [blog]: http://mas.ca.com/blog/ - [videos]: https://www.ca.com/us/developers/mas/videos.html + [techdocs.broadcom.com]: http://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/layer7-api-management/mobile-sdk-for-ca-mobile-api-gateway/2-0.html + [get-started]: http://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/layer7-api-management/mobile-sdk-for-ca-mobile-api-gateway/2-0.html + [docs]: http://techdocs.broadcom.com/content/broadcom/techdocs/us/en/ca-enterprise-software/layer7-api-management/mobile-sdk-for-ca-mobile-api-gateway/2-0.html [StackOverflow]: http://stackoverflow.com/questions/tagged/massdk [download]: https://github.com/CAAPIM/iOS-MAS-Foundation/archive/master.zip [contributing]: https://github.com/CAAPIM/iOS-MAS-Foundation/blob/develop/CONTRIBUTING.md