Esempio n. 1
0
        public async Task <bool> CreateAuthorizationCodeHandleAsync(string key, global::IdentityServer3.Core.Models.AuthorizationCode value,
                                                                    CancellationToken cancellationToken = default(CancellationToken))
        {
            var fRecord = new FlattenedAuthorizationCodeHandle(key, value);

            return(await CreateAuthorizationCodeHandleAsync(fRecord));
        }
        public static async Task <List <FlattenedAuthorizationCodeHandle> > InsertTestData_AuthorizationCode(int count = 1)
        {
            var dao = new IdentityServer3CassandraDao();
            await dao.EstablishConnectionAsync();

            IClientStore clientStore  = new ClientStore();
            var          insertTokens = await CassandraTestHelper.InsertTestData_Tokens(count); // only add one client

            var clientId     = insertTokens[0].ClientId;
            var clientRecord = await clientStore.FindClientByIdAsync(clientId);

            List <FlattenedAuthorizationCodeHandle> result = new List <FlattenedAuthorizationCodeHandle>();
            int i = 0;

            foreach (var insertToken in insertTokens)
            {
                var claimIdentityRecords = new List <ClaimIdentityRecord>()
                {
                    new ClaimIdentityRecord()
                    {
                        AuthenticationType = Constants.PrimaryAuthenticationType,
                        ClaimTypeRecords   = new List <ClaimTypeRecord>()
                        {
                            new ClaimTypeRecord()
                            {
                                Type      = Constants.ClaimTypes.Subject,
                                Value     = "Value:" + i,
                                ValueType = "VALUETYPE:" + i
                            }
                        }
                    }
                };
                FlattenedAuthorizationCodeHandle handle = new FlattenedAuthorizationCodeHandle
                {
                    ClientId        = clientId,
                    SubjectId       = insertToken.SubjectId,
                    Expires         = DateTimeOffset.UtcNow.AddMinutes(5),
                    CreationTime    = DateTimeOffset.UtcNow,
                    IsOpenId        = true,
                    RedirectUri     = "REDIRECTURI/" + i,
                    WasConsentShown = true,
                    Nonce           = "NONCE:" + i,

                    ClaimIdentityRecords = new FlattenedAuthorizationCodeHandle().SerializeClaimsIdentityRecords(claimIdentityRecords),
                    RequestedScopes      = new FlattenedAuthorizationCodeHandle().SerializeRequestScopes(clientRecord.AllowedScopes),
                    Key = Guid.NewGuid().ToString()
                };
                ++i;
                result.Add(handle);
            }
            await dao.CreateManyAuthorizationCodeHandleAsync(result);

            return(result);
        }
Esempio n. 3
0
 public async Task <bool> CreateAuthorizationCodeHandleAsync(FlattenedAuthorizationCodeHandle tokenHandle,
                                                             CancellationToken cancellationToken = default(CancellationToken))
 {
     try
     {
         MyMappings.Init();
         var list = new List <FlattenedAuthorizationCodeHandle> {
             tokenHandle
         };
         return(await CreateManyAuthorizationCodeHandleAsync(list, cancellationToken));
     }
     catch (Exception e)
     {
         return(false);
     }
 }