Skip to content

Commit 3e1e9cf

Browse files
Start to create a fake wallet
1 parent 528636d commit 3e1e9cf

3 files changed

Lines changed: 73 additions & 0 deletions

File tree

SimpleIdServer.CredentialIssuer.Host.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SimpleIdServer.CredentialIs
3535
EndProject
3636
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "json-ld.net", "json-ld.net\src\json-ld.net\json-ld.net.csproj", "{B51DC1D9-4A57-4D36-B61C-F93D61878321}"
3737
EndProject
38+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SimpleIdServer.CredentialIssuer.Console", "src\CredentialIssuer\SimpleIdServer.CredentialIssuer.Console\SimpleIdServer.CredentialIssuer.Console.csproj", "{DAB56B5C-8F1B-4B56-90A0-DB19332D8630}"
39+
EndProject
3840
Global
3941
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4042
Debug|Any CPU = Debug|Any CPU
@@ -89,6 +91,10 @@ Global
8991
{B51DC1D9-4A57-4D36-B61C-F93D61878321}.Debug|Any CPU.Build.0 = Debug|Any CPU
9092
{B51DC1D9-4A57-4D36-B61C-F93D61878321}.Release|Any CPU.ActiveCfg = Release|Any CPU
9193
{B51DC1D9-4A57-4D36-B61C-F93D61878321}.Release|Any CPU.Build.0 = Release|Any CPU
94+
{DAB56B5C-8F1B-4B56-90A0-DB19332D8630}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
95+
{DAB56B5C-8F1B-4B56-90A0-DB19332D8630}.Debug|Any CPU.Build.0 = Debug|Any CPU
96+
{DAB56B5C-8F1B-4B56-90A0-DB19332D8630}.Release|Any CPU.ActiveCfg = Release|Any CPU
97+
{DAB56B5C-8F1B-4B56-90A0-DB19332D8630}.Release|Any CPU.Build.0 = Release|Any CPU
9298
EndGlobalSection
9399
GlobalSection(SolutionProperties) = preSolution
94100
HideSolutionNode = FALSE
@@ -107,6 +113,7 @@ Global
107113
{6B7D2058-4163-4D5B-B002-FBBCD26C80FB} = {E81A364B-F1A9-4BAB-95F9-8163AF8A0FD9}
108114
{651DAE84-AB36-4D05-B604-3B4A6C885B05} = {E2AE7484-8B8A-4B03-A5E8-93E65905E3DF}
109115
{B51DC1D9-4A57-4D36-B61C-F93D61878321} = {CAD5C508-21EA-441F-843E-0E5B6CB9A102}
116+
{DAB56B5C-8F1B-4B56-90A0-DB19332D8630} = {E2AE7484-8B8A-4B03-A5E8-93E65905E3DF}
110117
EndGlobalSection
111118
GlobalSection(ExtensibilityGlobals) = postSolution
112119
SolutionGuid = {AEF94609-C4E0-43B5-ACF8-6EE13FDD5804}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// See https://aka.ms/new-console-template for more information
2+
using SimpleIdServer.CredentialIssuer.Api.CredentialIssuer;
3+
using System.Text.Json;
4+
using System.Text.Json.Nodes;
5+
using System.Web;
6+
using static QRCoder.PayloadGenerator;
7+
8+
using (var httpClient = new HttpClient())
9+
{
10+
var openidCredentialIssuer = GetOpenidCredentialIssuer(httpClient).Result;
11+
var authorizationEndpoint = GetAuthorizationEndpoint(httpClient, openidCredentialIssuer.AuthorizationServer).Result;
12+
ExecuteAuthorizationRequest(httpClient, authorizationEndpoint).Wait();
13+
}
14+
15+
async Task<ESBICredentialIssuerResult> GetOpenidCredentialIssuer(HttpClient httpClient)
16+
{
17+
var url = "https://api-conformance.ebsi.eu/conformance/v3/issuer-mock/.well-known/openid-credential-issuer";
18+
var requestMessage = new HttpRequestMessage(HttpMethod.Get, url);
19+
var httpResult = await httpClient.SendAsync(requestMessage);
20+
var json = await httpResult.Content.ReadAsStringAsync();
21+
var openidCredentialIssuer = JsonSerializer.Deserialize<ESBICredentialIssuerResult>(json);
22+
return openidCredentialIssuer;
23+
}
24+
25+
async Task<string> GetAuthorizationEndpoint(HttpClient httpClient, string authUrl)
26+
{
27+
var requestMessage = new HttpRequestMessage(HttpMethod.Get, $"{authUrl}/.well-known/openid-configuration");
28+
var httpResult = await httpClient.SendAsync(requestMessage);
29+
var json = await httpResult.Content.ReadAsStringAsync();
30+
return JsonObject.Parse(json)["authorization_endpoint"].ToString();
31+
}
32+
33+
async Task ExecuteAuthorizationRequest(HttpClient httpClient, string url)
34+
{
35+
var uriBuilder = new UriBuilder(url);
36+
var dic = new Dictionary<string, string>
37+
{
38+
{ "client_id", "did:key:z2dmzD81cgPx8Vki7JbuuMmFYrWPgYoytykUZ3eyqht1j9KbpMAoXtZtunruYnM4gCV65AKAUX2AwEReRhEaf3BRQNJArZPwQdmf9ENZcF8VT13a58WsHeVjJtvAKKPYEibaEfdUxvU7sgxEUTJpjEkq6BJKrRV1JQ1CqhYvGbmJ1WyoUQ" },
39+
{ "redirect_uri", "http://localhost:5005" },
40+
{ "scope", "openid" },
41+
{ "response_type", "code" }
42+
};
43+
uriBuilder.Query = string.Join("&", dic.Select(kvp => $"{kvp.Key}={kvp.Value}"));
44+
var requestMessage = new HttpRequestMessage
45+
{
46+
RequestUri = uriBuilder.Uri
47+
};
48+
var httpResult = await httpClient.SendAsync(requestMessage);
49+
var result = httpResult.Headers.Location.AbsoluteUri;
50+
var json = await httpResult.Content.ReadAsStringAsync();
51+
52+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
<ItemGroup>
11+
<ProjectReference Include="..\SimpleIdServer.CredentialIssuer\SimpleIdServer.CredentialIssuer.csproj" />
12+
</ItemGroup>
13+
14+
</Project>

0 commit comments

Comments
 (0)