/// <summary> /// Gets the hash code /// </summary> /// <returns>Hash code</returns> public override int GetHashCode() { unchecked // Overflow is fine, just wrap { var hashCode = 41; // Suitable nullity checks etc, of course :) if (Timestamp != null) { hashCode = hashCode * 59 + Timestamp.GetHashCode(); } if (ProfileId != null) { hashCode = hashCode * 59 + ProfileId.GetHashCode(); } if (ProfileName != null) { hashCode = hashCode * 59 + ProfileName.GetHashCode(); } if (SignatureRequired != null) { hashCode = hashCode * 59 + SignatureRequired.GetHashCode(); } if (Textures != null) { hashCode = hashCode * 59 + Textures.GetHashCode(); } return(hashCode); } }
public override void OnActionExecuting(HttpActionContext actionContext) { try { bool hasAccessed = false; string description = "签名验证不予通过!"; if (actionContext.ActionArguments == null || actionContext.ActionArguments.Count != 1) { hasAccessed = false; description = "签名验证参数为空!"; } else { SignatureRequired required = actionContext.ActionArguments.Values.First() as SignatureRequired; if (required == null) { hasAccessed = false; description = "签名验证参数不符合规范!"; } else { SecurityCheckManager securityCheckManager = new SecurityCheckManager(required.Version); ManagerResult <bool> checkResult = securityCheckManager.CheckSignature(required.Signature, required.TimeStamp, required.Nonce, required.AppId); hasAccessed = checkResult.ResultData; if (!hasAccessed) { description = "签名验证不予通过!"; } } } if (!hasAccessed) { // 在action执行前终止请求时,应该使用填充方法Response,将不返回action方法体。 actionContext.Response = actionContext.Request.CreateResponse <Response <object> >(new Response <object> { Code = -1, HasAccessed = false, Description = description }); } base.OnActionExecuting(actionContext); } catch (Exception ex) { LogHelper.WriteLog(LogType.Error, ex); } }
public RequestSignatureOptions ForPrefix(string prefix, StringComparison prefixComparison, SignatureRequired requirement, IEnumerable <string> signingKeys) { Prefixes.Add(new SignaturePrefix() { Prefix = prefix, PrefixComparison = prefixComparison, Requirement = requirement, SigningKeys = signingKeys.ToList() }); return(this); }
public void SignatureRequired_OnValidResponseMissingReceipt_IsCorrect() { // arrange const string posRefId = "test"; const string requestId = "12"; const string receiptToSign = "MISSING RECEIPT\n DECLINE AND TRY AGAIN."; // act var response = new SignatureRequired(posRefId, requestId, receiptToSign); // assert Assert.Equal(response.GetMerchantReceipt(), receiptToSign); }
public void SignatureRequired_OnValidResponse_ReturnObjects() { // arrange var secrets = SpiClientTestUtils.SetTestSecrets(); const string jsonStr = @"{""message"":{""data"":{""merchant_receipt"": ""\nEFTPOS FROM WESTPAC\nVAAS Product 2\n275 Kent St\nSydney 2000\nAustralia\n\n\nMID 02447506\nTSP 100381990116\nTIME 26APR17 11:29\nRRN 170426000358\nTRAN 000358 CREDIT\nAmex S\nCARD............4477\nAUTH 764167\n\nPURCHASE AUD100.00\nTIP AUD5.00\n\nTOTAL AUD105.00\n\n\n (001) APPROVE WITH\n SIGNATURE\n\n\n\n\n\n\nSIGN:_______________\n\n\n\n\n\n\n\n"",""pos_ref_id"":""prchs-06-06-2019-11-49-05""},""datetime"": ""2017-04-26T11:30:21.000"",""event"": ""signature_required"",""id"": ""24""}}"; // act var msg = Message.FromJson(jsonStr, secrets); var response = new SignatureRequired(msg); // assert Assert.Equal("signature_required", msg.EventName); Assert.Equal("24", response.RequestId); Assert.Equal("prchs-06-06-2019-11-49-05", response.PosRefId); Assert.NotNull(response.GetMerchantReceipt()); }
public void TransactionFlowState_OnValidResponseSignatureRequired_ReturnObjects() { // arrange var secrets = SpiClientTestUtils.SetTestSecrets(); const string jsonStr = @"{""message"":{""data"":{""merchant_receipt"": ""\nEFTPOS FROM WESTPAC\nVAAS Product 2\n275 Kent St\nSydney 2000\nAustralia\n\n\nMID 02447506\nTSP 100381990116\nTIME 26APR17 11:29\nRRN 170426000358\nTRAN 000358 CREDIT\nAmex S\nCARD............4477\nAUTH 764167\n\nPURCHASE AUD100.00\nTIP AUD5.00\n\nTOTAL AUD105.00\n\n\n (001) APPROVE WITH\n SIGNATURE\n\n\n\n\n\n\nSIGN:_______________\n\n\n\n\n\n\n\n"",""pos_ref_id"":""prchs-06-06-2019-11-49-05""},""datetime"": ""2017-04-26T11:30:21.000"",""event"": ""signature_required"",""id"": ""24""}}"; // act var msg = Message.FromJson(jsonStr, secrets); var response = new SignatureRequired(msg); var transactionFlowState = new TransactionFlowState("1", TransactionType.SettlementEnquiry, 0, msg, $"Waiting for EFTPOS connection to make a settlement enquiry"); transactionFlowState.SignatureRequired(response, "SignatureRequired"); // assert Assert.Equal(response, transactionFlowState.SignatureRequiredMessage); Assert.True(transactionFlowState.AwaitingSignatureCheck); Assert.Equal("SignatureRequired", transactionFlowState.DisplayMessage); }
/// <summary> /// Returns true if PlayerProfileTexturePropertyValue instances are equal /// </summary> /// <param name="other">Instance of PlayerProfileTexturePropertyValue to be compared</param> /// <returns>Boolean</returns> public bool Equals(PlayerProfileTexturePropertyValue other) { if (other is null) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return (( Timestamp == other.Timestamp || Timestamp != null && Timestamp.Equals(other.Timestamp) ) && ( ProfileId == other.ProfileId || ProfileId != null && ProfileId.Equals(other.ProfileId) ) && ( ProfileName == other.ProfileName || ProfileName != null && ProfileName.Equals(other.ProfileName) ) && ( SignatureRequired == other.SignatureRequired || SignatureRequired != null && SignatureRequired.Equals(other.SignatureRequired) ) && ( Textures == other.Textures || Textures != null && Textures.Equals(other.Textures) )); }
public RequestSignatureOptions(SignatureRequired defaultRequirement, IEnumerable <string> defaultSigningKeys) { DefaultRequirement = defaultRequirement; DefaultSigningKeys = defaultSigningKeys.ToList(); }