Record Class SignedLinkSpec

java.lang.Object
java.lang.Record
io.leandev.appfuse.security.link.SignedLinkSpec
Record Components:
subject - 身分識別(不透明字串,如 email / username),必填
purpose - 連結用途(消費端自定義),必填
target - 導向目標(相對路徑;null / 空字串表示預設首頁)
attributes - 泛用屬性袋(如租戶脈絡;consume 後原樣取回,可為 null)
ttl - 有效期,必填且須為正
redemption - 贖回政策(null 視為 LinkRedemption.SINGLE_USE)

public record SignedLinkSpec(String subject, String purpose, String target, Map<String,Object> attributes, Duration ttl, LinkRedemption redemption) extends Record

簽發簽章連結的輸入參數

以 builder 形式提供給 SignedLinkService.issue(SignedLinkSpec)redemption 缺省為 LinkRedemption#SINGLE_USE;attributes 缺省為空 Map。

範例:

String token = signedLinkService.issue(
    SignedLinkSpec.builder()
        .subject("alice@example.com")
        .purpose("passwordless-login")
        .ttl(Duration.ofMinutes(15))
        .build());
Since:
1.0
  • Constructor Details

    • SignedLinkSpec

      public SignedLinkSpec(String subject, String purpose, String target, Map<String,Object> attributes, Duration ttl, LinkRedemption redemption)
      Creates an instance of a SignedLinkSpec record class.
      Parameters:
      subject - the value for the subject record component
      purpose - the value for the purpose record component
      target - the value for the target record component
      attributes - the value for the attributes record component
      ttl - the value for the ttl record component
      redemption - the value for the redemption record component
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • subject

      public String subject()
      Returns the value of the subject record component.
      Returns:
      the value of the subject record component
    • purpose

      public String purpose()
      Returns the value of the purpose record component.
      Returns:
      the value of the purpose record component
    • target

      public String target()
      Returns the value of the target record component.
      Returns:
      the value of the target record component
    • attributes

      public Map<String,Object> attributes()
      Returns the value of the attributes record component.
      Returns:
      the value of the attributes record component
    • ttl

      public Duration ttl()
      Returns the value of the ttl record component.
      Returns:
      the value of the ttl record component
    • redemption

      public LinkRedemption redemption()
      Returns the value of the redemption record component.
      Returns:
      the value of the redemption record component