From fe5a60155dbb693809eb0e97047a20bab09d19d2 Mon Sep 17 00:00:00 2001 From: arjantijms Date: Fri, 17 Sep 2021 17:31:45 +0200 Subject: [PATCH] #193 Add wrapper for HttpAuthenticationMechanism Signed-off-by: arjantijms --- .../HttpAuthenticationMechanismWrapper.java | 61 +++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 api/src/main/java/jakarta/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanismWrapper.java diff --git a/api/src/main/java/jakarta/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanismWrapper.java b/api/src/main/java/jakarta/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanismWrapper.java new file mode 100644 index 0000000..a97d185 --- /dev/null +++ b/api/src/main/java/jakarta/security/enterprise/authentication/mechanism/http/HttpAuthenticationMechanismWrapper.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2021 Contributors to Eclipse Foundation. + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License v. 2.0, which is available at + * http://www.eclipse.org/legal/epl-2.0. + * + * This Source Code may also be made available under the following Secondary + * Licenses when the conditions for such availability set forth in the + * Eclipse Public License v. 2.0 are satisfied: GNU General Public License, + * version 2 with the GNU Classpath Exception, which is available at + * https://www.gnu.org/software/classpath/license.html. + * + * SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 + */ +package jakarta.security.enterprise.authentication.mechanism.http; + +import jakarta.security.enterprise.AuthenticationException; +import jakarta.security.enterprise.AuthenticationStatus; +import jakarta.servlet.http.HttpServletRequest; +import jakarta.servlet.http.HttpServletResponse; + +/** + * This class is an implementation of the HttpAuthenticationMechanism interface that + * can be subclassed by developers wishing to provide extra or different + * functionality. + *

+ * All methods default to calling the wrapped object. + * + * @since 3.0 + */ +public class HttpAuthenticationMechanismWrapper implements HttpAuthenticationMechanism { + + private final HttpAuthenticationMechanism httpAuthenticationMechanism; + + public HttpAuthenticationMechanismWrapper(HttpAuthenticationMechanism httpAuthenticationMechanism) { + this.httpAuthenticationMechanism = httpAuthenticationMechanism; + } + + public HttpAuthenticationMechanism getWrapped() { + return httpAuthenticationMechanism; + } + + @Override + public AuthenticationStatus validateRequest(HttpServletRequest request, HttpServletResponse response, + HttpMessageContext httpMessageContext) throws AuthenticationException { + return getWrapped().validateRequest(request, response, httpMessageContext); + } + + @Override + public AuthenticationStatus secureResponse(HttpServletRequest request, HttpServletResponse response, + HttpMessageContext httpMessageContext) throws AuthenticationException { + return getWrapped().secureResponse(request, response, httpMessageContext); + } + + @Override + public void cleanSubject(HttpServletRequest request, HttpServletResponse response, HttpMessageContext httpMessageContext) { + getWrapped().cleanSubject(request, response, httpMessageContext); + } + +} \ No newline at end of file