/// <inheritdoc /> public virtual Task RefreshTokenAsync(SecuritySettings securitySettings, CancellationToken cancellationToken) { if (securitySettings is ClaimsSecuritySettings claimsSecuritySettings) { this.token = claimsSecuritySettings.ClaimsToken; } else { throw new InvalidOperationException(string.Format(SR.ErrorClaimsTokenHandlerIncorrectSecuritySettings, securitySettings.GetType().Name)); } return(Task.CompletedTask); }
/// <inheritdoc /> public async Task InitializeTokenAsync(SecuritySettings securitySettings, CancellationToken cancellationToken) { if (securitySettings is DstsClaimsSecuritySettings dstsSecuritySettings) { // Use ClaimsToken if provided by the user directly else use the delegate to get the ClaimsToken from user. if (dstsSecuritySettings.ClaimsToken != null) { this.token = dstsSecuritySettings.ClaimsToken; } else if (dstsSecuritySettings.GetClaimsToken != null && this.metaData != null) { this.token = await dstsSecuritySettings.GetClaimsToken.Invoke(this.metaData, cancellationToken); } } else { throw new InvalidOperationException(string.Format(SR.ErrorAADTokenHandlerIncorrectSecuritySettings, securitySettings.GetType().Name)); } }