getHeaders(String name) {
- return exchange.getRequestHeaders().get(name);
- }
-
- @Override
- public String getMethod() {
- return exchange.getRequestMethod().toString();
- }
-
-
-
- @Override
- public String getHeader(String name) {
- return exchange.getRequestHeaders().getFirst(name);
- }
-
- @Override
- public InputStream getInputStream() {
- return getInputStream(false);
- }
-
- @Override
- public InputStream getInputStream(boolean buffered) {
- if (!exchange.isBlocking()) exchange.startBlocking();
-
- if (inputStream != null) {
- return inputStream;
- }
-
- if (buffered) {
- ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
- ServletRequest servletRequest = context.getServletRequest();
-
- inputStream = new BufferedInputStream(exchange.getInputStream());
-
- context.setServletRequest(UndertowHttpServletRequest.setupServletInputStream(servletRequest, inputStream));
- return inputStream;
- }
-
- return exchange.getInputStream();
- }
-
- @Override
- public String getRemoteAddr() {
- InetSocketAddress sourceAddress = exchange.getSourceAddress();
- if (sourceAddress == null) {
- return "";
- }
- InetAddress address = sourceAddress.getAddress();
- if (address == null) {
- // this is unresolved, so we just return the host name not exactly spec, but if the name should be
- // resolved then a PeerNameResolvingHandler should be used and this is probably better than just
- // returning null
- return sourceAddress.getHostString();
- }
- return address.getHostAddress();
- }
-
- @Override
- public void setError(AuthenticationError error) {
- exchange.putAttachment(AUTH_ERROR_ATTACHMENT_KEY, error);
- }
-
- @Override
- public void setError(LogoutError error) {
- exchange.putAttachment(LOGOUT_ERROR_ATTACHMENT_KEY, error);
-
- }
- }
-
- protected class ResponseFacade implements Response {
- @Override
- public void setStatus(int status) {
- exchange.setResponseCode(status);
- }
-
- @Override
- public void addHeader(String name, String value) {
- exchange.getResponseHeaders().add(new HttpString(name), value);
- }
-
- @Override
- public void setHeader(String name, String value) {
- exchange.getResponseHeaders().put(new HttpString(name), value);
- }
-
- @Override
- public void resetCookie(String name, String path) {
- CookieImpl cookie = new CookieImpl(name, "");
- cookie.setMaxAge(0);
- cookie.setPath(path);
- exchange.setResponseCookie(cookie);
- }
-
- @Override
- public void setCookie(String name, String value, String path, String domain, int maxAge, boolean secure, boolean httpOnly) {
- CookieImpl cookie = new CookieImpl(name, value);
- cookie.setPath(path);
- cookie.setDomain(domain);
- cookie.setMaxAge(maxAge);
- cookie.setSecure(secure);
- cookie.setHttpOnly(httpOnly);
- exchange.setResponseCookie(cookie);
- }
-
- @Override
- public OutputStream getOutputStream() {
- if (!exchange.isBlocking()) exchange.startBlocking();
- return exchange.getOutputStream();
- }
-
- @Override
- public void sendError(int code) {
- exchange.setResponseCode(code);
- }
-
- @Override
- public void sendError(int code, String message) {
- exchange.setResponseCode(code);
- exchange.getResponseHeaders().put(Headers.CONTENT_TYPE, "text/html");
- try {
- exchange.getOutputStream().write(message.getBytes());
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- exchange.endExchange();
- }
-
-
- @Override
- public void end() {
- exchange.endExchange();
- }
- }
-}
diff --git a/adapters/spi/undertow-adapter-spi/src/main/java/org/keycloak/adapters/undertow/UndertowHttpServletRequest.java b/adapters/spi/undertow-adapter-spi/src/main/java/org/keycloak/adapters/undertow/UndertowHttpServletRequest.java
deleted file mode 100644
index 338f66e22a..0000000000
--- a/adapters/spi/undertow-adapter-spi/src/main/java/org/keycloak/adapters/undertow/UndertowHttpServletRequest.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright 2023 Red Hat, Inc. and/or its affiliates
- * and other contributors as indicated by the @author tags.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.keycloak.adapters.undertow;
-
-import javax.servlet.ServletInputStream;
-import javax.servlet.ServletRequest;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletRequestWrapper;
-import java.io.IOException;
-import java.io.InputStream;
-
-public class UndertowHttpServletRequest {
-
- public static HttpServletRequestWrapper setupServletInputStream(ServletRequest servletRequest, final InputStream inputStream) {
- return new HttpServletRequestWrapper((HttpServletRequest) servletRequest) {
- @Override
- public ServletInputStream getInputStream() {
- inputStream.mark(0);
- return new ServletInputStream() {
- @Override
- public int read() throws IOException {
- return inputStream.read();
- }
- };
- }
- };
- }
-}
diff --git a/adapters/spi/undertow-adapter-spi/src/main/java/org/keycloak/adapters/undertow/UndertowUserSessionManagement.java b/adapters/spi/undertow-adapter-spi/src/main/java/org/keycloak/adapters/undertow/UndertowUserSessionManagement.java
deleted file mode 100755
index 953080c214..0000000000
--- a/adapters/spi/undertow-adapter-spi/src/main/java/org/keycloak/adapters/undertow/UndertowUserSessionManagement.java
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * Copyright 2016 Red Hat, Inc. and/or its affiliates
- * and other contributors as indicated by the @author tags.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.keycloak.adapters.undertow;
-
-import io.undertow.server.HttpServerExchange;
-import io.undertow.server.session.Session;
-import io.undertow.server.session.SessionConfig;
-import io.undertow.server.session.SessionListener;
-import io.undertow.server.session.SessionManager;
-import org.jboss.logging.Logger;
-
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-/**
- * Manages relationship to users and sessions so that forced admin logout can be implemented
- *
- * @author Bill Burke
- * @version $Revision: 1 $
- */
-public class UndertowUserSessionManagement implements SessionListener {
- private static final Logger log = Logger.getLogger(UndertowUserSessionManagement.class);
- protected volatile boolean registered;
- private final ExecutorService executor = Executors.newSingleThreadExecutor();
-
- public void login(SessionManager manager) {
- if (!registered) {
- manager.registerSessionListener(this);
- registered = true;
- }
- }
-
- /**
- * This method runs the given runnable in the current thread if the session manager does not use distributed sessions,
- * or in a separate thread if it does. This is to work around:
- *
- * org.infinispan.util.concurrent.TimeoutException: ISPN000299: Unable to acquire lock after 15 seconds for key SessionCreationMetaDataKey
- *
- * See https://issues.jboss.org/browse/KEYCLOAK-9822
- * @param r
- */
- private void workaroundIspnDeadlock(final SessionManager manager, Runnable r) {
- if (manager.getClass().getName().equals("org.wildfly.clustering.web.undertow.session.DistributableSessionManager")) {
- executor.submit(r);
- } else {
- r.run();
- }
- }
-
- public void logoutAll(final SessionManager manager) {
- final Set allSessions = manager.getAllSessions();
- workaroundIspnDeadlock(manager, new Runnable() {
- @Override
- public void run() {
- for (String sessionId : allSessions) logoutSession(manager, sessionId);
- }
- });
- }
-
- public void logoutHttpSessions(final SessionManager manager, final List sessionIds) {
- log.debugf("logoutHttpSessions: %s", sessionIds);
-
- workaroundIspnDeadlock(manager, new Runnable() {
- @Override
- public void run() {
- for (String sessionId : sessionIds) {
- logoutSession(manager, sessionId);
- }
- }
- });
- }
-
- protected void logoutSession(SessionManager manager, String httpSessionId) {
- log.debugf("logoutHttpSession: %s", httpSessionId);
- Session session = getSessionById(manager, httpSessionId);
- try {
- if (session != null) session.invalidate(null);
- } catch (Exception e) {
- log.warnf("Session %s not present or already invalidated.", httpSessionId);
- }
- }
-
- protected Session getSessionById(SessionManager manager, final String sessionId) {
- // TODO: Workaround for WFLY-3345. Remove this once we move to wildfly 8.2
- if (manager.getClass().getName().equals("org.wildfly.clustering.web.undertow.session.DistributableSessionManager")) {
- return manager.getSession(null, new SessionConfig() {
-
- @Override
- public void setSessionId(HttpServerExchange exchange, String sessionId) {
- }
-
- @Override
- public void clearSession(HttpServerExchange exchange, String sessionId) {
- }
-
- @Override
- public String findSessionId(HttpServerExchange exchange) {
- return sessionId;
- }
-
- @Override
- public SessionCookieSource sessionCookieSource(HttpServerExchange exchange) {
- return null;
- }
-
- @Override
- public String rewriteUrl(String originalUrl, String sessionId) {
- return null;
- }
-
- });
-
- } else {
- return manager.getSession(sessionId);
- }
- }
-
-
- @Override
- public void sessionCreated(Session session, HttpServerExchange exchange) {
- }
-
- @Override
- public void sessionDestroyed(Session session, HttpServerExchange exchange, SessionDestroyedReason reason) {
- }
-
-
- @Override
- public void sessionIdChanged(Session session, String oldSessionId) {
- }
-
- @Override
- public void attributeAdded(Session session, String name, Object value) {
- }
-
- @Override
- public void attributeUpdated(Session session, String name, Object newValue, Object oldValue) {
- }
-
- @Override
- public void attributeRemoved(Session session, String name, Object oldValue) {
- }
-
-}
diff --git a/pom.xml b/pom.xml
index 07e71499d6..431e10345b 100644
--- a/pom.xml
+++ b/pom.xml
@@ -997,11 +997,6 @@
keycloak-saml-as7-subsystem
${project.version}
-
- org.keycloak
- keycloak-undertow-adapter-spi
- ${project.version}
-
org.keycloak
keycloak-saml-wildfly-elytron-adapter