public JToken CreateProof(CreateProofOptions options, JsonLdProcessorOptions processorOptions)
        {
            if (!(options.VerificationMethod is Bls12381VerificationKey2020 verificationMethod))
            {
                throw new Exception(
                          $"Invalid verification method. " +
                          $"Expected '{nameof(Bls12381VerificationKey2020)}'. " +
                          $"Found '{options.VerificationMethod?.GetType().Name}'.");
            }

            // Prepare proof
            var compactedProof = JsonLdProcessor.Compact(
                input: new BbsBlsSignature2020
            {
                Context  = Constants.SECURITY_CONTEXT_V2_URL,
                TypeName = "https://w3c-ccg.github.io/ldp-bbs2020/context/v1#BbsBlsSignature2020"
            },
                context: Constants.SECURITY_CONTEXT_V2_URL,
                options: processorOptions);

            var proof = new BbsBlsSignature2020(compactedProof)
            {
                Context            = Constants.SECURITY_CONTEXT_V2_URL,
                VerificationMethod = options.VerificationMethod switch
                {
                    VerificationMethodReference reference => (string)reference,
                    VerificationMethod method => method.Id,
                    _ => throw new Exception("Unknown VerificationMethod type")
                },
Esempio n. 2
0
        /// <summary>
        /// Constructs the arguments for a Verify transaction.
        /// </summary>
        /// <param name="verificationMethod">The method of verification (sms or call).</param>
        /// <param name="phoneNumber">The phone number to send verification to.</param>
        /// <param name="verifyCode">The code to be sent to the user. If null - a code will be generated.</param>
        /// <param name="messageTemplate">An optional template for the message. Ignored if not SMS.</param>
        /// <param name="language">The language for the message. Ignored for SMS when a template is provided.</param>
        /// <param name="validityPeriod"></param>
        /// <param name="useCaseId"></param>
        /// <returns>A dictionary of arguments for a Verify transaction.</returns>
        private static Dictionary <string, string> ConstructVerifyArgs(
            VerificationMethod verificationMethod,
            string phoneNumber,
            string verifyCode,
            string messageTemplate,
            string language,
            string validityPeriod = null,
            string useCaseId      = RawVerifyService.DefaultUseCaseId)
        {
            // TODO: Review code generation rules.
            if (!string.IsNullOrEmpty(verifyCode))
            {
                if (verificationMethod == VerificationMethod.TwoWaySms)
                {
                    throw new ArgumentException("Verify Code cannot be specified for Two-Way SMS", "verifyCode");
                }
            }

            // TODO: Check code validity here?

            var args = new Dictionary <string, string>
            {
                { "phone_number", phoneNumber }
            };

            if (verificationMethod == VerificationMethod.Push)
            {
                if (!string.IsNullOrEmpty(verifyCode))
                {
                    args.Add("notification_value", verifyCode);
                }
            }
            else if (verificationMethod == VerificationMethod.TwoWaySms)
            {
                // Two way sms doesn't take a verify code. So nothing here.
            }
            else if (!string.IsNullOrEmpty(verifyCode))
            {
                args.Add("verify_code", verifyCode);
            }

            if (!string.IsNullOrEmpty(language))
            {
                args.Add("language", language);
            }

            if (verificationMethod == VerificationMethod.Sms || verificationMethod == VerificationMethod.Push)
            {
                args.Add("template", messageTemplate);
            }

            if (verificationMethod == VerificationMethod.TwoWaySms)
            {
                args.Add("message", messageTemplate);
                args.Add("validity_period", validityPeriod);
                args.Add("ucid", useCaseId);
            }

            return(args);
        }
Esempio n. 3
0
        public SitesEntry VerifySite(string url, SitesEntry entry = null)
        {
            if (entry == null)
            {
                entry = GetSite(url);
            }

            VerificationMethod method = new VerificationMethod("metatag", "true");
            var siteid = CreateSiteID(url);

            entry.VerificationMethod = method;
            var category = new AtomCategory("http://schemas.google.com/webmasters/tools/2007#site-info",
                                            "http://schemas.google.com/g/2005#kind");

            entry.Categories.Add(category);
            entry.Id           = new AtomId(string.Concat(SiteQueryUrl, siteid));
            entry.Content.Type = "";
            try
            {
                return(service.Update(entry));
            }
            catch (Exception ex)
            {
                Syslog.Write(ex);
            }
            return(null);
        }
Esempio n. 4
0
        /// <summary>
        /// Constructs the arguments for a Verify transaction.
        /// </summary>
        /// <param name="verificationMethod">The method of verification (sms or call).</param>
        /// <param name="phoneNumber">The phone number to send verification to.</param>
        /// <param name="verifyCode">The code to be sent to the user. If null - a code will be generated.</param>
        /// <param name="messageTemplate">An optional template for the message. Ignored if not SMS.</param>
        /// <param name="language">The language for the message. Ignored for SMS when a template is provided.</param>
        /// <returns>A dictionary of arguments for a Verify transaction.</returns>
        private static Dictionary <string, string> ConstructVerifyArgs(
            VerificationMethod verificationMethod,
            string phoneNumber,
            string verifyCode,
            string messageTemplate,
            string language)
        {
            // TODO: Review code generation rules.
            if (verifyCode == null)
            {
                Random r = new Random();
                verifyCode = r.Next(100, 99999).ToString();
            }

            // TODO: Check code validity here?

            Dictionary <string, string> args = new Dictionary <string, string>();

            args.Add("phone_number", phoneNumber);
            args.Add("verify_code", verifyCode.ToString());
            args.Add("language", language);

            if (verificationMethod == VerificationMethod.Sms)
            {
                args.Add("template", messageTemplate);
            }

            return(args);
        }
Esempio n. 5
0
        /// <summary>
        /// Returns true if the given verification method is a invoker or is
        /// controlled by an invoker of the given capability.
        /// </summary>
        /// <param name="capability"></param>
        /// <param name="verificationMethod"></param>
        /// <returns></returns>
        public static bool HasInvoker(this CapabilityDelegation capability, VerificationMethod verificationMethod)
        {
            var invokers = capability.GetInvokers();

            return(invokers.Count() > 0 &&
                   (invokers.Contains(verificationMethod.Id) ||
                    (verificationMethod.Controller != null && invokers.Contains(verificationMethod.Controller))));
        }
Esempio n. 6
0
        /// <summary>
        /// Returns true if the given verification method is a delegator or is
        /// controlled by a delegator of the given capability.
        /// </summary>
        /// <param name="capability"></param>
        /// <param name="verificationMethod"></param>
        /// <returns></returns>
        public static bool HasDelegator(this CapabilityDelegation capability, VerificationMethod verificationMethod)
        {
            var delegators = capability.GetDelegators();

            return(delegators.Count() > 0 &&
                   (delegators.Contains(verificationMethod.Id) ||
                    (verificationMethod.Controller != null && delegators.Contains(verificationMethod.Controller))));
        }
Esempio n. 7
0
        public async Task <IInitiateVerificationResponse> Initiate(VerificationMethod method)
        {
            ValidateIdentity();

            var request = new InitiateVerificationRequest
            {
                Identity  = _identity,
                Method    = ToString(method),
                Reference = _reference,
                Custom    = _custom,
            };

            return(new InitiateVerificationResponseAdapter(await _api.InitiateVerification(request).ConfigureAwait(false)));
        }
Esempio n. 8
0
        private string ToString(VerificationMethod method)
        {
            switch (method)
            {
            case VerificationMethod.FlashCall:
                return("flashCall");

            case VerificationMethod.Sms:
                return("sms");

            case VerificationMethod.Callout:
                return("callout");
            }

            throw new ArgumentException("Unsupported verification method: " + method);
        }
Esempio n. 9
0
        public void ConstructVerificationMethod()
        {
            var method = new VerificationMethod();

            Assert.Null(method.Id);
            Assert.Null(method.TypeName);
            Assert.Null(method.Controller);

            method.Id         = "did:123#key-1";
            method.TypeName   = "MockVerificationMethod";
            method.Controller = "did:123";

            Assert.Equal("did:123#key-1", method.Id);
            Assert.Equal("MockVerificationMethod", method.TypeName);
            Assert.Equal("did:123", method.Controller);
        }
Esempio n. 10
0
        public void SerializeDeserializeVerificationMethod()
        {
            var method = new VerificationMethod();

            method.TypeName   = "MockMethod";
            method.Id         = "1";
            method.Controller = "a";

            var json = JsonConvert.SerializeObject(method);

            Assert.NotNull(json);

            var method1 = JsonConvert.DeserializeObject <IVerificationMethod>(json);

            Assert.NotNull(method1);
            Assert.IsType <VerificationMethod>(method1);
        }
Esempio n. 11
0
        /// <summary>
        /// Common method for Verify SMS and call requests.
        /// </summary>
        /// <param name="verificationMethod">The verification method (call or sms).</param>
        /// <param name="phoneNumber">The phone number to send verification to.</param>
        /// <param name="verifyCode">
        /// The code to send to the user. When null a code will
        /// be generated for you.
        /// </param>
        /// <param name="messageTemplate">
        /// A template for the message to be sent to the user. This is ignored for voice calls.
        /// </param>
        /// <param name="language">
        /// The language that the message should be in. This parameter is ignored for
        /// SMS if you supplied a message template.
        /// </param>
        /// <returns>The raw JSON response for a verify REST API call.</returns>
        private string InternalVerify(
            VerificationMethod verificationMethod,
            string phoneNumber,
            string verifyCode      = null,
            string messageTemplate = null,
            string language        = null)
        {
            this.CleanupPhoneNumber(phoneNumber);

            if (messageTemplate == null)
            {
                messageTemplate = string.Empty;
            }

            if (string.IsNullOrEmpty(language))
            {
                language = "en";
            }

            Dictionary <string, string> args = ConstructVerifyArgs(
                verificationMethod,
                phoneNumber,
                verifyCode,
                messageTemplate,
                language);

            string resourceName = string.Format(
                RawVerifyService.VerifyResourceFormatString,
                verificationMethod.ToString().ToLowerInvariant());

            WebRequest request = this.ConstructWebRequest(
                resourceName,
                "POST",
                args);

            return(this.WebRequester.ReadResponseAsString(request));
        }
Esempio n. 12
0
        public async Task <IReportVerificationResponse> Report(VerificationMethod method)
        {
            ValidateIdentity();

            var request = new ReportVerificationRequest {
                Method = ToString(method)
            };

            switch (method)
            {
            case VerificationMethod.FlashCall:
            case VerificationMethod.Callout:
                if (string.IsNullOrWhiteSpace(_cli))
                {
                    throw new BadRequestException("Cli cannot be empty");
                }

                request.FlashCall = new FlashCallVerificationReportData {
                    Cli = _cli
                };
                break;

            case VerificationMethod.Sms:
                if (string.IsNullOrWhiteSpace(_code))
                {
                    throw new BadRequestException("Code cannot be empty");
                }

                request.Sms = new SmsVerificationReportData {
                    Code = _code, Cli = _cli
                };
                break;
            }

            return(await _api.ReportVerification(_identity, request).ConfigureAwait(false));
        }
 public VerificationMethodReference(VerificationMethod verificationMethod) : this(verificationMethod.Id)
 {
 }
Esempio n. 14
0
 public void Read (TProtocol iprot)
 {
   TField field;
   iprot.ReadStructBegin();
   while (true)
   {
     field = iprot.ReadFieldBegin();
     if (field.Type == TType.Stop) { 
       break;
     }
     switch (field.ID)
     {
       case 2:
         if (field.Type == TType.String) {
           SessionId = iprot.ReadString();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       case 3:
         if (field.Type == TType.I32) {
           Method = (VerificationMethod)iprot.ReadI32();
         } else { 
           TProtocolUtil.Skip(iprot, field.Type);
         }
         break;
       default: 
         TProtocolUtil.Skip(iprot, field.Type);
         break;
     }
     iprot.ReadFieldEnd();
   }
   iprot.ReadStructEnd();
 }
Esempio n. 15
0
 public void send_changeVerificationMethod(string sessionId, VerificationMethod method)
 #endif
 {
   oprot_.WriteMessageBegin(new TMessage("changeVerificationMethod", TMessageType.Call, seqid_));
   changeVerificationMethod_args args = new changeVerificationMethod_args();
   args.SessionId = sessionId;
   args.Method = method;
   args.Write(oprot_);
   oprot_.WriteMessageEnd();
   #if SILVERLIGHT
   return oprot_.Transport.BeginFlush(callback, state);
   #else
   oprot_.Transport.Flush();
   #endif
 }
Esempio n. 16
0
 public IAsyncResult send_changeVerificationMethod(AsyncCallback callback, object state, string sessionId, VerificationMethod method)
Esempio n. 17
0
      public VerificationSessionData changeVerificationMethod(string sessionId, VerificationMethod method)
      {
        #if !SILVERLIGHT
        send_changeVerificationMethod(sessionId, method);
        return recv_changeVerificationMethod();

        #else
        var asyncResult = Begin_changeVerificationMethod(null, null, sessionId, method);
        return End_changeVerificationMethod(asyncResult);

        #endif
      }
Esempio n. 18
0
 public IAsyncResult Begin_changeVerificationMethod(AsyncCallback callback, object state, string sessionId, VerificationMethod method)
 {
   return send_changeVerificationMethod(callback, state, sessionId, method);
 }
Esempio n. 19
0
        /// <summary>
        /// Common method for Verify SMS and call requests.
        /// </summary>
        /// <param name="verificationMethod">The verification method (call or sms).</param>
        /// <param name="phoneNumber">The phone number to send verification to.</param>
        /// <param name="verifyCode">
        /// The code to send to the user. When null a code will
        /// be generated for you.
        /// </param>
        /// <param name="messageTemplate">
        /// A template for the message to be sent to the user. This is ignored for voice calls.
        /// </param>
        /// <param name="language">
        /// The language that the message should be in. This parameter is ignored for
        /// SMS if you supplied a message template.
        /// </param>
        /// <returns>The raw JSON response for a verify REST API call.</returns>
        private string InternalVerify(
                    VerificationMethod verificationMethod,
                    string phoneNumber,
                    string verifyCode = null,
                    string messageTemplate = null,
                    string language = null)
        {
            this.CleanupPhoneNumber(phoneNumber);

            if (messageTemplate == null)
            {
                messageTemplate = string.Empty;
            }

            if (string.IsNullOrEmpty(language))
            {
                language = "en";
            }

            Dictionary<string, string> args = ConstructVerifyArgs(
                        verificationMethod,
                        phoneNumber,
                        verifyCode,
                        messageTemplate,
                        language);

            string resourceName = string.Format(
                        RawVerifyService.VerifyResourceFormatString,
                        verificationMethod.ToString().ToLowerInvariant());

            WebRequest request = this.ConstructWebRequest(
                        resourceName,
                        "POST",
                        args);

            return this.WebRequester.ReadResponseAsString(request);
        }
        public void Insert(int VerificationMethodKey,string VerificationMethodName,int Points,bool? Ismandatory,bool? Requiresmanualapproval)
        {
            VerificationMethod item = new VerificationMethod();

            item.VerificationMethodKey = VerificationMethodKey;

            item.VerificationMethodName = VerificationMethodName;

            item.Points = Points;

            item.Ismandatory = Ismandatory;

            item.Requiresmanualapproval = Requiresmanualapproval;

            item.Save(UserName);
        }
Esempio n. 21
0
 public KeyAgreementMethod(VerificationMethod embeddedVerification) : base(embeddedVerification)
 {
 }
Esempio n. 22
0
 public AuthenticationMethod(VerificationMethod embeddedVerification) : base(embeddedVerification)
 {
 }
Esempio n. 23
0
        private static void PerformVerify(string[] args, VerificationMethod method)
        {
            CheckArgument.ArrayLengthAtLeast(args, 1, "args");

            string phoneNumber = args[0];

            string code = null;
            if (args.Length >= 2)
            {
                code = args[1];
            }

            string language = "en";
            if (args.Length >= 3)
            {
                language = args[2];
            }

            VerifyService verify = new VerifyService(GetConfiguration());
            VerifyResponse verifyResponse = null;

            if (method == VerificationMethod.Sms)
            {
                verifyResponse = verify.SendSms(phoneNumber, code, string.Empty, language);
            }
            else if (method == VerificationMethod.Call)
            {
                verifyResponse = verify.InitiateCall(phoneNumber, code, language);
            }
            else if (method == VerificationMethod.Push)
            {
                verifyResponse = verify.InitiatePush(phoneNumber, code);
            }
            else if (method == VerificationMethod.TwoWaySms)
            {
                verifyResponse = verify.SendTwoWaySms(phoneNumber);
            }
            else
            {
                throw new NotImplementedException("Invalid verification method");
            }

            foreach (TeleSignApiError e in verifyResponse.Errors)
            {
                Console.WriteLine(
                            "ERROR: [{0}] - {1}", 
                            e.Code, 
                            e.Description);
            }

            while (true)
            {
                Console.Write("Enter the code sent to phone [Just <enter> checks status. 'quit' to exit]: ");
                string enteredCode = Console.ReadLine();

                if (enteredCode.Equals("quit", StringComparison.InvariantCultureIgnoreCase))
                {
                    break;
                }

                Console.WriteLine(string.IsNullOrEmpty(enteredCode) ? "Checking status..." : "Validating code...");

                VerifyResponse statusResponse = verify.ValidateCode(
                            verifyResponse.ReferenceId,
                            enteredCode);

                Console.WriteLine(
                            "Transaction Status: {0} -- {1}\r\nCode State: {2}",
                            statusResponse.Status.Code,
                            statusResponse.Status.Description,
                            (statusResponse.VerifyInfo != null) 
                                        ? statusResponse.VerifyInfo.CodeState.ToString()
                                        : "Not Sent");

                if ((statusResponse.VerifyInfo != null) && (statusResponse.VerifyInfo.CodeState == CodeState.Valid))
                {
                    Console.WriteLine("Code was valid. Exiting.");
                    break;
                }
            }
        }
Esempio n. 24
0
        private static void PerformVerify(string[] args, VerificationMethod method)
        {
            CheckArgument.ArrayLengthAtLeast(args, 1, "args");

            string phoneNumber = args[0];

            string code = null;

            if (args.Length >= 2)
            {
                code = args[1];
            }

            string language = "en";

            if (args.Length >= 3)
            {
                language = args[2];
            }

            VerifyService  verify         = new VerifyService(GetConfiguration());
            VerifyResponse verifyResponse = null;

            if (method == VerificationMethod.Sms)
            {
                verifyResponse = verify.SendSms(phoneNumber, code, string.Empty, language);
            }
            else if (method == VerificationMethod.Call)
            {
                verifyResponse = verify.InitiateCall(phoneNumber, code, language);
            }
            else
            {
                throw new NotImplementedException("Invalid verification method");
            }

            foreach (TeleSignApiError e in verifyResponse.Errors)
            {
                Console.WriteLine(
                    "ERROR: [{0}] - {1}",
                    e.Code,
                    e.Description);
            }

            while (true)
            {
                Console.Write("Enter the code sent to phone [Just <enter> checks status. 'quit' to exit]: ");
                string enteredCode = Console.ReadLine();

                if (enteredCode.Equals("quit", StringComparison.InvariantCultureIgnoreCase))
                {
                    break;
                }

                Console.WriteLine(string.IsNullOrEmpty(enteredCode) ? "Checking status..." : "Validating code...");

                VerifyResponse statusResponse = verify.ValidateCode(
                    verifyResponse.ReferenceId,
                    enteredCode);

                Console.WriteLine(
                    "Transaction Status: {0} -- {1}\r\nCode State: {2}",
                    statusResponse.Status.Code,
                    statusResponse.Status.Description,
                    statusResponse.VerifyInfo.CodeState);

                if (statusResponse.VerifyInfo.CodeState == CodeState.Valid)
                {
                    Console.WriteLine("Code was valid. Exiting.");
                    break;
                }
            }
        }
Esempio n. 25
0
        public void Read(TProtocol iprot)
        {
            TField field;

            iprot.ReadStructBegin();
            while (true)
            {
                field = iprot.ReadFieldBegin();
                if (field.Type == TType.Stop)
                {
                    break;
                }
                switch (field.ID)
                {
                case 1:
                    if (field.Type == TType.String)
                    {
                        SessionId = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 2:
                    if (field.Type == TType.I32)
                    {
                        Method = (VerificationMethod)iprot.ReadI32();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 3:
                    if (field.Type == TType.String)
                    {
                        Callback = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 4:
                    if (field.Type == TType.String)
                    {
                        NormalizedPhone = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 5:
                    if (field.Type == TType.String)
                    {
                        CountryCode = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 6:
                    if (field.Type == TType.String)
                    {
                        NationalSignificantNumber = iprot.ReadString();
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                case 7:
                    if (field.Type == TType.List)
                    {
                        {
                            AvailableVerificationMethods = new List <VerificationMethod>();
                            TList _list85 = iprot.ReadListBegin();
                            for (int _i86 = 0; _i86 < _list85.Count; ++_i86)
                            {
                                VerificationMethod _elem87 = (VerificationMethod)0;
                                _elem87 = (VerificationMethod)iprot.ReadI32();
                                AvailableVerificationMethods.Add(_elem87);
                            }
                            iprot.ReadListEnd();
                        }
                    }
                    else
                    {
                        TProtocolUtil.Skip(iprot, field.Type);
                    }
                    break;

                default:
                    TProtocolUtil.Skip(iprot, field.Type);
                    break;
                }
                iprot.ReadFieldEnd();
            }
            iprot.ReadStructEnd();
        }
Esempio n. 26
0
 public VerifyDomainsPOST(VerificationMethod validationMethod)
 {
     validation_method = validationMethod;
 }
Esempio n. 27
0
 public AssertionMethod(VerificationMethod embeddedVerification) : base(embeddedVerification)
 {
 }
Esempio n. 28
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is CardPaymentDetails other &&
                   ((Status == null && other.Status == null) || (Status?.Equals(other.Status) == true)) &&
                   ((Card == null && other.Card == null) || (Card?.Equals(other.Card) == true)) &&
                   ((EntryMethod == null && other.EntryMethod == null) || (EntryMethod?.Equals(other.EntryMethod) == true)) &&
                   ((CvvStatus == null && other.CvvStatus == null) || (CvvStatus?.Equals(other.CvvStatus) == true)) &&
                   ((AvsStatus == null && other.AvsStatus == null) || (AvsStatus?.Equals(other.AvsStatus) == true)) &&
                   ((AuthResultCode == null && other.AuthResultCode == null) || (AuthResultCode?.Equals(other.AuthResultCode) == true)) &&
                   ((ApplicationIdentifier == null && other.ApplicationIdentifier == null) || (ApplicationIdentifier?.Equals(other.ApplicationIdentifier) == true)) &&
                   ((ApplicationName == null && other.ApplicationName == null) || (ApplicationName?.Equals(other.ApplicationName) == true)) &&
                   ((ApplicationCryptogram == null && other.ApplicationCryptogram == null) || (ApplicationCryptogram?.Equals(other.ApplicationCryptogram) == true)) &&
                   ((VerificationMethod == null && other.VerificationMethod == null) || (VerificationMethod?.Equals(other.VerificationMethod) == true)) &&
                   ((VerificationResults == null && other.VerificationResults == null) || (VerificationResults?.Equals(other.VerificationResults) == true)) &&
                   ((StatementDescription == null && other.StatementDescription == null) || (StatementDescription?.Equals(other.StatementDescription) == true)) &&
                   ((DeviceDetails == null && other.DeviceDetails == null) || (DeviceDetails?.Equals(other.DeviceDetails) == true)) &&
                   ((CardPaymentTimeline == null && other.CardPaymentTimeline == null) || (CardPaymentTimeline?.Equals(other.CardPaymentTimeline) == true)) &&
                   ((RefundRequiresCardPresence == null && other.RefundRequiresCardPresence == null) || (RefundRequiresCardPresence?.Equals(other.RefundRequiresCardPresence) == true)) &&
                   ((Errors == null && other.Errors == null) || (Errors?.Equals(other.Errors) == true)));
        }
Esempio n. 29
0
 public CapabilityInvocationMethod(VerificationMethod embeddedVerification) : base(embeddedVerification)
 {
 }
Esempio n. 30
0
        public override int GetHashCode()
        {
            int hashCode = 1465447186;

            if (Status != null)
            {
                hashCode += Status.GetHashCode();
            }

            if (Card != null)
            {
                hashCode += Card.GetHashCode();
            }

            if (EntryMethod != null)
            {
                hashCode += EntryMethod.GetHashCode();
            }

            if (CvvStatus != null)
            {
                hashCode += CvvStatus.GetHashCode();
            }

            if (AvsStatus != null)
            {
                hashCode += AvsStatus.GetHashCode();
            }

            if (AuthResultCode != null)
            {
                hashCode += AuthResultCode.GetHashCode();
            }

            if (ApplicationIdentifier != null)
            {
                hashCode += ApplicationIdentifier.GetHashCode();
            }

            if (ApplicationName != null)
            {
                hashCode += ApplicationName.GetHashCode();
            }

            if (ApplicationCryptogram != null)
            {
                hashCode += ApplicationCryptogram.GetHashCode();
            }

            if (VerificationMethod != null)
            {
                hashCode += VerificationMethod.GetHashCode();
            }

            if (VerificationResults != null)
            {
                hashCode += VerificationResults.GetHashCode();
            }

            if (StatementDescription != null)
            {
                hashCode += StatementDescription.GetHashCode();
            }

            if (DeviceDetails != null)
            {
                hashCode += DeviceDetails.GetHashCode();
            }

            if (CardPaymentTimeline != null)
            {
                hashCode += CardPaymentTimeline.GetHashCode();
            }

            if (RefundRequiresCardPresence != null)
            {
                hashCode += RefundRequiresCardPresence.GetHashCode();
            }

            if (Errors != null)
            {
                hashCode += Errors.GetHashCode();
            }

            return(hashCode);
        }
Esempio n. 31
0
        /// <summary>
        /// Constructs the arguments for a Verify transaction.
        /// </summary>
        /// <param name="verificationMethod">The method of verification (sms or call).</param>
        /// <param name="phoneNumber">The phone number to send verification to.</param>
        /// <param name="verifyCode">The code to be sent to the user. If null - a code will be generated.</param>
        /// <param name="messageTemplate">An optional template for the message. Ignored if not SMS.</param>
        /// <param name="language">The language for the message. Ignored for SMS when a template is provided.</param>
        /// <returns>A dictionary of arguments for a Verify transaction.</returns>
        private static Dictionary<string, string> ConstructVerifyArgs(
                    VerificationMethod verificationMethod, 
                    string phoneNumber, 
                    string verifyCode, 
                    string messageTemplate, 
                    string language,
                    string validityPeriod = null,
                    string useCaseId = RawVerifyService.DefaultUseCaseId)
        {
            // TODO: Review code generation rules.
            if (verifyCode == null)
            {
                Random r = new Random();
                verifyCode = r.Next(100, 99999).ToString();
            }
            else
            {
                if (verificationMethod == VerificationMethod.TwoWaySms)
                {
                    throw new ArgumentException("Verify Code cannot be specified for Two-Way SMS", "verifyCode");
                }
            }

            // TODO: Check code validity here?

            Dictionary<string, string> args = new Dictionary<string, string>();
            args.Add("phone_number", phoneNumber);

            if (verificationMethod == VerificationMethod.Push)
            {
                if (!string.IsNullOrEmpty(verifyCode))
                {
                    args.Add("notification_value", verifyCode.ToString());
                }
            }
            else if (verificationMethod == VerificationMethod.TwoWaySms)
            {
                // Two way sms doesn't take a verify code. So nothing here.
            }
            else
            {
                args.Add("verify_code", verifyCode.ToString());
            }

            if (!string.IsNullOrEmpty(language))
            {
                args.Add("language", language);
            }

            if (verificationMethod == VerificationMethod.Sms || verificationMethod == VerificationMethod.Push)
            {
                args.Add("template", messageTemplate);
            }

            if (verificationMethod == VerificationMethod.TwoWaySms)
            {
                args.Add("message", messageTemplate);
                args.Add("validity_period", validityPeriod);
                args.Add("ucid", useCaseId);
            }

            return args;
        }
Esempio n. 32
0
        /// <summary>
        /// Phone verification request
        /// </summary>
        /// <param name="countryCode"></param>
        /// <param name="phoneNumber"></param>
        /// <param name="method"></param>
        /// <returns></returns>
        public virtual async Task <ResultModel <object> > PhoneVerificationRequestAsync(string countryCode, string phoneNumber, VerificationMethod method = VerificationMethod.Sms)
        {
            if (_twilioSettings.IsTestEnv)
            {
                return(new SuccessResultModel <object>(new
                {
                    Message = PhoneVerificationResources.TEST_ENV_TEXT
                }));
            }

            var response = new ResultModel <object>();
            var result   = await _client.PostAsync(
                $"/protected/json/phones/verification/start?via={method.ToString().ToLower()}&country_code={countryCode}&phone_number={phoneNumber}",
                null
                );

            if (!result.IsSuccessStatusCode)
            {
                return(new ApiNotRespondResultModel <object>());
            }
            var content = await result.Content.ReadAsStringAsync();

            _logger.LogDebug(result.ToString());
            _logger.LogDebug(content);

            var obj       = JObject.Parse(content);
            var isSuccess = obj.SelectToken("success").Value <bool>();

            response.IsSuccess = isSuccess;

            response.Result = content.Deserialize <object>();
            return(response);
        }