public void IssuedToken() { ClientCredentials c = new ClientCredentials(); IssuedTokenClientCredential iss = c.IssuedToken; Assert.IsNotNull(iss, "#1"); Assert.AreEqual(true, iss.CacheIssuedTokens, "#2"); Assert.AreEqual(SecurityKeyEntropyMode.CombinedEntropy, iss.DefaultKeyEntropyMode, "#3"); Assert.AreEqual(60, iss.IssuedTokenRenewalThresholdPercentage, "#4"); Assert.AreEqual(0, iss.IssuerChannelBehaviors.Count, "#5"); Assert.IsNull(iss.LocalIssuerAddress, "#6"); Assert.IsNull(iss.LocalIssuerBinding, "#7"); Assert.AreEqual(0, iss.LocalIssuerChannelBehaviors.Count, "#8"); Assert.AreEqual(TimeSpan.MaxValue, iss.MaxIssuedTokenCachingTime, "#9"); }
protected ClientCredentials(ClientCredentials other) { if (other == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("other"); } if (other.userName != null) { this.userName = new UserNamePasswordClientCredential(other.userName); } if (other.clientCertificate != null) { this.clientCertificate = new X509CertificateInitiatorClientCredential(other.clientCertificate); } if (other.serviceCertificate != null) { this.serviceCertificate = new X509CertificateRecipientClientCredential(other.serviceCertificate); } if (other.windows != null) { this.windows = new WindowsClientCredential(other.windows); } if (other.httpDigest != null) { this.httpDigest = new HttpDigestClientCredential(other.httpDigest); } if (other.issuedToken != null) { this.issuedToken = new IssuedTokenClientCredential(other.issuedToken); } if (other.peer != null) { this.peer = new PeerCredential(other.peer); } this.getInfoCardTokenCallback = other.getInfoCardTokenCallback; this.supportInteractive = other.supportInteractive; this.securityTokenHandlerCollectionManager = other.securityTokenHandlerCollectionManager; this.useIdentityConfiguration = other.useIdentityConfiguration; this.isReadOnly = other.isReadOnly; }
internal void ApplyConfiguration(IssuedTokenClientCredential issuedToken) { if (issuedToken == null) { throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("issuedToken"); } issuedToken.CacheIssuedTokens = this.CacheIssuedTokens; issuedToken.DefaultKeyEntropyMode = this.DefaultKeyEntropyMode; issuedToken.MaxIssuedTokenCachingTime = this.MaxIssuedTokenCachingTime; issuedToken.IssuedTokenRenewalThresholdPercentage = this.IssuedTokenRenewalThresholdPercentage; if (PropertyValueOrigin.Default != this.ElementInformation.Properties[ConfigurationStrings.LocalIssuer].ValueOrigin) { this.LocalIssuer.Validate(); issuedToken.LocalIssuerAddress = ConfigLoader.LoadEndpointAddress(this.LocalIssuer); if (!string.IsNullOrEmpty(this.LocalIssuer.Binding)) { issuedToken.LocalIssuerBinding = ConfigLoader.LookupBinding(this.LocalIssuer.Binding, this.LocalIssuer.BindingConfiguration, this.EvaluationContext); } } if (!string.IsNullOrEmpty(this.LocalIssuerChannelBehaviors)) { ConfigLoader.LoadChannelBehaviors(this.LocalIssuerChannelBehaviors, this.EvaluationContext, issuedToken.LocalIssuerChannelBehaviors); } if (PropertyValueOrigin.Default != this.ElementInformation.Properties[ConfigurationStrings.IssuerChannelBehaviors].ValueOrigin) { foreach (IssuedTokenClientBehaviorsElement issuerBehaviorElement in this.IssuerChannelBehaviors) { if (!string.IsNullOrEmpty(issuerBehaviorElement.BehaviorConfiguration)) { KeyedByTypeCollection <IEndpointBehavior> issuerBehaviors = new KeyedByTypeCollection <IEndpointBehavior>(); ConfigLoader.LoadChannelBehaviors(issuerBehaviorElement.BehaviorConfiguration, this.EvaluationContext, issuerBehaviors); issuedToken.IssuerChannelBehaviors.Add(new Uri(issuerBehaviorElement.IssuerAddress), issuerBehaviors); } } } }
private void Run() { //<snippet31> //<snippet30> WSHttpBinding b = new WSHttpBinding(); EndpointAddress ea = new EndpointAddress("http://localhost/Calculator"); CalculatorClient client = new CalculatorClient(b, ea); //<snippet9> IssuedTokenClientCredential itcc = client.ClientCredentials.IssuedToken; //</snippet9> //</snippet30> //<snippet10> itcc.LocalIssuerAddress = new EndpointAddress("http://fabrikam.com/sts"); //</snippet10> //</snippet31> AddressHeader a1 = AddressHeader.CreateAddressHeader("Hello", "World", "hello"); AddressHeader[] addressHeaders = new AddressHeader[] { a1 }; //<snippet11> itcc.LocalIssuerAddress = new EndpointAddress(new Uri("http://fabrikam.com/sts"), addressHeaders); //</snippet11> //<snippet12> itcc.LocalIssuerAddress = new EndpointAddress( new Uri("http://fabrikam.com/sts"), EndpointIdentity.CreateDnsIdentity("fabrikam.com"), addressHeaders); //</snippet12> //<snippet13> itcc.LocalIssuerBinding = new WSHttpBinding("LocalIssuerBinding"); //</snippet13> //<snippet32> SynchronousReceiveBehavior myEndpointBehavior = new SynchronousReceiveBehavior(); //<snippet14> itcc.LocalIssuerChannelBehaviors.Add(myEndpointBehavior); //</snippet14> //</snippet32> //<snippet15> itcc.MaxIssuedTokenCachingTime = new TimeSpan(0, 10, 0); //</snippet15> //<snippet16> itcc.IssuedTokenRenewalThresholdPercentage = 80; //</snippet16> //<snippet17> itcc.DefaultKeyEntropyMode = SecurityKeyEntropyMode.ServerEntropy; //</snippet17> //<snippet33> //<snippet18> X509CertificateRecipientClientCredential rcc = client.ClientCredentials.ServiceCertificate; //</snippet18> X509Certificate2 cert = new X509Certificate2(); //<snippet19> rcc.ScopedCertificates.Add(new Uri("http://fabrikam.com/sts"), cert); //</snippet19> //</snippet33> }