Exemplo n.º 1
0
        internal NoDiscoveryIdentifier(Identifier wrappedIdentifier)
            : base(false)
        {
            if (wrappedIdentifier == null) throw new ArgumentNullException("wrappedIdentifier");

            this.wrappedIdentifier = wrappedIdentifier;
        }
Exemplo n.º 2
0
		/// <summary>
		/// Attempts to parse a string for an OpenId Identifier.
		/// </summary>
		/// <param name="value">The string to be parsed.</param>
		/// <param name="result">The parsed Identifier form.</param>
		/// <returns>
		/// True if the operation was successful.  False if the string was not a valid OpenId Identifier.
		/// </returns>
		public static bool TryParse(string value, out Identifier result) {
			if (IsValid(value)) {
				result = Parse(value);
				return true;
			} else {
				result = null;
				return false;
			}
		}
Exemplo n.º 3
0
		internal OpenIdException(string message, Identifier identifier, IDictionary<string, string> query, Exception innerException)
			: base(message, innerException) {
			this.Query = query;
			Identifier = identifier;
			if (query != null) Protocol = Protocol.Detect(query);

			if (query != null) {
				Logger.ErrorFormat("OpenIdException: {0}{1}{2}", message, Environment.NewLine, Util.ToString(query));
			} else {
				Logger.ErrorFormat("OpenIdException: {0}", message);
			}
		}
Exemplo n.º 4
0
		internal override bool TryRequireSsl(out Identifier secureIdentifier) {
			secureIdentifier = IsDiscoverySecureEndToEnd ? this : new XriIdentifier(this, true);
			return true;
		}
Exemplo n.º 5
0
		/// <summary>
		/// Converts a given identifier to its secure equivalent.  
		/// UriIdentifiers originally created with an implied HTTP scheme change to HTTPS.
		/// Discovery is made to require SSL for the entire resolution process.
		/// </summary>
		/// <param name="secureIdentifier">
		/// The newly created secure identifier.
		/// If the conversion fails, <paramref name="secureIdentifier"/> retains
		/// <i>this</i> identifiers identity, but will never discover any endpoints.
		/// </param>
		/// <returns>
		/// True if the secure conversion was successful.
		/// False if the Identifier was originally created with an explicit HTTP scheme.
		/// </returns>
		internal abstract bool TryRequireSsl(out Identifier secureIdentifier);
Exemplo n.º 6
0
 public static string ExtractUserName(Identifier identifier)
 {
    return ExtractUserName(new Uri(identifier.ToString()));
 }
Exemplo n.º 7
0
        internal override bool TryRequireSsl(out Identifier secureIdentifier)
        {
            // If this Identifier is already secure, reuse it.
            if (IsDiscoverySecureEndToEnd) {
                secureIdentifier = this;
                return true;
            }

            // If this identifier already uses SSL for initial discovery, return one
            // that guarantees it will be used throughout the discovery process.
            if (String.Equals(Uri.Scheme, Uri.UriSchemeHttps, StringComparison.OrdinalIgnoreCase)) {
                secureIdentifier = new UriIdentifier(this.Uri, true);
                return true;
            }

            // Otherwise, try to make this Identifier secure by normalizing to HTTPS instead of HTTP.
            if (SchemeImplicitlyPrepended) {
                UriBuilder newIdentifierUri = new UriBuilder(this.Uri);
                newIdentifierUri.Scheme = Uri.UriSchemeHttps;
                if (newIdentifierUri.Port == 80) {
                    newIdentifierUri.Port = 443;
                }
                secureIdentifier = new UriIdentifier(newIdentifierUri.Uri, true);
                return true;
            }

            // This identifier is explicitly NOT https, so we cannot change it.
            secureIdentifier = new NoDiscoveryIdentifier(this);
            return false;
        }
Exemplo n.º 8
0
		internal override bool TryRequireSsl(out Identifier secureIdentifier) {
			return wrappedIdentifier.TryRequireSsl(out secureIdentifier);
		}
Exemplo n.º 9
0
 internal OpenIdException(string message, Identifier identifier)
     : this(message, identifier, null, null)
 {
 }
Exemplo n.º 10
0
 internal OpenIdException(string message, Identifier identifier, Exception innerException)
     : this(message, identifier, null, innerException)
 {
 }
Exemplo n.º 11
0
 internal OpenIdException(string message, Identifier identifier, IDictionary<string, string> query)
     : this(message, identifier, query, null)
 {
 }
Exemplo n.º 12
0
		/// <summary>
		/// Instantiates an <see cref="OpenIdException"/> based on deserialized data.
		/// </summary>
		/// <param name="info"></param>
		/// <param name="context"></param>
		protected OpenIdException(SerializationInfo info, StreamingContext context)
			: base(info, context) {
			Query = (IDictionary<string, string>)info.GetValue("query", typeof(IDictionary<string, string>));
			Identifier = (Identifier)info.GetValue("Identifier", typeof(Identifier));
		}