コード例 #1
0
        public static List <RefreshTokenHandleRecord> InsertTestData(ClientStore clientStore, ScopeStore scopeStore, TokenHandleStore ths, RefreshTokenStore store, int count = 1)
        {
            List <RefreshTokenHandleRecord> result = new List <RefreshTokenHandleRecord>();
            var insert      = TokenHandleStoreTest.InsertTestData(clientStore, scopeStore, ths, count);
            var subjectSeed = Guid.NewGuid().ToString();
            var clientId    = insert[0].Record.ClientId;

            foreach (var item in insert)
            {
                RefreshTokenHandle tokenHandle = new RefreshTokenHandle
                {
                    ClientId     = clientId,
                    AccessToken  = item.Record,
                    CreationTime = DateTimeOffset.UtcNow,
                    Key          = Guid.NewGuid().ToString(),
                    Expires      = DateTimeOffset.UtcNow.AddMinutes(5),
                    LifeTime     = 5,
                    SubjectId    = item.Record.SubjectId,
                    Version      = 1
                };
                var tokenHandleRecord = new RefreshTokenHandleRecord(tokenHandle);
                store.CreateAsync(tokenHandleRecord.Record);
                result.Add(tokenHandleRecord);
            }
            return(result);
        }
コード例 #2
0
        static List <AuthorizationCodeHandleRecord> InsertTestData(ClientStore clientStore,
                                                                   ScopeStore scopeStore,
                                                                   AuthorizationCodeStore authorizationCodeStore,
                                                                   TokenHandleStore ths, int count = 1)
        {
            var tokenInsert = TokenHandleStoreTest.InsertTestData(clientStore, scopeStore, ths, 10);

            var    clientId    = tokenInsert[0].Record.ClientId;
            string subjectSeed = Guid.NewGuid().ToString();
            List <AuthorizationCodeHandleRecord> result = new List <AuthorizationCodeHandleRecord>();
            int i = 0;

            foreach (var tokenRecord in tokenInsert)
            {
                var client = clientStore.FindClientByIdAsync(tokenRecord.Record.ClientId);

                AuthorizationCodeHandle handle = new AuthorizationCodeHandle
                {
                    ClientId        = tokenRecord.Record.ClientId,
                    SubjectId       = tokenRecord.Record.SubjectId,
                    Expires         = DateTimeOffset.UtcNow.AddMinutes(5),
                    CreationTime    = DateTimeOffset.UtcNow,
                    IsOpenId        = true,
                    RedirectUri     = "REDIRECTURI/" + i,
                    WasConsentShown = true,
                    Nonce           = "NONCE:" + i,

                    ClaimIdentityRecords = new List <ClaimIdentityRecord>()
                    {
                        new ClaimIdentityRecord()
                        {
                            AuthenticationType = Constants.PrimaryAuthenticationType,
                            ClaimTypeRecords   = new List <ClaimTypeRecord>()
                            {
                                new ClaimTypeRecord()
                                {
                                    Type      = Constants.ClaimTypes.Subject,
                                    Value     = tokenRecord.Record.SubjectId,
                                    ValueType = "VALUETYPE:" + i
                                }
                            }
                        }
                    },
                    RequestedScopes = client.Result.AllowedScopes,
                    Key             = Guid.NewGuid().ToString(),
                };

                var handleRecord = new AuthorizationCodeHandleRecord(handle);
                authorizationCodeStore.CreateAsync(handleRecord.Record);
                result.Add(handleRecord);
                ++i;
            }
            return(result);
        }