public OtpActivationRequestParams Get(OtpActivationRequest credentials)
        {
            var claimsPrincipal = _tokenClaimsPrincipalFactory.Create(credentials.OtpToken);

            if (claimsPrincipal == null)
            {
                return(null);
            }

            var userIdClaimValueProvider       = _userIdClaimValueProviderFactory.Create(claimsPrincipal);
            var otpSecretKeyClaimValueProvider = _otpSecretKeyClaimValueProvider.Create(claimsPrincipal);

            var userId         = userIdClaimValueProvider.GetValue();
            var secretKey      = otpSecretKeyClaimValueProvider.GetValue();
            var secretKeyBytes = secretKey.FromBase32(config: Base32Config.Rfc);

            return(new OtpActivationRequestParams {
                UserId = userId,
                SecretKey = secretKeyBytes,
                Otp = credentials.Otp,
                Password = credentials.Password
            });
        }
Example #2
0
        public string Renew(string outdatedToken)
        {
            if (string.IsNullOrEmpty(outdatedToken))
            {
                return(null);
            }

            var claimsPrincipal = _tokenClaimsPrincipalFactory.Create(outdatedToken);

            if (claimsPrincipal == null)
            {
                return(null);
            }

            var userIdClaimValueProvider   = _userIdClaimValueProviderFactory.Create(claimsPrincipal);
            var tokenTtlClaimValueProvider = _tokenTtlClaimValueProviderFactory.Create(claimsPrincipal);
            var rolesClaimValueProvider    = _rolesClaimValueProviderFactory.Create(claimsPrincipal);

            var userId            = userIdClaimValueProvider.GetValue();
            var hasLongTimeToLive = tokenTtlClaimValueProvider.HasLongTimeToLive();
            var roles             = rolesClaimValueProvider.GetValue();

            return(_createJwtTokenAsStringService.Create(userId, hasLongTimeToLive, roles));
        }