/// <inheritdoc/>
        public AccessToken GetAccessToken(string token)
        {
            if (token == null || token == string.Empty)
            {
                throw new ArgumentNullException(nameof(token));
            }

            var accessToken = _accessTokenRepository.Read(new AccessTokenTableEntity {
                TokenId = token
            });

            if (accessToken == null || accessToken.Status != AccessTokenStatus.NORMAL.ToString())
            {
                return(null);
            }

            if (accessToken.PrincipalType != PrincipalType.Application.ToString() &&
                accessToken.PrincipalType != PrincipalType.User.ToString())
            {
                throw new NotImplementedException();
            }

            var application = _applicationRepository.Read(new ApplicationTableEntity {
                ApplicationId = accessToken.ApplicationId
            });

            if (application == null || application.Status != ApplicationStatus.NORMAL.ToString())
            {
                return(null);
            }

            var roles = JsonUtil.Deserialize <List <string> >(application.Roles);

            if (accessToken.PrincipalType == PrincipalType.User.ToString())
            {
                var account = _accountService.GetAccount(accessToken.PrincipalId);
                if (account == null)
                {
                    return(null);
                }

                if (account.Person == null || account.Person.Status != PersonStatus.NORMAL)
                {
                    return(null);
                }

                roles = account.Roles;
            }

            var result = new AccessToken
            {
                Name          = accessToken.Name,
                Description   = accessToken.Description,
                Roles         = roles,
                Scopes        = JsonUtil.Deserialize <List <string> >(accessToken.Scopes),
                TokenId       = accessToken.TokenId,
                ApplicationId = accessToken.ApplicationId,
                PrincipalType = accessToken.PrincipalType,
                PrincipalId   = accessToken.PrincipalId,
                ExpiryTime    = accessToken.ExpiryTime,
                Status        = (AccessTokenStatus)Enum.Parse(typeof(AccessTokenStatus), accessToken.Status),
                CreateTime    = accessToken.CreateTime,
                UpdateTime    = accessToken.UpdateTime,
            };

            return(result);
        }