示例#1
0
 public static void Setup(TestContext context)
 {
     _stsTokenService = new StsTokenServiceCache(new StsTokenServiceConfiguration
     {
         ClientCertificate      = CertificateUtil.GetCertificate("0E6DBCC6EFAAFF72E3F3D824E536381B26DEECF5"),
         StsCertificate         = CertificateUtil.GetCertificate("d9f10c97aa647727adb64a349bb037c5c23c9a7a"),
         SendTimeout            = TimeSpan.FromDays(1),
         StsEndpointAddress     = "https://SecureTokenService.test-nemlog-in.dk/SecurityTokenService.svc",
         TokenLifeTimeInMinutes = 5,
         WspEndpointId          = "https://wsp.oioidws-net.dk"
     });
 }
        public static void Setup(TestContext context)
        {
            _stsTokenService = new StsTokenServiceCache(TokenServiceConfigurationFactory.CreateConfiguration());

            // Check certificates
            if (!CertMaker.rootCertIsTrusted())
            {
                CertMaker.trustRootCert();
            }

            // Start proxy server (to simulate man in the middle attacks)
            FiddlerApplication.Startup(
                8877, /* Port */
                true, /* Register as System Proxy */
                true, /* Decrypt SSL */
                false /* Allow Remote */
                );

            // Start WSP
            _process = Process.Start(@"..\..\..\..\Examples\Digst.OioIdws.WspExample\bin\Debug\Digst.OioIdws.WspExample.exe");
        }
示例#3
0
        /// <summary>
        /// Used in the signature case scenario
        /// </summary>
        public OioIdwsClient(OioIdwsClientSettings settings)
        {
            Settings = settings;
            if (settings == null)
            {
                throw new ArgumentNullException(nameof(settings));
            }

            if (settings.ClientCertificate == null)
            {
                throw new ArgumentNullException(nameof(settings.ClientCertificate));
            }

            if (!settings.ClientCertificate.HasPrivateKey)
            {
                throw new ArgumentException("You must have access to the private key of the ClientCertificate", nameof(settings.ClientCertificate));
            }

            if (settings.SecurityTokenService == null)
            {
                throw new ArgumentNullException(nameof(settings.SecurityTokenService));
            }

            if (settings.SecurityTokenService.Certificate == null)
            {
                throw new ArgumentNullException(nameof(settings.SecurityTokenService.Certificate), "Certificate for the SecurityTokenService must be set");
            }

            var tokenServiceConfiguration = new StsTokenServiceConfiguration
            {
                ClientCertificate      = Settings.ClientCertificate,
                StsCertificate         = Settings.SecurityTokenService.Certificate,
                StsEndpointAddress     = Settings.SecurityTokenService.EndpointAddress.ToString(),
                TokenLifeTimeInMinutes = (int?)Settings.SecurityTokenService.TokenLifeTime.GetValueOrDefault().TotalMinutes,
                SendTimeout            = Settings.SecurityTokenService.SendTimeout,
                WspEndpointId          = Settings.AudienceUri.ToString()
            };

            if (settings.SecurityTokenService.CacheClockSkew.HasValue)
            {
                tokenServiceConfiguration.CacheClockSkew = settings.SecurityTokenService.CacheClockSkew.Value;
            }

            if (settings.SecurityTokenService.UseTokenCache)
            {
                _stsTokenService = new StsTokenServiceCache(tokenServiceConfiguration);
            }
            else
            {
                _stsTokenService = new StsTokenService(tokenServiceConfiguration);
            }

            if (settings.UseTokenCache)
            {
                _accessTokenService = new AccessTokenServiceCache(this);
            }
            else
            {
                _accessTokenService = new AccessTokenService(Settings);
            }
        }
示例#4
0
 public StsTokenServiceCache(StsTokenServiceConfiguration config)
 {
     _stsTokenService = new StsTokenService(config);
     _cacheClockSkew  = config.CacheClockSkew;
     _wspEndpointId   = config.WspEndpointId;
 }