Record Class PermissionKey

java.lang.Object
java.lang.Record
com.chaosguide.iam.vertex.authz.PermissionKey

public record PermissionKey(String resource, String action) extends Record
不可变的权限标识,统一用 resource:action 表示,并直接作为 Spring Security authority。
  • Constructor Summary

    Constructors
    Constructor
    Description
    PermissionKey(String resource, String action)
    Creates an instance of a PermissionKey record class.
  • Method Summary

    Modifier and Type
    Method
    Description
    Returns the value of the action record component.
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    parse(String authority)
    从 authority 字符串反向解析权限 key;格式不合法时尽早失败,避免生成半截权限。
    Returns the value of the resource record component.
     
    Returns a string representation of this record class.

    Methods inherited from class Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • PermissionKey

      public PermissionKey(String resource, String action)
      Creates an instance of a PermissionKey record class.
      Parameters:
      resource - the value for the resource record component
      action - the value for the action record component
  • Method Details

    • toAuthority

      public String toAuthority()
    • parse

      public static PermissionKey parse(String authority)
      从 authority 字符串反向解析权限 key;格式不合法时尽早失败,避免生成半截权限。
    • toString

      public 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.
    • resource

      public String resource()
      Returns the value of the resource record component.
      Returns:
      the value of the resource record component
    • action

      public String action()
      Returns the value of the action record component.
      Returns:
      the value of the action record component