Class JdbcUserAuthorizationRepository

java.lang.Object
com.irurueta.authserver.authorization.infrastructure.persistence.tokens.JdbcUserAuthorizationRepository
All Implemented Interfaces:
UserAuthorizationRepository

@Repository public class JdbcUserAuthorizationRepository extends Object implements UserAuthorizationRepository
UserAuthorizationRepository over the oauth2_authorization table.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private static final String
    Statement deleting the abandoned authorizations: no token was ever issued for them, so every expiry column is null, and they were created before the given instant.
    private static final String
    Statement deleting the authorizations whose every token has expired.
    private final org.springframework.jdbc.core.simple.JdbcClient
    JDBC client used to run the statements.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    deleteAbandoned(Instant createdBefore)
    Deletes the abandoned authorizations: those that never got any token (an authorization or consent request the user never completed) and were created before an instant.
    int
    Deletes every authorization granted to a user.
    int
    Deletes the authorizations whose every token has expired.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DELETE_EXPIRED

      private static final String DELETE_EXPIRED
      Statement deleting the authorizations whose every token has expired. GREATEST ignores the tokens an authorization does not have, and is null for an authorization without any expiry, which is kept here and removed by deleteAbandoned(Instant) once it is old enough.
      See Also:
    • DELETE_ABANDONED

      private static final String DELETE_ABANDONED
      Statement deleting the abandoned authorizations: no token was ever issued for them, so every expiry column is null, and they were created before the given instant.
      See Also:
    • jdbcClient

      private final org.springframework.jdbc.core.simple.JdbcClient jdbcClient
      JDBC client used to run the statements.
  • Constructor Details

    • JdbcUserAuthorizationRepository

      public JdbcUserAuthorizationRepository()
  • Method Details

    • deleteByPrincipalName

      public int deleteByPrincipalName(String principalName)
      Description copied from interface: UserAuthorizationRepository
      Deletes every authorization granted to a user.
      Specified by:
      deleteByPrincipalName in interface UserAuthorizationRepository
      Parameters:
      principalName - name of the user the authorizations were granted to.
      Returns:
      the number of deleted authorizations.
    • deleteExpired

      public int deleteExpired(Instant now)
      Description copied from interface: UserAuthorizationRepository
      Deletes the authorizations whose every token has expired.
      Specified by:
      deleteExpired in interface UserAuthorizationRepository
      Parameters:
      now - current instant.
      Returns:
      the number of deleted authorizations.
    • deleteAbandoned

      public int deleteAbandoned(Instant createdBefore)
      Description copied from interface: UserAuthorizationRepository
      Deletes the abandoned authorizations: those that never got any token (an authorization or consent request the user never completed) and were created before an instant.
      Specified by:
      deleteAbandoned in interface UserAuthorizationRepository
      Parameters:
      createdBefore - instant before which an abandoned authorization is deleted.
      Returns:
      the number of deleted authorizations.