use of com.microsoft.azure.oidc.exception.GeneralException in project azure-tools-for-java by Microsoft.
the class SimpleAuthenticationFilter method doFilter.
@Override
public void doFilter(final ServletRequest request, final ServletResponse response, final FilterChain chain) throws IOException, ServletException {
final HttpServletRequest httpRequest = (HttpServletRequest) request;
final HttpServletResponse httpResponse = (HttpServletResponse) response;
try {
final String tokenString = getHelper().getTokenString(httpRequest, httpResponse, TOKEN_NAME);
final String errorString = getHelper().getErrorString(httpRequest, ERROR_NAME);
final Boolean isAuthenticationError = getHelper().isAuthenticationError(errorString);
final Boolean isUnauthenticated = tokenString == NO_TOKEN_STRING;
if (isUnauthenticated || isAuthenticationError) {
getHelper().doUnauthenticatedAction(chain, httpRequest, httpResponse, NO_TOKEN, isAuthenticationError);
return;
}
final Token token = getHelper().getToken(tokenString);
final Boolean isInvalidToken = !getHelper().isValidToken(token);
if (isInvalidToken) {
getHelper().doInvalidTokenAction(httpResponse);
return;
}
final Boolean isActiveToken = getHelper().isActiveToken(token);
if (isActiveToken) {
getHelper().doActiveTokenAction(chain, httpRequest, httpResponse, token);
return;
}
getHelper().doUnauthenticatedAction(chain, httpRequest, httpResponse, token, isAuthenticationError);
} catch (GeneralException | PreconditionException e) {
getHelper().doExceptionAction(httpResponse, e);
}
}
Aggregations