Record Class KnoluxS3ConnectionDetails

java.lang.Object
java.lang.Record
com.knolux.s3.KnoluxS3ConnectionDetails

public record KnoluxS3ConnectionDetails(String endpoint, String region, String accessKey, String secretKey, boolean forcePathStyle, boolean removePathPrefix, String pathPrefix, boolean trustSelfSigned) extends Record
S3 連線參數的不可變值物件,作為 KnoluxS3ClientFactory 建立與快取 client 的鍵。

可從靜態 KnoluxS3Properties 建立,也可由 KnoluxS3OperationSpec.toConnectionDetails() 在執行期間從請求 payload 動態組裝。

快取鍵安全性

toCacheKey() 中的 accessKey 以 SHA-256 摘要取代明文, secretKey 則完全不納入,防止憑證以明文出現在 heap 中的 Map key 字串、 日誌或 heap dump。

See Also:
  • Constructor Details

    • KnoluxS3ConnectionDetails

      public KnoluxS3ConnectionDetails(String endpoint, String region, String accessKey, String secretKey, boolean forcePathStyle, boolean removePathPrefix, String pathPrefix, boolean trustSelfSigned)
      Creates an instance of a KnoluxS3ConnectionDetails record class.
      Parameters:
      endpoint - the value for the endpoint record component
      region - the value for the region record component
      accessKey - the value for the accessKey record component
      secretKey - the value for the secretKey record component
      forcePathStyle - the value for the forcePathStyle record component
      removePathPrefix - the value for the removePathPrefix record component
      pathPrefix - the value for the pathPrefix record component
      trustSelfSigned - the value for the trustSelfSigned record component
  • Method Details

    • of

      從靜態 KnoluxS3Properties 建立連線參數(靜態模式工廠方法)。
      Parameters:
      props - 已綁定的設定屬性
      Returns:
      對應的連線參數
    • toCacheKey

      public String toCacheKey()
      產生 KnoluxS3ClientFactory 使用的 client 快取鍵。
      • secretKey 完全不納入,防止洩漏。
      • accessKey 以 SHA-256 摘要(hex)代替明文,避免憑證以字串形式存入 Map key。
      • 所有可為 nullString 欄位以空字串代入, 防止不同欄位為 null 時產生相同 key。
      Returns:
      長度固定、不含敏感明文的快取鍵字串
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • endpoint

      public String endpoint()
      Returns the value of the endpoint record component.
      Returns:
      the value of the endpoint record component
    • region

      public String region()
      Returns the value of the region record component.
      Returns:
      the value of the region record component
    • accessKey

      public String accessKey()
      Returns the value of the accessKey record component.
      Returns:
      the value of the accessKey record component
    • secretKey

      public String secretKey()
      Returns the value of the secretKey record component.
      Returns:
      the value of the secretKey record component
    • forcePathStyle

      public boolean forcePathStyle()
      Returns the value of the forcePathStyle record component.
      Returns:
      the value of the forcePathStyle record component
    • removePathPrefix

      public boolean removePathPrefix()
      Returns the value of the removePathPrefix record component.
      Returns:
      the value of the removePathPrefix record component
    • pathPrefix

      public String pathPrefix()
      Returns the value of the pathPrefix record component.
      Returns:
      the value of the pathPrefix record component
    • trustSelfSigned

      public boolean trustSelfSigned()
      Returns the value of the trustSelfSigned record component.
      Returns:
      the value of the trustSelfSigned record component