Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>In my codebase, we actually cache the token so we ensure that we don't make repeated calls to the STS. Using the same method, you could definitely alter it manually request another token whenever you wish. Here's how to hook into ClientCredentials:</p> <pre><code>public class CustomClientCredentials : ClientCredentials { public CustomClientCredentials() { } protected CustomClientCredentials(ClientCredentials other) : base(other) { } protected override ClientCredentials CloneCore() { return new CustomClientCredentials(this); } /// &lt;summary&gt; /// Returns a custom security token manager /// &lt;/summary&gt; /// &lt;returns&gt;&lt;/returns&gt; public override SecurityTokenManager CreateSecurityTokenManager() { return new CustomClientCredentialsSecurityTokenManager(this); } } public class CustomClientCredentialsSecurityTokenManager : ClientCredentialsSecurityTokenManager { public CustomClientCredentialsSecurityTokenManager(ClientCredentials credentials) : base(credentials) { } /// &lt;summary&gt; /// Returns a custom token provider when a issued token is required /// &lt;/summary&gt; public override SecurityTokenProvider CreateSecurityTokenProvider(SecurityTokenRequirement tokenRequirement) { if (IsIssuedSecurityTokenRequirement(tokenRequirement)) { // Adds the endpoint behaviors for calling the issuer IssuedSecurityTokenProvider baseProvider = (IssuedSecurityTokenProvider)base.CreateSecurityTokenProvider(tokenRequirement); CustomIssuedSecurityTokenProvider provider = new CustomIssuedSecurityTokenProvider(baseProvider); return provider; } return base.CreateSecurityTokenProvider(tokenRequirement); } } public class CustomIssuedSecurityTokenProvider : IssuedSecurityTokenProvider { private readonly IssuedSecurityTokenProvider _innerProvider; public CustomIssuedSecurityTokenProvider(IssuedSecurityTokenProvider innerProvider) { _innerProvider = innerProvider; CacheIssuedTokens = innerProvider.CacheIssuedTokens; IdentityVerifier = innerProvider.IdentityVerifier; IssuedTokenRenewalThresholdPercentage = innerProvider.IssuedTokenRenewalThresholdPercentage; IssuerAddress = innerProvider.IssuerAddress; IssuerBinding = innerProvider.IssuerBinding; innerProvider.IssuerChannelBehaviors.ForEach(IssuerChannelBehaviors.Add); KeyEntropyMode = innerProvider.KeyEntropyMode; MaxIssuedTokenCachingTime = innerProvider.MaxIssuedTokenCachingTime; MessageSecurityVersion = innerProvider.MessageSecurityVersion; SecurityAlgorithmSuite = innerProvider.SecurityAlgorithmSuite; SecurityTokenSerializer = innerProvider.SecurityTokenSerializer; TargetAddress = innerProvider.TargetAddress; innerProvider.TokenRequestParameters.ForEach(TokenRequestParameters.Add); _innerProvider.Open(); } ~CustomIssuedSecurityTokenProvider() { _innerProvider.Close(); } protected override SecurityToken GetTokenCore(TimeSpan timeout) { // We're ignoring the CacheIssuedTokens property in order to force an STS call var securityToken = _innerProvider.GetToken(timeout); return securityToken; } } </code></pre> <p>The GetTokenCore() method is where the STS gets called. When you call GetToken(), the STS will be asked to issue another token.</p> <p>From your question, I assume you know how to hook into your ClientCredentials from the app.config.</p> <p>There might be a way of setting the CacheIssuedTokens property in the App.config file, I'm just not sure of a way off the top of my head.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload