static TestUtilities()
        {
#pragma warning disable 618
            IPublicKeyDataProvider publicKeyDataProvider = new InMemoryPublicKeyDataProvider();
#pragma warning restore 618

            m_signer = EcDsaTokenSignerFactory
                       .Create(publicKeyDataProvider, EcDsaTokenSignerFactory.Curve.P256);

            IAccessTokenValidator accessTokenValidator = AccessTokenValidatorFactory
                                                         .CreateLocalValidator(publicKeyDataProvider);

            RequestAuthenticator = RequestAuthenticatorFactory.Create(accessTokenValidator);
        }
Ejemplo n.º 2
0
        private void SetUp(out Uri host, out string token, out Guid id)
        {
            string hostStr;
            var    server = HttpMockFactory.Create(out hostStr);

            host = new Uri(hostStr);

#pragma warning disable 618
            IPublicKeyDataProvider publicKeyDataProvider = new InMemoryPublicKeyDataProvider();
#pragma warning restore 618
            ITokenSigner tokenSigner = GetTokenSigner(publicKeyDataProvider);

            token = tokenSigner
                    .SignAsync(new UnsignedToken(
                                   "some issuer",
                                   "some audience",
                                   new List <Claim>(),
                                   DateTime.Now,
                                   DateTime.Now + TimeSpan.FromDays(1)
                                   ))
                    .SafeAsync()
                    .GetAwaiter()
                    .GetResult();

            var jwk = publicKeyDataProvider
                      .GetAllAsync()
                      .SafeAsync()
                      .GetAwaiter()
                      .GetResult()
                      .First();

            id = jwk.Id;

            server
            .Stub(r => r.Get("/.well-known/jwks"))
            .Return(JsonConvert.SerializeObject(new { keys = new object[] { jwk.ToJwkDto() } }))
            .OK();
        }