Record Class AuthResult

java.lang.Object
java.lang.Record
google.registry.request.auth.AuthResult
Record Components:
authLevel - the level of authentication obtained
user - information about the authenticated user, if there is one
serviceAccountEmail - service account email of the authenticated app, if there is one

public record AuthResult(AuthSettings.AuthLevel authLevel, Optional<User> user, Optional<String> serviceAccountEmail) extends Record
Results of authentication for a given HTTP request, as emitted by an AuthenticationMechanism.
  • Field Details

    • NOT_AUTHENTICATED

      public static final AuthResult NOT_AUTHENTICATED
      No authentication was made.

      In the authentication step, this means that none of the configured authentication methods were able to authenticate the user. But the authorization settings may be such that it's perfectly fine not to be authenticated. The RequestAuthenticator.authorize(google.registry.request.auth.AuthSettings, jakarta.servlet.http.HttpServletRequest) method returns NOT_AUTHENTICATED in this case, as opposed to absent() if authentication failed and was required. So as a return from an authorization check, this can be treated as a success.

  • Constructor Details

  • Method Details

    • isAuthenticated

      public boolean isAuthenticated()
    • userIdForLogging

      public String userIdForLogging()
    • createApp

      public static AuthResult createApp(String email)
    • createUser

      public static AuthResult createUser(User user)
    • 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.
    • authLevel

      public AuthSettings.AuthLevel authLevel()
      Returns the value of the authLevel record component.
      Returns:
      the value of the authLevel record component
    • user

      public Optional<User> user()
      Returns the value of the user record component.
      Returns:
      the value of the user record component
    • serviceAccountEmail

      public Optional<String> serviceAccountEmail()
      Returns the value of the serviceAccountEmail record component.
      Returns:
      the value of the serviceAccountEmail record component