From 11770231c5541442672e607a77ecf21a7ad778be Mon Sep 17 00:00:00 2001 From: Serkant Karaca Date: Mon, 11 Feb 2019 15:11:17 -0800 Subject: [PATCH] Moving AD SDK 4.5 and Xamarin.iOS10 support (#365) --- .../EventHubClient.cs | 4 +++- .../Microsoft.Azure.EventHubs.csproj | 20 ++++++++++++++----- .../AzureActiveDirectoryTokenProvider.cs | 8 ++++---- .../Primitives/ClientInfo.cs | 2 ++ .../Primitives/JsonSecurityToken.cs | 1 - .../Primitives/TokenProvider.cs | 5 ++++- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/Microsoft.Azure.EventHubs/EventHubClient.cs b/src/Microsoft.Azure.EventHubs/EventHubClient.cs index 749f282..7fb1a66 100644 --- a/src/Microsoft.Azure.EventHubs/EventHubClient.cs +++ b/src/Microsoft.Azure.EventHubs/EventHubClient.cs @@ -84,6 +84,7 @@ namespace Microsoft.Azure.EventHubs return eventHubClient; } +#if !UAP10_0 && !IOS /// /// Creates a new instance of the Event Hubs client using the specified endpoint, entity path, AAD authentication context. /// @@ -109,6 +110,7 @@ namespace Microsoft.Azure.EventHubs operationTimeout, transportType); } +#endif /// /// Creates a new instance of the Event Hubs client using the specified endpoint, entity path, AAD authentication context. @@ -142,7 +144,7 @@ namespace Microsoft.Azure.EventHubs transportType); } -#if !UAP10_0 +#if !UAP10_0 && !IOS /// /// Creates a new instance of the Event Hubs client using the specified endpoint, entity path, AAD authentication context. /// diff --git a/src/Microsoft.Azure.EventHubs/Microsoft.Azure.EventHubs.csproj b/src/Microsoft.Azure.EventHubs/Microsoft.Azure.EventHubs.csproj index 972fa65..70ac8f1 100644 --- a/src/Microsoft.Azure.EventHubs/Microsoft.Azure.EventHubs.csproj +++ b/src/Microsoft.Azure.EventHubs/Microsoft.Azure.EventHubs.csproj @@ -5,7 +5,7 @@ Microsoft.Azure.EventHubs 2.2.0 Microsoft - net461;netstandard2.0;uap10.0 + net461;netstandard2.0;uap10.0;Xamarin.iOS10 true Microsoft.Azure.EventHubs ../../build/keyfile.snk @@ -49,11 +49,15 @@ $(DefineConstants);NETSTANDARD2_0 + + $(DefineConstants);IOS + + - + @@ -67,17 +71,21 @@ + + + + + - + - - + True True @@ -92,4 +100,6 @@ + + diff --git a/src/Microsoft.Azure.EventHubs/Primitives/AzureActiveDirectoryTokenProvider.cs b/src/Microsoft.Azure.EventHubs/Primitives/AzureActiveDirectoryTokenProvider.cs index 6877cc6..5fd5d8d 100644 --- a/src/Microsoft.Azure.EventHubs/Primitives/AzureActiveDirectoryTokenProvider.cs +++ b/src/Microsoft.Azure.EventHubs/Primitives/AzureActiveDirectoryTokenProvider.cs @@ -13,8 +13,9 @@ namespace Microsoft.Azure.EventHubs public class AzureActiveDirectoryTokenProvider : TokenProvider { readonly AuthenticationContext authContext; + +#if !UAP10_0 && !IOS readonly ClientCredential clientCredential; -#if !UAP10_0 readonly ClientAssertionCertificate clientAssertionCertificate; #endif readonly string clientId; @@ -32,6 +33,7 @@ namespace Microsoft.Azure.EventHubs readonly AuthType authType; +#if !UAP10_0 && !IOS internal AzureActiveDirectoryTokenProvider(AuthenticationContext authContext, ClientCredential credential) { this.clientCredential = credential; @@ -40,7 +42,6 @@ namespace Microsoft.Azure.EventHubs this.clientId = clientCredential.ClientId; } -#if !UAP10_0 internal AzureActiveDirectoryTokenProvider(AuthenticationContext authContext, ClientAssertionCertificate clientAssertionCertificate) { this.clientAssertionCertificate = clientAssertionCertificate; @@ -72,16 +73,15 @@ namespace Microsoft.Azure.EventHubs switch (this.authType) { +#if !UAP10_0 && !IOS case AuthType.ClientCredential: authResult = await this.authContext.AcquireTokenAsync(ClientConstants.AadEventHubsAudience, this.clientCredential); break; -#if !UAP10_0 case AuthType.ClientAssertionCertificate: authResult = await this.authContext.AcquireTokenAsync(ClientConstants.AadEventHubsAudience, this.clientAssertionCertificate); break; #endif - case AuthType.InteractiveUserLogin: authResult = await this.authContext.AcquireTokenAsync(ClientConstants.AadEventHubsAudience, this.clientId, this.redirectUri, this.platformParameters, this.userIdentifier); break; diff --git a/src/Microsoft.Azure.EventHubs/Primitives/ClientInfo.cs b/src/Microsoft.Azure.EventHubs/Primitives/ClientInfo.cs index a1291ca..3a0165b 100644 --- a/src/Microsoft.Azure.EventHubs/Primitives/ClientInfo.cs +++ b/src/Microsoft.Azure.EventHubs/Primitives/ClientInfo.cs @@ -29,6 +29,8 @@ namespace Microsoft.Azure.EventHubs platform = "UAP"; #elif NET461 platform = Environment.OSVersion.VersionString; +#elif IOS + platform = "IOS"; #endif } catch { } diff --git a/src/Microsoft.Azure.EventHubs/Primitives/JsonSecurityToken.cs b/src/Microsoft.Azure.EventHubs/Primitives/JsonSecurityToken.cs index 2f3e32b..bd866a8 100644 --- a/src/Microsoft.Azure.EventHubs/Primitives/JsonSecurityToken.cs +++ b/src/Microsoft.Azure.EventHubs/Primitives/JsonSecurityToken.cs @@ -4,7 +4,6 @@ namespace Microsoft.Azure.EventHubs { using System; - using System.Collections.ObjectModel; using System.IdentityModel.Tokens; #if !NET461 using System.IdentityModel.Tokens.Jwt; diff --git a/src/Microsoft.Azure.EventHubs/Primitives/TokenProvider.cs b/src/Microsoft.Azure.EventHubs/Primitives/TokenProvider.cs index c0bb2d2..c208666 100644 --- a/src/Microsoft.Azure.EventHubs/Primitives/TokenProvider.cs +++ b/src/Microsoft.Azure.EventHubs/Primitives/TokenProvider.cs @@ -76,6 +76,8 @@ namespace Microsoft.Azure.EventHubs return new SharedAccessSignatureTokenProvider(keyName, sharedAccessKey, tokenTimeToLive, tokenScope); } + +#if !UAP10_0 && !IOS /// Creates an Azure Active Directory token provider. /// AuthenticationContext for AAD. /// The app credential. @@ -87,6 +89,7 @@ namespace Microsoft.Azure.EventHubs return new AzureActiveDirectoryTokenProvider(authContext, clientCredential); } +#endif /// Creates an Azure Active Directory token provider. /// AuthenticationContext for AAD. @@ -110,7 +113,7 @@ namespace Microsoft.Azure.EventHubs return new AzureActiveDirectoryTokenProvider(authContext, clientId, redirectUri, platformParameters, userIdentifier); } -#if !UAP10_0 +#if !UAP10_0 && !IOS /// Creates an Azure Active Directory token provider. /// AuthenticationContext for AAD. /// The client assertion certificate credential.