Пример #1
0
 /// <summary>
 /// Creates a new feed manager.
 /// </summary>
 /// <param name="config">User settings controlling network behaviour, solving, etc.</param>
 /// <param name="feedCache">The disk-based cache to store downloaded <see cref="Feed"/>s.</param>
 /// <param name="trustManager">Methods for verifying signatures and user trust.</param>
 /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param>
 public FeedManager(Config config, IFeedCache feedCache, ITrustManager trustManager, ITaskHandler handler)
 {
     _config       = config ?? throw new ArgumentNullException(nameof(config));
     _feedCache    = feedCache ?? throw new ArgumentNullException(nameof(feedCache));
     _trustManager = trustManager ?? throw new ArgumentNullException(nameof(trustManager));
     _handler      = handler ?? throw new ArgumentNullException(nameof(handler));
 }
Пример #2
0
        /// <summary>
        /// Creates a new feed manager.
        /// </summary>
        /// <param name="config">User settings controlling network behaviour, solving, etc.</param>
        /// <param name="feedCache">The disk-based cache to store downloaded <see cref="Feed"/>s.</param>
        /// <param name="trustManager">Methods for verifying signatures and user trust.</param>
        /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param>
        public FeedManager([NotNull] Config config, [NotNull] IFeedCache feedCache, [NotNull] ITrustManager trustManager, [NotNull] ITaskHandler handler)
        {
            #region Sanity checks
            if (config == null)
            {
                throw new ArgumentNullException(nameof(config));
            }
            if (feedCache == null)
            {
                throw new ArgumentNullException(nameof(feedCache));
            }
            if (trustManager == null)
            {
                throw new ArgumentNullException(nameof(trustManager));
            }
            if (handler == null)
            {
                throw new ArgumentNullException(nameof(handler));
            }
            #endregion

            _config       = config;
            _feedCache    = feedCache;
            _trustManager = trustManager;
            _handler      = handler;
        }
Пример #3
0
        /// <summary>
        /// Creates a new catalog manager.
        /// </summary>
        /// <param name="trustManager">Methods for verifying signatures and user trust.</param>
        /// <param name="handler">A callback object used when the the user needs to be informed about progress.</param>
        public CatalogManager([NotNull] ITrustManager trustManager, [NotNull] ITaskHandler handler)
        {
            #region Sanity checks
            if (trustManager == null) throw new ArgumentNullException("trustManager");
            #endregion

            _trustManager = trustManager;
            _handler = handler;
        }
Пример #4
0
        /// <summary>
        /// Creates a new catalog manager.
        /// </summary>
        /// <param name="trustManager">Methods for verifying signatures and user trust.</param>
        public CatalogManager([NotNull] ITrustManager trustManager)
        {
            #region Sanity checks
            if (trustManager == null)
            {
                throw new ArgumentNullException("trustManager");
            }
            #endregion

            _trustManager = trustManager;
        }
Пример #5
0
        /// <summary>
        /// Creates a new catalog manager.
        /// </summary>
        /// <param name="trustManager">Methods for verifying signatures and user trust.</param>
        /// <param name="handler">A callback object used when the the user needs to be informed about progress.</param>
        public CatalogManager([NotNull] ITrustManager trustManager, [NotNull] ITaskHandler handler)
        {
            #region Sanity checks
            if (trustManager == null)
            {
                throw new ArgumentNullException(nameof(trustManager));
            }
            #endregion

            _trustManager = trustManager;
            _handler      = handler;
        }
Пример #6
0
        public CallTrackerTask(string IpAddress, string deviceId)
        {
            _ipAddress = "https://" + IpAddress;
            _deviceId  = deviceId;

            client.RetryOnConnectionFailure = true;
            SSLContext sslContext = SSLContext.GetInstance("SSL");

            ITrustManager[] trustAllCerfs = new ITrustManager[] { new X509TrustManager() };
            sslContext.Init(null, trustAllCerfs, new Java.Security.SecureRandom());
            client.SetSslSocketFactory(sslContext.SocketFactory);
            client.SetHostnameVerifier(new HostNameVerifier());
        }
Пример #7
0
        /// <summary>
        /// Creates a new feed manager.
        /// </summary>
        /// <param name="config">User settings controlling network behaviour, solving, etc.</param>
        /// <param name="feedCache">The disk-based cache to store downloaded <see cref="Feed"/>s.</param>
        /// <param name="trustManager">Methods for verifying signatures and user trust.</param>
        /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param>
        public FeedManager([NotNull] Config config, [NotNull] IFeedCache feedCache, [NotNull] ITrustManager trustManager, [NotNull] ITaskHandler handler)
        {
            #region Sanity checks
            if (config == null) throw new ArgumentNullException("config");
            if (feedCache == null) throw new ArgumentNullException("feedCache");
            if (trustManager == null) throw new ArgumentNullException("trustManager");
            if (handler == null) throw new ArgumentNullException("handler");
            #endregion

            _config = config;
            _feedCache = feedCache;
            _trustManager = trustManager;
            _handler = handler;
        }
Пример #8
0
    /// <summary>
    /// Creates a new feed manager.
    /// </summary>
    /// <param name="config">User settings controlling network behaviour, solving, etc.</param>
    /// <param name="feedCache">The disk-based cache to store downloaded <see cref="Feed"/>s.</param>
    /// <param name="trustManager">Methods for verifying signatures and user trust.</param>
    /// <param name="handler">A callback object used when the the user needs to be asked questions or informed about download and IO tasks.</param>
    public FeedManager(Config config, IFeedCache feedCache, ITrustManager trustManager, ITaskHandler handler)
    {
        _config       = config ?? throw new ArgumentNullException(nameof(config));
        _feedCache    = feedCache ?? throw new ArgumentNullException(nameof(feedCache));
        _trustManager = trustManager ?? throw new ArgumentNullException(nameof(trustManager));
        _handler      = handler ?? throw new ArgumentNullException(nameof(handler));

        _feeds = new(feedUri =>
        {
            var feed = GetFeed(feedUri);
            feed.Normalize(feedUri);
            return(feed);
        });
    }
        private OkHttpClient GetUnsafeOkHttpClient()
        {
            ITrustManager[] trustAllCerts = new ITrustManager[] { new X509TrustManager() };
            SSLContext      sslContext    = SSLContext.GetInstance("SSL");

            sslContext.Init(null, trustAllCerts, null);
            SSLSocketFactory sslSocketFactory = sslContext.SocketFactory;
            OkHttpClient     okHttpClient     = new OkHttpClient();

            okHttpClient.SetSslSocketFactory(sslSocketFactory);
            okHttpClient.SetHostnameVerifier(new UnsafeHostnameVerifier());

            return(okHttpClient);
        }
Пример #10
0
        private void SetHandler()
        {
            var algoritm            = TrustManagerFactory.DefaultAlgorithm;
            var trustManagerFactory = TrustManagerFactory.GetInstance(algoritm);

            trustManagerFactory.Init((KeyStore)null);

            var        tm         = new ITrustManager[] { new PublicKeyManager() };
            SSLContext sslContext = SSLContext.GetInstance("TLS");

            sslContext.Init(null, tm, null);
            SSLContext.Default = sslContext;

            HttpsURLConnection.DefaultSSLSocketFactory = sslContext.SocketFactory;
        }
Пример #11
0
 private void AllowAllHosts()
 {
     // Setting TrustAll trust manager and AllowAllHostNameVerifier
     ITrustManager[] trustAllCerts = new ITrustManager[] { new AllowAllTrustManager() };
     try
     {
         SSLContext sc = SSLContext.GetInstance("SSL");
         sc.Init(null, trustAllCerts, new Java.Security.SecureRandom());
         HttpsURLConnection.DefaultSSLSocketFactory = sc.SocketFactory;
         HttpsURLConnection.DefaultHostnameVerifier = new AllowAllHostNameVerifier();
     }
     catch (Exception e)
     {
         Log.Error(TAG, "Exception during setting TrustAll key manager", e);
     }
 }
Пример #12
0
 /// <summary>
 /// Creates a new catalog manager.
 /// </summary>
 /// <param name="trustManager">Methods for verifying signatures and user trust.</param>
 /// <param name="handler">A callback object used when the the user needs to be informed about progress.</param>
 public CatalogManager(ITrustManager trustManager, ITaskHandler handler)
 {
     _trustManager = trustManager ?? throw new ArgumentNullException(nameof(trustManager));
     _handler      = handler ?? throw new ArgumentNullException(nameof(handler));
 }
Пример #13
0
 public TrustManagerTest()
 {
     _feedCacheMock = CreateMock <IFeedCache>();
     _openPgpMock   = CreateMock <IOpenPgp>();
     _trustManager  = new TrustManager(_config, _openPgpMock.Object, _trustDB, _feedCacheMock.Object, _handler);
 }
 public ImprovedSSLSocketFactory(SSLSocketFactory factory, ITrustManager trustManager)
 {
     _factory      = factory;
     _trustManager = trustManager;
 }