/// <summary> /// Creates an IAccessTokenProvider with the supplied test credentials. /// </summary> /// <param name="httpClient">The httpClient that makes the request to the auth server</param> /// <param name="tokenProvisioningEndpoint">The auth server</param> /// <param name="keyId">The id of the security token</param> /// <param name="rsaParameters">The public and private key for the supplied key id</param> /// <returns>An IAccessTokenProvider with the supplied test credentials</returns> public static IAccessTokenProvider Create( HttpClient httpClient, String tokenProvisioningEndpoint, Guid keyId, RSAParameters rsaParameters ) { #pragma warning disable 618 IPrivateKeyProvider privateKeyProvider = new StaticPrivateKeyProvider( keyId, rsaParameters ); #pragma warning restore 618 ITokenSigner tokenSigner = new TokenSigner( privateKeyProvider ); IAuthServiceClient authServiceClient = new AuthServiceClient( httpClient, new Uri( tokenProvisioningEndpoint ) ); INonCachingAccessTokenProvider noCacheTokenProvider = new AccessTokenProvider( tokenSigner, authServiceClient ); return new CachedAccessTokenProvider( noCacheTokenProvider, Timeout.InfiniteTimeSpan ); }
/// <summary> /// Factory method for creating new <see cref="IAccessTokenProvider"/> instances. <paramref name="httpClient"/> will not be diposed. /// </summary> /// <returns>A new <see cref="IAccessTokenProvider"/></returns> public static IAccessTokenProvider Create( ITokenSigner tokenSigner, HttpClient httpClient, Uri authEndpoint, TimeSpan tokenRefreshGracePeriod ) { IAuthServiceClient authServiceClient = new AuthServiceClient( httpClient, authEndpoint ); INonCachingAccessTokenProvider accessTokenProvider = new AccessTokenProvider( tokenSigner, authServiceClient ); return new CachedAccessTokenProvider( accessTokenProvider, tokenRefreshGracePeriod ); }