Skip to content

Commit

Permalink
Fixes #4223 - Move WebXmlXXX classes to web.xml extension (#4224)
Browse files Browse the repository at this point in the history
  • Loading branch information
mnriem authored Nov 17, 2024
1 parent 6f09225 commit cea9c97
Show file tree
Hide file tree
Showing 36 changed files with 79 additions and 165 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,6 @@ public interface WebApplicationManager {
*/
ServletRequestManager getServletRequestManager();

/**
* Get the web.xml manager.
*
* @return the web.xml manager.
*/
WebXmlManager getWebXmlManager();

/**
* Get the welcome file manager.
*
Expand Down Expand Up @@ -216,13 +209,6 @@ public interface WebApplicationManager {
*/
void setServletRequestManager(ServletRequestManager servletRequestManager);

/**
* Set the web.xml manager.
*
* @param webXmlManager the web.xml manager.
*/
void setWebXmlManager(WebXmlManager webXmlManager);

/**
* Set the welcome file manager.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
import cloud.piranha.core.api.SecurityManager;
import cloud.piranha.core.api.WelcomeFileManager;
import cloud.piranha.core.api.WebApplicationManager;
import cloud.piranha.core.api.WebXmlManager;
import cloud.piranha.resource.api.ResourceManager;
import cloud.piranha.resource.impl.DefaultResourceManager;
import cloud.piranha.core.api.ServletRequestManager;
Expand Down Expand Up @@ -111,11 +110,6 @@ public class DefaultWebApplicationManager implements WebApplicationManager {
*/
protected ServletRequestManager servletRequestManager = new DefaultServletRequestManager();

/**
* Stores the web.xml manager.
*/
protected WebXmlManager webXmlManager;

/**
* Stores the welcome file manager.
*/
Expand Down Expand Up @@ -186,11 +180,6 @@ public ServletRequestManager getServletRequestManager() {
return servletRequestManager;
}

@Override
public WebXmlManager getWebXmlManager() {
return webXmlManager;
}

@Override
public WelcomeFileManager getWelcomeFileManager() {
return welcomeFileManager;
Expand Down Expand Up @@ -251,11 +240,6 @@ public void setSecurityManager(SecurityManager securityManager) {
this.securityManager = securityManager;
}

@Override
public void setWebXmlManager(WebXmlManager webXmlManager) {
this.webXmlManager = webXmlManager;
}

@Override
public void setWelcomeFileManager(WelcomeFileManager welcomeFileManager) {
this.welcomeFileManager = welcomeFileManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@
*/
package cloud.piranha.core.impl;

import cloud.piranha.core.api.WebXml;
import cloud.piranha.core.api.WebXmlManager;
import cloud.piranha.core.api.WelcomeFileManager;
import java.util.List;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -179,21 +177,6 @@ void testGetServletRequestManager() {
assertNull(manager.getServletRequestManager());
}

/**
* Test getWebXmlManager method.
*/
@Test
void testGetWebXmlManager() {
DefaultWebApplicationManager manager = new DefaultWebApplicationManager();
assertNull(manager.getWebXmlManager());
manager.setWebXmlManager(new WebXmlManager() {
@Override
public WebXml getWebXml() {
return null;
}
});
}

/**
* Test getWelcomeFileManager method.
*/
Expand Down
7 changes: 7 additions & 0 deletions extension/exousia/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,5 +52,12 @@
<artifactId>javassist</artifactId>
<version>3.29.2-GA</version>
</dependency>
<!-- provided -->
<dependency>
<groupId>cloud.piranha.extension</groupId>
<artifactId>piranha-extension-webxml</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
import org.glassfish.exousia.mapping.SecurityRoleRef;

import cloud.piranha.core.api.WebApplication;
import cloud.piranha.core.api.WebXmlManager;
import cloud.piranha.extension.webxml.WebXmlManager;
import jakarta.security.jacc.PolicyConfiguration;
import jakarta.security.jacc.PolicyContextException;
import jakarta.servlet.FilterRegistration;
Expand Down Expand Up @@ -220,7 +220,7 @@ private List<SecurityConstraint> getConstraintsFromSecurityAnnotations(ServletCo
* @return the list of security constraints.
*/
private List<SecurityConstraint> getConstraintsFromWebXml(WebApplication webApplication) {
WebXmlManager manager = webApplication.getManager().getWebXmlManager();
WebXmlManager manager = (WebXmlManager) webApplication.getAttribute("cloud.piranha.extension.webxml.WebXmlManager");
return piranhaToExousiaConverter.getConstraintsFromWebXml(manager.getWebXml());
}

Expand All @@ -232,7 +232,7 @@ private List<SecurityConstraint> getConstraintsFromWebXml(WebApplication webAppl
* @throws ServletException when a Servlet error occurs.
*/
public Map<String, List<SecurityRoleRef>> getSecurityRoleRefsFromWebXml(WebApplication webApplication) throws ServletException {
WebXmlManager manager = webApplication.getManager().getWebXmlManager();
WebXmlManager manager = (WebXmlManager) webApplication.getAttribute("cloud.piranha.extension.webxml.WebXmlManager");
return piranhaToExousiaConverter.getSecurityRoleRefsFromWebXml(webApplication.getServletRegistrations().keySet(), manager.getWebXml());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
*/
package cloud.piranha.extension.exousia;

import cloud.piranha.core.api.WebXmlServletSecurityRoleRef;
import cloud.piranha.core.api.WebXml;
import cloud.piranha.core.api.WebXmlSecurityConstraint;
import cloud.piranha.core.api.WebXmlServlet;
import cloud.piranha.extension.webxml.WebXmlServletSecurityRoleRef;
import cloud.piranha.extension.webxml.WebXml;
import cloud.piranha.extension.webxml.WebXmlSecurityConstraint;
import cloud.piranha.extension.webxml.WebXmlServlet;
import jakarta.servlet.ServletSecurityElement;
import jakarta.servlet.annotation.ServletSecurity;
import static jakarta.servlet.annotation.ServletSecurity.TransportGuarantee.CONFIDENTIAL;
Expand Down
1 change: 1 addition & 0 deletions extension/exousia/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,6 @@
requires cloud.piranha.core.impl;
requires jakarta.security.jacc;
requires jakarta.servlet;
requires static cloud.piranha.extension.webxml;
requires transitive org.glassfish.exousia;
}
43 changes: 1 addition & 42 deletions extension/webxml/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@

<name>Piranha - Extension - web.xml</name>

<properties>
<argLine></argLine>
</properties>

<dependencies>
<!-- compile -->
<dependency>
Expand Down Expand Up @@ -45,12 +41,6 @@
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cloud.piranha.extension</groupId>
<artifactId>piranha-extension-security-servlet</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>cloud.piranha.extension</groupId>
<artifactId>piranha-extension-welcomefile</artifactId>
Expand Down Expand Up @@ -86,40 +76,9 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>@{argLine} --add-opens cloud.piranha.extension.webxml/cloud.piranha.extension.webxml.internal=ALL-UNNAMED</argLine>
<useModulePath>false</useModulePath>
</configuration>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<executions>
<execution>
<id>default-check</id>
<goals>
<goal>check</goal>
</goals>
<configuration>
<rules>
<rule>
<element>BUNDLE</element>
<limits>
<limit>
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.80</minimum>
</limit>
<limit>
<counter>CLASS</counter>
<value>MISSEDCOUNT</value>
<maximum>0</maximum>
</limit>
</limits>
</rule>
</rules>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

import java.io.Serializable;
import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

/**
* A context-param inside of web.xml/web-fragment.xml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

import java.util.HashMap;
import java.util.Map;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

/**
* An error-page inside of web.xml/web-fragment.xml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

/**
* A filter init-param inside of web.xml/web-fragment.xml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,6 @@
import cloud.piranha.extension.webxml.internal.InternalWebXmlProcessor;
import cloud.piranha.extension.webxml.internal.InternalWebXmlManager;
import cloud.piranha.core.api.WebApplication;
import cloud.piranha.core.api.WebXml;
import cloud.piranha.core.api.WebXmlServletMapping;
import jakarta.servlet.ServletContainerInitializer;
import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
Expand Down Expand Up @@ -73,7 +71,7 @@ public void onStartup(Set<Class<?>> classes, ServletContext servletContext) thro
try {
WebApplication webApplication = (WebApplication) servletContext;
InternalWebXmlManager manager = new InternalWebXmlManager();
webApplication.getManager().setWebXmlManager(manager);
webApplication.setAttribute("cloud.piranha.extension.webxml.WebXmlManager", manager);

InternalWebXmlParser parser = new InternalWebXmlParser();
InputStream inputStream = servletContext.getResourceAsStream("WEB-INF/web.xml");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

/**
* A taglib inside jsp-config of web.xml/web-fragment.xml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

/**
* A listener inside of web.xml/web-fragment.xml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

/**
* A login-config inside of web.xml/web-fragment.xml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

/**
* The WebXmlManager API.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

/**
* A mime-mapping inside of web.xml/web-fragment.xml.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

import java.util.ArrayList;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package cloud.piranha.core.api;
package cloud.piranha.extension.webxml;

/**
* A servlet init-param inside of web.xml/web-fragment.xml.
Expand Down
Loading

0 comments on commit cea9c97

Please sign in to comment.