Navigation Menu

Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Renamed enumeration values to follow C# conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
bbaia committed Jan 12, 2012
1 parent 5fd910c commit 9d5c6d0
Show file tree
Hide file tree
Showing 15 changed files with 39 additions and 39 deletions.
Expand Up @@ -76,7 +76,7 @@ protected override IList<IHttpMessageConverter> GetMessageConverters()

protected override OAuth2Version GetOAuth2Version()
{
return OAuth2Version.DRAFT_10;
return OAuth2Version.Draft10;
}

#region IFacebook Membres
Expand Down
Expand Up @@ -77,7 +77,7 @@ protected override IList<IHttpMessageConverter> GetMessageConverters()

protected override OAuth2Version GetOAuth2Version()
{
return OAuth2Version.DRAFT_8;
return OAuth2Version.Draft8;
}

#region GitHub Membres
Expand Down
Expand Up @@ -27,7 +27,7 @@ static void Main(string[] args)
RedirectUrl = "https://www.facebook.com/connect/login_success.html",
Scope = "offline_access,publish_stream"
};
string authorizationUrl = facebookServiceProvider.OAuthOperations.BuildAuthorizeUrl(GrantType.IMPLICIT_GRANT, parameters);
string authorizationUrl = facebookServiceProvider.OAuthOperations.BuildAuthorizeUrl(GrantType.ImplicitGrant, parameters);
Console.WriteLine("Redirect user to Facebook for authorization: " + authorizationUrl);
Process.Start(authorizationUrl);

Expand Down
Expand Up @@ -34,7 +34,7 @@ public ActionResult SignIn()
RedirectUrl = "http://localhost/Facebook/Callback",
Scope = "publish_stream"
};
return Redirect(facebookProvider.OAuthOperations.BuildAuthorizeUrl(GrantType.AUTHORIZATION_CODE, parameters));
return Redirect(facebookProvider.OAuthOperations.BuildAuthorizeUrl(GrantType.AuthorizationCode, parameters));
}

// GET: /Facebook/Callback
Expand Down
Expand Up @@ -57,7 +57,7 @@ public void Authenticate()
RedirectUrl = CallbackUrl,
Scope = "publish_stream"
};
this.AuthenticateUri = new Uri(this.FacebookServiceProvider.OAuthOperations.BuildAuthenticateUrl(GrantType.AUTHORIZATION_CODE, parameters));
this.AuthenticateUri = new Uri(this.FacebookServiceProvider.OAuthOperations.BuildAuthenticateUrl(GrantType.AuthorizationCode, parameters));
}

public void AuthenticateCallback(string code)
Expand Down
16 changes: 8 additions & 8 deletions src/Spring.Social.Core/Social/OAuth1/OAuth1Template.cs
Expand Up @@ -71,7 +71,7 @@ public RestTemplate RestTemplate
/// <param name="authorizeUrl">The authorize URL.</param>
/// <param name="accessTokenUrl">The access token URL.</param>
public OAuth1Template(string consumerKey, string consumerSecret, string requestTokenUrl, string authorizeUrl, string accessTokenUrl)
: this(consumerKey, consumerSecret, requestTokenUrl, authorizeUrl, accessTokenUrl, OAuth1Version.CORE_10_REVISION_A)
: this(consumerKey, consumerSecret, requestTokenUrl, authorizeUrl, accessTokenUrl, OAuth1Version.Core10a)
{
}

Expand Down Expand Up @@ -99,7 +99,7 @@ public OAuth1Template(string consumerKey, string consumerSecret, string requestT
/// <param name="authenticateUrl">The authenticate URL.</param>
/// <param name="accessTokenUrl">The access token URL.</param>
public OAuth1Template(string consumerKey, string consumerSecret, string requestTokenUrl, string authorizeUrl, string authenticateUrl, string accessTokenUrl)
: this(consumerKey, consumerSecret, requestTokenUrl, authorizeUrl, authenticateUrl, accessTokenUrl, OAuth1Version.CORE_10_REVISION_A)
: this(consumerKey, consumerSecret, requestTokenUrl, authorizeUrl, authenticateUrl, accessTokenUrl, OAuth1Version.Core10a)
{
}

Expand Down Expand Up @@ -194,7 +194,7 @@ public string BuildAuthenticateUrl(string requestToken, OAuth1Parameters paramet
public Task<OAuthToken> FetchRequestTokenAsync(string callbackUrl, NameValueCollection additionalParameters)
{
IDictionary<string, string> oauthParameters = new Dictionary<string, string>(1);
if (version == OAuth1Version.CORE_10_REVISION_A)
if (version == OAuth1Version.Core10a)
{
oauthParameters.Add("oauth_callback", callbackUrl);
}
Expand Down Expand Up @@ -222,7 +222,7 @@ public Task<OAuthToken> ExchangeForAccessTokenAsync(AuthorizedRequestToken reque
{
IDictionary<string, string> tokenParameters = new Dictionary<string, string>(2);
tokenParameters.Add("oauth_token", requestToken.Value);
if (version == OAuth1Version.CORE_10_REVISION_A)
if (version == OAuth1Version.Core10a)
{
tokenParameters.Add("oauth_verifier", requestToken.Verifier);
}
Expand Down Expand Up @@ -252,7 +252,7 @@ public Task<OAuthToken> ExchangeForAccessTokenAsync(AuthorizedRequestToken reque
public OAuthToken FetchRequestToken(string callbackUrl, NameValueCollection additionalParameters)
{
IDictionary<string, string> oauthParameters = new Dictionary<string, string>(1);
if (version == OAuth1Version.CORE_10_REVISION_A)
if (version == OAuth1Version.Core10a)
{
oauthParameters.Add("oauth_callback", callbackUrl);
}
Expand All @@ -275,7 +275,7 @@ public OAuthToken ExchangeForAccessToken(AuthorizedRequestToken requestToken, Na
{
IDictionary<string, string> tokenParameters = new Dictionary<string, string>(2);
tokenParameters.Add("oauth_token", requestToken.Value);
if (version == OAuth1Version.CORE_10_REVISION_A)
if (version == OAuth1Version.Core10a)
{
tokenParameters.Add("oauth_verifier", requestToken.Verifier);
}
Expand Down Expand Up @@ -307,7 +307,7 @@ public OAuthToken ExchangeForAccessToken(AuthorizedRequestToken requestToken, Na
public RestOperationCanceler FetchRequestTokenAsync(string callbackUrl, NameValueCollection additionalParameters, Action<RestOperationCompletedEventArgs<OAuthToken>> operationCompleted)
{
IDictionary<string, string> oauthParameters = new Dictionary<string, string>(1);
if (version == OAuth1Version.CORE_10_REVISION_A)
if (version == OAuth1Version.Core10a)
{
oauthParameters.Add("oauth_callback", callbackUrl);
}
Expand Down Expand Up @@ -347,7 +347,7 @@ public RestOperationCanceler ExchangeForAccessTokenAsync(AuthorizedRequestToken
{
IDictionary<string, string> tokenParameters = new Dictionary<string, string>(2);
tokenParameters.Add("oauth_token", requestToken.Value);
if (version == OAuth1Version.CORE_10_REVISION_A)
if (version == OAuth1Version.Core10a)
{
tokenParameters.Add("oauth_verifier", requestToken.Verifier);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Spring.Social.Core/Social/OAuth1/OAuth1Version.cs
Expand Up @@ -35,11 +35,11 @@ public enum OAuth1Version
/// <summary>
/// OAuth Core Version 1.0.
/// </summary>
CORE_10,
Core10,

/// <summary>
/// OAuth Core Version 1.0 Revision A.
/// </summary>
CORE_10_REVISION_A
Core10a
}
}
Expand Up @@ -105,12 +105,12 @@ public bool IsAuthorized
/// Subclasses may override to return another version.
/// </remarks>
/// <returns>
/// By default, returns OAuth2Version.BEARER indicating versions of OAuth2 that apply the bearer token scheme.
/// By default, returns OAuth2Version.Bearer indicating versions of OAuth2 that apply the bearer token scheme.
/// </returns>
/// <see cref="OAuth2Version"/>
protected virtual OAuth2Version GetOAuth2Version()
{
return OAuth2Version.BEARER;
return OAuth2Version.Bearer;
}

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions src/Spring.Social.Core/Social/OAuth2/GrantType .cs
Expand Up @@ -29,15 +29,15 @@ namespace Spring.Social.OAuth2
public enum GrantType
{
/// <summary>
/// AUTHORIZATION_CODE denotes the server-side authorization flow, and is
/// Denotes the server-side authorization flow, and is
/// associated with the response_type=code parameter value.
/// </summary>
AUTHORIZATION_CODE,
AuthorizationCode,

/// <summary>
/// IMPLICIT_GRANT denotes the client-side authorization flow and is
/// Denotes the client-side authorization flow and is
/// associated with the response_type=token parameter value.
/// </summary>
IMPLICIT_GRANT
ImplicitGrant
}
}
Expand Up @@ -58,13 +58,13 @@ public void BeforeExecute(IClientHttpRequestContext request)
{
switch (this.oauth2Version)
{
case OAuth2Version.BEARER:
case OAuth2Version.Bearer:
request.Headers["Authorization"] = "Bearer " + accessToken;
break;
case OAuth2Version.DRAFT_10:
case OAuth2Version.Draft10:
request.Headers["Authorization"] = "OAuth " + accessToken;
break;
case OAuth2Version.DRAFT_8:
case OAuth2Version.Draft8:
request.Headers["Authorization"] = "Token token=\"" + accessToken + "\"";
break;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Spring.Social.Core/Social/OAuth2/OAuth2Template.cs
Expand Up @@ -469,11 +469,11 @@ private AccessGrant ExtractAccessGrant(JsonValue response)
private static string BuildAuthUrl(string baseAuthUrl, GrantType grantType, OAuth2Parameters parameters)
{
StringBuilder authUrl = new StringBuilder(baseAuthUrl);
if (grantType == GrantType.AUTHORIZATION_CODE)
if (grantType == GrantType.AuthorizationCode)
{
authUrl.Append("&response_type=code");
}
else if (grantType == GrantType.IMPLICIT_GRANT)
else if (grantType == GrantType.ImplicitGrant)
{
authUrl.Append("&response_type=token");
}
Expand Down
6 changes: 3 additions & 3 deletions src/Spring.Social.Core/Social/OAuth2/OAuth2Version.cs
Expand Up @@ -36,16 +36,16 @@ public enum OAuth2Version
/// <summary>
/// OAuth Version 2.0 using bearer tokens (since Draft 12).
/// </summary>
BEARER,
Bearer,

/// <summary>
/// OAuth Version 2.0 Draft 10.
/// </summary>
DRAFT_10,
Draft10,

/// <summary>
/// OAuth Version 2.0 Draft 8.
/// </summary>
DRAFT_8
Draft8
}
}
Expand Up @@ -49,9 +49,9 @@ public class OAuth1TemplateTests
[SetUp]
public void Setup()
{
oauth10a = new OAuth1Template("consumer_key", "consumer_secret", REQUEST_TOKEN_URL, AUTHORIZE_URL, null, ACCESS_TOKEN_URL, OAuth1Version.CORE_10_REVISION_A);
oauth10 = new OAuth1Template("consumer_key", "consumer_secret", REQUEST_TOKEN_URL, AUTHORIZE_URL, AUTHENTICATE_URL, ACCESS_TOKEN_URL, OAuth1Version.CORE_10);
customOauth10 = new CustomOAuth1Template("consumer_key", "consumer_secret", REQUEST_TOKEN_URL, AUTHORIZE_URL, null, ACCESS_TOKEN_URL, OAuth1Version.CORE_10);
oauth10a = new OAuth1Template("consumer_key", "consumer_secret", REQUEST_TOKEN_URL, AUTHORIZE_URL, null, ACCESS_TOKEN_URL, OAuth1Version.Core10a);
oauth10 = new OAuth1Template("consumer_key", "consumer_secret", REQUEST_TOKEN_URL, AUTHORIZE_URL, AUTHENTICATE_URL, ACCESS_TOKEN_URL, OAuth1Version.Core10);
customOauth10 = new CustomOAuth1Template("consumer_key", "consumer_secret", REQUEST_TOKEN_URL, AUTHORIZE_URL, null, ACCESS_TOKEN_URL, OAuth1Version.Core10);
}

[Test]
Expand Down
Expand Up @@ -36,7 +36,7 @@ public class AbstractOAuth2ApiBindingTests : AbstractOAuth2ApiBinding
{
#region AbstractOAuth2ApiBinding implementation

public static OAuth2Version OAuth2Version = OAuth2Version.BEARER;
public static OAuth2Version OAuth2Version = OAuth2Version.Bearer;

public AbstractOAuth2ApiBindingTests()
: base()
Expand Down Expand Up @@ -87,7 +87,7 @@ public void RequestInterceptor()
[Test]
public void RequestInterceptor_Draft10()
{
AbstractOAuth2ApiBindingTests.OAuth2Version = OAuth2Version.DRAFT_10;
AbstractOAuth2ApiBindingTests.OAuth2Version = OAuth2Version.Draft10;
AbstractOAuth2ApiBindingTests apiBinding = new AbstractOAuth2ApiBindingTests("access_token");
AssertThatRequestInterceptorWritesAuthorizationHeader(apiBinding, "OAuth access_token");
apiBinding.UpdateStatus();
Expand All @@ -96,7 +96,7 @@ public void RequestInterceptor_Draft10()
[Test]
public void RequestInterceptor_Draft8()
{
AbstractOAuth2ApiBindingTests.OAuth2Version = OAuth2Version.DRAFT_8;
AbstractOAuth2ApiBindingTests.OAuth2Version = OAuth2Version.Draft8;
AbstractOAuth2ApiBindingTests apiBinding = new AbstractOAuth2ApiBindingTests("access_token");
AssertThatRequestInterceptorWritesAuthorizationHeader(apiBinding, "Token token=\"access_token\"");
apiBinding.UpdateStatus();
Expand Down
Expand Up @@ -56,7 +56,7 @@ public void BuildAuthorizeUrl_CodeResponseType()
parameters.RedirectUrl = "http://www.someclient.com/connect/foo";
parameters.Scope = "read,write";
string expected = AUTHORIZE_URL + "?client_id=client_id&response_type=code&redirect_uri=http%3A%2F%2Fwww.someclient.com%2Fconnect%2Ffoo&scope=read%2Cwrite";
string actual = oAuth2Template.BuildAuthorizeUrl(GrantType.AUTHORIZATION_CODE, parameters);
string actual = oAuth2Template.BuildAuthorizeUrl(GrantType.AuthorizationCode, parameters);
Assert.AreEqual(expected, actual);
}

Expand All @@ -67,7 +67,7 @@ public void BuildAuthorizeUrl_TokenResponseType()
parameters.RedirectUrl = "http://www.someclient.com/connect/foo";
parameters.Scope = "read,write";
string expected = AUTHORIZE_URL + "?client_id=client_id&response_type=token&redirect_uri=http%3A%2F%2Fwww.someclient.com%2Fconnect%2Ffoo&scope=read%2Cwrite";
string actual = oAuth2Template.BuildAuthorizeUrl(GrantType.IMPLICIT_GRANT, parameters);
string actual = oAuth2Template.BuildAuthorizeUrl(GrantType.ImplicitGrant, parameters);
Assert.AreEqual(expected, actual);
}

Expand All @@ -77,7 +77,7 @@ public void BuildAuthorizeUrl_NoScopeInParameters()
OAuth2Parameters parameters = new OAuth2Parameters();
parameters.RedirectUrl = "http://www.someclient.com/connect/foo";
string expected = AUTHORIZE_URL + "?client_id=client_id&response_type=code&redirect_uri=http%3A%2F%2Fwww.someclient.com%2Fconnect%2Ffoo";
string actual = oAuth2Template.BuildAuthorizeUrl(GrantType.AUTHORIZATION_CODE, parameters);
string actual = oAuth2Template.BuildAuthorizeUrl(GrantType.AuthorizationCode, parameters);
Assert.AreEqual(expected, actual);
}

Expand All @@ -91,7 +91,7 @@ public void BuildAuthorizeUrl_AdditionalParameters()
parameters.Add("anotherparam", "somevalue1");
parameters.Add("anotherparam", "somevalue2");
string expected = AUTHORIZE_URL + "?client_id=client_id&response_type=token&redirect_uri=http%3A%2F%2Fwww.someclient.com%2Fconnect%2Ffoo&scope=read%2Cwrite&display=touch&anotherparam=somevalue1&anotherparam=somevalue2";
string actual = oAuth2Template.BuildAuthorizeUrl(GrantType.IMPLICIT_GRANT, parameters);
string actual = oAuth2Template.BuildAuthorizeUrl(GrantType.ImplicitGrant, parameters);
Assert.AreEqual(expected, actual);
}

Expand Down

0 comments on commit 9d5c6d0

Please sign in to comment.