Page History
...
| Code Block | ||
|---|---|---|
| ||
public static async Task LoginToGateway(IdCard idCard, X509Certificate2 userCert)
{
var sosiGwAssertion = idCard.GetAssertion<AssertionType>();
var security = new GW.Security
{
Timestamp = new GW.Timestamp { Created = DateTimeEx.UtcNowRound - TimeSpan.FromMinutes(5) },
Assertion = sosiGwAssertion
};
const string endpointAddress = "http://test1.ekstern-test.nspop.dk:8080/sosigw/service/sosigw";
using var gwClient = new SosiGWFacadeClient(SosiGWSoapBinding, endpointAddress);
var dig = (await gwClient.requestIdCardDigestForSigningAsync(security, "whatever")).requestIdCardDigestForSigningResponse;
var digestHash = SHA1.HashData(dig.DigestValue);
var signature = userCert.GetRSAPrivateKey().SignHash(digestHash, HashAlgorithmName.SHA1, RSASignaturePadding.Pkcs1);
var cardRequestBody = new signIdCardRequestBody
{
SignatureValue = signature,
KeyInfo = new GW.KeyInfo
{
Item = new GW.X509Data { Item = userCert.Export(X509ContentType.Cert) }
}
};
// The STS signed card is saved in the sosiGw cache and is used for future calls through the proxy
var res = (await gwClient.signIdCardAsync(security, cardRequestBody)).signIdCardResponse;
if (res != signIdCardResponse.ok) { throw new Exception("Gateway logon error"); }
// Convert the GW Assertion to a dgwsType Assertion
var sosiGwAssertionDocument = SerializerUtil.Serialize(sosiGwAssertion).Root;
SerializerUtil.Deserialize<Assertion>(sosiGwAssertionDocument, typeof(AssertionType).Name);
} |
SOSI Gateway SBO
Dette bruges til almindelige SOAP kald, hvor GW vil berige ID kortet med det den har gemt i dens cache. Det er derfor et krav at ID kortet først er oprettet i GW. Bruges f.eks. til FMK og DDS.
Her vises et eksempel med FMK:
var idCardRequest = factory.CreateNewUserIdCard(system.SystemName, userInfo, new CareProvider(system.CareProviderIdFormat, system.CareProviderId, system.CareProviderName), AuthenticationLevel.MocesTrustedUser, "", "", user.Certificate, "");
- LoginToGateway(idCardRequest, global.NsiLge1);
- var client = new MedicineCardPortTypeClient("SosiGWFMK");
- var response = client.GetMedicineCard_2015_06_01(
new GetMedicineCardRequest_2015_06_01
{
Security = SecurityHeaderUtil.MakeSecurityUsingDgwsTypes(idc),
Header = requestHeader,
WhitelistingHeader = makeWhitelistingHeader,
GetMedicineCardRequest = new GetMedicineCardRequestType
{
PersonIdentifier = new PersonIdentifierType
{
source = "CPR",
Value = requestCpr
}
}
});
SOSI Gateway SBO
SOSI Gateway kan bruges til SBO (Sikker Browser Opstart).
...