コード例 #1
0
        public IOAuthAuthorizerUI GetAuthorizer <TResourceProvider>(
            AuthenticationInterfaceEnum browserType,
            IOAuthCallbackHandler callbackHandler)
            where TResourceProvider : ResourceProvider
        {
#if __ANDROID__
            switch (browserType)
            {
            case AuthenticationInterfaceEnum.Dedicated:
                return(new BrowserAuthorizerUI(
                           new ProtocolOAuthCallbackListener(
                               callbackHandler),
                           Platform.Current));

            case AuthenticationInterfaceEnum.Embedded:
                return(new WebViewAuthorizerUI(callbackHandler));

            default:
                throw new NotSupportedException();
            }
#elif __IOS__
            switch (browserType)
            {
            case AuthenticationInterfaceEnum.Dedicated:
                return(new BrowserAuthorizerUI(
                           new ProtocolOAuthCallbackListener(
                               callbackHandler),
                           Platform.Current));

            case AuthenticationInterfaceEnum.Embedded:
                return(new UIWebViewAuthorizerUI(callbackHandler));

            default:
                throw new NotSupportedException();
            }
#elif WINDOWS_UWP
            switch (browserType)
            {
            case AuthenticationInterfaceEnum.Dedicated:
                return(new BrowserAuthorizerUI(
                           new ProtocolOAuthCallbackListener(
                               callbackHandler),
                           Platform.Current));

            case AuthenticationInterfaceEnum.Embedded:
                return(new WebViewAuthorizerUI(callbackHandler));

            default:
                throw new NotSupportedException();
            }
#elif __WINDOWS__
            return(new BrowserAuthorizerUI(
                       new HttpOAuthCallbackListener(
                           new HttpServer(),
                           callbackHandler),
                       Platform.Current));
#else
            throw new NotSupportedException();
#endif
        }
コード例 #2
0
 public HttpOAuthCallbackListener(
     HttpServer httpServer,
     IOAuthCallbackHandler handler)
 {
     _httpServer = httpServer;
     _handler    = handler;
 }
コード例 #3
0
        public IOAuthAuthenticationTemplate <OAuth2Credentials> BuildOAuth2Template <TResourceProvider>(
            IOAuthFacade <OAuth2Credentials> authentication,
            AuthenticationInterfaceEnum ui,
            string userId,
            string clientSecret,
            ResponseTypeEnum flow)
            where TResourceProvider : ResourceProvider
        {
            if (flow == ResponseTypeEnum.Code)
            {
                var callbackHandler = new OAuth2QueryCallbackHandler(
                    _strategy,
                    OAuth2ParameterEnum.State.EnumToString(),
                    userId);

                var authenticationUI = _oauthAuthorizerUIFactory
                                       .GetAuthorizer <TResourceProvider>(
                    ui,
                    callbackHandler);

                return(new OAuth2CodeAuthenticationTemplate(
                           authenticationUI,
                           authentication,
                           clientSecret));
            }
            else
            {
                IOAuthCallbackHandler callbackHandler = null;
                if (ui == AuthenticationInterfaceEnum.Dedicated)
                {
                    callbackHandler = new OAuth2QueryCallbackHandler(
                        _strategy,
                        OAuth2ParameterEnum.State.EnumToString(),
                        userId);
                }
                else
                {
                    callbackHandler = new OAuth2FragmentCallbackHandler(
                        _strategy,
                        OAuth2ParameterEnum.State.EnumToString(),
                        userId);
                }

                var authenticationUI = _oauthAuthorizerUIFactory
                                       .GetAuthorizer <TResourceProvider>(
                    ui,
                    callbackHandler);

                return(new OAuth2TokenAuthenticationTemplate(
                           authenticationUI,
                           authentication));
            }
        }
コード例 #4
0
 public ProtocolOAuthCallbackListener(IOAuthCallbackHandler handler)
 {
     _handler = handler;
 }
コード例 #5
0
 public UIWebViewAuthorizerUI(IOAuthCallbackHandler handler)
 {
     _handler = handler;
 }