[java-shib-shared] branch main updated: JSPT-119 - Deprecate servlet request/response proxies

Scott Cantor cantor.2 at osu.edu
Thu Nov 10 14:34:38 UTC 2022


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch main
in repository java-shib-shared.

View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=c7485a258b1c81d0c693875b102301367756c393

The following commit(s) were added to refs/heads/main by this push:
     new c7485a25 JSPT-119 - Deprecate servlet request/response proxies
c7485a25 is described below

commit c7485a258b1c81d0c693875b102301367756c393
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Nov 10 09:34:35 2022 -0500

    JSPT-119 - Deprecate servlet request/response proxies
    
    https://shibboleth.atlassian.net/browse/JSPT-119
    
    Removed proxy classes.
---
 .../impl/ThreadLocalHttpServletRequestProxy.java   | 407 ---------------------
 .../impl/ThreadLocalHttpServletResponseProxy.java  | 233 ------------
 ... => HttpServletRequestResponseContextTest.java} |  55 ++-
 .../ThreadLocalHttpServletRequestProxyTest.java    |  86 -----
 .../AbstractIdentifiedInitializableComponent.java  |   5 +-
 5 files changed, 45 insertions(+), 741 deletions(-)

diff --git a/shib-networking/src/main/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletRequestProxy.java b/shib-networking/src/main/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletRequestProxy.java
deleted file mode 100644
index 0d684b09..00000000
--- a/shib-networking/src/main/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletRequestProxy.java
+++ /dev/null
@@ -1,407 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements.  See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You 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 net.shibboleth.shared.servlet.impl;
-
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.io.UnsupportedEncodingException;
-import java.security.Principal;
-import java.util.Collection;
-import java.util.Enumeration;
-import java.util.Locale;
-import java.util.Map;
-
-import jakarta.servlet.AsyncContext;
-import jakarta.servlet.DispatcherType;
-import jakarta.servlet.RequestDispatcher;
-import jakarta.servlet.ServletContext;
-import jakarta.servlet.ServletException;
-import jakarta.servlet.ServletInputStream;
-import jakarta.servlet.ServletRequest;
-import jakarta.servlet.ServletResponse;
-import jakarta.servlet.http.Cookie;
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import jakarta.servlet.http.HttpSession;
-import jakarta.servlet.http.HttpUpgradeHandler;
-import jakarta.servlet.http.Part;
-import net.shibboleth.shared.logic.Constraint;
-
-/**
- * An implementation of {@link HttpServletRequest} which serves as a proxy for the 
- * current thread-local servlet request obtained from {@link HttpServletRequestResponseContext}.
- */
-public class ThreadLocalHttpServletRequestProxy implements HttpServletRequest {
-
-    /** {@inheritDoc} */
-    public Object getAttribute(final String name) {
-        return getCurrent().getAttribute(name);
-    }
-
-    /** {@inheritDoc} */
-    public Enumeration<String> getAttributeNames() {
-        return getCurrent().getAttributeNames();
-    }
-
-    /** {@inheritDoc} */
-    public String getCharacterEncoding() {
-        return getCurrent().getCharacterEncoding();
-    }
-
-    /** {@inheritDoc} */
-    public void setCharacterEncoding(final String env) throws UnsupportedEncodingException {
-        getCurrent().setCharacterEncoding(env);
-    }
-
-    /** {@inheritDoc} */
-    public int getContentLength() {
-        return getCurrent().getContentLength();
-    }
-
-    /** {@inheritDoc} */
-    public String getContentType() {
-        return getCurrent().getContentType();
-    }
-
-    /** {@inheritDoc} */
-    public ServletInputStream getInputStream() throws IOException {
-        return getCurrent().getInputStream();
-    }
-
-    /** {@inheritDoc} */
-    public String getParameter(final String name) {
-        return getCurrent().getParameter(name);
-    }
-
-    /** {@inheritDoc} */
-    public Enumeration<String> getParameterNames() {
-        return getCurrent().getParameterNames();
-    }
-
-    /** {@inheritDoc} */
-    public String[] getParameterValues(final String name) {
-        return getCurrent().getParameterValues(name);
-    }
-
-    /** {@inheritDoc} */
-    public Map<String,String[]> getParameterMap() {
-        return getCurrent().getParameterMap();
-    }
-
-    /** {@inheritDoc} */
-    public String getProtocol() {
-        return getCurrent().getProtocol();
-    }
-
-    /** {@inheritDoc} */
-    public String getScheme() {
-        return getCurrent().getScheme();
-    }
-
-    /** {@inheritDoc} */
-    public String getServerName() {
-        return getCurrent().getServerName();
-    }
-
-    /** {@inheritDoc} */
-    public int getServerPort() {
-        return getCurrent().getServerPort();
-    }
-
-    /** {@inheritDoc} */
-    public BufferedReader getReader() throws IOException {
-        return getCurrent().getReader();
-    }
-
-    /** {@inheritDoc} */
-    public String getRemoteAddr() {
-        return getCurrent().getRemoteAddr();
-    }
-
-    /** {@inheritDoc} */
-    public String getRemoteHost() {
-        return getCurrent().getRemoteHost();
-    }
-
-    /** {@inheritDoc} */
-    public void setAttribute(final String name, final Object o) {
-        getCurrent().setAttribute(name, o);
-    }
-
-    /** {@inheritDoc} */
-    public void removeAttribute(final String name) {
-        getCurrent().removeAttribute(name);
-    }
-
-    /** {@inheritDoc} */
-    public Locale getLocale() {
-        return getCurrent().getLocale();
-    }
-
-    /** {@inheritDoc} */
-    public Enumeration<Locale> getLocales() {
-        return getCurrent().getLocales();
-    }
-
-    /** {@inheritDoc} */
-    public boolean isSecure() {
-        return getCurrent().isSecure();
-    }
-
-    /** {@inheritDoc} */
-    public RequestDispatcher getRequestDispatcher(final String path) {
-        return getCurrent().getRequestDispatcher(path);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("deprecation")
-    public String getRealPath(final String path) {
-        return getCurrent().getRealPath(path);
-    }
-
-    /** {@inheritDoc} */
-    public int getRemotePort() {
-        return getCurrent().getRemotePort();
-    }
-
-    /** {@inheritDoc} */
-    public String getLocalName() {
-        return getCurrent().getLocalName();
-    }
-
-    /** {@inheritDoc} */
-    public String getLocalAddr() {
-        return getCurrent().getLocalAddr();
-    }
-
-    /** {@inheritDoc} */
-    public int getLocalPort() {
-        return getCurrent().getLocalPort();
-    }
-
-    /** {@inheritDoc} */
-    public String getAuthType() {
-        return getCurrent().getAuthType();
-    }
-
-    /** {@inheritDoc} */
-    public Cookie[] getCookies() {
-        return getCurrent().getCookies();
-    }
-
-    /** {@inheritDoc} */
-    public long getDateHeader(final String name) {
-        return getCurrent().getDateHeader(name);
-    }
-
-    /** {@inheritDoc} */
-    public String getHeader(final String name) {
-        return getCurrent().getHeader(name);
-    }
-
-    /** {@inheritDoc} */
-    public Enumeration<String> getHeaders(final String name) {
-        return getCurrent().getHeaders(name);
-    }
-
-    /** {@inheritDoc} */
-    public Enumeration<String> getHeaderNames() {
-        return getCurrent().getHeaderNames();
-    }
-
-    /** {@inheritDoc} */
-    public int getIntHeader(final String name) {
-        return getCurrent().getIntHeader(name);
-    }
-
-    /** {@inheritDoc} */
-    public String getMethod() {
-        return getCurrent().getMethod();
-    }
-
-    /** {@inheritDoc} */
-    public String getPathInfo() {
-        return getCurrent().getPathInfo();
-    }
-
-    /** {@inheritDoc} */
-    public String getPathTranslated() {
-        return getCurrent().getPathTranslated();
-    }
-
-    /** {@inheritDoc} */
-    public String getContextPath() {
-        return getCurrent().getContextPath();
-    }
-
-    /** {@inheritDoc} */
-    public String getQueryString() {
-        return getCurrent().getQueryString();
-    }
-
-    /** {@inheritDoc} */
-    public String getRemoteUser() {
-        return getCurrent().getRemoteUser();
-    }
-
-    /** {@inheritDoc} */
-    public boolean isUserInRole(final String role) {
-        return getCurrent().isUserInRole(role);
-    }
-
-    /** {@inheritDoc} */
-    public Principal getUserPrincipal() {
-        return getCurrent().getUserPrincipal();
-    }
-
-    /** {@inheritDoc} */
-    public String getRequestedSessionId() {
-        return getCurrent().getRequestedSessionId();
-    }
-
-    /** {@inheritDoc} */
-    public String getRequestURI() {
-        return getCurrent().getRequestURI();
-    }
-
-    /** {@inheritDoc} */
-    public StringBuffer getRequestURL() {
-        return getCurrent().getRequestURL();
-    }
-
-    /** {@inheritDoc} */
-    public String getServletPath() {
-        return getCurrent().getServletPath();
-    }
-
-    /** {@inheritDoc} */
-    public HttpSession getSession(final boolean create) {
-        return getCurrent().getSession(create);
-    }
-
-    /** {@inheritDoc} */
-    public HttpSession getSession() {
-        return getCurrent().getSession();
-    }
-
-    /** {@inheritDoc} */
-    public boolean isRequestedSessionIdValid() {
-        return getCurrent().isRequestedSessionIdValid();
-    }
-
-    /** {@inheritDoc} */
-    public boolean isRequestedSessionIdFromCookie() {
-        return getCurrent().isRequestedSessionIdFromCookie();
-    }
-
-    /** {@inheritDoc} */
-    public boolean isRequestedSessionIdFromURL() {
-        return getCurrent().isRequestedSessionIdFromURL();
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("deprecation")
-    public boolean isRequestedSessionIdFromUrl() {
-        return getCurrent().isRequestedSessionIdFromUrl();
-    }
-    
-    /** {@inheritDoc} */
-    public ServletContext getServletContext() {
-        return getCurrent().getServletContext();
-    }
-
-    /** {@inheritDoc} */
-    public AsyncContext startAsync() {
-        return getCurrent().startAsync();
-    }
-
-    /** {@inheritDoc} */
-    public AsyncContext startAsync(final ServletRequest servletRequest, final ServletResponse servletResponse) {
-        return getCurrent().startAsync(servletRequest, servletResponse);
-    }
-
-    /** {@inheritDoc} */
-    public boolean isAsyncStarted() {
-        return getCurrent().isAsyncStarted();
-    }
-
-    /** {@inheritDoc} */
-    public boolean isAsyncSupported() {
-        return getCurrent().isAsyncSupported();
-    }
-
-    /** {@inheritDoc} */
-    public AsyncContext getAsyncContext() {
-        return getCurrent().getAsyncContext();
-    }
-
-    /** {@inheritDoc} */
-    public DispatcherType getDispatcherType() {
-        return getCurrent().getDispatcherType();
-    }
-
-    /** {@inheritDoc} */
-    public boolean authenticate(final HttpServletResponse response) throws IOException, ServletException {
-        return getCurrent().authenticate(response);
-    }
-
-    /** {@inheritDoc} */
-    public void login(final String username, final String password) throws ServletException {
-        getCurrent().login(username, password);
-    }
-
-    /** {@inheritDoc} */
-    public void logout() throws ServletException {
-        getCurrent().logout();
-    }
-
-    /** {@inheritDoc} */
-    public Collection<Part> getParts() throws IOException, ServletException {
-        return getCurrent().getParts();
-    }
-
-    /** {@inheritDoc} */
-    public Part getPart(final String name) throws IOException, ServletException {
-        return getCurrent().getPart(name);
-    }
-
-    /** {@inheritDoc} */
-    public long getContentLengthLong() {
-        return getCurrent().getContentLengthLong();
-    }
-
-    /** {@inheritDoc} */
-    public String changeSessionId() {
-        return getCurrent().changeSessionId();
-    }
-
-    /** {@inheritDoc} */
-    public <T extends HttpUpgradeHandler> T upgrade(final Class<T> handlerClass) throws IOException, ServletException {
-        return getCurrent().upgrade(handlerClass);
-    }
-    
-    /**
-     * Get the current HttpServletRequest from ThreadLocal storage.
-     * 
-     * @return the current request
-     */
-    protected HttpServletRequest getCurrent() {
-        return Constraint.isNotNull(HttpServletRequestResponseContext.getRequest(), 
-                "Current HttpServletRequest has not been loaded via HttpServletRequestResponseContext");
-    }
-}
diff --git a/shib-networking/src/main/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletResponseProxy.java b/shib-networking/src/main/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletResponseProxy.java
deleted file mode 100644
index 2952c110..00000000
--- a/shib-networking/src/main/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletResponseProxy.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements.  See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You 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 net.shibboleth.shared.servlet.impl;
-
-import java.io.IOException;
-import java.io.PrintWriter;
-import java.util.Collection;
-import java.util.Locale;
-
-import jakarta.servlet.ServletOutputStream;
-import jakarta.servlet.http.Cookie;
-import jakarta.servlet.http.HttpServletResponse;
-import net.shibboleth.shared.logic.Constraint;
-
-/**
- * An implementation of {@link HttpServletResponse} which serves as a proxy for the 
- * current thread-local servlet response obtained from {@link HttpServletRequestResponseContext}.
- */
-public class ThreadLocalHttpServletResponseProxy implements HttpServletResponse {
-
-    /** {@inheritDoc} */
-    public String getCharacterEncoding() {
-        return getCurrent().getCharacterEncoding();
-    }
-
-    /** {@inheritDoc} */
-    public String getContentType() {
-        return getCurrent().getContentType();
-    }
-
-    /** {@inheritDoc} */
-    public ServletOutputStream getOutputStream() throws IOException {
-        return getCurrent().getOutputStream();
-    }
-
-    /** {@inheritDoc} */
-    public PrintWriter getWriter() throws IOException {
-        return getCurrent().getWriter();
-    }
-
-    /** {@inheritDoc} */
-    public void setCharacterEncoding(final String charset) {
-        getCurrent().setCharacterEncoding(charset);
-    }
-
-    /** {@inheritDoc} */
-    public void setContentLength(final int len) {
-        getCurrent().setContentLength(len);
-    }
-
-    /** {@inheritDoc} */
-    public void setContentType(final String type) {
-        getCurrent().setContentType(type);
-    }
-
-    /** {@inheritDoc} */
-    public void setBufferSize(final int size) {
-        getCurrent().setBufferSize(size);
-    }
-
-    /** {@inheritDoc} */
-    public int getBufferSize() {
-        return getCurrent().getBufferSize();
-    }
-
-    /** {@inheritDoc} */
-    public void flushBuffer() throws IOException {
-        getCurrent().flushBuffer();
-    }
-
-    /** {@inheritDoc} */
-    public void resetBuffer() {
-        getCurrent().resetBuffer();
-    }
-
-    /** {@inheritDoc} */
-    public boolean isCommitted() {
-        return getCurrent().isCommitted();
-    }
-
-    /** {@inheritDoc} */
-    public void reset() {
-        getCurrent().reset();
-    }
-
-    /** {@inheritDoc} */
-    public void setLocale(final Locale loc) {
-        getCurrent().setLocale(loc);
-    }
-
-    /** {@inheritDoc} */
-    public Locale getLocale() {
-        return getCurrent().getLocale();
-    }
-
-    /** {@inheritDoc} */
-    public void addCookie(final Cookie cookie) {
-        getCurrent().addCookie(cookie);
-    }
-
-    /** {@inheritDoc} */
-    public boolean containsHeader(final String name) {
-        return getCurrent().containsHeader(name);
-    }
-
-    /** {@inheritDoc} */
-    public String encodeURL(final String url) {
-        return getCurrent().encodeURL(url);
-    }
-
-    /** {@inheritDoc} */
-    public String encodeRedirectURL(final String url) {
-        return getCurrent().encodeRedirectURL(url);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("deprecation")
-    public String encodeUrl(final String url) {
-        return getCurrent().encodeUrl(url);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("deprecation")
-    public String encodeRedirectUrl(final String url) {
-        return getCurrent().encodeRedirectUrl(url);
-    }
-
-    /** {@inheritDoc} */
-    public void sendError(final int sc, final String msg) throws IOException {
-        getCurrent().sendError(sc, msg);
-    }
-
-    /** {@inheritDoc} */
-    public void sendError(final int sc) throws IOException {
-        getCurrent().sendError(sc);
-    }
-
-    /** {@inheritDoc} */
-    public void sendRedirect(final String location) throws IOException {
-        getCurrent().sendRedirect(location);
-    }
-
-    /** {@inheritDoc} */
-    public void setDateHeader(final String name, final long date) {
-        getCurrent().setDateHeader(name, date);
-    }
-
-    /** {@inheritDoc} */
-    public void addDateHeader(final String name, final long date) {
-        getCurrent().addDateHeader(name, date);
-    }
-
-    /** {@inheritDoc} */
-    public void setHeader(final String name, final String value) {
-        getCurrent().setHeader(name, value);
-    }
-
-    /** {@inheritDoc} */
-    public void addHeader(final String name, final String value) {
-        getCurrent().addHeader(name, value);
-    }
-
-    /** {@inheritDoc} */
-    public void setIntHeader(final String name, final int value) {
-        getCurrent().setIntHeader(name, value);
-    }
-
-    /** {@inheritDoc} */
-    public void addIntHeader(final String name, final int value) {
-        getCurrent().addIntHeader(name, value);
-    }
-
-    /** {@inheritDoc} */
-    public void setStatus(final int sc) {
-        getCurrent().setStatus(sc);
-    }
-
-    /** {@inheritDoc} */
-    @SuppressWarnings("deprecation")
-    public void setStatus(final int sc, final String sm) {
-        getCurrent().setStatus(sc, sm);
-    }
-    
-    /** {@inheritDoc} */
-    public int getStatus() {
-        return getCurrent().getStatus();
-    }
-
-    /** {@inheritDoc} */
-    public String getHeader(final String name) {
-        return getCurrent().getHeader(name);
-    }
-
-    /** {@inheritDoc} */
-    public Collection<String> getHeaders(final String name) {
-        return getCurrent().getHeaders(name);
-    }
-
-    /** {@inheritDoc} */
-    public Collection<String> getHeaderNames() {
-        return getCurrent().getHeaderNames();
-    }
-
-    /** {@inheritDoc} */
-    public void setContentLengthLong(final long len) {
-        getCurrent().setContentLengthLong(len);
-    }
-
-    /**
-     * Get the current HttpServletResponse from ThreadLocal storage.
-     * 
-     * @return the current response
-     */
-    protected HttpServletResponse getCurrent() {
-        return Constraint.isNotNull(HttpServletRequestResponseContext.getResponse(),
-                "Current HttpServletResponse has not been loaded via HttpServletRequestResponseContext");
-    }
-}
diff --git a/shib-networking/src/test/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletResponseProxyTest.java b/shib-networking/src/test/java/net/shibboleth/shared/servlet/impl/HttpServletRequestResponseContextTest.java
similarity index 56%
rename from shib-networking/src/test/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletResponseProxyTest.java
rename to shib-networking/src/test/java/net/shibboleth/shared/servlet/impl/HttpServletRequestResponseContextTest.java
index aafe0106..98ac9636 100644
--- a/shib-networking/src/test/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletResponseProxyTest.java
+++ b/shib-networking/src/test/java/net/shibboleth/shared/servlet/impl/HttpServletRequestResponseContextTest.java
@@ -29,23 +29,22 @@ import jakarta.servlet.http.HttpServletResponse;
 import net.shibboleth.shared.logic.ConstraintViolationException;
 
 /**
- * Tests for {@link ThreadLocalHttpServletResponseProxy}.
+ * Tests for {@link HttpServletRequestResponseContext}.
  */
-public class ThreadLocalHttpServletResponseProxyTest {
-    
+public class HttpServletRequestResponseContextTest {
     private HttpServletRequest request;
     private HttpServletResponse response;
     
     @BeforeMethod
     public void setUp() {
-        MockHttpServletRequest mockRequest = new MockHttpServletRequest();
+        final MockHttpServletRequest mockRequest = new MockHttpServletRequest();
         mockRequest.setMethod("GET");
         mockRequest.setRequestURI("/foo");
         mockRequest.addHeader("MyRequestHeader", "MyRequestHeaderValue");
         mockRequest.addParameter("MyParam", "MyParamValue");
         request = mockRequest;
         
-        MockHttpServletResponse mockResponse = new MockHttpServletResponse();
+        final MockHttpServletResponse mockResponse = new MockHttpServletResponse();
         mockResponse.setContentType("text/html");
         mockResponse.setCharacterEncoding("UTF-8");
         mockResponse.setHeader("MyResponseHeader", "MyResponseHeaderValue");
@@ -57,13 +56,44 @@ public class ThreadLocalHttpServletResponseProxyTest {
         HttpServletRequestResponseContext.clearCurrent();
     }
     
+    @Test(expectedExceptions=ConstraintViolationException.class)
+    public void testRequestNoLoad() {
+        Assert.assertNull(HttpServletRequestResponseContext.getRequest()); 
+        Assert.assertNull(HttpServletRequestResponseContext.getResponse()); 
+        
+        final ThreadLocalHttpServletRequestSupplier proxy = new ThreadLocalHttpServletRequestSupplier();
+        proxy.get().getMethod();
+    }
+    
+    @Test
+    public void testRequest() {
+        Assert.assertNull(HttpServletRequestResponseContext.getRequest()); 
+        Assert.assertNull(HttpServletRequestResponseContext.getResponse()); 
+        
+        HttpServletRequestResponseContext.loadCurrent(request, response);
+        
+        final ThreadLocalHttpServletRequestSupplier proxy = new ThreadLocalHttpServletRequestSupplier();
+        final HttpServletRequest request = proxy.get();
+        Assert.assertEquals(request.getMethod(), "GET");
+        Assert.assertEquals(request.getRequestURI(), "/foo");
+        Assert.assertEquals(request.getHeader("MyRequestHeader"), "MyRequestHeaderValue");
+        Assert.assertEquals(request.getParameter("MyParam"), "MyParamValue");
+        
+        HttpServletRequestResponseContext.clearCurrent();
+        
+        Assert.assertNull(HttpServletRequestResponseContext.getRequest()); 
+        Assert.assertNull(HttpServletRequestResponseContext.getResponse()); 
+        
+    }
+
+    
     @Test(expectedExceptions=ConstraintViolationException.class)
     public void testResponseNoLoad() {
         Assert.assertNull(HttpServletRequestResponseContext.getRequest()); 
         Assert.assertNull(HttpServletRequestResponseContext.getResponse()); 
         
-        ThreadLocalHttpServletResponseProxy proxy = new ThreadLocalHttpServletResponseProxy();
-        proxy.getContentType();
+        final ThreadLocalHttpServletResponseSupplier proxy = new ThreadLocalHttpServletResponseSupplier();
+        proxy.get().getContentType();
     }
     
     @Test
@@ -73,10 +103,11 @@ public class ThreadLocalHttpServletResponseProxyTest {
         
         HttpServletRequestResponseContext.loadCurrent(request, response);
         
-        ThreadLocalHttpServletResponseProxy proxy = new ThreadLocalHttpServletResponseProxy();
-        Assert.assertEquals(proxy.getContentType(), "text/html;charset=UTF-8");
-        Assert.assertEquals(proxy.getCharacterEncoding(), "UTF-8");
-        Assert.assertTrue(proxy.containsHeader("MyResponseHeader"));
+        final ThreadLocalHttpServletResponseSupplier proxy = new ThreadLocalHttpServletResponseSupplier();
+        final HttpServletResponse response = proxy.get();
+        Assert.assertEquals(response.getContentType(), "text/html;charset=UTF-8");
+        Assert.assertEquals(response.getCharacterEncoding(), "UTF-8");
+        Assert.assertTrue(response.containsHeader("MyResponseHeader"));
         
         HttpServletRequestResponseContext.clearCurrent();
         
@@ -85,4 +116,4 @@ public class ThreadLocalHttpServletResponseProxyTest {
         
     }
 
-}
+}
\ No newline at end of file
diff --git a/shib-networking/src/test/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletRequestProxyTest.java b/shib-networking/src/test/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletRequestProxyTest.java
deleted file mode 100644
index 5a5183a3..00000000
--- a/shib-networking/src/test/java/net/shibboleth/shared/servlet/impl/ThreadLocalHttpServletRequestProxyTest.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * Licensed to the University Corporation for Advanced Internet Development,
- * Inc. (UCAID) under one or more contributor license agreements.  See the
- * NOTICE file distributed with this work for additional information regarding
- * copyright ownership. The UCAID licenses this file to You 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 net.shibboleth.shared.servlet.impl;
-
-import org.springframework.mock.web.MockHttpServletRequest;
-import org.springframework.mock.web.MockHttpServletResponse;
-import org.testng.Assert;
-import org.testng.annotations.AfterMethod;
-import org.testng.annotations.BeforeMethod;
-import org.testng.annotations.Test;
-
-import jakarta.servlet.http.HttpServletRequest;
-import jakarta.servlet.http.HttpServletResponse;
-import net.shibboleth.shared.logic.ConstraintViolationException;
-
-/**
- * Tests for {@link ThreadLocalHttpServletRequestProxy}.
- */
-public class ThreadLocalHttpServletRequestProxyTest {
-    private HttpServletRequest request;
-    private HttpServletResponse response;
-    
-    @BeforeMethod
-    public void setUp() {
-        MockHttpServletRequest mockRequest = new MockHttpServletRequest();
-        mockRequest.setMethod("GET");
-        mockRequest.setRequestURI("/foo");
-        mockRequest.addHeader("MyRequestHeader", "MyRequestHeaderValue");
-        mockRequest.addParameter("MyParam", "MyParamValue");
-        request = mockRequest;
-        
-        MockHttpServletResponse mockResponse = new MockHttpServletResponse();
-        mockResponse.setHeader("MyResponseHeader", "MyResponseHeaderValue");
-        response = mockResponse;
-    }
-    
-    @AfterMethod
-    public void tearDown()  {
-        HttpServletRequestResponseContext.clearCurrent();
-    }
-    
-    @Test(expectedExceptions=ConstraintViolationException.class)
-    public void testRequestNoLoad() {
-        Assert.assertNull(HttpServletRequestResponseContext.getRequest()); 
-        Assert.assertNull(HttpServletRequestResponseContext.getResponse()); 
-        
-        ThreadLocalHttpServletRequestProxy proxy = new ThreadLocalHttpServletRequestProxy();
-        proxy.getMethod();
-    }
-    
-    @Test
-    public void testRequest() {
-        Assert.assertNull(HttpServletRequestResponseContext.getRequest()); 
-        Assert.assertNull(HttpServletRequestResponseContext.getResponse()); 
-        
-        HttpServletRequestResponseContext.loadCurrent(request, response);
-        
-        ThreadLocalHttpServletRequestProxy proxy = new ThreadLocalHttpServletRequestProxy();
-        Assert.assertEquals(proxy.getMethod(), "GET");
-        Assert.assertEquals(proxy.getRequestURI(), "/foo");
-        Assert.assertEquals(proxy.getHeader("MyRequestHeader"), "MyRequestHeaderValue");
-        Assert.assertEquals(proxy.getParameter("MyParam"), "MyParamValue");
-        
-        HttpServletRequestResponseContext.clearCurrent();
-        
-        Assert.assertNull(HttpServletRequestResponseContext.getRequest()); 
-        Assert.assertNull(HttpServletRequestResponseContext.getResponse()); 
-        
-    }
-
-}
diff --git a/shib-support/src/main/java/net/shibboleth/shared/component/AbstractIdentifiedInitializableComponent.java b/shib-support/src/main/java/net/shibboleth/shared/component/AbstractIdentifiedInitializableComponent.java
index 8602f51a..42120d1d 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/component/AbstractIdentifiedInitializableComponent.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/component/AbstractIdentifiedInitializableComponent.java
@@ -18,7 +18,6 @@
 package net.shibboleth.shared.component;
 
 import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
 import javax.annotation.concurrent.GuardedBy;
 import javax.annotation.concurrent.ThreadSafe;
 
@@ -35,10 +34,10 @@ public abstract class AbstractIdentifiedInitializableComponent extends AbstractI
         IdentifiedComponent {
 
     /** The unique identifier for this component. */
-    @Nullable @NonnullAfterInit @GuardedBy("this") private String id;
+    @NonnullAfterInit @GuardedBy("this") private String id;
 
     /** {@inheritDoc} */
-    @Nullable @NonnullAfterInit public synchronized String getId() {
+    @NonnullAfterInit @NotEmpty public synchronized String getId() {
         return id;
     }
     

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list