Moving AD SDK 4.5 and Xamarin.iOS10 support (#365)
This commit is contained in:
Родитель
cec369a9fa
Коммит
11770231c5
|
@ -84,6 +84,7 @@ namespace Microsoft.Azure.EventHubs
|
|||
return eventHubClient;
|
||||
}
|
||||
|
||||
#if !UAP10_0 && !IOS
|
||||
/// <summary>
|
||||
/// Creates a new instance of the Event Hubs client using the specified endpoint, entity path, AAD authentication context.
|
||||
/// </summary>
|
||||
|
@ -109,6 +110,7 @@ namespace Microsoft.Azure.EventHubs
|
|||
operationTimeout,
|
||||
transportType);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
/// <summary>
|
||||
/// Creates a new instance of the Event Hubs client using the specified endpoint, entity path, AAD authentication context.
|
||||
/// </summary>
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
<AssemblyTitle>Microsoft.Azure.EventHubs</AssemblyTitle>
|
||||
<VersionPrefix>2.2.0</VersionPrefix>
|
||||
<Authors>Microsoft</Authors>
|
||||
<TargetFrameworks>net461;netstandard2.0;uap10.0</TargetFrameworks>
|
||||
<TargetFrameworks>net461;netstandard2.0;uap10.0;Xamarin.iOS10</TargetFrameworks>
|
||||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
|
||||
<AssemblyName>Microsoft.Azure.EventHubs</AssemblyName>
|
||||
<AssemblyOriginatorKeyFile>../../build/keyfile.snk</AssemblyOriginatorKeyFile>
|
||||
|
@ -49,11 +49,15 @@
|
|||
<DefineConstants>$(DefineConstants);NETSTANDARD2_0</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$(TargetFramework)' == 'Xamarin.iOS10'">
|
||||
<DefineConstants>$(DefineConstants);IOS</DefineConstants>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'net461' ">
|
||||
<Reference Include="System" />
|
||||
<Reference Include="Microsoft.CSharp" />
|
||||
<Reference Include="System.IdentityModel" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="4.0.4.403061554" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="4.0.4.403061554" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'netstandard2.0' ">
|
||||
|
@ -67,17 +71,21 @@
|
|||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.2.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup Condition=" '$(TargetFramework)' == 'Xamarin.iOS10' ">
|
||||
<PackageReference Include="MSBuild.Sdk.Extras" Version="1.6.40" PrivateAssets="All" />
|
||||
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="5.2.4" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Azure.Amqp" Version="2.3.7" />
|
||||
<PackageReference Include="Microsoft.Azure.Services.AppAuthentication" Version="1.0.3" />
|
||||
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="3.19.8" />
|
||||
<PackageReference Include="Microsoft.IdentityModel.Clients.ActiveDirectory" Version="4.5.0" />
|
||||
<PackageReference Include="System.Diagnostics.DiagnosticSource" Version="4.5.0" />
|
||||
<PackageReference Include="System.Net.Http" Version="4.3.3" />
|
||||
<PackageReference Include="System.Reflection.TypeExtensions" Version="4.5.0" />
|
||||
</ItemGroup>
|
||||
|
||||
|
||||
<ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Update="Resources.Designer.cs">
|
||||
<DesignTime>True</DesignTime>
|
||||
<AutoGen>True</AutoGen>
|
||||
|
@ -92,4 +100,6 @@
|
|||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
|
||||
<Import Project="$(MSBuildSdkExtrasTargets)" Condition="Exists('$(MSBuildSdkExtrasTargets)')" />
|
||||
|
||||
</Project>
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -29,6 +29,8 @@ namespace Microsoft.Azure.EventHubs
|
|||
platform = "UAP";
|
||||
#elif NET461
|
||||
platform = Environment.OSVersion.VersionString;
|
||||
#elif IOS
|
||||
platform = "IOS";
|
||||
#endif
|
||||
}
|
||||
catch { }
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -76,6 +76,8 @@ namespace Microsoft.Azure.EventHubs
|
|||
return new SharedAccessSignatureTokenProvider(keyName, sharedAccessKey, tokenTimeToLive, tokenScope);
|
||||
}
|
||||
|
||||
|
||||
#if !UAP10_0 && !IOS
|
||||
/// <summary>Creates an Azure Active Directory token provider.</summary>
|
||||
/// <param name="authContext">AuthenticationContext for AAD.</param>
|
||||
/// <param name="clientCredential">The app credential.</param>
|
||||
|
@ -87,6 +89,7 @@ namespace Microsoft.Azure.EventHubs
|
|||
|
||||
return new AzureActiveDirectoryTokenProvider(authContext, clientCredential);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>Creates an Azure Active Directory token provider.</summary>
|
||||
/// <param name="authContext">AuthenticationContext for AAD.</param>
|
||||
|
@ -110,7 +113,7 @@ namespace Microsoft.Azure.EventHubs
|
|||
return new AzureActiveDirectoryTokenProvider(authContext, clientId, redirectUri, platformParameters, userIdentifier);
|
||||
}
|
||||
|
||||
#if !UAP10_0
|
||||
#if !UAP10_0 && !IOS
|
||||
/// <summary>Creates an Azure Active Directory token provider.</summary>
|
||||
/// <param name="authContext">AuthenticationContext for AAD.</param>
|
||||
/// <param name="clientAssertionCertificate">The client assertion certificate credential.</param>
|
||||
|
|
Загрузка…
Ссылка в новой задаче