|
@@ -82,7 +82,7 @@ public final class JdbcOneTimeTokenService implements OneTimeTokenService, Dispo
|
|
// @formatter:on
|
|
// @formatter:on
|
|
|
|
|
|
// @formatter:off
|
|
// @formatter:off
|
|
- private static final String SAVE_AUTHORIZED_CLIENT_SQL = "INSERT INTO " + TABLE_NAME
|
|
|
|
|
|
+ private static final String SAVE_ONE_TIME_TOKEN_SQL = "INSERT INTO " + TABLE_NAME
|
|
+ " (" + COLUMN_NAMES + ") VALUES (?, ?, ?)";
|
|
+ " (" + COLUMN_NAMES + ") VALUES (?, ?, ?)";
|
|
// @formatter:on
|
|
// @formatter:on
|
|
|
|
|
|
@@ -97,7 +97,7 @@ public final class JdbcOneTimeTokenService implements OneTimeTokenService, Dispo
|
|
// @formatter:on
|
|
// @formatter:on
|
|
|
|
|
|
// @formatter:off
|
|
// @formatter:off
|
|
- private static final String DELETE_SESSIONS_BY_EXPIRY_TIME_QUERY = "DELETE FROM "
|
|
|
|
|
|
+ private static final String DELETE_ONE_TIME_TOKENS_BY_EXPIRY_TIME_QUERY = "DELETE FROM "
|
|
+ TABLE_NAME
|
|
+ TABLE_NAME
|
|
+ " WHERE expires_at < ?";
|
|
+ " WHERE expires_at < ?";
|
|
// @formatter:on
|
|
// @formatter:on
|
|
@@ -113,7 +113,7 @@ public final class JdbcOneTimeTokenService implements OneTimeTokenService, Dispo
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Sets the chron expression used for cleaning up expired sessions. The default is to
|
|
|
|
|
|
+ * Sets the chron expression used for cleaning up expired tokens. The default is to
|
|
* run hourly.
|
|
* run hourly.
|
|
*
|
|
*
|
|
* For more advanced use cases the cleanupCron may be set to null which will disable
|
|
* For more advanced use cases the cleanupCron may be set to null which will disable
|
|
@@ -141,7 +141,7 @@ public final class JdbcOneTimeTokenService implements OneTimeTokenService, Dispo
|
|
private void insertOneTimeToken(OneTimeToken oneTimeToken) {
|
|
private void insertOneTimeToken(OneTimeToken oneTimeToken) {
|
|
List<SqlParameterValue> parameters = this.oneTimeTokenParametersMapper.apply(oneTimeToken);
|
|
List<SqlParameterValue> parameters = this.oneTimeTokenParametersMapper.apply(oneTimeToken);
|
|
PreparedStatementSetter pss = new ArgumentPreparedStatementSetter(parameters.toArray());
|
|
PreparedStatementSetter pss = new ArgumentPreparedStatementSetter(parameters.toArray());
|
|
- this.jdbcOperations.update(SAVE_AUTHORIZED_CLIENT_SQL, pss);
|
|
|
|
|
|
+ this.jdbcOperations.update(SAVE_ONE_TIME_TOKEN_SQL, pss);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -192,7 +192,7 @@ public final class JdbcOneTimeTokenService implements OneTimeTokenService, Dispo
|
|
public void cleanupExpiredTokens() {
|
|
public void cleanupExpiredTokens() {
|
|
List<SqlParameterValue> parameters = List.of(new SqlParameterValue(Types.TIMESTAMP, Instant.now()));
|
|
List<SqlParameterValue> parameters = List.of(new SqlParameterValue(Types.TIMESTAMP, Instant.now()));
|
|
PreparedStatementSetter pss = new ArgumentPreparedStatementSetter(parameters.toArray());
|
|
PreparedStatementSetter pss = new ArgumentPreparedStatementSetter(parameters.toArray());
|
|
- int deletedCount = this.jdbcOperations.update(DELETE_SESSIONS_BY_EXPIRY_TIME_QUERY, pss);
|
|
|
|
|
|
+ int deletedCount = this.jdbcOperations.update(DELETE_ONE_TIME_TOKENS_BY_EXPIRY_TIME_QUERY, pss);
|
|
if (this.logger.isDebugEnabled()) {
|
|
if (this.logger.isDebugEnabled()) {
|
|
this.logger.debug("Cleaned up " + deletedCount + " expired tokens");
|
|
this.logger.debug("Cleaned up " + deletedCount + " expired tokens");
|
|
}
|
|
}
|