public static void CreateMetaData(MetadataDescriptor data, string fileName, Encoding encoding)
        {
            if (string.IsNullOrEmpty(fileName))
                fileName = "FederationMetadata.xml";

            if (data.EntityId == null)
                throw new ApplicationException("Entity ID is null");
            //Uri entityId = new Uri(data.EntityId);

            //move to subtypes - validator
            //if (data.BindingLocation == null)
            //    throw new ApplicationException("no binding location");

            //if (data.BindingType == null)
            //    throw new ApplicationException("no binding type provided");

            //if (data.MainContact == null)
            //    throw new ApplicationException("no contact supplied");

            //branch here
            if (data is SamlIdpData)
                CreateIdentityProviderMetadata(data as SamlIdpData, fileName, encoding);

            if (data is SamlSpData)
                CreateIdentityProviderMetadata(data as SamlSpData, fileName, encoding);

            if (data is StsData)
                CreatePassiveStsMetadata(data as StsData, fileName, encoding);
        }
Esempio n. 2
0
 public static T ToObject <T>(this MetadataDescriptor obj, string fileName) where T : MetadataDescriptor
 {
     using (StreamReader reader = new StreamReader(fileName))
     {
         XmlSerializer ser = new XmlSerializer(typeof(T));
         var           rv  = ser.Deserialize(reader) as T;
         return(rv);
     }
 }
Esempio n. 3
0
 public static void ToXml(this MetadataDescriptor obj, string fileName)
 {
     using (StreamWriter writer = new StreamWriter(fileName, false, Encoding.UTF8))
     {
         XmlSerializer ser = new XmlSerializer(obj.GetType());
         ser.Serialize(writer, obj);
         writer.Flush();
     }
 }
        private void btnGenerateXml_Click(object sender, EventArgs e)
        {
            string fileName = string.IsNullOrEmpty(txtSettings.Text) ? "FederationMetadata.xml" : txtOutFile.Text;

            txtOutFile.Text = fileName;
            MetadataDescriptor md = metadataEditor1.MetaData;

            MetadataHelper.CreateMetaData(md, fileName, Encoding.ASCII);
        }
Esempio n. 5
0
        public static void CreateMetaData(MetadataDescriptor data, string fileName, Encoding encoding)
        {
            if (string.IsNullOrEmpty(fileName))
            {
                fileName = "FederationMetadata.xml";
            }

            if (data.EntityId == null)
            {
                throw new ApplicationException("Entity ID is null");
            }
            //Uri entityId = new Uri(data.EntityId);


            //move to subtypes - validator
            //if (data.BindingLocation == null)
            //    throw new ApplicationException("no binding location");

            //if (data.BindingType == null)
            //    throw new ApplicationException("no binding type provided");

            //if (data.MainContact == null)
            //    throw new ApplicationException("no contact supplied");

            //branch here
            if (data is SamlIdpData)
            {
                CreateIdentityProviderMetadata(data as SamlIdpData, fileName, encoding);
            }

            if (data is SamlSpData)
            {
                CreateIdentityProviderMetadata(data as SamlSpData, fileName, encoding);
            }

            if (data is StsData)
            {
                CreatePassiveStsMetadata(data as StsData, fileName, encoding);
            }
        }