public SsoAdminClient( Uri ssoSdkUri, Uri stsUri, X509CertificateValidator serverCertificateValidator) { var ssoUri = ssoSdkUri.ToString(); _hostName = ssoSdkUri.Host; _certificateVAlidator = serverCertificateValidator; _ssoAdminClient = new SsoPortTypeClient(GetBinding(), new EndpointAddress(new Uri(ssoUri))); _ssoAdminClient.ChannelFactory.Endpoint.EndpointBehaviors.Add(new WsTrustBehavior()); var serverAuthentication = GetServerAuthentication(serverCertificateValidator); if (serverAuthentication != null) { _ssoAdminClient .ChannelFactory .Credentials .ServiceCertificate .SslCertificateAuthentication = serverAuthentication; } // Create STS Client for authorized operations _stsClient = new STSClient(stsUri, serverCertificateValidator); }
public SsoAdminClient(string hostname, string user, SecureString password, X509CertificateValidator serverCertificateValidator) { if (hostname == null) { throw new ArgumentNullException(nameof(hostname)); } if (user == null) { throw new ArgumentNullException(nameof(user)); } if (password == null) { throw new ArgumentNullException(nameof(password)); } var lsClient = new LookupServiceClient(hostname, serverCertificateValidator); // Create STS Client var stsUri = lsClient.GetStsEndpointUri(); _securityContext = new UserPassSecurityContext(user, password, stsUri, serverCertificateValidator); // Initialize security context with Saml token by username and password _securityContext.GetToken(); // Create SSO Admin Binding Client var ssoAdminUri = lsClient.GetSsoAdminEndpointUri(); ServiceUri = ssoAdminUri; User = user; _ssoAdminBindingClient = new SsoPortTypeClient(GetBinding(), new EndpointAddress(ssoAdminUri)); _ssoAdminBindingClient.ChannelFactory.Endpoint.EndpointBehaviors.Add(new WsTrustBehavior()); var serverAuthentication = GetServerAuthentication(serverCertificateValidator); if (serverAuthentication != null) { _ssoAdminBindingClient .ChannelFactory .Credentials .ServiceCertificate .SslCertificateAuthentication = serverAuthentication; } }