static IdpConfig() { // read the configuration parameters from desk string dirName = "spmetadata"; _spMetadataDict = new Dictionary <string, AuthRequestSubset>(); if (!Directory.Exists(dirName)) { Directory.CreateDirectory(dirName); } string[] spMetadataFiles = Directory.GetFiles("spmetadata", "*.xml"); foreach (string spMetaDataFilePath in spMetadataFiles) { AuthRequestSubset spMetadata = GetSPMetadataByFileName(spMetaDataFilePath); _spMetadataDict.Add(spMetadata.EntityId, spMetadata); } }
public static AuthRequestSubset SignIn(string SAMLRequest, string SigAlg, string Signature) { string deflatedMessage = BusinessLogicUtil.DeflateDecompress(SAMLRequest); string SAMLRequest_serviceProviderID; { XmlDocument xmlDoc_SAMLRequest = new XmlDocument(); xmlDoc_SAMLRequest.LoadXml(deflatedMessage); //XmlElement root = xmlDoc_SAMLRequest.DocumentElement; //SAMLRequest_serviceProviderID = root.Attributes["ID"]?.InnerText; XmlNodeList nodeList = xmlDoc_SAMLRequest.GetElementsByTagName("Issuer", "urn:oasis:names:tc:SAML:2.0:assertion"); if (nodeList.Count == 0) { throw new Exception($"Issuer not found in SAMLRequest"); } SAMLRequest_serviceProviderID = nodeList[0]?.InnerText; } //IdpConfig.Instance AuthRequestSubset spMetaData = IdpConfig.Instance.GetSPMetadataById(SAMLRequest_serviceProviderID); return(spMetaData); }