public static IAppBuilder UseAppServiceAuthentication(this IAppBuilder appBuilder, AppServiceAuthenticationOptions options)
        {
            if (appBuilder == null)
            {
                throw new ArgumentNullException("appBuilder");
            }

            if (options == null)
            {
                throw new ArgumentNullException("options");
            }

            appBuilder.Use(typeof(AppServiceAuthenticationMiddleware), new object[]
            {
                appBuilder,
                options
            });

            return appBuilder;
        }
        public void UseMobileAppAuthentication_ConfiguresServiceAuthentication_WhenAuthEnabled()
        {
            // Arrange
            MobileAppConfiguration configOptions = new MobileAppConfiguration();
            this.config.SetMobileAppConfiguration(configOptions);
            AppServiceAuthenticationOptions options = new AppServiceAuthenticationOptions();

            this.appBuilderMock.Setup(p => p.Use(It.IsAny<object>(), It.IsAny<object[]>()))
                .Callback<object, object[]>((mockObject, mockArgs) =>
                {
                    options = (AppServiceAuthenticationOptions)mockArgs[1];
                })
                .Returns(this.appBuilder)
                .Verifiable();

            // Act
            this.appBuilder.UseAppServiceAuthentication(options);

            // Assert
            this.appBuilderMock.Verify(p => p.Use(It.IsAny<object>(), It.IsAny<object[]>()), Times.Once);
            Assert.Equal("MobileApp", options.AuthenticationType);
        }
 public MobileAppAuthenticationOptionsTests()
 {
     this.options = new AppServiceAuthenticationOptions();
     this.options.SigningKey = SigningKey;
 }
 private AppServiceAuthenticationOptions CreateTestOptions()
 {
     AppServiceAuthenticationOptions options = new AppServiceAuthenticationOptions
     {
         SigningKey = TestSigningKey,
     };
     return options;
 }
        private static AppServiceAuthenticationOptions CreateTestOptions(HttpConfiguration config)
        {
            AppServiceAuthenticationOptions options = new AppServiceAuthenticationOptions
            {
                ValidAudiences = new[] { TestWebsiteUrl },
                ValidIssuers = new[] { TestWebsiteUrl },
                SigningKey = SigningKeyAlpha,
                TokenHandler = config.GetAppServiceTokenHandler()
            };

            return options;
        }
 public new AuthenticationTicket Authenticate(IOwinRequest request, AppServiceAuthenticationOptions options)
 {
     return base.Authenticate(request, options);
 }
 private void ValidateLoginToken(string token, AppServiceAuthenticationOptions options)
 {
     // validate the token and get the claims principal
     ClaimsPrincipal claimsPrincipal = null;
     Assert.True(this.tokenHandler.TryValidateLoginToken(token, options.SigningKey, TestWebsiteUrls, TestWebsiteUrls, out claimsPrincipal));
 }