public void ConfigViaCode() { //Create SSOBinding var ssoBinding = new SsoBinding(); ssoBinding.Security.Mode = WSFederationHttpSecurityMode.Message; ssoBinding.Security.Message.IssuedKeyType = SecurityKeyType.AsymmetricKey; ssoBinding.Security.Message.NegotiateServiceCredential = false; ssoBinding.Security.Message.EstablishSecurityContext = false; ssoBinding.Security.Message.IssuerAddress = new EndpointAddress("https://services-acpt.ehealth.fgov.be/IAM/Saml11TokenService/Legacy/v1"); ssoBinding.Security.Message.IssuerBinding = new StsBinding(); bindMandate(ssoBinding); //bindHospital(ssoBinding); //Create the Consult proxy GenericInsurabilityPortTypeClient client = new GenericInsurabilityPortTypeClient(ssoBinding, new EndpointAddress("https://services-acpt.ehealth.fgov.be/GenericInsurability/v1")); client.Endpoint.Behaviors.Remove <ClientCredentials>(); client.Endpoint.Behaviors.Add(new SsoClientCredentials()); authenticateSelf(client); //authenticateHosptial(client); DoTest(client); }
public void ConfigViaCode() { //Create SSOBinding var ssoBinding = new SsoBinding(); ssoBinding.Security.Mode = WSFederationHttpSecurityMode.Message; ssoBinding.Security.Message.IssuedKeyType = SecurityKeyType.AsymmetricKey; ssoBinding.Security.Message.NegotiateServiceCredential = false; ssoBinding.Security.Message.EstablishSecurityContext = false; ssoBinding.Security.Message.IssuerAddress = new EndpointAddress("https://services-acpt.ehealth.fgov.be/IAM/Saml11TokenService/Legacy/v1"); ssoBinding.Security.Message.IssuerBinding = new StsBinding(); bindMandate(ssoBinding); //bindHospital(ssoBinding); //Create the Consult proxy GenericInsurabilityPortTypeClient client = new GenericInsurabilityPortTypeClient(ssoBinding, new EndpointAddress("https://services-acpt.ehealth.fgov.be/GenericInsurability/v1")); client.Endpoint.Behaviors.Remove<ClientCredentials>(); client.Endpoint.Behaviors.Add(new SsoClientCredentials()); authenticateSelf(client); //authenticateHosptial(client); DoTest(client); }
private static void authenticateHosptial(GenericInsurabilityPortTypeClient client) { X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly); //get the eHealth certificate of the hospital X509Certificate2 ehCert = store.Certificates.Find(X509FindType.FindByThumbprint, "415442ca384c853231e203fafa9a436f33b4043b", false)[0]; XmlDocument fscConfig = new XmlDocument(); fscConfig.LoadXml(@"<path>C:\Users\admin\Documents\tmp</path>"); client.Endpoint.Behaviors.Add(new SessionBehavior(ehCert, TimeSpan.FromHours(1), typeof(FileSessionCache), fscConfig)); client.ClientCredentials.ClientCertificate.Certificate = ehCert; //must be put after the behavior }
private static void authenticateSelf(GenericInsurabilityPortTypeClient client) { X509Store store = new X509Store(StoreName.My, StoreLocation.CurrentUser); store.Open(OpenFlags.ReadOnly); X509Certificate2 ehCert = store.Certificates.Find(X509FindType.FindByThumbprint, "c93081ddfaf2773a118791ac6c81fc11a3194014", false)[0]; XmlDocument fscConfig = new XmlDocument(); fscConfig.LoadXml(@"<path>C:\Users\admin\Documents\tmp</path>"); client.Endpoint.Behaviors.Add(new SessionBehavior(ehCert, TimeSpan.FromHours(1), typeof(FileSessionCache), fscConfig)); client.ClientCredentials.ClientCertificate.SetCertificate(StoreLocation.CurrentUser, StoreName.My, X509FindType.FindByThumbprint, "1ac02600f2f2b68f99f1e8eeab2e780470e0ea4c"); }
public void ConfigViaConfig() { GenericInsurabilityPortTypeClient client = new GenericInsurabilityPortTypeClient("MandateEP"); DoTest(client); }
private static void DoTest(GenericInsurabilityPortTypeClient client) { GetInsurabilityAsXmlOrFlatRequestType request = new GetInsurabilityAsXmlOrFlatRequestType(); //Create common input with info about the requestor, must match SAML request.CommonInput = new CommonInputType(); request.CommonInput.InputReference = "PRIG1234567890"; request.CommonInput.Request = new RequestType1(); request.CommonInput.Request.IsTest = false; request.CommonInput.Origin = new OriginType(); request.CommonInput.Origin.Package = new PackageType(); request.CommonInput.Origin.Package.Name = new ValueRefString(); request.CommonInput.Origin.Package.Name.Value = "eH-I Test"; request.CommonInput.Origin.Package.License = new LicenseType(); //request.CommonInput.Origin.Package.License.Username = "******"; //request.CommonInput.Origin.Package.License.Password = "******"; request.CommonInput.Origin.Package.License.Username = "******"; request.CommonInput.Origin.Package.License.Password = "******"; //setDoctor(request); //setHospital(request); setMandatedDoctor(request); //Create record common input, contains additional tracking info request.RecordCommonInput = new RecordCommonInputType(); request.RecordCommonInput.InputReferenceSpecified = true; request.RecordCommonInput.InputReference = new decimal(1234567890123L); //Create actual request (attributes should not be provided) request.Request = new SingleInsurabilityRequestType(); request.Request.CareReceiverId = new CareReceiverIdType(); request.Request.CareReceiverId.Inss = "79021802145"; request.Request.InsurabilityRequestDetail = new InsurabilityRequestDetailType(); request.Request.InsurabilityRequestDetail.Period = new PeriodType(); request.Request.InsurabilityRequestDetail.Period.PeriodStartSpecified = true; request.Request.InsurabilityRequestDetail.Period.PeriodStart = DateTime.UtcNow; request.Request.InsurabilityRequestDetail.Period.PeriodEndSpecified = true; request.Request.InsurabilityRequestDetail.Period.PeriodEnd = DateTime.UtcNow; request.Request.InsurabilityRequestDetail.InsurabilityContactType = InsurabilityContactTypeType.ambulatory_care; request.Request.InsurabilityRequestDetail.InsurabilityRequestType = InsurabilityRequestTypeType.information; //Make call GetInsurabilityResponseType insResp = client.getInsurability(request); //Verify result Assert.AreEqual("200", insResp.Status.Code); CareReceiverDetailType crDetail = insResp.Response.Items.OfType<CareReceiverDetailType>().FirstOrDefault(); CareReceiverIdType crId = insResp.Response.Items.OfType<CareReceiverIdType>().FirstOrDefault(); InsurabilityResponseDetailType rspDetail = insResp.Response.Items.OfType<InsurabilityResponseDetailType>().FirstOrDefault(); MessageFaultType fault = insResp.Response.Items.OfType<MessageFaultType>().FirstOrDefault(); if (fault != null) { foreach(DetailType detail in fault.Details) { Assert.Inconclusive("Error at {1}: {0} ({2})", detail.DetailCode, detail.Location, detail.Message.Value); } if (fault.MultiIO.Length > 0) { Assert.Inconclusive("Multiple affilications where detected: {0}", fault.MultiIO); } Assert.Fail("Error by {1}: {0} ({2})", fault.FaultCode, fault.FaultSource, fault.Message); } //Assert.AreEqual("BROUCKAERT", crDetail.LastName); //Assert.IsTrue(rspDetail.InsurabilityList.InsurabilityItem.Length > 0); }
private static void DoTest(GenericInsurabilityPortTypeClient client) { GetInsurabilityAsXmlOrFlatRequestType request = new GetInsurabilityAsXmlOrFlatRequestType(); //Create common input with info about the requestor, must match SAML request.CommonInput = new CommonInputType(); request.CommonInput.InputReference = "PRIG1234567890"; request.CommonInput.Request = new RequestType1(); request.CommonInput.Request.IsTest = false; request.CommonInput.Origin = new OriginType(); request.CommonInput.Origin.Package = new PackageType(); request.CommonInput.Origin.Package.Name = new ValueRefString(); request.CommonInput.Origin.Package.Name.Value = "eH-I Test"; request.CommonInput.Origin.Package.License = new LicenseType(); //request.CommonInput.Origin.Package.License.Username = "******"; //request.CommonInput.Origin.Package.License.Password = "******"; request.CommonInput.Origin.Package.License.Username = "******"; request.CommonInput.Origin.Package.License.Password = "******"; //setDoctor(request); //setHospital(request); setMandatedDoctor(request); //Create record common input, contains additional tracking info request.RecordCommonInput = new RecordCommonInputType(); request.RecordCommonInput.InputReferenceSpecified = true; request.RecordCommonInput.InputReference = new decimal(1234567890123L); //Create actual request (attributes should not be provided) request.Request = new SingleInsurabilityRequestType(); request.Request.CareReceiverId = new CareReceiverIdType(); request.Request.CareReceiverId.Inss = "79021802145"; request.Request.InsurabilityRequestDetail = new InsurabilityRequestDetailType(); request.Request.InsurabilityRequestDetail.Period = new PeriodType(); request.Request.InsurabilityRequestDetail.Period.PeriodStartSpecified = true; request.Request.InsurabilityRequestDetail.Period.PeriodStart = DateTime.UtcNow; request.Request.InsurabilityRequestDetail.Period.PeriodEndSpecified = true; request.Request.InsurabilityRequestDetail.Period.PeriodEnd = DateTime.UtcNow; request.Request.InsurabilityRequestDetail.InsurabilityContactType = InsurabilityContactTypeType.ambulatory_care; request.Request.InsurabilityRequestDetail.InsurabilityRequestType = InsurabilityRequestTypeType.information; //Make call GetInsurabilityResponseType insResp = client.getInsurability(request); //Verify result Assert.AreEqual("200", insResp.Status.Code); CareReceiverDetailType crDetail = insResp.Response.Items.OfType <CareReceiverDetailType>().FirstOrDefault(); CareReceiverIdType crId = insResp.Response.Items.OfType <CareReceiverIdType>().FirstOrDefault(); InsurabilityResponseDetailType rspDetail = insResp.Response.Items.OfType <InsurabilityResponseDetailType>().FirstOrDefault(); MessageFaultType fault = insResp.Response.Items.OfType <MessageFaultType>().FirstOrDefault(); if (fault != null) { foreach (DetailType detail in fault.Details) { Assert.Inconclusive("Error at {1}: {0} ({2})", detail.DetailCode, detail.Location, detail.Message.Value); } if (fault.MultiIO.Length > 0) { Assert.Inconclusive("Multiple affilications where detected: {0}", fault.MultiIO); } Assert.Fail("Error by {1}: {0} ({2})", fault.FaultCode, fault.FaultSource, fault.Message); } //Assert.AreEqual("BROUCKAERT", crDetail.LastName); //Assert.IsTrue(rspDetail.InsurabilityList.InsurabilityItem.Length > 0); }