//----------------------------------------------------------------------- // // Copyright (c) Outercurve Foundation. All rights reserved. // //----------------------------------------------------------------------- namespace DotNetOpenAuth.OAuth { using System; using System.Diagnostics; using System.Diagnostics.CodeAnalysis; using System.Linq; using DotNetOpenAuth.Messaging; using DotNetOpenAuth.OAuth.ChannelElements; /// /// A description of the endpoints on a Service Provider. /// public class ServiceProviderHostDescription { /// /// The field used to store the value of the property. /// [DebuggerBrowsable(DebuggerBrowsableState.Never)] private MessageReceivingEndpoint requestTokenEndpoint; /// /// Initializes a new instance of the class. /// public ServiceProviderHostDescription() { this.ProtocolVersion = Protocol.Default.ProtocolVersion; } /// /// Gets or sets the OAuth version supported by the Service Provider. /// public ProtocolVersion ProtocolVersion { get; set; } /// /// Gets or sets the URL used to obtain an unauthorized Request Token, /// described in Section 6.1 (Obtaining an Unauthorized Request Token). /// /// /// The request URL query MUST NOT contain any OAuth Protocol Parameters. /// This is the URL that messages are directed to. /// /// Thrown if this property is set to a URI with OAuth protocol parameters. public MessageReceivingEndpoint RequestTokenEndpoint { get { return this.requestTokenEndpoint; } set { if (value != null && UriUtil.QueryStringContainPrefixedParameters(value.Location, OAuth.Protocol.ParameterPrefix)) { throw new ArgumentException(OAuthStrings.RequestUrlMustNotHaveOAuthParameters); } this.requestTokenEndpoint = value; } } /// /// Gets or sets the URL used to obtain User authorization for Consumer access, /// described in Section 6.2 (Obtaining User Authorization). /// /// /// This is the URL that messages are /// indirectly (via the user agent) sent to. /// public MessageReceivingEndpoint UserAuthorizationEndpoint { get; set; } /// /// Gets or sets the URL used to exchange the User-authorized Request Token /// for an Access Token, described in Section 6.3 (Obtaining an Access Token). /// /// /// This is the URL that messages are directed to. /// public MessageReceivingEndpoint AccessTokenEndpoint { get; set; } /// /// Gets or sets the signing policies that apply to this Service Provider. /// [SuppressMessage("Microsoft.Performance", "CA1819:PropertiesShouldNotReturnArrays", Justification = "Type initializers require this format.")] public ITamperProtectionChannelBindingElement[] TamperProtectionElements { get; set; } /// /// Gets the OAuth version supported by the Service Provider. /// internal Version Version { get { return Protocol.Lookup(this.ProtocolVersion).Version; } } /// /// Creates a signing element that includes all the signing elements this service provider supports. /// /// The created signing element. internal ITamperProtectionChannelBindingElement CreateTamperProtectionElement() { RequiresEx.ValidState(this.TamperProtectionElements != null); return new SigningBindingElementChain(this.TamperProtectionElements.Select(el => (ITamperProtectionChannelBindingElement)el.Clone()).ToArray()); } } }