本文整理汇总了C#中AuthenticationService.AddProvider方法的典型用法代码示例。如果您正苦于以下问题:C# AuthenticationService.AddProvider方法的具体用法?C# AuthenticationService.AddProvider怎么用?C# AuthenticationService.AddProvider使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AuthenticationService
的用法示例。
在下文中一共展示了AuthenticationService.AddProvider方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AuthenticationRegistry
public AuthenticationRegistry(IAuthenticationProvider facebookProvider,
IAuthenticationProvider googleProvider,
IAuthenticationProvider twitterProvider)
{
var authenticationService = new AuthenticationService();
if (facebookProvider != null)
{
authenticationService.AddProvider(facebookProvider);
}
if (googleProvider != null)
{
authenticationService.AddProvider(googleProvider);
}
if (twitterProvider != null)
{
authenticationService.AddProvider(twitterProvider);
}
For<IAuthenticationService>()
.Use(authenticationService)
.Named("Authentication Service.");
}
开发者ID:codeprogression,项目名称:WorldDomination.Web.Authentication,代码行数:25,代码来源:AuthenticationRegistry.cs
示例2: GivenAnExistingProvider_AddProvider_ThrowsAnException
public void GivenAnExistingProvider_AddProvider_ThrowsAnException()
{
// Arrange.
var authenticationService = new AuthenticationService();
var facebookProvider = new FacebookProvider("a", "b", new Uri("http://www.google.com"));
// Act.
authenticationService.AddProvider(facebookProvider);
var result = Assert.Throws<AuthenticationException>(
() => authenticationService.AddProvider(facebookProvider));
// Assert.
Assert.NotNull(result);
Assert.Equal("Trying to add a facebook provider, but one already exists.", result.Message);
}
示例3: HomeController
static HomeController()
{
// For the purpose of this example we just made the service static in
// a static constructor, normally you would do this using dependency injection
// but for the take of simplicity we added it it here. Please refer
// to the Advanced sample for the DI version. Don't use a static constructor
// like this in your project, please. :)
var facebookProvider = new FacebookProvider(FacebookAppId, FacebookAppSecret);
var twitterProvider = new TwitterProvider(TwitterConsumerKey, TwitterConsumerSecret);
var googleProvider = new GoogleProvider(GoogleConsumerKey, GoogleConsumerSecret);
AuthenticationService = new AuthenticationService();
AuthenticationService.AddProvider(facebookProvider);
AuthenticationService.AddProvider(twitterProvider);
AuthenticationService.AddProvider(googleProvider);
}
示例4: RegisterAuthenticationProviders
private static void RegisterAuthenticationProviders(TinyIoCContainer container)
{
Condition.Requires(container).IsNotNull();
var twitterProvider = new TwitterProvider(TwitterConsumerKey, TwitterConsumerSecret);
var facebookProvider = new FacebookProvider(FacebookAppId, FacebookAppSecret);
var googleProvider = new GoogleProvider(GoogleConsumerKey, GoogleConsumerSecret);
var authenticationService = new AuthenticationService();
authenticationService.AddProvider(twitterProvider);
authenticationService.AddProvider(facebookProvider);
authenticationService.AddProvider(googleProvider);
container.Register<IAuthenticationService>(authenticationService);
}
示例5: HomeController
public HomeController()
{
var facebookProvider = new FacebookProvider(FacebookAppId, FacebookAppSecret,
new Uri(
"http://localhost:1337/home/AuthenticateCallback?providerKey=facebook"));
var twitterProvider = new TwitterProvider(TwitterConsumerKey, TwitterConsumerSecret,
new Uri(
"http://localhost:1337/home/AuthenticateCallback?providerKey=twitter"));
var googleProvider = new GoogleProvider(GoogleConsumerKey, GoogleConsumerSecret,
new Uri(
"http://localhost:1337/home/AuthenticateCallback?providerKey=google"));
_authenticationService = new AuthenticationService();
_authenticationService.AddProvider(facebookProvider);
_authenticationService.AddProvider(twitterProvider);
_authenticationService.AddProvider(googleProvider);
}
示例6: HomeController
public HomeController()
{
var facebookProvider =
new FakeFacebookProvider(new Uri("http://localhost:1338/home/AuthenticateCallback?providerKey=facebook"));
var twitterProvider =
new FakeTwitterProvider(new Uri("http://localhost:1338/home/AuthenticateCallback?providerKey=twitter"));
var googleProvider =
new FakeGoogleProvider(new Uri("http://localhost:1338/home/AuthenticateCallback?providerKey=google"));
_authenticationService = new AuthenticationService();
_authenticationService.AddProvider(facebookProvider);
_authenticationService.AddProvider(twitterProvider);
_authenticationService.AddProvider(googleProvider);
// Some providers that error.
var facebookProviderThatErrors =
new FakeFacebookProvider(
new Uri("http://localhost:1338/home/AuthenticateCallbackThatErrors?providerKey=facebook"))
{
AuthenticateClientExceptionMessage =
"ZOMG! Something nasty has occured! ID10T Error!1!1!1. -le sad panda-"
};
var twitterProviderThatErrors =
new FakeTwitterProvider(
new Uri("http://localhost:1338/home/AuthenticateCallbackThatErrors?providerKey=twitter"))
{
AuthenticateClientExceptionMessage =
"ZOMG! Something nasty has occured! ID10T Error!1!1!1. -le sad panda-"
};
var googleProviderThatErrors =
new FakeGoogleProvider(
new Uri("http://localhost:1338/home/AuthenticateCallbackThatErrors?providerKey=google"))
{
AuthenticateClientExceptionMessage =
"ZOMG! Something nasty has occured! ID10T Error!1!1!1. -le sad panda-"
};
_authenticationServiceThatErrors = new AuthenticationService();
_authenticationServiceThatErrors.AddProvider(facebookProviderThatErrors);
_authenticationServiceThatErrors.AddProvider(twitterProviderThatErrors);
_authenticationServiceThatErrors.AddProvider(googleProviderThatErrors);
}
示例7: GivenAValidProviderKeyWithNoState_RedirectToAuthenticate_ReturnsAUri
public void GivenAValidProviderKeyWithNoState_RedirectToAuthenticate_ReturnsAUri()
{
// Arrange.
var authenticationService = new AuthenticationService();
authenticationService.AddProvider(new FacebookProvider("aa", "bb", new Uri("http://www.whatever.com")));
// Act.
var result = authenticationService.RedirectToAuthenticationProvider("Facebook");
// Assert.
Assert.NotNull(result);
Assert.Equal("https://www.facebook.com/dialog/oauth?client_id=aa&scope=email&redirect_uri=http://www.whatever.com/", result.AbsoluteUri);
}
示例8: GivenANewProvider_AddProvider_AddsTheProviderToTheProviderCollection
public void GivenANewProvider_AddProvider_AddsTheProviderToTheProviderCollection()
{
// Arrange.
var authenticationService = new AuthenticationService();
// Act.
authenticationService.AddProvider(new FacebookProvider("a", "b", new Uri("http://www.google.com")));
// Assert.
var providers = authenticationService.AuthenticationProviders;
Assert.NotNull(providers);
Assert.Equal(1, providers.Count);
Assert.NotNull(providers["facebook"]);
}
示例9: GivenANewProvider_AddProvider_AddsTheProviderToTheProviderCollection
public void GivenANewProvider_AddProvider_AddsTheProviderToTheProviderCollection()
{
// Arrange.
var authenticationService = new AuthenticationService();
// Act.
authenticationService.AddProvider(new TwitterProvider("a", "b"));
// Assert.
var providers = authenticationService.AuthenticationProviders;
Assert.NotNull(providers);
Assert.Equal(3, providers.Count);
Assert.NotNull(providers["twitter"]);
}
开发者ID:codeprogression,项目名称:WorldDomination.Web.Authentication,代码行数:14,代码来源:AuthenticationServiceFacts.cs
示例10: GivenAnExistingProvider_AddProvider_ThrowsAnException
public void GivenAnExistingProvider_AddProvider_ThrowsAnException()
{
// Arrange.
var authenticationService = new AuthenticationService();
var facebookProvider = new FacebookProvider(new ProviderParams { Key = "a", Secret = "b" });
// Act.
var result = Assert.Throws<WorldDominationConfigurationException>(
() => authenticationService.AddProvider(facebookProvider, false));
// Assert.
Assert.NotNull(result);
Assert.Equal("The provider 'Facebook' already exists and cannot be overridden, either set `replaceExisting` to `true`, or remove the provider first.", result.Message);
}
示例11: GivenAnExistingProvider_AddProvider_ThrowsAnException
public void GivenAnExistingProvider_AddProvider_ThrowsAnException()
{
// Arrange.
var authenticationService = new AuthenticationService();
var facebookProvider = new FacebookProvider(new ProviderParams { Key = "a", Secret = "b" });
// Act.
var result = Assert.Throws<AuthenticationException>(
() => authenticationService.AddProvider(facebookProvider));
// Assert.
Assert.NotNull(result);
Assert.Equal("Trying to add a facebook provider, but one already exists.", result.Message);
}
示例12: RegisterAuthenticationProviders
private static void RegisterAuthenticationProviders(TinyIoCContainer container)
{
Condition.Requires(container).IsNotNull();
var twitterProvider = new TwitterProvider(TwitterConsumerKey, TwitterConsumerSecret,
new Uri(
"http://localhost:6969/AuthenticateCallback?providerKey=Twitter"));
var facebookProvider = new FacebookProvider(FacebookAppId, FacebookAppSecret,
new Uri(
"http://localhost:6969/AuthenticateCallback?providerKey=facebook"));
var googleProvider = new GoogleProvider(GoogleConsumerKey, GoogleConsumerSecret,
new Uri(
"http://localhost:6969/AuthenticateCallback?providerKey=google"));
var authenticationService = new AuthenticationService();
authenticationService.AddProvider(twitterProvider);
authenticationService.AddProvider(facebookProvider);
authenticationService.AddProvider(googleProvider);
container.Register<IAuthenticationService>(authenticationService);
}
示例13: GivenAFakeProviderKeyWhichDoesExist_RedirectToAuthenticate_ReturnsAUri
public void GivenAFakeProviderKeyWhichDoesExist_RedirectToAuthenticate_ReturnsAUri()
{
// Arrange.
const string name = "FakeProviderWoot";
var fakeProvider = new FakeProvider(name)
{
AccessToken = new AccessToken
{
ExpiresOn = DateTime.Now.AddMinutes(100),
PublicToken = "I.Am.A.Public.Token"
},
UserInformation = new UserInformation
{
Email = "[email protected]",
Gender = GenderType.Male,
Name = "Fake Name",
Id = "1234567890",
UserName = "Fake.UserName"
}
};
var authenticationService = new AuthenticationService();
authenticationService.AddProvider(fakeProvider);
// Act.
var result = authenticationService.RedirectToAuthenticationProvider(name,
new Uri(
"http://i.want.to.go.home.com/click/feet/together?provider=google"));
// Assert.
Assert.NotNull(result);
Assert.Equal("http://i.want.to.go.home.com/click/feet/together?provider=google&state=This%20is%20some%20fake%20state", result.AbsoluteUri);
}