public SystemIdCard CreateNewSystemIdCard(string itSystemName, CareProvider careProvider, AuthenticationLevel authenticationLevel, string username, string password, X509Certificate2 certificate, string alternativeIdentifier) { SystemInfo systemInfo = new SystemInfo(careProvider, itSystemName); return(new SystemIdCard(GetDgwsVersion(), authenticationLevel, GetIssuer(), systemInfo, certificate?.GetCertHashString(), alternativeIdentifier, username, password)); }
public List <CareProvider> Get(string userName) { List <CareProvider> careProviders = new List <CareProvider>(); CareProvider careProvider; using (SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Pets"].ConnectionString)) { try { connection.Open(); using (SqlCommand command = new SqlCommand("dbo.GetCareProviders", connection)) { command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.AddWithValue("userName", userName); using (SqlDataReader reader = command.ExecuteReader()) { while (reader.Read()) { careProvider = new CareProvider(); careProvider.ID = ((int)reader["ID"]); careProvider.Name = ((string)reader["Name"]); careProviders.Add(careProvider); } } } return(careProviders); } catch (Exception ex) { throw new Exception(ex.Message); } } }
private void AddProvider() { var provider = new CareProvider(); _family.CurrentChild.ProfessionalCareProviders.Add(provider); CareProviders.Add(provider); }
public async Task <IHttpActionResult> Post(CareProvider cp) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } db.CareProviders.Add(cp); await db.SaveChangesAsync(); return(Created(cp)); }
// private Federation getMockFederation() // { // return new SOSITestFederation(System.getProperties()) { // @Override // public boolean isValidSTSCertificate(X509Certificate certificate) // { // return vocesVault.getSystemCredentialPair().getCertificate().equals(certificate); // } // }; //} //private UserInfo BuildUserInfo(OioSamlAssertionToIdCardRequest request) // { // var assertion = request.OioSamlAssertion; // string cpr = "XXXXXXXX"; // Perform lookup based on assertion.getCvrNumberIdentifier() and assertion.getRidNumberIdentifier() // string givenName; // string surName; // if (request.UserGivenName != null && request.UserSurName != null) // { // givenName = request.UserGivenName; // surName = request.UserSurName; // } // else // { // // The IdP cannot split CommonName and neither should we (assertion.getSurName() returns null) // givenName = // assertion.CommonName; // surName = "-"; // } // //var email = assertion.GetAttributeValue("urn:oid:0.9.2342.19200300.100.1.3"); // var email = assertion.Email; // string occupation = null; // var role = "YYYYY"; // Lookup based on CPR, use request.getUserEducationCode() to pick the right one (or validate) // var authorizationCode = "ZZZZZ";// Lookup based on CPR, use request.getUserAuthorizationCode() to pick the right one (or validate) // return new UserInfo(cpr, givenName, surName, email, occupation, role, authorizationCode); // } private UserIdCard CreateIdCard() { SOSIFactory sosiFactory = new SOSIFactory(null, new CredentialVaultSignatureProvider(mocesVault)); CareProvider careProvider = new CareProvider(SubjectIdentifierType.medcomcvrnumber, "30808460", "Lægehuset på bakken"); UserInfo userInfo = new UserInfo("1111111118", "Hans", "Dampf", "", "", "7170", "341KY"); String alternativeIdentifier = new CertificateInfo(mocesVault.GetSystemCredentials()).ToString(); var userIdCard = sosiFactory.CreateNewUserIdCard("IT-System", userInfo, careProvider, AuthenticationLevel.MocesTrustedUser, null, null, null, alternativeIdentifier); userIdCard.Sign <Assertion>(sosiFactory.SignatureProvider); return(userIdCard); }
public override IDeepCopyable CopyTo(IDeepCopyable other) { var dest = other as Patient; if (dest != null) { base.CopyTo(dest); if (Identifier != null) { dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy()); } if (Name != null) { dest.Name = new List <Hl7.Fhir.Model.HumanName>(Name.DeepCopy()); } if (Telecom != null) { dest.Telecom = new List <Hl7.Fhir.Model.Contact>(Telecom.DeepCopy()); } if (Gender != null) { dest.Gender = (Hl7.Fhir.Model.CodeableConcept)Gender.DeepCopy(); } if (BirthDateElement != null) { dest.BirthDateElement = (Hl7.Fhir.Model.FhirDateTime)BirthDateElement.DeepCopy(); } if (Deceased != null) { dest.Deceased = (Hl7.Fhir.Model.Element)Deceased.DeepCopy(); } if (Address != null) { dest.Address = new List <Hl7.Fhir.Model.Address>(Address.DeepCopy()); } if (MaritalStatus != null) { dest.MaritalStatus = (Hl7.Fhir.Model.CodeableConcept)MaritalStatus.DeepCopy(); } if (MultipleBirth != null) { dest.MultipleBirth = (Hl7.Fhir.Model.Element)MultipleBirth.DeepCopy(); } if (Photo != null) { dest.Photo = new List <Hl7.Fhir.Model.Attachment>(Photo.DeepCopy()); } if (Contact != null) { dest.Contact = new List <Hl7.Fhir.Model.Patient.ContactComponent>(Contact.DeepCopy()); } if (Animal != null) { dest.Animal = (Hl7.Fhir.Model.Patient.AnimalComponent)Animal.DeepCopy(); } if (Communication != null) { dest.Communication = new List <Hl7.Fhir.Model.CodeableConcept>(Communication.DeepCopy()); } if (CareProvider != null) { dest.CareProvider = new List <Hl7.Fhir.Model.ResourceReference>(CareProvider.DeepCopy()); } if (ManagingOrganization != null) { dest.ManagingOrganization = (Hl7.Fhir.Model.ResourceReference)ManagingOrganization.DeepCopy(); } if (Link != null) { dest.Link = new List <Hl7.Fhir.Model.Patient.PatientLinkComponent>(Link.DeepCopy()); } if (ActiveElement != null) { dest.ActiveElement = (Hl7.Fhir.Model.FhirBoolean)ActiveElement.DeepCopy(); } return(dest); } else { throw new ArgumentException("Can only copy to an object of the same type", "other"); } }
private IdCard InternalBuild(XElement idCardElement) { IdCard result; string itSystemName = null, ocesCertHash = null, id = null, version = null, cpr = null, givenName = null, surName = null, email = null, occupation = null, userRole = null, authorizationCode = null, careProviderId = null, careProviderIdType = null, careProviderName = null, authLevel = null; bool hasIdCardData = false, hasSystemLog = false, hasUserLog = false; string alternativeIdentifier = null; string username = null; string password = null; DateTime createdDate = new DateTime(), expiryDate = new DateTime(); // Check validity interval var timeConstraints = idCardElement.Descendants("{" + SamlTags.Conditions.Ns + "}" + SamlTags.Conditions.TagName); var conditionsAttributes = timeConstraints.Attributes(); try { foreach (var attribute in conditionsAttributes) { var attributeValue = attribute.Value; var attributeName = attribute.Name; if (SamlAttributes.NotOnOrAfter == attributeName) { expiryDate = DateTime.Parse(attributeValue); } else if (SamlAttributes.NotBefore == attributeName) { createdDate = DateTime.Parse(attributeValue); } } } catch (Exception e) { throw new ModelBuildException("SAML:Conditions could not be parsed", e); } //Check for an alternative Identifier var subjectNameIdNode = idCardElement.Descendants("{" + SamlTags.NameID.Ns + "}" + SamlTags.NameID.TagName).FirstOrDefault(); var nameIdFormatNode = subjectNameIdNode.Attribute((SamlAttributes.Format)); if (nameIdFormatNode.Value.Equals(SubjectIdentifierTypeValues.Other)) { alternativeIdentifier = subjectNameIdNode.Value; } // IDCard attributes var issuerNode = idCardElement.Descendants("{" + SamlTags.Issuer.Ns + "}" + SamlTags.Issuer.TagName).FirstOrDefault(); var issuer = issuerNode.Value; var attributeStatementNodeList = idCardElement.Descendants("{" + SamlTags.AttributeStatement.Ns + "}" + SamlTags.AttributeStatement.TagName); bool?isUserIDCard = null; foreach (var attributeStatement in attributeStatementNodeList) { var map = attributeStatement.Attributes(); foreach (var attribute in map) { var attributeValue = attribute.Value; if (IdValues.SystemLog.Equals(attributeValue)) { // Iterate saml:Attributes in SystemLog var samlAttributeNodes = attributeStatement.Descendants("{" + SamlTags.Attribute.Ns + "}" + SamlTags.Attribute.TagName); foreach (var samlAttribute in samlAttributeNodes) { var attributeName = samlAttribute.Attribute("Name").Value; var attributeNameValue = GetAttributeNameValue(samlAttribute, attributeName); if (MedComAttributes.ItSystemName.Equals(attributeName)) { itSystemName = attributeNameValue; } else if (MedComAttributes.CareProviderId.Equals(attributeName)) { careProviderId = attributeNameValue; var nameFormatAttribute = samlAttribute.Attribute(SamlAttributes.NameFormat); if (nameFormatAttribute == null) { throw new ModelBuildException( "DGWS violation: 'medcom:CareProviderID' SAML attribute must contain a 'NameFormat' attribute!"); } careProviderIdType = nameFormatAttribute.Value; } else if (MedComAttributes.CareProviderName.Equals(attributeName)) { careProviderName = attributeNameValue; } } hasSystemLog = true; } else if (IdValues.IdCardData.Equals(attributeValue)) { // Iterate saml:Attributes in IDCard var samlAttributeNodes = attributeStatement.Descendants("{" + SamlTags.Attribute.Ns + "}" + SamlTags.Attribute.TagName); foreach (var samlAttribute in samlAttributeNodes) { var attributeName = samlAttribute.Attribute("Name").Value; var attributeNameValue = GetAttributeNameValue(samlAttribute, attributeName); // Cert Hash if (SosiAttributes.OcesCertHash.Equals(attributeName)) { ocesCertHash = attributeNameValue; // CardID } else if (SosiAttributes.IDCardID.Equals(attributeName)) { id = attributeNameValue; // CardVersion } else if (SosiAttributes.IDCardVersion.Equals(attributeName)) { version = attributeNameValue; // IDCardType } else if (SosiAttributes.IDCardType.Equals(attributeName)) { if (IdCard.IDCARDTYPE_USER.Equals(attributeNameValue)) { isUserIDCard = true; } else if (IdCard.IDCARDTYPE_SYSTEM.Equals(attributeNameValue)) { isUserIDCard = false; } } else if (SosiAttributes.AuthenticationLevel.Equals(attributeName)) { authLevel = attributeNameValue; } } hasIdCardData = true; } else if (IdValues.UserLog.Equals(attributeValue)) { // Iterate saml:Attributes in UserLog var samlAttributeNodes = attributeStatement.Descendants("{" + SamlTags.Attribute.Ns + "}" + SamlTags.Attribute.TagName); foreach (var samlAttribute in samlAttributeNodes) { var attributeName = samlAttribute.Attribute("Name").Value; var attributeNameValue = GetAttributeNameValue(samlAttribute, attributeName); if (MedComAttributes.UserCivilRegistrationNumber.Equals(attributeName)) { cpr = attributeNameValue; } else if (MedComAttributes.UserGivenName.Equals(attributeName)) { givenName = attributeNameValue; } else if (MedComAttributes.UserSurname.Equals(attributeName)) { surName = attributeNameValue; } else if (MedComAttributes.UserEmailAddress.Equals(attributeName)) { email = attributeNameValue; } else if (MedComAttributes.UserOccupation.Equals(attributeName)) { occupation = attributeNameValue; } else if (MedComAttributes.UserRole.Equals(attributeName)) { userRole = attributeNameValue; } else if (MedComAttributes.UserAuthorizationCode.Equals(attributeName)) { authorizationCode = attributeNameValue; } } hasUserLog = true; } } } SubjectIdentifierType careProviderIdEnum; Enum.TryParse(careProviderIdType.Replace(":", ""), true, out careProviderIdEnum); CareProvider careProvider = new CareProvider(careProviderIdEnum, careProviderId, careProviderName); SystemInfo systemInfo = new SystemInfo(careProvider, itSystemName); // All IDCard types must have a IDCardData element if (!hasIdCardData) { throw new ModelBuildException("IDCardData element missing for IDCard"); } // All IDCard types must have a SystemLog element if (!hasSystemLog) { throw new ModelBuildException("SystemLog element missing for IDCard"); } if (isUserIDCard == null) { throw new ModelBuildException("ID Card type not found or invalid"); } else if (isUserIDCard.Value) { if (!hasUserLog) { throw new ModelBuildException("UserLog element missing for UserIDCard"); } UserInfo userInfo = new UserInfo(cpr, givenName, surName, email, occupation, userRole, authorizationCode); result = new UserIdCard(version, idCardElement, id, AuthenticationLevel.GetEnumeratedValue(int.Parse(authLevel)), ocesCertHash, issuer, systemInfo, userInfo, createdDate, expiryDate, alternativeIdentifier, username, password); } else { if (hasUserLog) { throw new ModelBuildException("IDCard type is 'system', but also has a UserLog element (??)"); } result = new SystemIdCard(version, idCardElement, id, AuthenticationLevel.GetEnumeratedValue(int.Parse(authLevel)), ocesCertHash, issuer, systemInfo, createdDate, expiryDate, alternativeIdentifier, username, password); } return(result); }