Record Class Subject
java.lang.Object
java.lang.Record
io.kroxylicious.proxy.authentication.Subject
- Record Components:
principals- the set of identifiers associated with this subject.
Represents an actor in the system.
Subjects are composed of a possibly-empty set of identifiers represented as Principal instances.
An anonymous actor is represented by a Subject with an empty set of principals.
As a convenience, anonymous() returns such a subject.
The principals included in a subject might comprise the following:
- information proven by a client, such as a SASL authorized id,
- information known about the client, such as the remote peer's IP address,
- information obtained about the client from a trusted source, such as lookup up role or group information from a directory.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionallPrincipalsOfType(Class<P> principalType) Returns all principals of the given type.static SubjectReturns the anonymous subject (no principals).final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.booleanReturns whether this is the anonymous subject.Returns the value of theprincipalsrecord component.final StringtoString()Returns a string representation of this record class.uniquePrincipalOfType(Class<P> uniquePrincipalType) Returns the unique principal of the given type, if present.
-
Constructor Details
-
Subject
Creates a subject from the given principals.- Parameters:
principals- the principals
-
Subject
Creates a subject from the given principal set. Validates that non-empty subjects have exactly oneUserprincipal.- Parameters:
principals- the principals
-
-
Method Details
-
anonymous
Returns the anonymous subject (no principals).- Returns:
- the anonymous subject
-
uniquePrincipalOfType
Returns the unique principal of the given type, if present.- Type Parameters:
P- the principal type- Parameters:
uniquePrincipalType- the principal type, which must be annotated withUnique- Returns:
- the principal, or empty
-
isAnonymous
public boolean isAnonymous()Returns whether this is the anonymous subject.- Returns:
- true if this subject has no principals
-
allPrincipalsOfType
Returns all principals of the given type.- Type Parameters:
P- the principal type- Parameters:
principalType- the principal type- Returns:
- the matching principals
-
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. -
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. -
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). -
principals
Returns the value of theprincipalsrecord component.- Returns:
- the value of the
principalsrecord component
-