예제 #1
0
        public void ProviderInstallerCheck(Context context)
        {
            try
            {
                // Checking if the ProviderInstaller is installed and updated
                ProviderInstaller.InstallIfNeeded(context);
                Toast.MakeText(context, "Provider installed and updated!", ToastLength.Long).Show();
            }
            catch (GooglePlayServicesRepairableException e)
            {
                /* If the ProviderInstaller is installed but not updated
                 * A popup asks the user to do a manual update of the Google Play Services
                 */
#pragma warning disable CS0618 // Type or member is obsolete
                GooglePlayServicesUtil.ShowErrorNotification(e.ConnectionStatusCode, context);
#pragma warning restore CS0618 // Type or member is obsolete
                Toast.MakeText(context, "Provider it outdated. Please update your Google Play Service", ToastLength.Long).Show();
            }
            catch (GooglePlayServicesNotAvailableException e)
            {
                /* If the ProviderInstaller is not installed but not updated
                 * A popup redirects the user to the Google Play Services page on the Google PlayStore
                 * and let the user download them.
                 */
#pragma warning disable CS0618 // Type or member is obsolete
                Dialog dialog = GooglePlayServicesUtil.GetErrorDialog(e.ErrorCode, this, REQUEST_GOOGLE_PLAY_SERVICES_DOWNLOAD);
#pragma warning restore CS0618 // Type or member is obsolete

                dialog.SetCancelable(false);
                dialog.Show();
            }
        }
예제 #2
0
        public MainApplication(IntPtr handle, JniHandleOwnership transer)
            : base(handle, transer)
        {
            if (ServiceContainer.RegisteredServices.Count == 0)
            {
                RegisterLocalServices();
                var deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
                ServiceContainer.Init(deviceActionService.DeviceUserAgent, Constants.ClearCiphersCacheKey,
                                      Constants.AndroidAllClearCipherCacheKeys);

                // TODO: Update when https://github.com/bitwarden/mobile/pull/1662 gets merged
                var deleteAccountActionFlowExecutioner = new DeleteAccountActionFlowExecutioner(
                    ServiceContainer.Resolve <IApiService>("apiService"),
                    ServiceContainer.Resolve <IMessagingService>("messagingService"),
                    ServiceContainer.Resolve <IPlatformUtilsService>("platformUtilsService"),
                    ServiceContainer.Resolve <IDeviceActionService>("deviceActionService"));
                ServiceContainer.Register <IDeleteAccountActionFlowExecutioner>("deleteAccountActionFlowExecutioner", deleteAccountActionFlowExecutioner);

                var verificationActionsFlowHelper = new VerificationActionsFlowHelper(
                    ServiceContainer.Resolve <IKeyConnectorService>("keyConnectorService"),
                    ServiceContainer.Resolve <IPasswordRepromptService>("passwordRepromptService"),
                    ServiceContainer.Resolve <ICryptoService>("cryptoService"));
                ServiceContainer.Register <IVerificationActionsFlowHelper>("verificationActionsFlowHelper", verificationActionsFlowHelper);
            }
#if !FDROID
            if (Build.VERSION.SdkInt <= BuildVersionCodes.Kitkat)
            {
                ProviderInstaller.InstallIfNeededAsync(ApplicationContext, this);
            }
#endif
        }
예제 #3
0
 public virtual void Init()
 {
     if (_dctd == null) _dctd = ProviderInstaller.Install(this);
     _dctd.CategorySortOrder = CustomSortOrder.AscendingById;
     _dctd.PropertySortOrder = CustomSortOrder.AscendingById;
     UpdateEditorAttributes();
 }
예제 #4
0
        public override void OnCreate()
        {
            base.OnCreate();
            CrossCurrentActivity.Current.Init(this);

            if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
            {
                // Support TLS1.2 on Android versions before Lollipop
                ProviderInstaller.InstallIfNeeded(Application.Context);
            }
        }
예제 #5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
            {
                // Support TLS1.2 on Android versions before Lollipop
                ProviderInstaller.InstallIfNeeded(Application.Context);
            }

            var vm = new MainViewModel();

            Button button = FindViewById <Button>(Resource.Id.myButton);

            button.Click += async delegate {
                // The easiest way to pin a host is turn on pinning with a broken configuration and read the expected configuration when the connection fails.
                // Be sure to do this on a trusted network, and without man -in-the - middle tools like Charles or Fiddler.

                /*var hostname = "gorest.co.in";
                 *
                 * var certificatePinner = new Square.OkHttp3.CertificatePinner.Builder()
                 *  .Add(hostname, "sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=")
                 *  .Build();
                 *
                 * var client = new OkHttpClient.Builder()
                 *  .CertificatePinner(certificatePinner)
                 *  .Build();
                 *
                 * var request = new Request.Builder()
                 *  .Url("https://" + hostname)
                 *  .Build();
                 *
                 * var call = client.NewCall(request);
                 *
                 * var response = await call.ExecuteAsync();*/

                // As expected, this fails with a certificate pinning exception:

                /*Certificate pinning failure!
                 * Peer certificate chain:
                 *  sha256/CZEvkurQ3diX6pndH4Z5/dUNzK1Gm6+n8Hdx/DQgjO0=: CN=sni96286.cloudflaressl.com,OU=PositiveSSL Multi-Domain,OU=Domain Control Validated
                 *  sha256/x9SZw6TwIqfmvrLZ/kz1o0Ossjmn728BnBKpUFqGNVM=: CN=COMODO ECC Domain Validation Secure Server CA 2,O=COMODO CA Limited,L=Salford,ST=Greater Manchester,C=GB
                 *  sha256/58qRu/uxh4gFezqAcERupSkRYBlBAvfcw7mEjGPLnNU=: CN=COMODO ECC Certification Authority,O=COMODO CA Limited,L=Salford,ST=Greater Manchester,C=GB
                 * Pinned certificates for reqres.in:
                 *  sha256/AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=*/

                // Follow up by pasting the public key hashes from the exception into the NativeMessageHandler certificate pinner's configuration.

                await vm.Get();
            };
        }
        public SmartElementProperty(SmartElement element)
        {
            this.element             = element;
            m_dctd                   = ProviderInstaller.Install(this);
            m_dctd.PropertySortOrder = CustomSortOrder.AscendingById;
            TypeDescriptor.Refresh(this);
            Parameter[] parameters = element.parameters;

            for (int i = 0; i < parameters.Length; ++i)
            {
                CustomPropertyDescriptor property = m_dctd.GetProperty("pram" + (i + 1));
                Init(property, parameters[i]);
            }
        }
예제 #7
0
        public TestClass()
        {
            m_dctd = ProviderInstaller.Install(this);

            PropG = 1;
            PropH = 2;
            CreateOnTheFlyPropertyE( );
            CustomPropertyDescriptor cpd = m_dctd.GetProperty("PropI");

            PopululateDropDownListFromDatabaseSource(cpd);

            cpd = m_dctd.GetProperty("PropJ");
            PopululateDropDownListFromDatabaseSource(cpd);
        }
        public MainApplication(IntPtr handle, JniHandleOwnership transer)
            : base(handle, transer)
        {
            //AndroidEnvironment.UnhandledExceptionRaiser += AndroidEnvironment_UnhandledExceptionRaiser;

            if (!Resolver.IsSet)
            {
                SetIoc(this);
            }

            if (Build.VERSION.SdkInt <= BuildVersionCodes.Kitkat)
            {
                ProviderInstaller.InstallIfNeededAsync(ApplicationContext, this);
            }
        }
예제 #9
0
        public MainApplication(IntPtr handle, JniHandleOwnership transer)
            : base(handle, transer)
        {
            if (ServiceContainer.RegisteredServices.Count == 0)
            {
                RegisterLocalServices();
                var deviceActionService = ServiceContainer.Resolve <IDeviceActionService>("deviceActionService");
                ServiceContainer.Init(deviceActionService.DeviceUserAgent);
            }
#if !FDROID
            if (Build.VERSION.SdkInt <= BuildVersionCodes.Kitkat)
            {
                ProviderInstaller.InstallIfNeededAsync(ApplicationContext, this);
            }
#endif
        }
예제 #10
0
        public PropertyWrapper(object owner)
        {
            m_dctd  = ProviderInstaller.Install(this);
            m_owner = owner;
            CustomPropertyDescriptor cpd = m_dctd.GetProperty("SelectedProperty");

            foreach (PropertyDescriptor pd in TypeDescriptor.GetProperties(owner))
            {
                StandardValueAttribute sva = new StandardValueAttribute(pd);
                sva.DisplayName = pd.DisplayName;
                sva.Description = pd.Description;
                cpd.StatandardValues.Add(sva);
            }
            SelectedProperty         = (cpd.StatandardValues.ToArray( )[0].Value) as CustomPropertyDescriptor;
            m_dctd.CategorySortOrder = CustomSortOrder.None;
            m_dctd.PropertySortOrder = CustomSortOrder.None;

            this.PropertyFlags = m_cpd.PropertyFlags;
        }
예제 #11
0
        public MainApplication(IntPtr handle, JniHandleOwnership transer)
            : base(handle, transer)
        {
            if (ServiceContainer.RegisteredServices.Count == 0)
            {
                RegisterLocalServices();
                ServiceContainer.Init();
                if (App.Migration.MigrationHelpers.NeedsMigration())
                {
                    var task = App.Migration.MigrationHelpers.PerformMigrationAsync();
                    Task.Delay(2000).Wait();
                }
            }
#if !FDROID
            if (Build.VERSION.SdkInt <= BuildVersionCodes.Kitkat)
            {
                ProviderInstaller.InstallIfNeededAsync(ApplicationContext, this);
            }
#endif
        }
예제 #12
0
        protected override void OnCreate(Bundle bundle)
        {
            try
            {
                base.OnCreate(bundle);
                InputDialog.DisplayDialog += OnDisplayDialog;
                AndroidEnvironment.UnhandledExceptionRaiser += HandleUnhandledException;

                global::Xamarin.Forms.Forms.Init(this, bundle);

                context = ApplicationContext; // or activity.getApplicationContext()
                PackageManager packageManager = context.PackageManager;
                string         packageName    = context.PackageName;
                AppData.Version = new OnSiteVersion(string.Format("{0}", packageManager.GetPackageInfo(packageName, 0).VersionName));

                LoadApplication(new App());

                //AppContext.AppContext.ShowInput = () =>
                //{
                //    InputMethodManager showinput = (InputMethodManager)GetSystemService(InputMethodService);
                //    showinput.ToggleSoftInput(ShowFlags.Forced, 0);
                //};


                if (Build.VERSION.SdkInt <= BuildVersionCodes.Kitkat)
                {
                    ProviderInstaller.InstallIfNeeded(ApplicationContext);
                }
                SSLContext sslContext = SSLContext.GetInstance("TLSv1.2");
                sslContext.Init(null, null, null);
                SSLEngine engine = sslContext.CreateSSLEngine();
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }
 private void SetupCustomTypeDescriptor()
 {
     Descriptor = ProviderInstaller.Install(this);
 }
        public NativeMessageHandler(bool throwOnCaptiveNetwork, TLSConfig tLSConfig, NativeCookieHandler cookieHandler = null, IWebProxy proxy = null)
        {
            this.throwOnCaptiveNetwork = throwOnCaptiveNetwork;

            var clientBuilder = client.NewBuilder();

            this.TLSConfig = tLSConfig;

            var tlsSpecBuilder = new ConnectionSpec.Builder(ConnectionSpec.ModernTls).TlsVersions(new[] { TlsVersion.Tls12, TlsVersion.Tls13 });
            var tlsSpec        = tlsSpecBuilder.Build();

            var specs = new List <ConnectionSpec>()
            {
                tlsSpec
            };

            if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop || NetworkSecurityPolicy.Instance.IsCleartextTrafficPermitted)
            {
                specs.Add(ConnectionSpec.Cleartext);
            }

            clientBuilder.ConnectionSpecs(specs);
            clientBuilder.Protocols(new[] { Protocol.Http11 }); // Required to avoid stream was reset: PROTOCOL_ERROR

            // Add Certificate Pins
            if (!TLSConfig.DangerousAcceptAnyServerCertificateValidator &&
                TLSConfig.Pins != null &&
                TLSConfig.Pins.Count > 0 &&
                TLSConfig.Pins.FirstOrDefault(p => p.PublicKeys.Count() > 0) != null)
            {
                this.PinningMode = "PublicKeysOnly";

                this.CertificatePinner = new CertificatePinner();

                foreach (var pin in TLSConfig.Pins)
                {
                    this.CertificatePinner.AddPins(pin.Hostname, pin.PublicKeys);
                }

                clientBuilder.CertificatePinner(CertificatePinner.Build());
            }

            // Set client credentials
            SetClientCertificate(TLSConfig.ClientCertificate);

            if (cookieHandler != null)
            {
                clientBuilder.CookieJar(cookieHandler);
            }

            // Adding proxy support
            if (proxy != null && proxy is WebProxy)
            {
                var webProxy = proxy as WebProxy;

                var type    = Java.Net.Proxy.Type.Http;
                var address = new InetSocketAddress(webProxy.Address.Host, webProxy.Address.Port);
                var jProxy  = new Proxy(type, address);
                clientBuilder.Proxy(jProxy);

                if (webProxy.Credentials != null)
                {
                    var credentials = (NetworkCredential)webProxy.Credentials;
                    clientBuilder.ProxyAuthenticator(new ProxyAuthenticator(credentials.UserName, credentials.Password));
                }
            }

            var sslContext = SSLContext.GetInstance("TLS");

            // Support self-signed certificates
            if (TLSConfig.DangerousAcceptAnyServerCertificateValidator)
            {
                // Install the all-trusting trust manager
                var trustManager = new CustomX509TrustManager();
                sslContext.Init(KeyManagers, new ITrustManager[] { trustManager }, new SecureRandom());
                // Create an ssl socket factory with our all-trusting manager
                var sslSocketFactory = sslContext.SocketFactory;
                clientBuilder.SslSocketFactory(sslSocketFactory, trustManager);
            }
            else
            {
                // Set SslSocketFactory
                if (Build.VERSION.SdkInt < BuildVersionCodes.Lollipop)
                {
                    // Support TLS1.2 on Android versions before Lollipop
                    ProviderInstaller.InstallIfNeeded(Application.Context); // To enable TLS
                    clientBuilder.SslSocketFactory(new TlsSslSocketFactory(), TlsSslSocketFactory.GetSystemDefaultTrustManager());
                }
                else
                {
                    sslContext.Init(KeyManagers, null, null);
                    clientBuilder.SslSocketFactory(sslContext.SocketFactory, TlsSslSocketFactory.GetSystemDefaultTrustManager());
                }
            }

            clientBuilder.HostnameVerifier(new HostnameVerifier(this));
            client = clientBuilder.Build();
        }
예제 #15
0
 internal void InstallTypeDescriptor()
 {
     _dctd = ProviderInstaller.Install(this);
     _dctd.PropertySortOrder = CustomSortOrder.AscendingById;
 }
예제 #16
0
 public FacerLayer()
 {
     _dctd = ProviderInstaller.Install(this);
     _dctd.PropertySortOrder = CustomSortOrder.DescendingById;
     _dctd.CategorySortOrder = CustomSortOrder.DescendingById;
 }
예제 #17
0
 public override void InstallBindings()
 {
     ProviderInstaller.Install(Container);
 }