public ServiceResult <GetOpenedSecuritiesOM> GetOpenedSecurities() { var result = new AuthenticatorComponent().GetMerchantOpenedSecurities(this.GetMerchantAccountId()); return(new ServiceResult <GetOpenedSecuritiesOM> { Data = result }); }
public ServiceResult <GetStatusOfSecurityOM> GetStatusOfSecurity() { var result = new AuthenticatorComponent().GetMerchantStatusOfSecurity(this.GetMerchantAccountId()); return(new ServiceResult <GetStatusOfSecurityOM> { Data = result }); }
public ServiceResult <string> Validate(MerchantValidateIM im) { var result = new AuthenticatorComponent().ValidateMerchantAccount(this.GetMerchantAccountId(), im.Code); return(new ServiceResult <string> { Data = result }); }
public ServiceResult <string> Validate(UserValidateIM im) { var result = new AuthenticatorComponent().ValidateUserAccount(this.GetUser(), im.Code); return(new ServiceResult <string> { Data = result }); }
public ServiceResult <GenerateSecretKeyOM> GenerateSecretKey() { var result = new AuthenticatorComponent().GenerateMerchantSecretKey(this.GetMerchantAccountId()); return(new ServiceResult <GenerateSecretKeyOM> { Data = new GenerateSecretKeyOM { SecretKey = result.ManualEntryKey, QrCodeUrl = result.QrCodeSetupUrl } }); }
public ServiceResult <GenerateSecretKeyOM> GenerateSecretKey() { var user = this.GetUser(); var result = new AuthenticatorComponent().GenerateUserSecretKey(user); return(new ServiceResult <GenerateSecretKeyOM> { Data = new GenerateSecretKeyOM { SecretKey = result.ManualEntryKey, QrCodeUrl = result.QrCodeSetupUrl } }); }
/// <summary>Asynchronously authenticates the request.</summary> /// <returns>The task that completes the authentication.</returns> /// <param name="context">The authentication context.</param> /// <param name="cancellationToken">The cancellation token.</param> public async Task AuthenticateAsync(HttpAuthenticationContext context, CancellationToken cancellationToken) { if (context == null) { throw new ArgumentNullException(nameof(context)); } if (context.ActionContext.ActionDescriptor.GetCustomAttributes <AllowAnonymousAttribute>().Count > 0) { return; } HttpRequestMessage request = context.Request; if (request == null) { throw new InvalidOperationException("Request must not be null"); } if (context.Request.Headers.Authorization == null) { throw new UnauthorizedException(); } var authHeader = request.Headers.Authorization.Parameter; if (string.IsNullOrWhiteSpace(authHeader)) { throw new UnauthorizedException(); } var lang = context.Request.Headers.AcceptLanguage.FirstOrDefault()?.Value; if (!string.IsNullOrWhiteSpace(lang) && !(lang.Contains("en") || lang.Contains("zh"))) { throw new CommonException(ReasonCode.MISSING_REQUIRED_FIELDS, MessageResources.SystemError); } var authComponent = new AuthenticatorComponent(); var account = authComponent.Token(authHeader, lang); context.Principal = new ClaimsPrincipal(); context.Request.Properties.Add("User", account); }