HTTPResponse createResponse(final HttpURLConnection conn, final String out) throws IOException { final HTTPResponse response = new HTTPResponse(conn.getResponseCode()); final String location = conn.getHeaderField("Location"); if (!StringHelper.isBlank(location)) { response.setLocation(new URL(location)); } try { response.setContentType(conn.getContentType()); } catch (final ParseException e) { throw new IOException("Couldn't parse Content-Type header: " + e.getMessage(), e); } response.setCacheControl(conn.getHeaderField("Cache-Control")); response.setPragma(conn.getHeaderField("Pragma")); response.setWWWAuthenticate(conn.getHeaderField("WWW-Authenticate")); if (!StringHelper.isBlank(out)) { response.setContent(out); } return response; }
HTTPResponse createResponse(final HttpURLConnection conn, final String out) throws IOException { final HTTPResponse response = new HTTPResponse(conn.getResponseCode()); final String location = conn.getHeaderField("Location"); if (!StringHelper.isBlank(location)) { try { response.setLocation(new URI(location)); } catch (URISyntaxException e) { throw new IOException("Invalid location URI " + location, e); } } try { response.setContentType(conn.getContentType()); } catch (final ParseException e) { throw new IOException("Couldn't parse Content-Type header: " + e.getMessage(), e); } response.setCacheControl(conn.getHeaderField("Cache-Control")); response.setPragma(conn.getHeaderField("Pragma")); response.setWWWAuthenticate(conn.getHeaderField("WWW-Authenticate")); if (!StringHelper.isBlank(out)) { response.setContent(out); } return response; }
HTTPResponse createResponse(final HttpURLConnection conn, final String out) throws IOException { final HTTPResponse response = new HTTPResponse(conn.getResponseCode()); final String location = conn.getHeaderField("Location"); if (!StringHelper.isBlank(location)) { try { response.setLocation(new URI(location)); } catch (URISyntaxException e) { throw new IOException("Invalid location URI " + location, e); } } try { response.setContentType(conn.getContentType()); } catch (final ParseException e) { throw new IOException("Couldn't parse Content-Type header: " + e.getMessage(), e); } response.setCacheControl(conn.getHeaderField("Cache-Control")); response.setPragma(conn.getHeaderField("Pragma")); response.setWWWAuthenticate(conn.getHeaderField("WWW-Authenticate")); if (!StringHelper.isBlank(out)) { response.setContent(out); } return response; }
public void revoke(@FormParam("token") String token, @FormParam("token_type_hint") String tokenTypeHint, HttpServletRequest servletRequest, HttpServletResponse servletResponse) throws IOException { if (token == null) { ServletUtils.applyHTTPResponse(new TokenErrorResponse(OAuth2Error.INVALID_GRANT).toHTTPResponse(), servletResponse); return; } ClientID clientId = null; try { ClientAuthentication clientAuth = ClientAuthentication.parse(FixedServletUtils.createHTTPRequest(servletRequest)); if (clientAuth != null) { clientId = clientAuth.getClientID(); } } catch (ParseException e) { // ignore; no clientid given } if ("login_session".equals(tokenTypeHint)) { LoginSessionToken loginSessionToken = new LoginSessionToken(token); tokenStore.remove(loginSessionToken); tokenStore.invalidateLoginSession(loginSessionToken); } else { tokenStore.remove(token, clientId); } HTTPResponse httpResponse = new HTTPResponse(HTTPResponse.SC_OK); httpResponse.setHeader("Content-Type", "text/plain"); httpResponse.setHeader("Pragma", "no-cache"); httpResponse.setHeader("Cache-Control", "no-store"); ServletUtils.applyHTTPResponse(httpResponse, servletResponse); }
servletRequest.removeAttribute("loginSession"); tokenStore.removeLoginSession(loginSession); HTTPResponse httpResponse = new HTTPResponse(303); httpResponse.setLocation(request.toURI()); ServletUtils.applyHTTPResponse(httpResponse, resp);