Record Class Principal

java.lang.Object
java.lang.Record
io.jenkins.plugins.authcommons.Principal
Record Components:
sid - the identifier to store in authorization configuration, e.g. a username or a group object id
type - whether this is a user or a group
displayName - a human readable name, e.g. the user's full name; the factory methods fall back to the SID
description - optional secondary information that helps tell similar principals apart, e.g. an email address
avatarUrl - optional URL of a small picture of the principal, e.g. a profile photo; it is loaded by the browser, so it is typically served by the providing plugin with the same permission checks as the search

public record Principal(String sid, PrincipalType type, String displayName, String description, String avatarUrl) extends Record
A user or group known to the security realm, as returned by a PrincipalSearchProvider.
  • Constructor Details

    • Principal

      public Principal(@NonNull String sid, @NonNull PrincipalType type, @NonNull String displayName, @CheckForNull String description, @CheckForNull String avatarUrl)
      Creates an instance of a Principal record class.
      Parameters:
      sid - the value for the sid record component
      type - the value for the type record component
      displayName - the value for the displayName record component
      description - the value for the description record component
      avatarUrl - the value for the avatarUrl record component
    • Principal

      public Principal(@NonNull String sid, @NonNull PrincipalType type, @NonNull String displayName, @CheckForNull String description)
  • Method Details

    • user

      public static Principal user(@NonNull String sid, @CheckForNull String displayName, @CheckForNull String description)
    • group

      public static Principal group(@NonNull String sid, @CheckForNull String displayName, @CheckForNull String description)
    • withAvatarUrl

      @NonNull public Principal withAvatarUrl(@CheckForNull String avatarUrl)
      Returns:
      a copy of this principal with the given avatar URL
    • toJson

      @NonNull public net.sf.json.JSONObject toJson()
    • 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.
    • sid

      @NonNull public String sid()
      Returns the value of the sid record component.
      Returns:
      the value of the sid record component
    • type

      @NonNull public PrincipalType type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • displayName

      @NonNull public String displayName()
      Returns the value of the displayName record component.
      Returns:
      the value of the displayName record component
    • description

      @CheckForNull public String description()
      Returns the value of the description record component.
      Returns:
      the value of the description record component
    • avatarUrl

      @CheckForNull public String avatarUrl()
      Returns the value of the avatarUrl record component.
      Returns:
      the value of the avatarUrl record component