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 Summary
ConstructorsConstructorDescriptionSignedLinkSpec(String subject, String purpose, String target, Map<String, Object> attributes, Duration ttl, LinkRedemption redemption) Creates an instance of aSignedLinkSpecrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of theattributesrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.purpose()Returns the value of thepurposerecord component.Returns the value of theredemptionrecord component.subject()Returns the value of thesubjectrecord component.target()Returns the value of thetargetrecord component.final StringtoString()Returns a string representation of this record class.ttl()Returns the value of thettlrecord component.
-
Constructor Details
-
SignedLinkSpec
public SignedLinkSpec(String subject, String purpose, String target, Map<String, Object> attributes, Duration ttl, LinkRedemption redemption) Creates an instance of aSignedLinkSpecrecord class.- Parameters:
subject- the value for thesubjectrecord componentpurpose- the value for thepurposerecord componenttarget- the value for thetargetrecord componentattributes- the value for theattributesrecord componentttl- the value for thettlrecord componentredemption- the value for theredemptionrecord component
-
-
Method Details
-
toString
-
hashCode
-
equals
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 withObjects::equals(Object,Object). -
subject
-
purpose
-
target
-
attributes
Returns the value of theattributesrecord component.- Returns:
- the value of the
attributesrecord component
-
ttl
-
redemption
Returns the value of theredemptionrecord component.- Returns:
- the value of the
redemptionrecord component
-