
com.formkiq.server.config.RaceConditionFixedJdbcTokenStore Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of formkiq-server Show documentation
Show all versions of formkiq-server Show documentation
Server-side integration for the FormKiQ ios application
package com.formkiq.server.config;
import javax.sql.DataSource;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.store.JdbcTokenStore;
/**
* Custom JDBCTokenStore to return a 403 when a Race Condition occurs in Spring
* OAuth. It seems the Spring OAuth people are unable / unwilling to fix this so
* a 403 is better than a 500 and can retry.
*
*/
public class RaceConditionFixedJdbcTokenStore extends JdbcTokenStore {
/**
* constructor.
* @param dataSource {@link DataSource}
*/
public RaceConditionFixedJdbcTokenStore(final DataSource dataSource) {
super(dataSource);
}
@Override
public void storeAccessToken(final OAuth2AccessToken token,
final OAuth2Authentication authentication) {
try {
super.storeAccessToken(token, authentication);
} catch (RuntimeException e) {
throw new AccessDeniedException(
"Server too busy. Please wait and try again");
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy