Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate AuthenticationProvider lib into Provisioning device lib #2916

Merged
merged 9 commits into from Oct 26, 2022

Conversation

abhipsaMisra
Copy link
Member

The types in AuthenticationProvider are being used only in Microsoft.Azure.Devices.Provisioning.Client, so moving the types in there.

DPS auth -> IoT hub auth:

        private IAuthenticationMethod CreateAuthenticationMethodFromAuthProvider(
            AuthenticationProvider provisioningAuth,
            string deviceId)
        {
            VerboseTestLogger.WriteLine($"{nameof(CreateAuthenticationMethodFromAuthProvider)}({deviceId})");

            IAuthenticationMethod auth;
            if (provisioningAuth is AuthenticationProviderX509 x509Auth)
            {
                X509Certificate2 cert = x509Auth.GetAuthenticationCertificate();
                auth = new ClientAuthenticationWithX509Certificate(cert, deviceId);
            }
            else if (provisioningAuth is AuthenticationProviderSymmetricKey symmetricKeyAuth)
            {
                auth = new ClientAuthenticationWithSharedAccessKeyRefresh(symmetricKeyAuth.GetPrimaryKey(), deviceId);
            }
            else
            {
                throw new NotSupportedException($"Unknown provisioning auth type.");
            }

            return auth;
        }

@abhipsaMisra
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Co-authored-by: David R. Williamson <drwill@microsoft.com>
@abhipsaMisra
Copy link
Member Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

@abhipsaMisra abhipsaMisra merged commit 1fc7ef1 into previews/v2 Oct 26, 2022
@abhipsaMisra abhipsaMisra deleted the abmisr/auth branch October 26, 2022 00:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants