1
//-----------------------------------------------------------------------
2 // <copyright file="NoDiscoveryIdentifier.cs" company="Andrew Arnott">
3 // Copyright (c) Andrew Arnott. All rights reserved.
5 //-----------------------------------------------------------------------
7 namespace DotNetOpenAuth
.OpenId
{
8 using System
.Collections
.Generic
;
10 using DotNetOpenAuth
.Messaging
;
11 using DotNetOpenAuth
.OpenId
.RelyingParty
;
14 /// Wraps an existing Identifier and prevents it from performing discovery.
16 internal class NoDiscoveryIdentifier
: Identifier
{
18 /// The wrapped identifier.
20 private Identifier wrappedIdentifier
;
23 /// Initializes a new instance of the <see cref="NoDiscoveryIdentifier"/> class.
25 /// <param name="wrappedIdentifier">The ordinary Identifier whose discovery is being masked.</param>
26 internal NoDiscoveryIdentifier(Identifier wrappedIdentifier
)
28 ErrorUtilities
.VerifyArgumentNotNull(wrappedIdentifier
, "wrappedIdentifier");
30 this.wrappedIdentifier
= wrappedIdentifier
;
34 /// Returns a <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
37 /// A <see cref="T:System.String"/> that represents the current <see cref="T:System.Object"/>.
39 public override string ToString() {
40 return this.wrappedIdentifier
.ToString();
44 /// Tests equality between two <see cref="Identifier"/>s.
46 /// <param name="obj">The <see cref="T:System.Object"/> to compare with the current <see cref="T:System.Object"/>.</param>
48 /// true if the specified <see cref="T:System.Object"/> is equal to the current <see cref="T:System.Object"/>; otherwise, false.
50 /// <exception cref="T:System.NullReferenceException">
51 /// The <paramref name="obj"/> parameter is null.
53 public override bool Equals(object obj
) {
54 return this.wrappedIdentifier
.Equals(obj
);
58 /// Gets the hash code for an <see cref="Identifier"/> for storage in a hashtable.
61 /// A hash code for the current <see cref="T:System.Object"/>.
63 public override int GetHashCode() {
64 return this.wrappedIdentifier
.GetHashCode();
68 /// Performs discovery on the Identifier.
70 /// <param name="requestHandler">The web request handler to use for discovery.</param>
72 /// An initialized structure containing the discovered provider endpoint information.
74 internal override IEnumerable
<ServiceEndpoint
> Discover(IDirectSslWebRequestHandler requestHandler
) {
75 return Enumerable
.Empty
<ServiceEndpoint
>();
79 /// Returns an <see cref="Identifier"/> that has no URI fragment.
80 /// Quietly returns the original <see cref="Identifier"/> if it is not
81 /// a <see cref="UriIdentifier"/> or no fragment exists.
84 /// A new <see cref="Identifier"/> instance if there was a
85 /// fragment to remove, otherwise this same instance..
87 internal override Identifier
TrimFragment() {
88 return new NoDiscoveryIdentifier(this.wrappedIdentifier
.TrimFragment());
92 /// Converts a given identifier to its secure equivalent.
93 /// UriIdentifiers originally created with an implied HTTP scheme change to HTTPS.
94 /// Discovery is made to require SSL for the entire resolution process.
96 /// <param name="secureIdentifier">The newly created secure identifier.
97 /// If the conversion fails, <paramref name="secureIdentifier"/> retains
98 /// <i>this</i> identifiers identity, but will never discover any endpoints.</param>
100 /// True if the secure conversion was successful.
101 /// False if the Identifier was originally created with an explicit HTTP scheme.
103 internal override bool TryRequireSsl(out Identifier secureIdentifier
) {
104 return this.wrappedIdentifier
.TryRequireSsl(out secureIdentifier
);