Beispiel #1
0
 public OIDCAuthenticator(AuthenticationConfig authenticationConfig,
                          KeycloakConfig keycloakConfig,
                          ICredentialManager credentialManager,
                          IHttpServiceModule httpServiceModule,
                          ILogger logger) : base(authenticationConfig, keycloakConfig, credentialManager, httpServiceModule, logger)
 {
 }
        /// <summary>
        /// Initializes a new instance of the <see cref="T:AeroGear.Mobile.Auth.AbstractAuthService"/> class.
        /// </summary>
        /// <param name="mobileCore">Mobile core.</param>
        /// <param name="serviceConfig">Service config.</param>
        public AbstractAuthService(MobileCore mobileCore = null, ServiceConfiguration serviceConfig = null)
        {
            MobileCore = mobileCore ?? MobileCore.Instance;
            var serviceConfiguration = NonNull(serviceConfig ?? MobileCore.GetFirstServiceConfigurationByType(Type), "serviceConfig");

            KeycloakConfig = new KeycloakConfig(serviceConfiguration);
        }
Beispiel #3
0
 public async void addKeycloak(string unparsedConfig)
 {
     var            options  = JsonHelper.Deserialize <string[]>(unparsedConfig)[0];
     var            config   = JsonHelper.Deserialize <KeycloakConfig>(options);
     KeycloakConfig keycloak = KeycloakConfig.Create(config.clientId, config.host, config.realm);
     await AccountManager.AddKeyCloak(keycloak);
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="T:AeroGear.Mobile.Auth.Authenticator.AbstractAuthenticator"/> class.
 /// </summary>
 /// <param name="authenticationConfig">Authentication config.</param>
 /// <param name="keycloakConfig">Keycloak config.</param>
 /// <param name="credentialManager">Credential manager.</param>
 /// <param name="httpServiceModule">Http service module.</param>
 /// <param name="logger">Logger.</param>
 public AbstractAuthenticator(AuthenticationConfig authenticationConfig, KeycloakConfig keycloakConfig, ICredentialManager credentialManager, IHttpServiceModule httpServiceModule, ILogger logger)
 {
     this.authenticationConfig = NonNull(authenticationConfig, "authenticationConfig");
     this.keycloakConfig       = NonNull(keycloakConfig, "keycloakConfig");
     this.credentialManager    = NonNull(credentialManager, "credentialManager");
     this.httpService          = NonNull(httpServiceModule, "httpServiceModule");
     this.logger = NonNull(logger, "logger");
 }
        public void SetUp()
        {
            var assembly = Assembly.GetExecutingAssembly();

            using (var configStream = assembly.GetManifestResourceStream("AeroGear.Mobile.Auth.Tests.Resources.mobile-services.json"))
            {
                var serviceConfig = MobileCoreJsonParser.Parse(configStream);
                var authConfig    = serviceConfig["keycloak"];
                keycloakConfig = new KeycloakConfig(authConfig);
            }
        }
Beispiel #6
0
        public void SetUp()
        {
            var assembly = Assembly.GetExecutingAssembly();

            using (var configStream = assembly.GetManifestResourceStream("AeroGear.Mobile.Auth.Tests.Resources.mobile-services.json"))
            {
                var mobileCoreConfig = MobileCoreConfiguration.Parse(configStream);
                var authConfig       = mobileCoreConfig.GetFirstServiceConfigurationByType("keycloak");
                keycloakConfig = new KeycloakConfig(authConfig);
            }
        }
Beispiel #7
0
        public void SetUp()
        {
            authenticationConfig  = AuthenticationConfig.Builder.RedirectUri("test://example.com").Build();
            keycloakConfig        = new KeycloakConfig(kcConfig);
            credentialManagerMock = new CredentialManagerMock();
            IHttpResponse httpResponse        = (HttpResponseMock)HttpResponseMock.newResponse().withStatusCode(200);
            var           requestToBeExecuted = new HttpRequestToBeExecutedMock(Task.FromResult(httpResponse), null);
            IHttpRequest  httpRequestMock     = (HttpRequestMock)HttpRequestMock.newRequest().withGetResult(requestToBeExecuted);

            httpModuleMock      = (HttpServiceModuleMock)HttpServiceModuleMock.newMock().withNewRequest(httpRequestMock);
            authenticatorToTest = new OIDCAuthenticator(authenticationConfig, keycloakConfig, credentialManagerMock, httpModuleMock, logger);
        }
Beispiel #8
0
        /// <summary>
        /// Invoked when this page is about to be displayed in a Frame.
        /// </summary>
        /// <param name="e">Event data that describes how this page was reached.
        /// This parameter is typically used to configure the page.</param>
        protected async override void OnNavigatedTo(NavigationEventArgs e)
        {
            // TODO: Prepare page for display here.

            // TODO: If your application contains multiple pages, ensure that you are
            // handling the hardware Back button by registering for the
            // Windows.Phone.UI.Input.HardwareButtons.BackPressed event.
            // If you are using the NavigationHelper provided by some templates,
            // this event is handled for you.

            captureMgr = new MediaCapture();
            await captureMgr.InitializeAsync();

            capturePreview.Source = captureMgr;
            await captureMgr.StartPreviewAsync();

            IsPreviewing   = true;
            uploadLocation = new Dictionary <string, Uri>();

            DisplayInformation displayInfo = DisplayInformation.GetForCurrentView();

            displayInfo.OrientationChanged += DisplayInfo_OrientationChanged;
            DisplayInfo_OrientationChanged(displayInfo, null);

            var config = await GoogleConfig.Create(
                "517285908032-11moj33qbn01m7sem6g7gmfco2tp252v.apps.googleusercontent.com",
                new List <string>(new string[] { "https://www.googleapis.com/auth/drive" }),
                "google"
                );

            uploadLocation.Add("google", new Uri("https://www.googleapis.com/upload/drive/v2/files"));
            await AccountManager.AddAccount(config);

            var keyCloak = await KeycloakConfig.Create("shoot-third-party", "https://localhost:8443", "shoot-realm");

            uploadLocation.Add("shoot-third-party", new Uri("https://localhost:8443/shoot/rest/photos"));
            await AccountManager.AddKeyCloak(keyCloak);

            var facebook = FacebookConfig.Create("YYY", "XXX",
                                                 new List <string>(new string[] { "photo_upload, publish_actions" }), "facebook");

            uploadLocation.Add("facebook", new Uri("https://graph.facebook.com/me/photos"));
            await AccountManager.AddFacebook(facebook);
        }
        public void SetUp()
        {
            authenticationConfig = AuthenticationConfig.Builder.RedirectUri("test://example.com").Build();
            keycloakConfig       = new KeycloakConfig(kcConfig);

            credentialManagerMock = new Mock <ICredentialManager>();
            httpModuleMock        = new Mock <IHttpServiceModule>();

            var httpRequestMock     = new Mock <IHttpRequest>();
            var requestToBeExecuted = new Mock <IHttpRequestToBeExecuted>();
            var httpResponse        = new Mock <IHttpResponse>();

            httpResponse.Setup(response => response.StatusCode).Returns(200);
            requestToBeExecuted.Setup(arg => arg.Execute()).Returns(Task.FromResult(httpResponse.Object));
            httpRequestMock.Setup(request => request.Get(It.IsAny <string>())).Returns(requestToBeExecuted.Object);
            httpModuleMock.Setup(arg => arg.NewRequest()).Returns(httpRequestMock.Object);

            authenticatorToTest = new OIDCAuthenticator(authenticationConfig, keycloakConfig, credentialManagerMock.Object, httpModuleMock.Object, logger.Object);
        }