Java Code Examples for io.undertow.server.HttpServerExchange#removeAttachment()
The following examples show how to use
io.undertow.server.HttpServerExchange#removeAttachment() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DigestAuthenticationMechanism.java From quarkus-http with Apache License 2.0 | 5 votes |
public void sendAuthenticationInfoHeader(final HttpServerExchange exchange) { DigestContext context = exchange.getAttachment(DigestContext.ATTACHMENT_KEY); DigestQop qop = context.getQop(); String currentNonce = context.getNonce(); String nextNonce = nonceManager.nextNonce(currentNonce, exchange); if (qop != null || !nextNonce.equals(currentNonce)) { StringBuilder sb = new StringBuilder(); sb.append(NEXT_NONCE).append("=\"").append(nextNonce).append("\""); if (qop != null) { Map<DigestAuthorizationToken, String> parsedHeader = context.getParsedHeader(); sb.append(",").append(HttpHeaderNames.QOP.toString()).append("=\"").append(qop.getToken()).append("\""); byte[] ha1 = context.getHa1(); byte[] ha2; if (qop == DigestQop.AUTH) { ha2 = createHA2Auth(context); } else { ha2 = createHA2AuthInt(); } String rspauth = new String(createRFC2617RequestDigest(ha1, ha2, context), StandardCharsets.UTF_8); sb.append(",").append(HttpHeaderNames.RESPONSE_AUTH.toString()).append("=\"").append(rspauth).append("\""); sb.append(",").append(HttpHeaderNames.CNONCE.toString()).append("=\"").append(parsedHeader.get(DigestAuthorizationToken.CNONCE)).append("\""); sb.append(",").append(HttpHeaderNames.NONCE_COUNT.toString()).append("=").append(parsedHeader.get(DigestAuthorizationToken.NONCE_COUNT)); } exchange.addResponseHeader(AUTHENTICATION_INFO, sb.toString()); } exchange.removeAttachment(DigestContext.ATTACHMENT_KEY); }
Example 2
Source File: InMemorySessionManager.java From quarkus-http with Apache License 2.0 | 5 votes |
@Override public void invalidate(final HttpServerExchange exchange) { invalidate(exchange, SessionListener.SessionDestroyedReason.INVALIDATED); if (exchange != null) { exchange.removeAttachment(sessionManager.NEW_SESSION); } Object evictionToken = this.evictionToken; if (evictionToken != null) { sessionManager.evictionQueue.removeToken(evictionToken); } }
Example 3
Source File: DigestAuthenticationMechanism.java From lams with GNU General Public License v2.0 | 5 votes |
public void sendAuthenticationInfoHeader(final HttpServerExchange exchange) { DigestContext context = exchange.getAttachment(DigestContext.ATTACHMENT_KEY); DigestQop qop = context.getQop(); String currentNonce = context.getNonce(); String nextNonce = nonceManager.nextNonce(currentNonce, exchange); if (qop != null || !nextNonce.equals(currentNonce)) { StringBuilder sb = new StringBuilder(); sb.append(NEXT_NONCE).append("=\"").append(nextNonce).append("\""); if (qop != null) { Map<DigestAuthorizationToken, String> parsedHeader = context.getParsedHeader(); sb.append(",").append(Headers.QOP.toString()).append("=\"").append(qop.getToken()).append("\""); byte[] ha1 = context.getHa1(); byte[] ha2; if (qop == DigestQop.AUTH) { ha2 = createHA2Auth(context); } else { ha2 = createHA2AuthInt(); } String rspauth = new String(createRFC2617RequestDigest(ha1, ha2, context), StandardCharsets.UTF_8); sb.append(",").append(Headers.RESPONSE_AUTH.toString()).append("=\"").append(rspauth).append("\""); sb.append(",").append(Headers.CNONCE.toString()).append("=\"").append(parsedHeader.get(DigestAuthorizationToken.CNONCE)).append("\""); sb.append(",").append(Headers.NONCE_COUNT.toString()).append("=").append(parsedHeader.get(DigestAuthorizationToken.NONCE_COUNT)); } HeaderMap responseHeader = exchange.getResponseHeaders(); responseHeader.add(AUTHENTICATION_INFO, sb.toString()); } exchange.removeAttachment(DigestContext.ATTACHMENT_KEY); }
Example 4
Source File: InMemorySessionManager.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public void invalidate(final HttpServerExchange exchange) { invalidate(exchange, SessionListener.SessionDestroyedReason.INVALIDATED); if(exchange != null) { exchange.removeAttachment(sessionManager.NEW_SESSION); } Object evictionToken = this.evictionToken; if(evictionToken != null) { sessionManager.evictionQueue.removeToken(evictionToken); } }
Example 5
Source File: TokenAuthenticator.java From hawkular-metrics with Apache License 2.0 | 5 votes |
/** * Called when the Kubernetes master server reponse has been inspected. */ private void onRequestResult(HttpServerExchange serverExchange, PooledConnection connection, boolean allowed) { connectionPools.get(serverExchange.getIoThread()).release(connection); // Remove attachment early to make it eligible for GC AuthContext context = serverExchange.removeAttachment(AUTH_CONTEXT_KEY); apiLatency.update(context.getClientResponseTime(), NANOSECONDS); authLatency.update(context.getLatency(), NANOSECONDS); if (allowed) { serverExchange.dispatch(containerHandler); } else { endExchange(serverExchange, FORBIDDEN); } }
Example 6
Source File: PredicatesHandler.java From quarkus-http with Apache License 2.0 | 4 votes |
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { final int length = handlers.length; Integer current = exchange.getAttachment(CURRENT_POSITION); do { int pos; if (current == null) { if (outerHandler) { exchange.removeAttachment(RESTART); exchange.removeAttachment(DONE); if (exchange.getAttachment(Predicate.PREDICATE_CONTEXT) == null) { exchange.putAttachment(Predicate.PREDICATE_CONTEXT, new TreeMap<String, Object>()); } } pos = 0; } else { //if it has been marked as done if (exchange.getAttachment(DONE) != null) { exchange.removeAttachment(CURRENT_POSITION); next.handleRequest(exchange); return; } pos = current; } for (; pos < length; ++pos) { final Holder handler = handlers[pos]; if (handler.predicate.resolve(exchange)) { exchange.putAttachment(CURRENT_POSITION, pos + 1); handler.handler.handleRequest(exchange); if(shouldRestart(exchange, current)) { break; } else { return; } } else if(handler.elseBranch != null) { exchange.putAttachment(CURRENT_POSITION, pos + 1); handler.elseBranch.handleRequest(exchange); if(shouldRestart(exchange, current)) { break; } else { return; } } } } while (shouldRestart(exchange, current)); next.handleRequest(exchange); }
Example 7
Source File: ExtendedLoadBalancingProxyClient.java From galeb with Apache License 2.0 | 4 votes |
@Override public void queuedRequestFailed(HttpServerExchange exchange) { exchange.removeAttachment(HostSelector.REAL_DEST); exchange.getResponseHeaders().add(ResponseCodeOnError.Header.X_GALEB_ERROR, ResponseCodeOnError.QUEUED_REQUEST_FAILED.getMessage()); callback.queuedRequestFailed(exchange); }
Example 8
Source File: ExtendedLoadBalancingProxyClient.java From galeb with Apache License 2.0 | 4 votes |
@Override public void failed(HttpServerExchange exchange) { exchange.removeAttachment(HostSelector.REAL_DEST); UndertowLogger.PROXY_REQUEST_LOGGER.proxyFailedToConnectToBackend(exchange.getRequestURI(), host.uri); callback.failed(exchange); }
Example 9
Source File: ExtendedLoadBalancingProxyClient.java From galeb with Apache License 2.0 | 4 votes |
@Override public void couldNotResolveBackend(HttpServerExchange exchange) { exchange.removeAttachment(HostSelector.REAL_DEST); exchange.getResponseHeaders().add(ResponseCodeOnError.Header.X_GALEB_ERROR, ResponseCodeOnError.COULD_NOT_RESOLVE_BACKEND.getMessage()); callback.couldNotResolveBackend(exchange); }
Example 10
Source File: PredicatesHandler.java From lams with GNU General Public License v2.0 | 4 votes |
@Override public void handleRequest(HttpServerExchange exchange) throws Exception { final int length = handlers.length; Integer current = exchange.getAttachment(CURRENT_POSITION); do { int pos; if (current == null) { if (outerHandler) { exchange.removeAttachment(RESTART); exchange.removeAttachment(DONE); if (exchange.getAttachment(Predicate.PREDICATE_CONTEXT) == null) { exchange.putAttachment(Predicate.PREDICATE_CONTEXT, new TreeMap<String, Object>()); } } pos = 0; } else { //if it has been marked as done if (exchange.getAttachment(DONE) != null) { exchange.removeAttachment(CURRENT_POSITION); next.handleRequest(exchange); return; } pos = current; } for (; pos < length; ++pos) { final Holder handler = handlers[pos]; if (handler.predicate.resolve(exchange)) { exchange.putAttachment(CURRENT_POSITION, pos + 1); handler.handler.handleRequest(exchange); if(shouldRestart(exchange, current)) { break; } else { return; } } else if(handler.elseBranch != null) { exchange.putAttachment(CURRENT_POSITION, pos + 1); handler.elseBranch.handleRequest(exchange); if(shouldRestart(exchange, current)) { break; } else { return; } } } } while (shouldRestart(exchange, current)); next.handleRequest(exchange); }