/// <summary> /// Creates a new OAuth protected request configured for an ASP.NET context, /// with the the current user or session id used as a state key. /// </summary> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <param name="callbackUri">Callback URI</param> /// <returns>An OAuth protected request for the protected resource, /// configured for an ASP.NET context</returns> public static OAuthRequest Create(EndPoint resourceEndPoint, OAuthService settings, Uri callbackUri) { return AspNetOAuthRequest.Create( resourceEndPoint, settings, callbackUri, GetEndUserIdFromHttpContextUser() ?? GetEndUserIdFromHttpSession()); }
/// <summary> /// Creates a new OAuth protected request configured for an ASP.NET context, /// with the current URL as the callback URL and the current user or session id /// used as a state key. /// </summary> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <returns>An OAuth protected request for the protected resource, /// configured for an ASP.NET context</returns> public static OAuthRequest Create(EndPoint resourceEndPoint, OAuthService settings) { HttpContext context = HttpContext.Current; return AspNetOAuthRequest.Create( resourceEndPoint, settings, context.Request.Url, GetEndUserIdFromHttpContextUser() ?? GetEndUserIdFromHttpSession()); }
public static OAuthService Create( EndPoint requestTokenEndPoint, Uri authorizationUrl, EndPoint accessTokenEndPoint, bool useAuthorizationHeader, string realm, string signatureMethod, string oauthVersion, IConsumer consumer, ServiceLocatorProvider serviceLocatorProvider) { return new OAuthService() { ComponentLocator = serviceLocatorProvider(), RequestTokenEndPoint = requestTokenEndPoint, AuthorizationUrl = authorizationUrl, AccessTokenEndPoint = accessTokenEndPoint, UseAuthorizationHeader = useAuthorizationHeader, Realm = realm, SignatureMethod = signatureMethod, OAuthVersion = oauthVersion, Consumer = consumer }; }
public static OAuthService Create( EndPoint requestTokenEndPoint, Uri authorizationUrl, EndPoint accessTokenEndPoint, bool useAuthorizationHeader, string realm, string signatureMethod, string oauthVersion, IConsumer consumer) { return OAuthService.Create( requestTokenEndPoint, authorizationUrl, accessTokenEndPoint, useAuthorizationHeader, realm, signatureMethod, oauthVersion, consumer, () => ServiceLocator.Current); }
/// <summary> /// Creates an OAuthService using defaults for most parameters, loading components /// from the service locator provided by the supplied provider. /// </summary> /// <remarks> /// <para>The OAuthService created will have the following defaults:</para> /// <list type="table"> /// <listheader> /// <term>Property</term> /// <description>Value</description> /// </listheader> /// <item> /// <term>HttpMethod</term> /// <description><c>"POST"</c></description> /// </item> /// <item> /// <term>UseAuthorizationHeader</term> /// <description><c>true</c></description> /// </item> /// <item> /// <term>Realm</term> /// <description><c>null</c></description> /// </item> /// <item> /// <term>OAuthVersion</term> /// <description><c>"1.0"</c></description> /// </item> /// </list> /// </remarks> /// <param name="requestTokenEndPoint">EndPoint for obtaining request tokens</param> /// <param name="authorizationUrl">URL to send users to for authorization</param> /// <param name="accessTokenEndPoint">EndPoint for obtaining access tokens</param> /// <param name="signatureMethod">Signature method to use</param> /// <param name="consumer">Consumer credentials</param> /// <param name="serviceLocatorProvider">Service locator provider which provides /// a service locator for components</param> /// <returns>An OAuthService</returns> public static OAuthService Create( EndPoint requestTokenEndPoint, Uri authorizationUrl, EndPoint accessTokenEndPoint, string signatureMethod, IConsumer consumer, ServiceLocatorProvider serviceLocatorProvider) { return OAuthService.Create( requestTokenEndPoint, authorizationUrl, accessTokenEndPoint, true, null, signatureMethod, Constants.Version1_0, consumer, serviceLocatorProvider); }
/// <summary> /// Creates an OAuthService using defaults for most parameters, loading components /// from the current global service locator. /// </summary> /// <remarks> /// <para>The OAuthService created will have the following defaults:</para> /// <list type="table"> /// <listheader> /// <term>Property</term> /// <description>Value</description> /// </listheader> /// <item> /// <term>HttpMethod</term> /// <description><c>"POST"</c></description> /// </item> /// <item> /// <term>UseAuthorizationHeader</term> /// <description><c>true</c></description> /// </item> /// <item> /// <term>Realm</term> /// <description><c>null</c></description> /// </item> /// <item> /// <term>SignatureMethod</term> /// <description><c>"HMAC-SHA1"</c></description> /// </item> /// <item> /// <term>OAuthVersion</term> /// <description><c>"1.0"</c></description> /// </item> /// <item> /// <term>ConfigSection</term> /// <description><c>"oauth.net.consumer"</c></description> /// </item> /// </list> /// </remarks> /// <param name="requestTokenEndPoint">EndPoint for obtaining request tokens</param> /// <param name="authorizationUrl">URL to send users to for authorization</param> /// <param name="accessTokenEndPoint">EndPoint for obtaining access tokens</param> /// <param name="consumer">Consumer credentials</param> /// <returns>An OAuthService</returns> public static OAuthService Create( EndPoint requestTokenEndPoint, Uri authorizationUrl, EndPoint accessTokenEndPoint, IConsumer consumer) { return OAuthService.Create( requestTokenEndPoint, authorizationUrl, accessTokenEndPoint, true, null, "HMAC-SHA1", Constants.Version1_0, consumer, () => ServiceLocator.Current); }
private bool Equals(EndPoint other) { return string.Equals(this.HttpMethod, other.HttpMethod) && ((this.Uri == null && other.Uri == null) || (this.Uri != null && this.Uri.Equals(other.Uri))); }
/// <summary> /// Creates a new OAuth protected request configured for an ASP.NET context. /// </summary> /// <param name="resourceEndPoint">Protected resource End Point</param> /// <param name="settings">Service settings</param> /// <param name="callbackUri">Callback URI</param> /// <param name="endUserId">End user ID</param> /// <returns>An OAuth protected request for the protected resource, /// configured for an ASP.NET context</returns> public static OAuthRequest Create(EndPoint resourceEndPoint, OAuthService settings, Uri callbackUri, string endUserId) { OAuthRequest request = OAuthRequest.Create(resourceEndPoint, settings, callbackUri, endUserId); request.AuthorizationHandler = AspNetOAuthRequest.HandleAuthorization; request.VerificationHandler = AspNetOAuthRequest.HandleVerification; return request; }