public override int GetHashCode() { int hashCode = -942988970; if (Context != null) { hashCode += Context.GetHashCode(); } if (AuthorizationCode != null) { hashCode += AuthorizationCode.GetHashCode(); } if (ExpiresAt != null) { hashCode += ExpiresAt.GetHashCode(); } if (Error != null) { hashCode += Error.GetHashCode(); } return(hashCode); }
public override byte[] ToBytes() { return(TLUtils.Combine( TLUtils.SignatureToBytes(Signature), PermAuthKeyId.ToBytes(), Nonce.ToBytes(), ExpiresAt.ToBytes(), EncryptedMessage.ToBytes())); }
public override int GetHashCode() { int hashCode = 1685690023; if (Context != null) { hashCode += Context.GetHashCode(); } if (AccessToken != null) { hashCode += AccessToken.GetHashCode(); } if (TokenType != null) { hashCode += TokenType.GetHashCode(); } if (ExpiresAt != null) { hashCode += ExpiresAt.GetHashCode(); } if (MerchantId != null) { hashCode += MerchantId.GetHashCode(); } if (SubscriptionId != null) { hashCode += SubscriptionId.GetHashCode(); } if (PlanId != null) { hashCode += PlanId.GetHashCode(); } if (IdToken != null) { hashCode += IdToken.GetHashCode(); } if (RefreshToken != null) { hashCode += RefreshToken.GetHashCode(); } if (ShortLived != null) { hashCode += ShortLived.GetHashCode(); } return(hashCode); }
public static void SaveValues() { using (IniFile iniFile = new IniFile(authfile)) { iniFile.IniWriteValue("tokens", "auth", Token); iniFile.IniWriteValue("expiry", "in", ExpiresIn); iniFile.IniWriteValue("expiry", "at", ExpiresAt.ToString()); iniFile.IniWriteValue("tokens", "refresh", RefreshToken); } }
public override bool Equals(Object obj) { if (obj == null || GetType() != obj.GetType()) { return(false); } Session recognitionResultsObj = obj as Session; return(UserID.Equals(recognitionResultsObj.UserID) && Start.Equals(recognitionResultsObj.Start) && ExpiresAt.Equals(ExpiresAt) && Status.Equals(Status)); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is CreateMobileAuthorizationCodeResponse other && ((Context == null && other.Context == null) || (Context?.Equals(other.Context) == true)) && ((AuthorizationCode == null && other.AuthorizationCode == null) || (AuthorizationCode?.Equals(other.AuthorizationCode) == true)) && ((ExpiresAt == null && other.ExpiresAt == null) || (ExpiresAt?.Equals(other.ExpiresAt) == true)) && ((Error == null && other.Error == null) || (Error?.Equals(other.Error) == true))); }
public override int GetHashCode() { int hash = 1; if (holdIndicator_ != null) { hash ^= HoldIndicator.GetHashCode(); } if (expiresAt_ != null) { hash ^= ExpiresAt.GetHashCode(); } if (package_ != null) { hash ^= Package.GetHashCode(); } return(hash); }
public string Encode() { MemoryStream stream = new MemoryStream(); BinaryWriter bwriter = new BinaryWriter(stream); Random r = new Random(); int bs = r.Next(1, 255); // a randomized byte to prepend after Id bwriter.Write(InviteId.ToString()); bwriter.Write((byte)bs); bwriter.Write(ReunionId.ToString()); bs = r.Next(1, 255); // a randomized byte to append after ReunionId bwriter.Write((byte)bs); bwriter.Write(ExpiresAt.ToShortDateString()); bs = r.Next(1, 255); // a randomized byte to append after ExpiresAt bwriter.Write(InviteEmail); bs = r.Next(1, 255); // a randomized byte to append after InviteEmail bwriter.Write(bs); bwriter.Close(); return(HttpUtility.UrlEncode(Convert.ToBase64String(stream.ToArray()))); }
/// <summary> /// Generate the SAS token /// </summary> /// <param name="resourceUri">Contains [hubname].azure-device.net/devices/[deviceid]</param> /// <param name="signingKey">Signing key from connection string</param> /// <param name="expiresInMinutes">Number of minutes before the generated SAS token expires</param> /// <returns></returns> private string GeneratePassword(string resourceUri, string signingKey, int expiresInMinutes) { resourceUri = WebUtility.UrlEncode(resourceUri); ExpiresAt = DateTime.UtcNow.AddMinutes(expiresInMinutes); TimeSpan secondsFromBaseTime = ExpiresAt.Subtract(EPOCH); string toSign = string.Format("{0}\n{1}", resourceUri, Math.Ceiling(secondsFromBaseTime.TotalSeconds)); string signed = ""; string result = ""; using (HMACSHA256 hmac = new HMACSHA256(Convert.FromBase64String(signingKey))) { signed = Convert.ToBase64String(hmac.ComputeHash(Encoding.UTF8.GetBytes(toSign))); } signed = WebUtility.UrlEncode(signed); result = string.Format("sr={0}&sig={1}&se={2}", resourceUri, signed, Math.Ceiling(secondsFromBaseTime.TotalSeconds)); return(result); }
public override int GetHashCode() { int hashCode = 1777017961; if (Context != null) { hashCode += Context.GetHashCode(); } if (AccessToken != null) { hashCode += AccessToken.GetHashCode(); } if (TokenType != null) { hashCode += TokenType.GetHashCode(); } if (ExpiresAt != null) { hashCode += ExpiresAt.GetHashCode(); } if (MerchantId != null) { hashCode += MerchantId.GetHashCode(); } if (SubscriptionId != null) { hashCode += SubscriptionId.GetHashCode(); } if (PlanId != null) { hashCode += PlanId.GetHashCode(); } return(hashCode); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is RenewTokenResponse other && ((Context == null && other.Context == null) || (Context?.Equals(other.Context) == true)) && ((AccessToken == null && other.AccessToken == null) || (AccessToken?.Equals(other.AccessToken) == true)) && ((TokenType == null && other.TokenType == null) || (TokenType?.Equals(other.TokenType) == true)) && ((ExpiresAt == null && other.ExpiresAt == null) || (ExpiresAt?.Equals(other.ExpiresAt) == true)) && ((MerchantId == null && other.MerchantId == null) || (MerchantId?.Equals(other.MerchantId) == true)) && ((SubscriptionId == null && other.SubscriptionId == null) || (SubscriptionId?.Equals(other.SubscriptionId) == true)) && ((PlanId == null && other.PlanId == null) || (PlanId?.Equals(other.PlanId) == true))); }
public override bool Equals(object obj) { if (obj == null) { return(false); } if (obj == this) { return(true); } return(obj is V1Order other && ((Context == null && other.Context == null) || (Context?.Equals(other.Context) == true)) && ((Errors == null && other.Errors == null) || (Errors?.Equals(other.Errors) == true)) && ((Id == null && other.Id == null) || (Id?.Equals(other.Id) == true)) && ((BuyerEmail == null && other.BuyerEmail == null) || (BuyerEmail?.Equals(other.BuyerEmail) == true)) && ((RecipientName == null && other.RecipientName == null) || (RecipientName?.Equals(other.RecipientName) == true)) && ((RecipientPhoneNumber == null && other.RecipientPhoneNumber == null) || (RecipientPhoneNumber?.Equals(other.RecipientPhoneNumber) == true)) && ((State == null && other.State == null) || (State?.Equals(other.State) == true)) && ((ShippingAddress == null && other.ShippingAddress == null) || (ShippingAddress?.Equals(other.ShippingAddress) == true)) && ((SubtotalMoney == null && other.SubtotalMoney == null) || (SubtotalMoney?.Equals(other.SubtotalMoney) == true)) && ((TotalShippingMoney == null && other.TotalShippingMoney == null) || (TotalShippingMoney?.Equals(other.TotalShippingMoney) == true)) && ((TotalTaxMoney == null && other.TotalTaxMoney == null) || (TotalTaxMoney?.Equals(other.TotalTaxMoney) == true)) && ((TotalPriceMoney == null && other.TotalPriceMoney == null) || (TotalPriceMoney?.Equals(other.TotalPriceMoney) == true)) && ((TotalDiscountMoney == null && other.TotalDiscountMoney == null) || (TotalDiscountMoney?.Equals(other.TotalDiscountMoney) == true)) && ((CreatedAt == null && other.CreatedAt == null) || (CreatedAt?.Equals(other.CreatedAt) == true)) && ((UpdatedAt == null && other.UpdatedAt == null) || (UpdatedAt?.Equals(other.UpdatedAt) == true)) && ((ExpiresAt == null && other.ExpiresAt == null) || (ExpiresAt?.Equals(other.ExpiresAt) == true)) && ((PaymentId == null && other.PaymentId == null) || (PaymentId?.Equals(other.PaymentId) == true)) && ((BuyerNote == null && other.BuyerNote == null) || (BuyerNote?.Equals(other.BuyerNote) == true)) && ((CompletedNote == null && other.CompletedNote == null) || (CompletedNote?.Equals(other.CompletedNote) == true)) && ((RefundedNote == null && other.RefundedNote == null) || (RefundedNote?.Equals(other.RefundedNote) == true)) && ((CanceledNote == null && other.CanceledNote == null) || (CanceledNote?.Equals(other.CanceledNote) == true)) && ((Tender == null && other.Tender == null) || (Tender?.Equals(other.Tender) == true)) && ((OrderHistory == null && other.OrderHistory == null) || (OrderHistory?.Equals(other.OrderHistory) == true)) && ((PromoCode == null && other.PromoCode == null) || (PromoCode?.Equals(other.PromoCode) == true)) && ((BtcReceiveAddress == null && other.BtcReceiveAddress == null) || (BtcReceiveAddress?.Equals(other.BtcReceiveAddress) == true)) && ((BtcPriceSatoshi == null && other.BtcPriceSatoshi == null) || (BtcPriceSatoshi?.Equals(other.BtcPriceSatoshi) == true))); }
public override string ToString() { return(string.Format("{0} {1} {2}", ID, ExpiresAt.ToString("hh:mm:ss.fff"), Expired)); }
public override int GetHashCode() { int hashCode = 820864276; if (Context != null) { hashCode += Context.GetHashCode(); } if (Errors != null) { hashCode += Errors.GetHashCode(); } if (Id != null) { hashCode += Id.GetHashCode(); } if (BuyerEmail != null) { hashCode += BuyerEmail.GetHashCode(); } if (RecipientName != null) { hashCode += RecipientName.GetHashCode(); } if (RecipientPhoneNumber != null) { hashCode += RecipientPhoneNumber.GetHashCode(); } if (State != null) { hashCode += State.GetHashCode(); } if (ShippingAddress != null) { hashCode += ShippingAddress.GetHashCode(); } if (SubtotalMoney != null) { hashCode += SubtotalMoney.GetHashCode(); } if (TotalShippingMoney != null) { hashCode += TotalShippingMoney.GetHashCode(); } if (TotalTaxMoney != null) { hashCode += TotalTaxMoney.GetHashCode(); } if (TotalPriceMoney != null) { hashCode += TotalPriceMoney.GetHashCode(); } if (TotalDiscountMoney != null) { hashCode += TotalDiscountMoney.GetHashCode(); } if (CreatedAt != null) { hashCode += CreatedAt.GetHashCode(); } if (UpdatedAt != null) { hashCode += UpdatedAt.GetHashCode(); } if (ExpiresAt != null) { hashCode += ExpiresAt.GetHashCode(); } if (PaymentId != null) { hashCode += PaymentId.GetHashCode(); } if (BuyerNote != null) { hashCode += BuyerNote.GetHashCode(); } if (CompletedNote != null) { hashCode += CompletedNote.GetHashCode(); } if (RefundedNote != null) { hashCode += RefundedNote.GetHashCode(); } if (CanceledNote != null) { hashCode += CanceledNote.GetHashCode(); } if (Tender != null) { hashCode += Tender.GetHashCode(); } if (OrderHistory != null) { hashCode += OrderHistory.GetHashCode(); } if (PromoCode != null) { hashCode += PromoCode.GetHashCode(); } if (BtcReceiveAddress != null) { hashCode += BtcReceiveAddress.GetHashCode(); } if (BtcPriceSatoshi != null) { hashCode += BtcPriceSatoshi.GetHashCode(); } return(hashCode); }
/// <summary> /// Returns true if the token is within 10 minutes of expiring. /// </summary> /// <returns></returns> public bool IsCloseToExpiry() { return(ExpiresAt.Subtract(DateTime.UtcNow).TotalMinutes < 10); }
public override int GetHashCode() { int hashCode = -657729285; if (Recipient != null) { hashCode += Recipient.GetHashCode(); } if (ExpiresAt != null) { hashCode += ExpiresAt.GetHashCode(); } if (AutoCompleteDuration != null) { hashCode += AutoCompleteDuration.GetHashCode(); } if (ScheduleType != null) { hashCode += ScheduleType.GetHashCode(); } if (PickupAt != null) { hashCode += PickupAt.GetHashCode(); } if (PickupWindowDuration != null) { hashCode += PickupWindowDuration.GetHashCode(); } if (PrepTimeDuration != null) { hashCode += PrepTimeDuration.GetHashCode(); } if (Note != null) { hashCode += Note.GetHashCode(); } if (PlacedAt != null) { hashCode += PlacedAt.GetHashCode(); } if (AcceptedAt != null) { hashCode += AcceptedAt.GetHashCode(); } if (RejectedAt != null) { hashCode += RejectedAt.GetHashCode(); } if (ReadyAt != null) { hashCode += ReadyAt.GetHashCode(); } if (ExpiredAt != null) { hashCode += ExpiredAt.GetHashCode(); } if (PickedUpAt != null) { hashCode += PickedUpAt.GetHashCode(); } if (CanceledAt != null) { hashCode += CanceledAt.GetHashCode(); } if (CancelReason != null) { hashCode += CancelReason.GetHashCode(); } if (IsCurbsidePickup != null) { hashCode += IsCurbsidePickup.GetHashCode(); } if (CurbsidePickupDetails != null) { hashCode += CurbsidePickupDetails.GetHashCode(); } return(hashCode); }
public override int GetHashCode() { return(UserID ^ Start.GetHashCode() ^ ExpiresAt.GetHashCode() ^ Status.GetHashCode()); }
/// <summary> /// Check if token expired by time /// (tolerance applies) /// </summary> /// <param name="dateTime">Time for check</param> /// <returns>true if expired</returns> private bool Expired(DateTime dateTime) { return(ExpiresAt.CompareTo(dateTime) <= 0); }
public string Serialize() { using var ms = new MemoryStream(); using var writer = XmlDictionaryWriter.CreateTextWriter(ms, Encoding.UTF8, false); // <t:RequestSecurityTokenResponseCollection> writer.WriteStartElement(WsTrustConstants_1_3.PreferredPrefix, WsFederationConstants.Elements.RequestSecurityTokenResponseCollection, WsTrustConstants.Namespaces.WsTrust1_3); // <t:RequestSecurityTokenResponse> writer.WriteStartElement(WsTrustConstants_1_3.PreferredPrefix, WsTrustConstants.Elements.RequestSecurityTokenResponse, WsTrustConstants.Namespaces.WsTrust1_3); // @Context writer.WriteAttributeString(WsFederationConstants.Attributes.Context, Context); // <t:Lifetime> writer.WriteStartElement(WsTrustConstants.Elements.Lifetime, WsTrustConstants.Namespaces.WsTrust1_3); // <wsu:Created></wsu:Created> writer.WriteElementString(WsUtility.PreferredPrefix, WsUtility.Elements.Created, WsUtility.Namespace, CreatedAt.ToString(SamlConstants.GeneratedDateTimeFormat, DateTimeFormatInfo.InvariantInfo)); // <wsu:Expires></wsu:Expires> writer.WriteElementString(WsUtility.PreferredPrefix, WsUtility.Elements.Expires, WsUtility.Namespace, ExpiresAt.ToString(SamlConstants.GeneratedDateTimeFormat, DateTimeFormatInfo.InvariantInfo)); // </t:Lifetime> writer.WriteEndElement(); // <wsp:AppliesTo> writer.WriteStartElement(WsPolicy.PreferredPrefix, WsPolicy.Elements.AppliesTo, WsPolicy.Namespace); // <wsa:EndpointReference> writer.WriteStartElement(WsAddressing.PreferredPrefix, WsAddressing.Elements.EndpointReference, WsAddressing.Namespace); // <wsa:Address></wsa:Address> writer.WriteElementString(WsAddressing.PreferredPrefix, WsAddressing.Elements.Address, WsAddressing.Namespace, AppliesTo); writer.WriteEndElement(); // </wsa:EndpointReference> writer.WriteEndElement(); // </wsp:AppliesTo> // <t:RequestedSecurityToken> writer.WriteStartElement(WsTrustConstants_1_3.PreferredPrefix, WsTrustConstants.Elements.RequestedSecurityToken, WsTrustConstants.Namespaces.WsTrust1_3); // write assertion SecurityTokenHandler.WriteToken(writer, RequestedSecurityToken); // </t:RequestedSecurityToken> writer.WriteEndElement(); // </t:RequestSecurityTokenResponse> writer.WriteEndElement(); // <t:RequestSecurityTokenResponseCollection> writer.WriteEndElement(); writer.Flush(); return(Encoding.UTF8.GetString(ms.ToArray())); }
/// <summary> /// Check if token expired by time /// (tolerance applies) /// </summary> /// <param name="dateTime">Time for check</param> /// <param name="tolerance">tolerance in seconds</param> /// <returns>true if expired</returns> public bool Expired(DateTime dateTime, long tolerance) { return(ExpiresAt.CompareTo(dateTime.AddSeconds(-tolerance)) <= 0); }
public virtual bool HasExpired() { return(ExpiresAt.CompareTo(DateTime.Now) <= 0); }