Exemple #1
0
        /// <summary>
        /// Determine which endpoint to use based on the protocol defaults, configuration data and metadata.
        /// </summary>
        /// <param name="defaultBinding">The binding to use if none has been specified in the configuration and the metadata allows all bindings.</param>
        /// <param name="config">The endpoint as described in the configuration. May be null.</param>
        /// <param name="metadata">A list of endpoints of the given type (eg. SSO or SLO) that the metadata contains. </param>
        internal static IDPEndPointElement DetermineEndpointConfiguration(SAMLBinding defaultBinding, IDPEndPointElement config, List <IDPEndPointElement> metadata)
        {
            IDPEndPointElement result = new IDPEndPointElement();

            result.Binding = defaultBinding;

            // Determine which binding to use.
            if (config != null)
            {
                result.Binding = config.Binding;
            }
            else
            {
                // Verify that the metadata allows the default binding.
                bool allowed = metadata.Exists(delegate(IDPEndPointElement el) { return(el.Binding == defaultBinding); });
                if (!allowed)
                {
                    if (result.Binding == SAMLBinding.POST)
                    {
                        result.Binding = SAMLBinding.REDIRECT;
                    }
                    else
                    {
                        result.Binding = SAMLBinding.POST;
                    }
                }
            }

            if (config != null && !string.IsNullOrEmpty(config.Url))
            {
                result.Url = config.Url;
            }
            else
            {
                IDPEndPointElement endpoint =
                    metadata.Find(delegate(IDPEndPointElement el) { return(el.Binding == result.Binding); });

                if (endpoint == null)
                {
                    throw new ConfigurationErrorsException(
                              String.Format("No IdentityProvider supporting SAML binding {0} found in metadata",
                                            result.Binding));
                }

                result.Url = endpoint.Url;
            }

            return(result);
        }
Exemple #2
0
        private string GetBinding(SAMLBinding samlBinding, string defaultValue)
        {
            switch (samlBinding)
            {
            case SAMLBinding.ARTIFACT:
                return(Saml20Constants.ProtocolBindings.HTTP_Artifact);

            case SAMLBinding.POST:
                return(Saml20Constants.ProtocolBindings.HTTP_Post);

            case SAMLBinding.REDIRECT:
                return(Saml20Constants.ProtocolBindings.HTTP_Redirect);

            case SAMLBinding.SOAP:
                return(Saml20Constants.ProtocolBindings.HTTP_SOAP);

            case SAMLBinding.NOT_SET:
                return(defaultValue);

            default:
                throw new ConfigurationErrorsException(String.Format("Unsupported SAML binding {0}", Enum.GetName(typeof(SAMLBinding), samlBinding)));
            }
        }
Exemple #3
0
 /// <summary>
 /// Get the first SSO endpoint that supports the given binding.
 /// </summary>
 /// <returns>The endpoint or <c>null</c> if metadata does not have an SSO endpoint with the given binding.</returns>
 public IDPEndPointElement SSOEndpoint(SAMLBinding binding)
 {
     return(SSOEndpoints().Find(
                delegate(IDPEndPointElement endp) { return endp.Binding == binding; }));
 }
        /// <summary>
        /// Determine which endpoint to use based on the protocol defaults, configuration data and metadata.
        /// </summary>
        /// <param name="defaultBinding">The binding to use if none has been specified in the configuration and the metadata allows all bindings.</param>
        /// <param name="config">The endpoint as described in the configuration. May be null.</param>
        /// <param name="metadata">A list of endpoints of the given type (eg. SSO or SLO) that the metadata contains. </param>        
        internal static IDPEndPointElement DetermineEndpointConfiguration(SAMLBinding defaultBinding, IDPEndPointElement config, List<IDPEndPointElement> metadata)
        {
            IDPEndPointElement result = new IDPEndPointElement();
            result.Binding = defaultBinding;

            // Determine which binding to use.
            if (config != null)
            {
                result.Binding = config.Binding;
            } else {
                // Verify that the metadata allows the default binding.
                bool allowed = metadata.Exists(delegate(IDPEndPointElement el) { return el.Binding == defaultBinding; });
                if (!allowed)
                {
                    if (result.Binding == SAMLBinding.POST)
                        result.Binding = SAMLBinding.REDIRECT;
                    else
                        result.Binding = SAMLBinding.POST;
                }                    
            }

            if (config != null && !string.IsNullOrEmpty(config.Url))
            {
                result.Url = config.Url;
            } else
            {
                IDPEndPointElement endpoint =
                    metadata.Find(delegate(IDPEndPointElement el) { return el.Binding == result.Binding; });

                if (endpoint == null)
                    throw new ConfigurationErrorsException(
                        String.Format("No IdentityProvider supporting SAML binding {0} found in metadata",
                                      result.Binding));

                result.Url = endpoint.Url;
            }

            return result;
        }
        private string GetBinding(SAMLBinding samlBinding, string defaultValue)
        {
            switch (samlBinding)
            {
                case SAMLBinding.ARTIFACT:
                    return Saml20Constants.ProtocolBindings.HTTP_Artifact;
                case SAMLBinding.POST:
                    return Saml20Constants.ProtocolBindings.HTTP_Post;
                case SAMLBinding.REDIRECT:
                    return Saml20Constants.ProtocolBindings.HTTP_Redirect;
                case SAMLBinding.SOAP :
                    return Saml20Constants.ProtocolBindings.HTTP_SOAP;
                case SAMLBinding.NOT_SET:
                    return defaultValue;
                default:
                    throw new ConfigurationErrorsException(String.Format("Unsupported SAML binding {0}", Enum.GetName(typeof(SAMLBinding), samlBinding)));

            }
        }
 /// <summary>
 /// Get the first SSO endpoint that supports the given binding.
 /// </summary>        
 /// <returns>The endpoint or <c>null</c> if metadata does not have an SSO endpoint with the given binding.</returns>
 public IDPEndPointElement SSOEndpoint(SAMLBinding binding)
 {
     return SSOEndpoints().Find(
         delegate(IDPEndPointElement endp) { return endp.Binding == binding; });
 }