com.networknt.oauth.token.handler.Oauth2RefreshTokenRefreshTokenGetHandler Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of oauth2-refresh-token Show documentation
Show all versions of oauth2-refresh-token Show documentation
A micro service server that manages refresh token.
package com.networknt.oauth.token.handler;
import com.hazelcast.map.IMap;
import com.networknt.config.Config;
import com.networknt.handler.LightHttpHandler;
import com.networknt.oauth.cache.CacheStartupHookProvider;
import com.networknt.oauth.cache.model.RefreshToken;
import io.undertow.server.HttpServerExchange;
import io.undertow.util.Headers;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class Oauth2RefreshTokenRefreshTokenGetHandler extends RefreshTokenAuditHandler implements LightHttpHandler {
private static final String REFRESH_TOKEN_NOT_FOUND = "ERR12029";
private static Logger logger = LoggerFactory.getLogger(Oauth2RefreshTokenRefreshTokenGetHandler.class);
@SuppressWarnings("unchecked")
@Override
public void handleRequest(HttpServerExchange exchange) throws Exception {
String refreshToken = exchange.getQueryParameters().get("refreshToken").getFirst();
if(logger.isDebugEnabled()) logger.debug("refreshToken = " + refreshToken);
IMap tokens = CacheStartupHookProvider.hz.getMap("tokens");
RefreshToken token = tokens.get(refreshToken);
if(token == null) {
setExchangeStatus(exchange, REFRESH_TOKEN_NOT_FOUND, refreshToken);
} else {
exchange.getResponseHeaders().add(Headers.CONTENT_TYPE, "application/json");
exchange.getResponseSender().send(Config.getInstance().getMapper().writeValueAsString(token));
}
processAudit(exchange);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy