Skip to content

Instantly share code, notes, and snippets.

@johnviggo
Created March 7, 2016 12:23
Show Gist options
  • Save johnviggo/a1c7de42db9dc5274ea0 to your computer and use it in GitHub Desktop.
Save johnviggo/a1c7de42db9dc5274ea0 to your computer and use it in GitHub Desktop.
using Difi.Oppslagstjeneste.Klient;
using System;
using System.Security.Cryptography.X509Certificates;
namespace Hemit.BizTalk.DifiTest
{
class Program
{
static void Main(string[] args)
{
string sThumbPrint = "ce5e1b25bf811536b9833ba1edd90f05519a4c72";
Console.WriteLine("Henter cert med thumbprint " + sThumbPrint);
X509Store certStore = new X509Store(StoreName.My, StoreLocation.CurrentUser);
// Try to open the store.
certStore.Open(OpenFlags.ReadOnly);
// Find the certificate that matches the thumbprint.
X509Certificate2Collection certCollection = certStore.Certificates.Find(X509FindType.FindByThumbprint, sThumbPrint, false);
certStore.Close();
// Check to see if our certificate was added to the collection. If no, throw an error, if yes, create a certificate using it.
if (0 == certCollection.Count)
{
Console.WriteLine("Fant ikke sertifikat med thumbprint " + sThumbPrint);
}
else
{
Console.WriteLine("Sertifikat for thumbprint " + sThumbPrint + " funnet: " + certCollection[0].FriendlyName);
}
Console.WriteLine("OppslagstjenesteKlient.HentPersoner med thumbprint " + sThumbPrint);
System.Collections.Generic.IEnumerable<Difi.Oppslagstjeneste.Klient.Domene.Entiteter.Person> personer = HentPersoner("08088800205");
}
private static System.Collections.Generic.IEnumerable<Difi.Oppslagstjeneste.Klient.Domene.Entiteter.Person> HentPersoner(string personNummer)
{
var konfig = new OppslagstjenesteKonfigurasjon(Miljø.FunksjoneltTestmiljø);
OppslagstjenesteKlient register = new OppslagstjenesteKlient("ce5e1b25bf811536b9833ba1edd90f05519a4c72", konfig);
var personer = register.HentPersoner(new string[] { personNummer },
Informasjonsbehov.Person |
Informasjonsbehov.Sertifikat |
Informasjonsbehov.Kontaktinfo |
Informasjonsbehov.SikkerDigitalPost);
return personer;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment