From 3ef956fd6bfc08772fa23c2606d6d72cadfce691 Mon Sep 17 00:00:00 2001 From: Sergei Demchenko Date: Mon, 9 Sep 2024 14:21:34 -0700 Subject: [PATCH] Support GetSupportedContracts api. (#1421) --- .../IdentityCore.xcodeproj/project.pbxproj | 20 +++++++ ...ativeMessageGetSupportedContractsRequest.h | 35 ++++++++++++ ...ativeMessageGetSupportedContractsRequest.m | 53 +++++++++++++++++++ ...tiveMessageGetSupportedContractsResponse.h | 36 +++++++++++++ ...tiveMessageGetSupportedContractsResponse.m | 48 +++++++++++++++++ 5 files changed, 192 insertions(+) create mode 100644 IdentityCore/src/broker_operation/request/browser_native_message_request/MSIDBrowserNativeMessageGetSupportedContractsRequest.h create mode 100644 IdentityCore/src/broker_operation/request/browser_native_message_request/MSIDBrowserNativeMessageGetSupportedContractsRequest.m create mode 100644 IdentityCore/src/broker_operation/response/browser_native_message_response/MSIDBrowserNativeMessageGetSupportedContractsResponse.h create mode 100644 IdentityCore/src/broker_operation/response/browser_native_message_response/MSIDBrowserNativeMessageGetSupportedContractsResponse.m diff --git a/IdentityCore/IdentityCore.xcodeproj/project.pbxproj b/IdentityCore/IdentityCore.xcodeproj/project.pbxproj index dbfcb70ac..bb13288c4 100644 --- a/IdentityCore/IdentityCore.xcodeproj/project.pbxproj +++ b/IdentityCore/IdentityCore.xcodeproj/project.pbxproj @@ -431,6 +431,12 @@ 23C10AA02B40D9350063D97C /* MSIDBrowserNativeMessageSignOutResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 23C10A9D2B40D9340063D97C /* MSIDBrowserNativeMessageSignOutResponse.m */; }; 23C548052A2A5DBF00633DC0 /* MSIDBrokerOperationBrowserNativeMessageRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 23C548032A2A5DBF00633DC0 /* MSIDBrokerOperationBrowserNativeMessageRequest.h */; }; 23C548062A2A5DBF00633DC0 /* MSIDBrokerOperationBrowserNativeMessageRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 23C548042A2A5DBF00633DC0 /* MSIDBrokerOperationBrowserNativeMessageRequest.m */; }; + 23C898142C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 23C898132C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.m */; }; + 23C898152C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.m in Sources */ = {isa = PBXBuildFile; fileRef = 23C898132C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.m */; }; + 23C898162C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.h in Headers */ = {isa = PBXBuildFile; fileRef = 23C898122C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.h */; }; + 23C898192C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 23C898182C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.m */; }; + 23C8981A2C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.m in Sources */ = {isa = PBXBuildFile; fileRef = 23C898182C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.m */; }; + 23C8981B2C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.h in Headers */ = {isa = PBXBuildFile; fileRef = 23C898172C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.h */; }; 23CA0C4A220A3B6900768729 /* MSIDPKeyAuthHandlerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 23CA0C49220A3B6900768729 /* MSIDPKeyAuthHandlerTests.m */; }; 23CA0C4B220A4A5D00768729 /* MSIDPKeyAuthHandlerTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 23CA0C49220A3B6900768729 /* MSIDPKeyAuthHandlerTests.m */; }; 23CA0C5F220A68D400768729 /* MSIDPkeyAuthHelperTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 23CA0C5E220A68D400768729 /* MSIDPkeyAuthHelperTests.m */; }; @@ -2286,6 +2292,10 @@ 23C10A9D2B40D9340063D97C /* MSIDBrowserNativeMessageSignOutResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrowserNativeMessageSignOutResponse.m; sourceTree = ""; }; 23C548032A2A5DBF00633DC0 /* MSIDBrokerOperationBrowserNativeMessageRequest.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MSIDBrokerOperationBrowserNativeMessageRequest.h; sourceTree = ""; }; 23C548042A2A5DBF00633DC0 /* MSIDBrokerOperationBrowserNativeMessageRequest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MSIDBrokerOperationBrowserNativeMessageRequest.m; sourceTree = ""; }; + 23C898122C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBrowserNativeMessageGetSupportedContractsRequest.h; sourceTree = ""; }; + 23C898132C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrowserNativeMessageGetSupportedContractsRequest.m; sourceTree = ""; }; + 23C898172C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MSIDBrowserNativeMessageGetSupportedContractsResponse.h; sourceTree = ""; }; + 23C898182C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDBrowserNativeMessageGetSupportedContractsResponse.m; sourceTree = ""; }; 23CA0C49220A3B6900768729 /* MSIDPKeyAuthHandlerTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = MSIDPKeyAuthHandlerTests.m; sourceTree = ""; }; 23CA0C5B220A540A00768729 /* NSData+MSIDTestUtil.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSData+MSIDTestUtil.h"; sourceTree = ""; }; 23CA0C5C220A540A00768729 /* NSData+MSIDTestUtil.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSData+MSIDTestUtil.m"; sourceTree = ""; }; @@ -3689,6 +3699,8 @@ 2352AF312AA7C7B700FA2253 /* MSIDBrowserNativeMessageGetTokenResponse.m */, 23C10A9C2B40D9340063D97C /* MSIDBrowserNativeMessageSignOutResponse.h */, 23C10A9D2B40D9340063D97C /* MSIDBrowserNativeMessageSignOutResponse.m */, + 23C898172C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.h */, + 23C898182C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.m */, ); path = browser_native_message_response; sourceTree = ""; @@ -3921,6 +3933,8 @@ 23642EE12A8AF3500078FF1A /* MSIDBrowserNativeMessageGetTokenRequest.m */, 23391BD42B17F2FD00EB121B /* MSIDBrowserNativeMessageSignOutRequest.h */, 23391BD52B17F2FD00EB121B /* MSIDBrowserNativeMessageSignOutRequest.m */, + 23C898122C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.h */, + 23C898132C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.m */, ); path = browser_native_message_request; sourceTree = ""; @@ -5926,6 +5940,7 @@ 23071655229F56AE00FDD044 /* MSIDAADV2Oauth2FactoryForV1Request.h in Headers */, B286B9CF2389DF03007833AD /* MSIDLogger+Trace.h in Headers */, B286B9AA2389DD43007833AD /* MSIDCertificateChooser.h in Headers */, + 23C898162C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.h in Headers */, 238E19E12086FE28004DF483 /* MSIDAuthorizationCodeGrantRequest.h in Headers */, 238EF038208FDBA20035ABE6 /* MSIDAADV1RefreshTokenGrantRequest.h in Headers */, 589BDB272718F18800BF3799 /* MSIDCredentialHeader.h in Headers */, @@ -6002,6 +6017,7 @@ 238EF042208FE88C0035ABE6 /* MSIDAADAuthorizationCodeGrantRequest.h in Headers */, B28686C6240655EF004E83FC /* MSIDLoginKeychainUtil.h in Headers */, 05566D102204BB8A002DBA40 /* MSIDMacKeychainTokenCache.h in Headers */, + 23C8981B2C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.h in Headers */, B210F4311FDDE7EB005A8F76 /* MSIDTokenResponse.h in Headers */, B286B99B2389DCA2007833AD /* MSIDSSOExtensionRequestDelegate+Internal.h in Headers */, B2B1D57220425DFD00DD81F0 /* MSIDAccountCacheItem.h in Headers */, @@ -7066,6 +7082,7 @@ 1E37AAD5252196CC00EBED3B /* NSData+JWT.m in Sources */, B286B9872389DC24007833AD /* MSIDBrokerOperationGetAccountsRequest.m in Sources */, B297E1F220A25F0C00F370EC /* MSIDLegacyTokenCacheItem.m in Sources */, + 23C8981A2C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.m in Sources */, B286B9992389DC9D007833AD /* MSIDSSOExtensionSilentTokenRequest.m in Sources */, B2C7089921991D0000D917B8 /* MSIDAADV2BrokerResponse.m in Sources */, B20E3CB61FC4FE400029C097 /* MSIDOAuth2Constants.m in Sources */, @@ -7212,6 +7229,7 @@ B8DBEF652395CA6100A16651 /* MSIDKeychainTokenCache.m in Sources */, 600D19BE20964D9E0004CD43 /* MSIDWorkPlaceJoinUtil.m in Sources */, 659929AC26296B0200830FD5 /* MSIDRequestTelemetryConstants.m in Sources */, + 23C898152C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.m in Sources */, 58B81F8424AD0F8B00E8799E /* MSIDWebResponseBaseOperation.m in Sources */, B214C3A01FE854FE0070C4F2 /* MSIDLegacyTokenCacheAccessor.m in Sources */, 1E62D0E5228B75E3000E2BBC /* MSIDKeychainUtil.m in Sources */, @@ -7760,6 +7778,7 @@ 238E19C42086FC38004DF483 /* MSIDHttpResponseSerializer.m in Sources */, 1E707FDA2406FA7900716148 /* MSIDBrokerNativeAppOperationResponse.m in Sources */, 232173EC2182B195009852C6 /* MSIDIntuneUserDefaultsCacheDataSource.m in Sources */, + 23C898142C8928DD00071482 /* MSIDBrowserNativeMessageGetSupportedContractsRequest.m in Sources */, 60DC9FFE2374DF6D00AEA52E /* MSIDDeviceInfo.m in Sources */, 2317FFC12A44FDD400E3DAA2 /* MSIDBrowserNativeMessageGetCookiesRequest.m in Sources */, 23B0189C23554B2B00207FEC /* MSIDBrokerOperationInteractiveTokenRequest.m in Sources */, @@ -7807,6 +7826,7 @@ 238A04902089A3C800989EE0 /* MSIDHttpRequestTelemetry.m in Sources */, 04D32CB21FD62141000B123E /* MSIDError.m in Sources */, 728209C926FE94D800B5F018 /* MSIDJwtAlgorithm.m in Sources */, + 23C898192C892A3800071482 /* MSIDBrowserNativeMessageGetSupportedContractsResponse.m in Sources */, 2352AF332AA7C7B700FA2253 /* MSIDBrowserNativeMessageGetTokenResponse.m in Sources */, B443F0022AD6328700782168 /* MSIDBrokerOperationPasskeyCredentialRequest.m in Sources */, B20657B01FC91FD100412B7D /* MSIDTelemetryEventStrings.m in Sources */, diff --git a/IdentityCore/src/broker_operation/request/browser_native_message_request/MSIDBrowserNativeMessageGetSupportedContractsRequest.h b/IdentityCore/src/broker_operation/request/browser_native_message_request/MSIDBrowserNativeMessageGetSupportedContractsRequest.h new file mode 100644 index 000000000..a96d47cd8 --- /dev/null +++ b/IdentityCore/src/broker_operation/request/browser_native_message_request/MSIDBrowserNativeMessageGetSupportedContractsRequest.h @@ -0,0 +1,35 @@ +// +// Copyright (c) Microsoft Corporation. +// All rights reserved. +// +// This code is licensed under the MIT License. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MSIDBaseBrokerOperationRequest.h" +#import "MSIDJsonSerializable.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MSIDBrowserNativeMessageGetSupportedContractsRequest : MSIDBaseBrokerOperationRequest + +@end + +NS_ASSUME_NONNULL_END diff --git a/IdentityCore/src/broker_operation/request/browser_native_message_request/MSIDBrowserNativeMessageGetSupportedContractsRequest.m b/IdentityCore/src/broker_operation/request/browser_native_message_request/MSIDBrowserNativeMessageGetSupportedContractsRequest.m new file mode 100644 index 000000000..db11c3bd4 --- /dev/null +++ b/IdentityCore/src/broker_operation/request/browser_native_message_request/MSIDBrowserNativeMessageGetSupportedContractsRequest.m @@ -0,0 +1,53 @@ +// +// Copyright (c) Microsoft Corporation. +// All rights reserved. +// +// This code is licensed under the MIT License. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MSIDBrowserNativeMessageGetSupportedContractsRequest.h" +#import "MSIDJsonSerializableFactory.h" + +@implementation MSIDBrowserNativeMessageGetSupportedContractsRequest + ++ (void)load +{ + [MSIDJsonSerializableFactory registerClass:self forClassType:self.operation]; +} + ++ (NSString *)operation +{ + return @"GetSupportedContracts"; +} + +#pragma mark - MSIDJsonSerializable + +- (instancetype)initWithJSONDictionary:(NSDictionary *)json error:(NSError *__autoreleasing *)error +{ + return [super init]; +} + +- (NSDictionary *)jsonDictionary +{ + return @{}; +} + +@end diff --git a/IdentityCore/src/broker_operation/response/browser_native_message_response/MSIDBrowserNativeMessageGetSupportedContractsResponse.h b/IdentityCore/src/broker_operation/response/browser_native_message_response/MSIDBrowserNativeMessageGetSupportedContractsResponse.h new file mode 100644 index 000000000..8ec3bd5a7 --- /dev/null +++ b/IdentityCore/src/broker_operation/response/browser_native_message_response/MSIDBrowserNativeMessageGetSupportedContractsResponse.h @@ -0,0 +1,36 @@ +// +// Copyright (c) Microsoft Corporation. +// All rights reserved. +// +// This code is licensed under the MIT License. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MSIDBrokerNativeAppOperationResponse.h" + +NS_ASSUME_NONNULL_BEGIN + +@interface MSIDBrowserNativeMessageGetSupportedContractsResponse : MSIDBrokerNativeAppOperationResponse + +@property (nonatomic) NSArray *supportedContracts; + +@end + +NS_ASSUME_NONNULL_END diff --git a/IdentityCore/src/broker_operation/response/browser_native_message_response/MSIDBrowserNativeMessageGetSupportedContractsResponse.m b/IdentityCore/src/broker_operation/response/browser_native_message_response/MSIDBrowserNativeMessageGetSupportedContractsResponse.m new file mode 100644 index 000000000..5c10048bf --- /dev/null +++ b/IdentityCore/src/broker_operation/response/browser_native_message_response/MSIDBrowserNativeMessageGetSupportedContractsResponse.m @@ -0,0 +1,48 @@ +// +// Copyright (c) Microsoft Corporation. +// All rights reserved. +// +// This code is licensed under the MIT License. +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files(the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and / or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions : +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +#import "MSIDBrowserNativeMessageGetSupportedContractsResponse.h" + +@implementation MSIDBrowserNativeMessageGetSupportedContractsResponse + +#pragma mark - MSIDJsonSerializable + +- (instancetype)initWithJSONDictionary:(NSDictionary *)json error:(NSError *__autoreleasing*)error +{ + @throw MSIDException(MSIDGenericException, @"Not implemented.", nil); +} + +- (NSDictionary *)jsonDictionary +{ + if (!self.supportedContracts) + { + MSID_LOG_WITH_CTX(MSIDLogLevelError, nil, @"Failed to create GetSupportedContracts json response."); + return nil; + } + + return @{@"contracts": self.supportedContracts}; +} + +@end