示例#1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:AeroGear.Mobile.Auth.AuthService"/> class.
 /// </summary>
 /// <param name="mobileCore">Mobile core.</param>
 /// <param name="serviceConfig">Service configuration.</param>
 public AuthService(MobileCore mobileCore = null, ServiceConfiguration serviceConfig = null) : base(mobileCore, serviceConfig)
 {
     Core.Logger.Info("AuthService construct start");
     Core.Logger.Info("AuthService construct storage");
     CredentialManager = new CredentialManager(ServiceFinder.Resolve <IPlatformBridge>().GetUserPreferences("AeroGear.Mobile.Auth.Credentials"));
     Core.Logger.Info("AuthService construct credential manager");
 }
        public async Task TestCallHttpLayerAsync()
        {
            MobileCore.Init(new TestInjector(Assembly.GetExecutingAssembly()));
            var httpLayer = MobileCore.Instance.HttpLayer;

            Assert.IsNotNull(httpLayer, "Mobile Core must return the HTTP layer");
            var request = httpLayer.NewRequest();

            Assert.IsNotNull(request, "NewRequest() must create a request");
            UriBuilder uriBuilder = new UriBuilder(localUrl);

            uriBuilder.Path = GET_TEST_PATH;

            var response = await request.Get(uriBuilder.Uri.ToString()).Execute();

            Assert.NotNull(response);
            Assert.Null(response.Error);
            Assert.IsTrue(response.Successful);
            Assert.AreEqual(200, response.StatusCode);
            Assert.AreEqual(GET_TEST_BODY, response.Body);
            var jsonObject = JsonObject.Parse(response.Body);

            Assert.AreEqual(HELLO_WORLD, (string)jsonObject["text"]);
            MobileCore.Instance.Destroy();
        }
示例#3
0
        public void Configure(MobileCore core, ServiceConfiguration config)
        {
            this.identifier = config.Id;
            string metricsUrl = config.Url;

            this.publisher = new NetworkMetricsPublisher(metricsUrl);
        }
        /// <summary>
        /// Initializes Mobile core for Android.
        /// </summary>
        /// <param name="app">Xamarin.Forms.Application object</param>
        /// <param name="options">additional initialization options</param>
        public static void Init(Application app, Options options)
        {
            IPlatformInjector platformInjector = DependencyService.Get <IPlatformInjector>();

            platformInjector.ExecutingAssembly = app.GetType().Assembly;
            MobileCore.Init(platformInjector, options);
        }
        /// <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);
        }
 public void TestCoreInitAndDestroy()
 {
     Assert.Catch <InitializationException>(() => MobileCore.Instance.GetType(), "check uninitialized exception before init");
     MobileCore.Init(new TestInjector(Assembly.GetExecutingAssembly()));
     Assert.NotNull(MobileCore.Instance, "check core initialized successfuly");
     MobileCore.Instance.Destroy();
     Assert.Catch <InitializationException>(() => MobileCore.Instance.GetType(), "check uninitialized exception after destroy");
 }
示例#7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="T:AeroGear.Mobile.Auth.AuthService"/> class.
        /// </summary>
        /// <param name="mobileCore">Mobile core.</param>
        /// <param name="serviceConfig">Service configuration.</param>
        public AuthService(MobileCore mobileCore = null, ServiceConfiguration serviceConfig = null) : base(mobileCore, serviceConfig)
        {
            mobileCore.Logger.Info("AuthService construct start");
            var storageManager = new StorageManager("AeroGear.Mobile.Auth.Credentials", Android.App.Application.Context);

            mobileCore.Logger.Info("AuthService construct storage");
            CredentialManager = new CredentialManager(storageManager);
            mobileCore.Logger.Info("AuthService construct credential manager");
        }
        public void TestRegisterService()
        {
            var testInstance = new TestService();

            MobileCore.Init(new TestInjector(Assembly.GetExecutingAssembly()));
            MobileCore.Instance.RegisterService <ITestService>(testInstance);

            var registeredInstance = MobileCore.Instance.GetService <ITestService>();

            Assert.NotNull(registeredInstance);
            Assert.AreSame(testInstance, registeredInstance);
        }
        public SecurityCheckPage()
        {
            MobileCore core = MobileCore.Instance;

            if (core.GetFirstServiceConfigurationByType("metrics") != null)
            {
                this.metricsService = core.GetService <MetricsService>();
            }

            InitializeComponent();
            BindingContext = this;

            ReportCheckResults(DependencyService.Get <ISecurityCheckProvider>().SecurityChecks);
        }
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            global::Xamarin.Forms.Forms.Init();
            var        xamApp      = new App();
            MobileCore core        = MobileCoreIOS.Init(xamApp.GetType().Assembly);
            var        authService = AuthService.InitializeService();
            var        authConfig  = AuthenticationConfig.Builder.RedirectUri("org.aerogear.mobile.example:/callback").Build();

            authService.Configure(authConfig);
            LoadApplication(xamApp);
            CachedImageRenderer.Init();
            ImageCircleRenderer.Init();
            return(base.FinishedLaunching(app, options));
        }
示例#11
0
 public void Setup()
 {
     MobileCore.Application = CrossCurrentActivity.Current.Activity.Application;
     MobileCore.LogLevel    = LoggingMode.Debug;
     try
     {
         Analytics.RegisterExtension();
         Adobe.Experience.Android.Identity.Identity.RegisterExtension();
         MobileCore.Start(new AdobeCallback());
     }
     catch (InvalidInitException ex)
     {
         Log.Debug("ADOBE_INIT_FAILURE", ex.Message);
     }
 }
        public void TestServiceConfigCasingType()
        {
            MobileCore.Init(new TestInjector(Assembly.GetExecutingAssembly()));
            var serviceConfigByType = MobileCore.Instance.GetServiceConfigurationsByType("dummy");

            MobileCore.Instance.RegisterService <IDummyModule>(new DummyTypeCasingModule(serviceConfigByType[1]));

            var module = MobileCore.Instance.GetService <IDummyModule>();

            Assert.IsNotNull(module);
            Assert.AreEqual("Hello world, from anotherdummy!", module.Data1);
            Assert.AreEqual(420, module.Data2);
            Assert.IsFalse(module.Data3);

            MobileCore.Instance.Destroy();
        }
        public void TestFirstServiceConfigByType()
        {
            MobileCore.Init(new TestInjector(Assembly.GetExecutingAssembly()));
            var serviceConfig = MobileCore.Instance.GetFirstServiceConfigurationByType("dummy");

            MobileCore.Instance.RegisterService <IDummyModule>(new DummyModule(serviceConfig));

            var module = MobileCore.Instance.GetService <IDummyModule>();

            Assert.IsNotNull(module);
            Assert.AreEqual("dummy", module.Type);
            Assert.AreEqual("Hello world!", module.Data1);
            Assert.AreEqual(42, module.Data2);
            Assert.IsTrue(module.Data3);

            MobileCore.Instance.Destroy();
        }
 public void Configure(MobileCore core, ServiceConfiguration config)
 {
     throw new NotImplementedException();
 }
示例#15
0
        public AuthService(MobileCore mobileCore = null, ServiceConfiguration serviceConfig = null) : base(mobileCore, serviceConfig)
        {
            var storageManager = new StorageManager("AeroGear.Mobile.Auth.Credentials");

            CredentialManager = new CredentialManager(storageManager);
        }
 public void Configure(MobileCore core, ServiceConfiguration serviceConfiguration)
 {
 }
示例#17
0
 public void TrackEvent(string eventName, Dictionary <string, string> data)
 {
     MobileCore.TrackAction(eventName, data);
 }
示例#18
0
 protected override void OnStart()
 {
     MobileCore core = new MobileCore();
 }
示例#19
0
 public static ISecurityService InitializeService(MobileCore core = null, ServiceConfiguration config = null)
 {
     return((core ?? MobileCore.Instance).RegisterService <ISecurityService>(new SecurityService()));
 }
示例#20
0
 public void Configure(MobileCore core, ServiceConfiguration serviceConfiguration)
 {
     Data1 = serviceConfiguration["data1"];
     Data2 = int.Parse(serviceConfiguration["data2"]);
     Data3 = bool.Parse(serviceConfiguration["data3"]);
 }
示例#21
0
 public void SetUp()
 {
     MobileCore.Init(new TestInjector(Assembly.GetExecutingAssembly()));
 }
示例#22
0
 public void Call(Java.Lang.Object p0)
 {
     MobileCore.ConfigureWithAppID(AppConfigurations.AdobeAppId);
 }
示例#23
0
 /// <summary>
 /// Initializes the service and pass the configuration to be used to configure it
 /// </summary>
 /// <returns>The initialized service.</returns>
 /// <param name="core">The Mobile core instance. If <code>null</code> then <code>MobileCore.Instance</code> is used.</param>
 /// <param name="config">The service configuration. If <code>null</code> then <code>MobileCore.GetServiceConfiguration(Type)</code> is used.</param>
 public static IAuthService InitializeService(MobileCore core = null, ServiceConfiguration config = null)
 {
     return((core ?? MobileCore.Instance).RegisterService <IAuthService>(new AuthService(core, config)));
 }
示例#24
0
 public void TrackEvent(string eventName)
 {
     MobileCore.TrackAction(eventName, null);
 }
 public void Configure(MobileCore core, ServiceConfiguration serviceConfiguration)
 {
     this.serviceConfiguration = serviceConfiguration;
 }
示例#26
0
 public void TrackState(string screenName, Dictionary <string, string> additionalContextData)
 {
     MobileCore.TrackState(screenName, additionalContextData);
 }
 public AuthService(MobileCore mobileCore = null, ServiceConfiguration serviceConfig = null) : base(mobileCore, serviceConfig)
 {
     CredentialManager = new CredentialManager(ServiceFinder.Resolve <IPlatformBridge>().GetUserPreferences("AeroGear.Mobile.Auth.Credentials"));
 }