예제 #1
0
        /// <summary>
        /// get token response
        /// </summary>
        /// <param name="request">token reqeust</param>
        /// <param name="requestType">requestType</param>
        /// <returns>AngelTokenResponse</returns>
        public static async Task <AngelTokenResponse> GetTokenResponse(AngelTokenRequest request, TokenRequestType requestType)
        {
            if (request == null)
            {
                return(null);
            }

            AngelTokenResponse      angelResposne      = null;
            TokenResponse           response           = null;
            TokenRevocationResponse revocationResponse = null;

            switch (requestType)
            {
            case TokenRequestType.client_credential:
                response = await GetClientCredentialToken(request.Map());

                angelResposne = response?.Map();
                break;

            case TokenRequestType.resource_password:
                response = await GetResourcePasswordToken(request.MapPasswordRequest());

                angelResposne = response?.Map();
                break;

            case TokenRequestType.revocation:
                revocationResponse = await ForceTokenTimeout(request.MapRevocationRequest());

                angelResposne = response?.Map();
                break;

            case TokenRequestType.refresh:
                response = await ReferenceToken(request.MapRefRequest());

                angelResposne = response?.Map();
                break;
            }

            return(angelResposne);
        }