Class IdCommandContext<E extends IdProtocolMessageType,S extends IdSessionType>

java.lang.Object
com.io7m.idstore.server.controller.command_exec.IdCommandContext<E,S>
Type Parameters:
E - The type of error messages
S - The type of sessions
Direct Known Subclasses:
IdACommandContext, IdUCommandContext

public abstract class IdCommandContext<E extends IdProtocolMessageType,S extends IdSessionType> extends Object
The context for execution of a command (or set of commands in a transaction).
  • Constructor Details

    • IdCommandContext

      public IdCommandContext(com.io7m.repetoir.core.RPServiceDirectoryType inServices, UUID inRequestId, IdDatabaseTransactionType inTransaction, S inSession, String inRemoteHost, String inRemoteUserAgent)
      The context for execution of a command (or set of commands in a transaction).
      Parameters:
      inServices - The service directory
      inRequestId - The request ID
      inTransaction - The transaction
      inSession - The user session
      inRemoteHost - The remote host
      inRemoteUserAgent - The remote user agent
  • Method Details

    • session

      public final S session()
      Returns:
      The user session
    • remoteHost

      public final String remoteHost()
      Returns:
      The remote host
    • remoteUserAgent

      public final String remoteUserAgent()
      Returns:
      The remote user agent
    • services

      public final com.io7m.repetoir.core.RPServiceDirectoryType services()
      Returns:
      The service directory used during execution
    • requestId

      public final UUID requestId()
      Returns:
      The ID of the incoming request
    • transaction

      public final IdDatabaseTransactionType transaction()
      Returns:
      The database transaction
    • tracer

      public final io.opentelemetry.api.trace.Tracer tracer()
      Returns:
      The OpenTelemetry tracer
    • now

      public final OffsetDateTime now()
      Returns:
      The current time
    • failFormatted

      public final IdCommandExecutionFailure failFormatted(int statusCode, IdErrorCode errorCode, String messageId, Object... args)
      Produce an exception indicating an error, with a formatted error message.
      Parameters:
      statusCode - The HTTP status code
      errorCode - The error code
      messageId - The string resource message ID
      args - The string resource format arguments
      Returns:
      An execution failure
    • fail

      public final IdCommandExecutionFailure fail(int statusCode, IdErrorCode errorCode, String message)
      Produce an exception indicating an error, with a string constant message.
      Parameters:
      statusCode - The HTTP status code
      errorCode - The error code
      message - The string message
      Returns:
      An execution failure
    • failDatabase

      public final IdCommandExecutionFailure failDatabase(IdDatabaseException e)
      Produce an exception indicating a database error.
      Parameters:
      e - The database exception
      Returns:
      An execution failure
    • failSecurity

      Produce an exception indicating a security policy error.
      Parameters:
      e - The security exception
      Returns:
      An execution failure
    • failMail

      public final IdCommandExecutionFailure failMail(IdEmail email, Exception e)
      Produce an exception indicating a mail system error.
      Parameters:
      email - The email address
      e - The mail system exception
      Returns:
      An execution failure
    • failValidity

      Produce an exception indicating a validation error.
      Parameters:
      e - The exception
      Returns:
      An execution failure
    • failPassword

      Produce an exception indicating a password format error.
      Parameters:
      e - The exception
      Returns:
      An execution failure
    • failProtocol

      Produce an exception indicating a protocol error.
      Parameters:
      e - The exception
      Returns:
      An execution failure
    • securityCheck

      public void securityCheck(IdSecActionType action) throws IdSecurityException, IdCommandExecutionFailure
      Check the given action against the security policy.
      Parameters:
      action - The action
      Throws:
      IdSecurityException - On errors
      IdCommandExecutionFailure - On errors