CallerPrincipalCallback (JASPIC 3.1 API Documentation - Apache Tomcat 11.0.23)
Description: declaration: package: jakarta.security.auth.message.callback, class: CallerPrincipalCallback

# Class CallerPrincipalCallback

java.lang.Object
jakarta.security.auth.message.callback.CallerPrincipalCallback

All Implemented Interfaces:
  `Callback`

public class CallerPrincipalCallback extends Object implements Callback
Callback that enables an authentication module to inform the runtime of the caller principal or name of the caller principal. The callback handler populates the given Subject with the authenticated principal, or returns the principal/name that was provided.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `CallerPrincipalCallback(Subject subject, String name)`
  Constructs a callback with a Subject and a caller name.
  `CallerPrincipalCallback(Subject subject, Principal principal)`
  Constructs a callback with a Subject and a Principal.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `String`
  `getName()`
  Returns the name associated with this callback, or `null` if a Principal was provided instead.
  `Principal`
  `getPrincipal()`
  Returns the Principal associated with this callback, or `null` if a name was provided instead.
  `Subject`
  `getSubject()`
  Returns the Subject associated with this callback.

  ### Methods inherited from class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Constructor Details

  - ### CallerPrincipalCallback

    public CallerPrincipalCallback(Subject subject, Principal principal)
    Constructs a callback with a Subject and a Principal. The callback handler will add the principal to the subject.
    Parameters:
      `subject` - the subject to which the principal will be added
      `principal` - the principal representing the caller

  - ### CallerPrincipalCallback

    public CallerPrincipalCallback(Subject subject, String name)
    Constructs a callback with a Subject and a caller name. The callback handler will create a principal from the name and add it to the subject.
    Parameters:
      `subject` - the subject to which the principal will be added
      `name` - the name of the caller

- ## Method Details

  - ### getSubject

    public Subject getSubject()
    Returns the Subject associated with this callback.
    Returns:
      the Subject

  - ### getPrincipal

    public Principal getPrincipal()
    Returns the Principal associated with this callback, or `null` if a name was provided instead.
    Returns:
      the Principal, or `null`

  - ### getName

    public String getName()
    Returns the name associated with this callback, or `null` if a Principal was provided instead.
    Returns:
      the name, or `null`