Skip to content
This repository has been archived by the owner on Dec 9, 2020. It is now read-only.

Commit

Permalink
Refactored samples
Browse files Browse the repository at this point in the history
  • Loading branch information
Micah Martin committed May 23, 2012
1 parent 452adb5 commit a3f7d7a
Show file tree
Hide file tree
Showing 14 changed files with 64 additions and 88 deletions.
8 changes: 4 additions & 4 deletions samples/MVC3Sample/Controllers/OAuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CrackerJack.OAuth;
using CrackerJack.OAuth.Request;
using CrackerJack.OAuth.Response;
using OAuth2Provider;
using OAuth2Provider.Request;
using OAuth2Provider.Response;

namespace MVC3Sample.Controllers
{
Expand All @@ -18,7 +18,7 @@ public ActionResult Token()
{
try
{
var oauthRequest = new TokenRequest(Request, MvcApplication.ServiceLocator);
var oauthRequest = new TokenRequest(new HttpRequestBaseRequest(Request), MvcApplication.ServiceLocator);

var token = oauthRequest.Authorize();

Expand Down
8 changes: 4 additions & 4 deletions samples/MVC3Sample/Controllers/SecureController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CrackerJack.OAuth;
using CrackerJack.OAuth.Issuer;
using CrackerJack.OAuth.Request;
using OAuth2Provider;
using OAuth2Provider.Issuer;
using OAuth2Provider.Request;

namespace MVC3Sample.Controllers
{
Expand Down Expand Up @@ -41,7 +41,7 @@ protected virtual void AuthorizeRequest(ActionExecutingContext filterContext)

try
{
var resourceRequest = new ResourceRequest(Request, _serviceLocator);
var resourceRequest = new ResourceRequest(new HttpRequestBaseRequest(Request), _serviceLocator);
isAuthorized = resourceRequest.Authorize();

TokenData = _serviceLocator.Issuer.DecodeAccessToken(resourceRequest.AccessToken);
Expand Down
2 changes: 1 addition & 1 deletion samples/MVC3Sample/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CrackerJack.OAuth.Response;
using OAuth2Provider.Response;

namespace MVC3Sample
{
Expand Down
13 changes: 2 additions & 11 deletions samples/MVC3Sample/Global.asax.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc;
using System.Web.Routing;
using CrackerJack.OAuth;
using OAuth2Provider;
using Samples.Core;

namespace MVC3Sample
Expand Down Expand Up @@ -37,9 +31,6 @@ protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();

// Use LocalDB for Entity Framework by default
Database.DefaultConnectionFactory = new SqlConnectionFactory("Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");

RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);
}
Expand Down
13 changes: 3 additions & 10 deletions samples/MVC3Sample/MVC3Sample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,13 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CrackerJack.OAuth">
<HintPath>..\..\binaries\CrackerJack.OAuth.dll</HintPath>
</Reference>
<Reference Include="EntityFramework">
<HintPath>..\packages\EntityFramework.4.1.10331.0\lib\net40\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="Microsoft.CSharp" />
<Reference Include="Microsoft.Web.Infrastructure, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Microsoft.Web.Infrastructure.1.0.0.0\lib\net40\Microsoft.Web.Infrastructure.dll</HintPath>
</Reference>
<Reference Include="NuGet.Core, Version=1.0.11220.104, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<Private>True</Private>
<HintPath>..\packages\Nuget.Core.1.0.1120.104\lib\net40\NuGet.Core.dll</HintPath>
<Reference Include="OAuth2Provider">
<HintPath>..\..\binaries\OAuth2Provider.dll</HintPath>
</Reference>
<Reference Include="System.Data.Entity" />
<Reference Include="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
Expand Down Expand Up @@ -198,7 +191,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Samples.Core\Samples.Core.csproj">
<Project>{06c23bea-1a09-4fb6-9766-5e474e7b32b1}</Project>
<Project>{06C23BEA-1A09-4FB6-9766-5E474E7B32B1}</Project>
<Name>Samples.Core</Name>
</ProjectReference>
</ItemGroup>
Expand Down
3 changes: 3 additions & 0 deletions samples/MVC3Sample/MVC3Sample.csproj.user
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
Expand Down
2 changes: 1 addition & 1 deletion samples/MVC3Sample/OAuthResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Web;
using System.Web.Mvc;
using CrackerJack.OAuth.Response;
using OAuth2Provider.Response;

namespace MVC3Sample
{
Expand Down
6 changes: 3 additions & 3 deletions samples/Samples.Core/OAuthServiceLocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
using System.Collections.Generic;
using System.Linq;
using System.Web;
using CrackerJack.OAuth;
using CrackerJack.OAuth.Issuer;
using CrackerJack.OAuth.Repository;
using OAuth2Provider;
using OAuth2Provider.Issuer;
using OAuth2Provider.Repository;

namespace Samples.Core
{
Expand Down
4 changes: 2 additions & 2 deletions samples/Samples.Core/Samples.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CrackerJack.OAuth">
<HintPath>..\..\binaries\CrackerJack.OAuth.dll</HintPath>
<Reference Include="OAuth2Provider">
<HintPath>..\..\binaries\OAuth2Provider.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Core" />
Expand Down
6 changes: 6 additions & 0 deletions samples/Samples.Core/Samples.Core.csproj.user
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
</Project>
66 changes: 31 additions & 35 deletions samples/WebApiSample/Controllers/OAuthController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,41 @@
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using CrackerJack.OAuth;
using CrackerJack.OAuth.Request;
using CrackerJack.OAuth.Response;

namespace WebApiSample.Controllers
{
public class OAuthController : ApiController
{

public ActionResult Token()
{
try
{
var oauthRequest = new TokenRequest(Request, MvcApplication.ServiceLocator);

var token = oauthRequest.Authorize();

if (token.RedirectsUri.HasValue())
{

var redirectUri = OAuthResponse
.TokenResponse(token.AccessToken, token.ExpiresIn, token.RefreshToken)
.SetLocation(token.RedirectsUri)
.BuildQueryMessage().LocationUri;

return Redirect(redirectUri);
}

var response = OAuthResponse
.TokenResponse(token.AccessToken, token.ExpiresIn, token.RefreshToken)
.BuildJsonMessage();

return this.OAuth(response);
}
catch (OAuthException ex)
{
var response = new ErrorResponseBuilder(ex).BuildJsonMessage();
return this.OAuth(response);
}
}
//public ActionResult Token()
//{
// try
// {
// var oauthRequest = new TokenRequest(Request, MvcApplication.ServiceLocator);

// var token = oauthRequest.Authorize();

// if (token.RedirectsUri.HasValue())
// {

// var redirectUri = OAuthResponse
// .TokenResponse(token.AccessToken, token.ExpiresIn, token.RefreshToken)
// .SetLocation(token.RedirectsUri)
// .BuildQueryMessage().LocationUri;

// return Redirect(redirectUri);
// }

// var response = OAuthResponse
// .TokenResponse(token.AccessToken, token.ExpiresIn, token.RefreshToken)
// .BuildJsonMessage();

// return this.OAuth(response);
// }
// catch (OAuthException ex)
// {
// var response = new ErrorResponseBuilder(ex).BuildJsonMessage();
// return this.OAuth(response);
// }
//}
}
}
15 changes: 1 addition & 14 deletions samples/WebApiSample/Global.asax.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data.Entity;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Optimization;
using System.Web.Routing;

namespace WebApiSample
Expand Down Expand Up @@ -43,13 +35,8 @@ protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();

// Use LocalDB for Entity Framework by default
Database.DefaultConnectionFactory = new SqlConnectionFactory("Data Source=(localdb)\v11.0; Integrated Security=True; MultipleActiveResultSets=True");

RegisterGlobalFilters(GlobalFilters.Filters);
RegisterRoutes(RouteTable.Routes);

BundleTable.Bundles.RegisterTemplateBundles();
}
}
}
3 changes: 0 additions & 3 deletions samples/WebApiSample/WebApiSample.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="CrackerJack.OAuth">
<HintPath>..\..\binaries\CrackerJack.OAuth.dll</HintPath>
</Reference>
<Reference Include="EntityFramework">
<HintPath>..\packages\EntityFramework.4.1.10331.0\lib\net40\EntityFramework.dll</HintPath>
</Reference>
Expand Down
3 changes: 3 additions & 0 deletions samples/WebApiSample/WebApiSample.csproj.user
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<ProjectView>ShowAllFiles</ProjectView>
</PropertyGroup>
<ProjectExtensions>
<VisualStudio>
<FlavorProperties GUID="{349c5851-65df-11da-9384-00065b846f21}">
Expand Down

0 comments on commit a3f7d7a

Please sign in to comment.