-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
systemregisterclient calls auth comp (#271)
* systemregisterclient calls auth comp * json and appsetting fixes * remove local dev stuff
- Loading branch information
1 parent
12580d2
commit fe55e9f
Showing
4 changed files
with
54 additions
and
79 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
117 changes: 39 additions & 78 deletions
117
...entication.UI/Altinn.Authentication.UI.Integration/SystemRegister/SystemRegisterClient.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 |
---|---|---|
@@ -1,90 +1,51 @@ | ||
using Altinn.Authentication.UI.Core.SystemRegister; | ||
using Altinn.Authentication.UI.Core.Authentication; | ||
using Altinn.Authentication.UI.Core.SystemRegister; | ||
using Altinn.Authentication.UI.Integration.AccessToken; | ||
using Altinn.Authentication.UI.Integration.Configuration; | ||
using Microsoft.AspNetCore.Http; | ||
using Microsoft.Extensions.Logging; | ||
using Altinn.Authentication.UI.Core.Extensions; | ||
using System.Text.Json; | ||
using Microsoft.Extensions.Options; | ||
|
||
namespace Altinn.Authentication.UI.Integration.SystemRegister; | ||
|
||
public class SystemRegisterClient : ISystemRegisterClient | ||
{ | ||
private static async Task<List<RegisteredSystemDTO>> MockTestHelper() | ||
private readonly ILogger _logger; | ||
private readonly HttpClient _httpClient; | ||
private readonly IHttpContextAccessor _httpContextAccessor; | ||
private readonly PlatformSettings _platformSettings; | ||
private readonly IAccessTokenProvider _accessTokenProvider; | ||
|
||
public SystemRegisterClient( | ||
ILogger<SystemRegisterClient> logger, | ||
HttpClient httpClient, | ||
IHttpContextAccessor httpContextAccessor, | ||
IOptions<PlatformSettings> platformSettings, | ||
IAccessTokenProvider accessTokenProvider) | ||
{ | ||
await Task.Delay(250); | ||
|
||
RegisteredSystemDTO regsys1 = new() | ||
{ | ||
SystemTypeId = "4human_hr_system_2024_2", | ||
SystemVendor = "4Human", | ||
Description = "4Humans HR system 2024 versjon.", | ||
DefaultRights = | ||
[ | ||
new DefaultRightsDTO { Right = "Sykemelding - Oppgi leder", ServiceProvider = "Arbeids- og velferdsetaten (NAV)" }, | ||
new DefaultRightsDTO { Right = "Søknad om sykepenger", ServiceProvider = "Arbeids- og velferdsetaten (NAV)" } | ||
] | ||
|
||
}; | ||
|
||
RegisteredSystemDTO regsys2 = new() | ||
{ | ||
SystemTypeId = "din_lokale_regnskapspartner", | ||
SystemVendor = "Din Lokale Regnskapspartner AS", | ||
Description = "Regnskap og Revisor tjenester", | ||
DefaultRights = | ||
[ | ||
new DefaultRightsDTO { Right = "MVA rapportering", ServiceProvider = "Skatteetaten" }, | ||
new DefaultRightsDTO { Right = "Årsregnskap", ServiceProvider = "Skatteetaten" } | ||
] | ||
}; | ||
|
||
RegisteredSystemDTO regsys3 = new() | ||
{ | ||
SystemTypeId = "fiken_smabedrift", | ||
SystemVendor = "Fiken", | ||
Description = "Fiken Småbedrift pakken", | ||
DefaultRights = | ||
[ | ||
new DefaultRightsDTO { Right = "MVA rapportering", ServiceProvider = "Skatteetaten" }, | ||
new DefaultRightsDTO { Right = "Årsregnskap", ServiceProvider = "Skatteetaten" } | ||
] | ||
}; | ||
|
||
RegisteredSystemDTO regsys4 = new() | ||
{ | ||
SystemTypeId = "visma_mva_pakke", | ||
SystemVendor ="Visma", | ||
Description = "Visma MVA rapportering", | ||
DefaultRights = | ||
[ | ||
new DefaultRightsDTO { Right = "MVA rapportering", ServiceProvider = "Skatteetaten" } | ||
] | ||
_logger = logger; | ||
_httpContextAccessor = httpContextAccessor; | ||
_platformSettings = platformSettings.Value; | ||
_accessTokenProvider = accessTokenProvider; | ||
httpClient.BaseAddress = new Uri(_platformSettings!.ApiAuthenticationEndpoint!); | ||
httpClient.DefaultRequestHeaders.Add(_platformSettings.SubscriptionKeyHeaderName, _platformSettings.SubscriptionKey); | ||
_httpClient = httpClient; | ||
} | ||
|
||
}; | ||
public async Task<List<RegisteredSystemDTO>> GetListRegSys(CancellationToken cancellationToken = default) | ||
{ | ||
string token = JwtTokenUtil.GetTokenFromContext(_httpContextAccessor.HttpContext!, _platformSettings.JwtCookieName!)!; | ||
string endpointUrl = $"systemregister"; | ||
var accessToken = await _accessTokenProvider.GetAccessToken(); | ||
|
||
RegisteredSystemDTO regsys5 = new() | ||
{ | ||
SystemTypeId = "visma_skatt_totalpakke", | ||
SystemVendor ="Visma", | ||
Description = "Visma Totalpakke for alle skatterapporterings behov", | ||
DefaultRights = | ||
[ | ||
new DefaultRightsDTO { Right = "MVA rapportering", ServiceProvider = "Skatteetaten" }, | ||
new DefaultRightsDTO { Right = "Årsregnskap", ServiceProvider = "Skatteetaten" }, | ||
new DefaultRightsDTO { Right = "Bytte av Revisor", ServiceProvider = "Skatteetaten" }, | ||
new DefaultRightsDTO { Right = "Levere Lakselus", ServiceProvider = "Mattilsynet" }, | ||
] | ||
}; | ||
HttpResponseMessage response = await _httpClient.GetAsync(token, endpointUrl, accessToken); | ||
|
||
List<RegisteredSystemDTO> theList = new() | ||
if (response.IsSuccessStatusCode) | ||
{ | ||
regsys1, | ||
regsys2, | ||
regsys3, | ||
regsys4, | ||
regsys5 | ||
}; | ||
|
||
return theList; | ||
} | ||
|
||
public async Task<List<RegisteredSystemDTO>> GetListRegSys(CancellationToken cancellationToken) | ||
{ | ||
return await MockTestHelper(); | ||
return JsonSerializer.Deserialize<List<RegisteredSystemDTO>>(await response.Content.ReadAsStringAsync(cancellationToken), new JsonSerializerOptions() { PropertyNameCaseInsensitive = true})!; | ||
} | ||
return []; | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
bff/src/Altinn.Authentication.UI/Altinn.Authentication.UI/appsettings.json
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