Example #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="X509SecuritySettings" /> class.
 /// </summary>
 /// <param name="clientCertificate">The client certificate for the communication with server.</param>
 /// <param name="remoteX509SecuritySettings">Security settings to verify remote X509 certificate.</param>
 public X509SecuritySettings(X509Certificate clientCertificate, RemoteX509SecuritySettings remoteX509SecuritySettings)
     : base(SecurityType.X509)
 {
     clientCertificate.ThrowIfNull(nameof(clientCertificate));
     remoteX509SecuritySettings.ThrowIfNull(nameof(remoteX509SecuritySettings));
     this.ClientCertificate          = clientCertificate;
     this.RemoteX509SecuritySettings = remoteX509SecuritySettings;
 }
Example #2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="ClaimsSecuritySettings" /> class.
        /// </summary>
        /// <param name="claimsToken">string representation of claims token acquired from STS (security token service).</param>
        /// <param name="remoteX509SecuritySettings">Security settings to verify remote X509 certificate.</param>
        public ClaimsSecuritySettings(string claimsToken, RemoteX509SecuritySettings remoteX509SecuritySettings) : base(SecurityType.Claims)
        {
            if (string.IsNullOrWhiteSpace(claimsToken))
            {
                throw new ArgumentException(SR.ErrorLocalClaims);
            }

            remoteX509SecuritySettings.ThrowIfNull(nameof(remoteX509SecuritySettings));
            this.ClaimsToken = claimsToken;
            this.RemoteX509SecuritySettings = remoteX509SecuritySettings;
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="X509SecuritySettings" /> class.
        /// </summary>
        /// <param name="clientCertificate">The client certificate for the communication with server.</param>
        /// <param name="remoteX509SecuritySettings">Security settings to verify remote X509 certificate.</param>
        public X509SecuritySettings(X509Certificate2 clientCertificate, RemoteX509SecuritySettings remoteX509SecuritySettings)
            : base(SecurityType.X509)
        {
            clientCertificate.ThrowIfNull(nameof(clientCertificate));
            remoteX509SecuritySettings.ThrowIfNull(nameof(remoteX509SecuritySettings));

            if (!clientCertificate.HasPrivateKey)
            {
                throw new InvalidOperationException(SR.ClientCertDoesntContainPrivateKey);
            }

            this.ClientCertificate          = clientCertificate;
            this.RemoteX509SecuritySettings = remoteX509SecuritySettings;
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="ClaimsSecuritySettings" /> class.
 /// </summary>
 /// <param name="remoteX509SecuritySettings">Security settings to verify remote X509 certificate.</param>
 internal ClaimsSecuritySettings(RemoteX509SecuritySettings remoteX509SecuritySettings)
     : base(SecurityType.Claims)
 {
     remoteX509SecuritySettings.ThrowIfNull(nameof(remoteX509SecuritySettings));
     this.RemoteX509SecuritySettings = remoteX509SecuritySettings;
 }