/// <summary>
        /// Check that the options are valid. Should throw an exception if things are not ok.
        /// </summary>
        /// <exception cref="InvalidOperationException">
        /// You must either set Authority or IntrospectionEndpoint
        /// or
        /// You must either set a ClientId or set an introspection HTTP handler
        /// </exception>
        /// <exception cref="ArgumentException">TokenRetriever must be set - TokenRetriever</exception>
        public override void Validate()
        {
            base.Validate();

            if (Authority.IsMissing() && IntrospectionEndpoint.IsMissing())
            {
                throw new InvalidOperationException("You must either set Authority or IntrospectionEndpoint");
            }

            if (ClientId.IsMissing() && IntrospectionHttpHandler == null)
            {
                throw new InvalidOperationException("You must either set a ClientId or set an introspection HTTP handler");
            }

            if (GetClaimsFromUserinfoEndpoint)
            {
                if (Authority.IsMissing() && UserinfoEndpoint.IsMissing())
                {
                    throw new InvalidOperationException("You must either set Authority or UserinfoEndpoint");
                }
            }

            if (TokenRetriever == null)
            {
                throw new ArgumentException("TokenRetriever must be set", nameof(TokenRetriever));
            }
        }
示例#2
0
        public void Merge(OpenidEndpoints endpoints)
        {
            if (endpoints == null)
            {
                return;
            }

            if (Issuer.IsEmpty())
            {
                Issuer = endpoints.Issuer;
            }
            if (JwksUri.IsEmpty())
            {
                JwksUri = endpoints.JwksUri;
            }
            if (AuthorizationEndpoint.IsEmpty())
            {
                AuthorizationEndpoint = endpoints.AuthorizationEndpoint;
            }
            if (TokenEndpoint.IsEmpty())
            {
                TokenEndpoint = endpoints.TokenEndpoint;
            }
            if (UserinfoEndpoint.IsEmpty())
            {
                UserinfoEndpoint = endpoints.UserinfoEndpoint;
            }
            if (EndSessionEndpoint.IsEmpty())
            {
                EndSessionEndpoint = endpoints.EndSessionEndpoint;
            }
            if (CheckSessionIframe.IsEmpty())
            {
                CheckSessionIframe = endpoints.CheckSessionIframe;
            }
            if (RevocationEndpoint.IsEmpty())
            {
                RevocationEndpoint = endpoints.RevocationEndpoint;
            }
        }