Subject: Help Creating the XML Meta Data
Date: 2016-12-07 15:06:04
From: Eric Marker
Source: help-creating-xml-meta-data
----------------------------------------------------------------------

I am trying to create the XML Meta Data.  I am the Service Provider and the XML Meta Data is for the IdP to configure their SAML IdP server.  (My question follows the working sample below)

 

I found the following code (which works great) to generate the initial XML Meta Data:

[code lang='c#']

       void  SamlXMLDescription()
        {
            EntityDescriptor entityDescriptor = new EntityDescriptor();
            entityDescriptor.Id = "MPCSHKBKAJTWEF5RsrHcS2.R3Fb";
            AttributeAuthorityDescriptor attributeAuthorityDescriptor = new AttributeAuthorityDescriptor();
            entityDescriptor.AttributeAuthorityDescriptors.Add(attributeAuthorityDescriptor);

            AttributeService attributeService = new AttributeService();
            attributeService.Binding = "urn:oasis:names:tc:SAML:2.0:bindings:SOAP";
            attributeService.Location = "https://www.industrysafe.com/sso2/AssertionService.aspx";
            attributeAuthorityDescriptor.AttributeServices.Add(attributeService);

            // X509Certificate2 x509Certificate = new X509Certificate2(@"Pkey.pfx", "password");
            X509Certificate2 x509Certificate =  (X509Certificate2)Application[Global.SSOKey];

            IdpSsoDescriptor ssoDescriptor = new IdpSsoDescriptor();

            //SingleLogoutService slo = new SingleLogoutService();
            //slo.Location = "https://xxx.xxxx.xxxx.com/idp/SLO.saml2";
            //ssoDescriptor.SingleLogoutServices.Add(slo);

            SingleSignOnService sso = new SingleSignOnService();
            sso.Location = "https://adfs.traonline.com/adfs/ls";
            ssoDescriptor.SingleSignOnServices.Add(sso);

            entityDescriptor.IdpSsoDescriptors.Add(ssoDescriptor);

            ContactPerson person = new ContactPerson();
            person.Company = "IndustrySafe.com";
            person.EmailAddresses.Add("stephen.ehrlich@industrysafe.com");
            person.GivenName = "Stephen";

            entityDescriptor.ContactPeople.Add(person);

            //ssoDescriptor.Sign(x509Certificate);
            entityDescriptor.Sign(x509Certificate);

            string xml = entityDescriptor.GetXml().OuterXml;

            writeToFile(xml);

        }

[/code]

Now the Question, I want to add some code the the above working sample which add s Meta Data to the returning SAML Response contains the following code:

[code lang='xml']

     <saml:Subject>
         <saml:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">jdoe</saml:NameID>
         <saml:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
            <saml:SubjectConfirmationData NotOnOrAfter="2014-03-25T20:33:49Z" Recipient="https://www.industrysafe.com/SSO/AssertionService.aspx?binding=urn%3aoasis%3anames%3atc%3aSAML%3a2.0%3abindings%3aHTTP-POST" InResponseTo="_##########################" />
         </saml:SubjectConfirmation>
      </saml:Subject>
[/code]

---------------------------------------------------------------------- Note: This question has been asked on the Q&A forum of Thang Dang's fraudulent ComponentPro brand If you purchased anything from ComponentPro, you have been scammed. Contact the payment processor who sold you the license and ask for your money back. Back to ComponentPro Q&A Forum Index