-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPZGetStub.cs
More file actions
50 lines (44 loc) · 1.28 KB
/
PZGetStub.cs
File metadata and controls
50 lines (44 loc) · 1.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using OldMusicBox.ePUAP.Client.Model.Common;
using OldMusicBox.ePUAP.Client;
using System.Security.Cryptography.X509Certificates;
using OldMusicBox.ePUAP.Client.Model.GetSignedDocument;
using Newtonsoft.Json;
namespace PZBridge
{
internal class PZGetStub
{
static string Base64Encode(string plainText)
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(plainText);
return System.Convert.ToBase64String(plainTextBytes);
}
public static void Execute(string[] args)
{
string id = args[1].Split('=').Last();
string tmpFile = Path.Combine(Path.GetTempPath(), $"pzbridge_stub_{id}.xml");
if (!File.Exists(tmpFile))
{
Program.SendFault($"No stub signed document found for id {id}");
return;
}
string xml = File.ReadAllText(tmpFile);
var response = new {
Content = Base64Encode(xml),
Signature = new {
IsValid = true,
NaturalPerson = new {
FirstName = "[name]",
CurrentFamilyName = "[surname]",
PersonalIdentifier = "[pesel]"
},
SignatureData = new {
IdentityIssuer = "PZBridge-stub",
IdentityIssueTimestamp = "[date]"
}
},
IsValid = true
};
Console.Write("{\"ok\": true, \"data\": " + Program.ReplaceStubPlaceholders(JsonConvert.SerializeObject(response)) + "}");
}
}
}