Skip to content

Commit eac59be

Browse files
Merge pull request #94 from StuartFerguson/task/#93_net5upgrade
Net 5 Upgrade
2 parents 64bc346 + 1a1f711 commit eac59be

91 files changed

Lines changed: 4950 additions & 2131 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

SecurityService.Client/ISecurityServiceClient.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ public interface ISecurityServiceClient
2424
Task<CreateApiResourceResponse> CreateApiResource(CreateApiResourceRequest createApiResourceRequest,
2525
CancellationToken cancellationToken);
2626

27+
/// <summary>
28+
/// Creates the API scope.
29+
/// </summary>
30+
/// <param name="createApiScopeRequest">The create API scope request.</param>
31+
/// <param name="cancellationToken">The cancellation token.</param>
32+
/// <returns></returns>
33+
Task<CreateApiScopeResponse> CreateApiScope(CreateApiScopeRequest createApiScopeRequest,
34+
CancellationToken cancellationToken);
35+
2736
/// <summary>
2837
/// Creates the client.
2938
/// </summary>
@@ -69,13 +78,29 @@ Task<CreateUserResponse> CreateUser(CreateUserRequest createUserRequest,
6978
Task<ApiResourceDetails> GetApiResource(String apiResourceName,
7079
CancellationToken cancellationToken);
7180

81+
/// <summary>
82+
/// Gets the API scope.
83+
/// </summary>
84+
/// <param name="apiScopeName">Name of the API scope.</param>
85+
/// <param name="cancellationToken">The cancellation token.</param>
86+
/// <returns></returns>
87+
Task<ApiScopeDetails> GetApiScope(String apiScopeName,
88+
CancellationToken cancellationToken);
89+
7290
/// <summary>
7391
/// Gets the API resources.
7492
/// </summary>
7593
/// <param name="cancellationToken">The cancellation token.</param>
7694
/// <returns></returns>
7795
Task<List<ApiResourceDetails>> GetApiResources(CancellationToken cancellationToken);
7896

97+
/// <summary>
98+
/// Gets the API scopes.
99+
/// </summary>
100+
/// <param name="cancellationToken">The cancellation token.</param>
101+
/// <returns></returns>
102+
Task<List<ApiScopeDetails>> GetApiScopes(CancellationToken cancellationToken);
103+
79104
/// <summary>
80105
/// Gets the client.
81106
/// </summary>

SecurityService.Client/SecurityService.Client.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55
<TargetsForTfmSpecificBuildOutput>$(TargetsForTfmSpecificBuildOutput);IncludeP2PAssets</TargetsForTfmSpecificBuildOutput>
66
</PropertyGroup>
77

88
<ItemGroup>
9-
<PackageReference Include="ClientProxyBase" Version="0.0.8.1" />
9+
<PackageReference Include="ClientProxyBase" Version="1.0.3" />
1010
</ItemGroup>
1111

1212
<ItemGroup>

SecurityService.Client/SecurityServiceClient.cs

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,47 @@ public async Task<CreateApiResourceResponse> CreateApiResource(CreateApiResource
9595
return response;
9696
}
9797

98+
/// <summary>
99+
/// Creates the API scope.
100+
/// </summary>
101+
/// <param name="createApiScopeRequest">The create API scope request.</param>
102+
/// <param name="cancellationToken">The cancellation token.</param>
103+
/// <returns></returns>
104+
public async Task<CreateApiScopeResponse> CreateApiScope(CreateApiScopeRequest createApiScopeRequest,
105+
CancellationToken cancellationToken)
106+
{
107+
CreateApiScopeResponse response = null;
108+
String requestUri = this.BuildRequestUrl("/api/apiscopes");
109+
110+
try
111+
{
112+
String requestSerialised = JsonConvert.SerializeObject(createApiScopeRequest);
113+
114+
StringContent httpContent = new StringContent(requestSerialised, Encoding.UTF8, "application/json");
115+
116+
// Add the access token to the client headers
117+
//this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
118+
119+
// Make the Http Call here
120+
HttpResponseMessage httpResponse = await this.HttpClient.PostAsync(requestUri, httpContent, cancellationToken);
121+
122+
// Process the response
123+
String content = await this.HandleResponse(httpResponse, cancellationToken);
124+
125+
// call was successful so now deserialise the body to the response object
126+
response = JsonConvert.DeserializeObject<CreateApiScopeResponse>(content);
127+
}
128+
catch(Exception ex)
129+
{
130+
// An exception has occurred, add some additional information to the message
131+
Exception exception = new Exception($"Error creating api scope {createApiScopeRequest.Name}.", ex);
132+
133+
throw exception;
134+
}
135+
136+
return response;
137+
}
138+
98139
/// <summary>
99140
/// Creates the client.
100141
/// </summary>
@@ -331,6 +372,78 @@ public async Task<List<ApiResourceDetails>> GetApiResources(CancellationToken ca
331372
return response;
332373
}
333374

375+
/// <summary>
376+
/// Gets the API scope.
377+
/// </summary>
378+
/// <param name="apiScopeName">Name of the API scope.</param>
379+
/// <param name="cancellationToken">The cancellation token.</param>
380+
/// <returns></returns>
381+
public async Task<ApiScopeDetails> GetApiScope(String apiScopeName,
382+
CancellationToken cancellationToken)
383+
{
384+
ApiScopeDetails response = null;
385+
String requestUri = this.BuildRequestUrl($"/api/apiscopes/{apiScopeName}");
386+
387+
try
388+
{
389+
// Add the access token to the client headers
390+
//this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
391+
392+
// Make the Http Call here
393+
HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken);
394+
395+
// Process the response
396+
String content = await this.HandleResponse(httpResponse, cancellationToken);
397+
398+
// call was successful so now deserialise the body to the response object
399+
response = JsonConvert.DeserializeObject<ApiScopeDetails>(content);
400+
}
401+
catch(Exception ex)
402+
{
403+
// An exception has occurred, add some additional information to the message
404+
Exception exception = new Exception($"Error getting api scope {apiScopeName}.", ex);
405+
406+
throw exception;
407+
}
408+
409+
return response;
410+
}
411+
412+
/// <summary>
413+
/// Gets the API scopes.
414+
/// </summary>
415+
/// <param name="cancellationToken">The cancellation token.</param>
416+
/// <returns></returns>
417+
public async Task<List<ApiScopeDetails>> GetApiScopes(CancellationToken cancellationToken)
418+
{
419+
List<ApiScopeDetails> response = null;
420+
String requestUri = this.BuildRequestUrl("/api/apiscopes");
421+
422+
try
423+
{
424+
// Add the access token to the client headers
425+
//this.HttpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
426+
427+
// Make the Http Call here
428+
HttpResponseMessage httpResponse = await this.HttpClient.GetAsync(requestUri, cancellationToken);
429+
430+
// Process the response
431+
String content = await this.HandleResponse(httpResponse, cancellationToken);
432+
433+
// call was successful so now deserialise the body to the response object
434+
response = JsonConvert.DeserializeObject<List<ApiScopeDetails>>(content);
435+
}
436+
catch(Exception ex)
437+
{
438+
// An exception has occurred, add some additional information to the message
439+
Exception exception = new Exception("Error getting api scopes.", ex);
440+
441+
throw exception;
442+
}
443+
444+
return response;
445+
}
446+
334447
/// <summary>
335448
/// Gets the client.
336449
/// </summary>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
namespace SecurityService.DataTransferObjects.Requests
2+
{
3+
using System;
4+
using System.Diagnostics.CodeAnalysis;
5+
using Newtonsoft.Json;
6+
7+
[ExcludeFromCodeCoverage]
8+
public class CreateApiScopeRequest
9+
{
10+
#region Properties
11+
12+
/// <summary>
13+
/// Gets or sets the description.
14+
/// </summary>
15+
/// <value>
16+
/// The description.
17+
/// </value>
18+
[JsonProperty("description")]
19+
public String Description { get; set; }
20+
21+
/// <summary>
22+
/// Gets or sets the display name.
23+
/// </summary>
24+
/// <value>
25+
/// The display name.
26+
/// </value>
27+
[JsonProperty("display_name")]
28+
public String DisplayName { get; set; }
29+
30+
/// <summary>
31+
/// Gets or sets the name.
32+
/// </summary>
33+
/// <value>
34+
/// The name.
35+
/// </value>
36+
[JsonProperty("name")]
37+
public String Name { get; set; }
38+
39+
#endregion
40+
}
41+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
namespace SecurityService.DataTransferObjects.Responses
2+
{
3+
using System;
4+
using System.Diagnostics.CodeAnalysis;
5+
using Newtonsoft.Json;
6+
7+
[ExcludeFromCodeCoverage]
8+
public class ApiScopeDetails
9+
{
10+
#region Properties
11+
12+
/// <summary>
13+
/// Gets or sets the description.
14+
/// </summary>
15+
/// <value>
16+
/// The description.
17+
/// </value>
18+
[JsonProperty("description")]
19+
public String Description { get; set; }
20+
21+
/// <summary>
22+
/// Gets or sets the display name.
23+
/// </summary>
24+
/// <value>
25+
/// The display name.
26+
/// </value>
27+
[JsonProperty("display_name")]
28+
public String DisplayName { get; set; }
29+
30+
/// <summary>
31+
/// Gets or sets a value indicating whether this <see cref="ApiResourceDetails"/> is enabled.
32+
/// </summary>
33+
/// <value>
34+
/// <c>true</c> if enabled; otherwise, <c>false</c>.
35+
/// </value>
36+
[JsonProperty("enabled")]
37+
public Boolean Enabled { get; set; }
38+
39+
/// <summary>
40+
/// Gets or sets the name.
41+
/// </summary>
42+
/// <value>
43+
/// The name.
44+
/// </value>
45+
[JsonProperty("name")]
46+
public String Name { get; set; }
47+
48+
#endregion
49+
}
50+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
namespace SecurityService.DataTransferObjects.Responses
2+
{
3+
using System;
4+
using System.Diagnostics.CodeAnalysis;
5+
using Newtonsoft.Json;
6+
7+
[ExcludeFromCodeCoverage]
8+
public class CreateApiScopeResponse
9+
{
10+
/// <summary>
11+
/// Gets or sets the name of the API scope.
12+
/// </summary>
13+
/// <value>
14+
/// The name of the API scope.
15+
/// </value>
16+
[JsonProperty("api_scope_name")]
17+
public String ApiScopeName { get; set; }
18+
}
19+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<TargetFramework>netstandard2.0</TargetFramework>
4+
<TargetFramework>net5.0</TargetFramework>
55
</PropertyGroup>
66

77
<ItemGroup>
88
<PackageReference Include="Microsoft.CSharp" Version="4.7.0" />
99
<PackageReference Include="Newtonsoft.Json" Version="12.0.3" />
10-
<PackageReference Include="System.ComponentModel.Annotations" Version="4.7.0" />
10+
<PackageReference Include="System.ComponentModel.Annotations" Version="5.0.0" />
1111
</ItemGroup>
1212

1313
</Project>

0 commit comments

Comments
 (0)