コード例 #1
0
 public WebClientTransport(
     IHttpClient httpClient,
     ICrypto crypto,
     ICache publicKeyCache,
     string baseUrl,
     EntityIdentifier issuer,
     IJwtService jwtService,
     IJweService jweService,
     int offsetTTL,
     int currentPublicKeyTTL,
     EntityKeyMap keyMap,
     IJsonEncoder jsonDecoder)
 {
     _httpClient          = httpClient;
     _crypto              = crypto;
     _publicKeyCache      = publicKeyCache;
     _baseUrl             = baseUrl;
     _issuer              = issuer;
     _jwtService          = jwtService;
     _jweService          = jweService;
     _offsetTtl           = offsetTTL;
     _currentPublicKeyTtl = currentPublicKeyTTL;
     _keyMap              = keyMap;
     _jsonDecoder         = jsonDecoder;
 }
コード例 #2
0
 /// <summary>
 /// Create an instance
 /// </summary>
 /// <param name="crypto">The crypto provider to use</param>
 /// <param name="httpClient">The HTTP client to use</param>
 /// <param name="keyCache">The caching provider to use for storing public keys</param>
 /// <param name="apiBaseUrl">The API base URL to use</param>
 /// <param name="apiIdentifier">The API audience identifier to use</param>
 /// <param name="requestExpireSeconds">The default expire time for requests in-flight</param>
 /// <param name="offsetTtl">The amount of time to cache our server-to-client time-drift</param>
 /// <param name="currentPublicKeyTtl">The amount of time to cache the server's public key</param>
 /// <param name="entityKeyMap">A list of private keys tied to entities</param>
 public FactoryFactory(ICrypto crypto, IHttpClient httpClient, ICache keyCache, string apiBaseUrl, string apiIdentifier, int requestExpireSeconds, int offsetTtl, int currentPublicKeyTtl, EntityKeyMap entityKeyMap)
 {
     _crypto               = crypto;
     _httpClient           = httpClient;
     _keyCache             = keyCache;
     _apiBaseUrl           = apiBaseUrl;
     _apiIdentifier        = apiIdentifier;
     _requestExpireSeconds = requestExpireSeconds;
     _offsetTtl            = offsetTtl;
     _currentPublicKeyTtl  = currentPublicKeyTtl;
     _entityKeyMap         = entityKeyMap;
 }
コード例 #3
0
        public void AddKey_ShouldOverwrite()
        {
            var km         = new EntityKeyMap();
            var rsa        = new RSACryptoServiceProvider();
            var identifier = new EntityIdentifier(EntityType.Directory, Guid.NewGuid());

            km.AddKey(identifier, "key", rsa);
            var rsa2 = km.GetKey(identifier, "key");

            Assert.AreSame(rsa, rsa2);

            var rsa3 = new RSACryptoServiceProvider();

            km.AddKey(identifier, "key", rsa3);

            var rsa4 = km.GetKey(identifier, "key");

            Assert.AreSame(rsa3, rsa4);
        }
コード例 #4
0
        public void GetKey_ShouldThrowNoKeyFoundException()
        {
            var km = new EntityKeyMap();

            km.GetKey(new EntityIdentifier(EntityType.Organization, Guid.NewGuid()), "key");
        }