-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #53 from michelin/issue_#33_get_device_connection_…
…string_only_on_button_click Issue #33 get device connection string only on button click
- Loading branch information
Showing
6 changed files
with
76 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/AzureIoTHub.Portal/Server/Managers/ConnectionStringManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (c) CGI France - Grand Est. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Server.Managers | ||
{ | ||
using System.Threading.Tasks; | ||
using AzureIoTHub.Portal.Server.Helpers; | ||
using AzureIoTHub.Portal.Server.Services; | ||
|
||
public class ConnectionStringManager : IConnectionStringManager | ||
{ | ||
private readonly IDeviceService deviceService; | ||
|
||
public ConnectionStringManager(IDeviceService deviceService) | ||
{ | ||
this.deviceService = deviceService; | ||
} | ||
|
||
public async Task<string> GetSymmetricKey(string deviceId) | ||
{ | ||
try | ||
{ | ||
var attestationMechanism = await this.deviceService.GetDpsAttestionMechanism(); | ||
|
||
return DeviceHelper.RetrieveSymmetricKey(deviceId, attestationMechanism); | ||
} | ||
catch (System.Exception e) | ||
{ | ||
throw new System.Exception(e.Message); | ||
} | ||
} | ||
} | ||
} |
12 changes: 12 additions & 0 deletions
12
src/AzureIoTHub.Portal/Server/Managers/IConnectionStringManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// Copyright (c) CGI France - Grand Est. All rights reserved. | ||
// Licensed under the MIT license. See LICENSE file in the project root for full license information. | ||
|
||
namespace AzureIoTHub.Portal.Server.Managers | ||
{ | ||
using System.Threading.Tasks; | ||
|
||
public interface IConnectionStringManager | ||
{ | ||
Task<string> GetSymmetricKey(string deviceId); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters