From 215ba012f2d161ba15852860b25c56dea6c0c017 Mon Sep 17 00:00:00 2001 From: Benjamin Marwell Date: Thu, 27 May 2021 08:18:34 +0200 Subject: [PATCH] [SHIRO-823] remove broken jaxrs sample project. --- samples/jaxrs/pom.xml | 221 ------------------ .../samples/jaxrs/SampleApplication.java | 50 ---- .../jaxrs/resources/HelloResource.java | 47 ---- .../jaxrs/resources/SecureResource.java | 75 ------ .../jaxrs/src/main/resources/META-INF/NOTICE | 15 -- samples/jaxrs/src/main/resources/logback.xml | 34 --- samples/jaxrs/src/main/resources/shiro.ini | 43 ---- .../jaxrs/src/main/webapp/WEB-INF/web.cxf.xml | 41 ---- .../web/jaxrs/ContainerIntegrationIT.groovy | 143 ------------ samples/pom.xml | 1 - 10 files changed, 670 deletions(-) delete mode 100644 samples/jaxrs/pom.xml delete mode 100644 samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/SampleApplication.java delete mode 100644 samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/HelloResource.java delete mode 100644 samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/SecureResource.java delete mode 100644 samples/jaxrs/src/main/resources/META-INF/NOTICE delete mode 100644 samples/jaxrs/src/main/resources/logback.xml delete mode 100644 samples/jaxrs/src/main/resources/shiro.ini delete mode 100644 samples/jaxrs/src/main/webapp/WEB-INF/web.cxf.xml delete mode 100644 samples/jaxrs/src/test/groovy/org/apache/shiro/web/jaxrs/ContainerIntegrationIT.groovy diff --git a/samples/jaxrs/pom.xml b/samples/jaxrs/pom.xml deleted file mode 100644 index 6878195dd..000000000 --- a/samples/jaxrs/pom.xml +++ /dev/null @@ -1,221 +0,0 @@ - - - - - - - org.apache.shiro.samples - shiro-samples - 2.0.0-SNAPSHOT - ../pom.xml - - - 4.0.0 - samples-jaxrs - Apache Shiro :: Samples :: JAX-RS - war - - - - - - org.eclipse.jetty - jetty-maven-plugin - ${jetty.version} - - / - - 9080 - 60000 - - - ./target/yyyy_mm_dd.request.log - 90 - true - false - GMT - - - - - - - - org.eclipse.jetty - jetty-maven-plugin - - - - - - - - org.apache.shiro - shiro-servlet-plugin - - - - org.apache.shiro - shiro-jaxrs - - - - jakarta.ws.rs - jakarta.ws.rs-api - ${jaxrs.api.version} - provided - - - - - org.slf4j - jcl-over-slf4j - runtime - - - ch.qos.logback - logback-classic - runtime - - - - org.apache.shiro.integrationtests - shiro-its-support - test - - - - com.jayway.restassured - rest-assured - 2.9.0 - test - - - commons-logging - commons-logging - - - - - - - - - jersey - - true - - - 2.23.2 - - - - org.glassfish.jersey.containers - jersey-container-grizzly2-servlet - ${jersey.version} - - - - - resteasy - - 3.9.0.Final - - - - org.jboss.resteasy - resteasy-jaxrs - ${resteasy.version} - - - - org.jboss.resteasy - resteasy-servlet-initializer - ${resteasy.version} - - - - org.jboss.resteasy - resteasy-jackson2-provider - ${resteasy.version} - - - - - cxf - - 3.3.5 - - - - org.apache.cxf - cxf-rt-rs-http-sci - ${cxf.version} - - - org.apache.cxf - cxf-rt-frontend-jaxws - ${cxf.version} - - - - - - org.eclipse.jetty - jetty-maven-plugin - - - src/main/webapp/WEB-INF/web.cxf.xml - - - - - maven-war-plugin - - src/main/webapp/WEB-INF/web.cxf.xml - - - - - - - - jdk19-plus - - [9,) - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - **/ContainerIntegrationIT.* - - - - - - - - - - diff --git a/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/SampleApplication.java b/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/SampleApplication.java deleted file mode 100644 index b7ae94961..000000000 --- a/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/SampleApplication.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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 org.apache.shiro.samples.jaxrs; - -import org.apache.shiro.samples.jaxrs.resources.HelloResource; -import org.apache.shiro.samples.jaxrs.resources.SecureResource; -import org.apache.shiro.web.jaxrs.ShiroFeature; - -import javax.ws.rs.ApplicationPath; -import javax.ws.rs.core.Application; -import java.util.HashSet; -import java.util.Set; - -/** - * Simple JAX-RS {@link Application} that is implementation agnostic. - * @since 1.4 - */ -@ApplicationPath("/") -public class SampleApplication extends Application { - - @Override - public Set> getClasses() { - Set> classes = new HashSet>(); - - // register Shiro - classes.add(ShiroFeature.class); - - // register resources - classes.add(HelloResource.class); - classes.add(SecureResource.class); - - return classes; - } -} diff --git a/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/HelloResource.java b/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/HelloResource.java deleted file mode 100644 index 6ba4d6446..000000000 --- a/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/HelloResource.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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 org.apache.shiro.samples.jaxrs.resources; - - -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; -import javax.ws.rs.container.AsyncResponse; -import javax.ws.rs.container.Suspended; - -@Path("say") -public class HelloResource { - - - @Produces({"application/json","plain/text"}) - @GET - public String saySomething(@QueryParam("words") @DefaultValue("Hello!") String words) { - return words; - } - - @Produces({"application/json","plain/text"}) - @GET - @Path("async") - public void saySomethingAsync(@QueryParam("words") @DefaultValue("Hello!") String words, - @Suspended AsyncResponse asyncResponse) { - asyncResponse.resume(words); - } -} diff --git a/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/SecureResource.java b/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/SecureResource.java deleted file mode 100644 index c5909875c..000000000 --- a/samples/jaxrs/src/main/java/org/apache/shiro/samples/jaxrs/resources/SecureResource.java +++ /dev/null @@ -1,75 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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 org.apache.shiro.samples.jaxrs.resources; - - -import org.apache.shiro.authz.annotation.RequiresAuthentication; -import org.apache.shiro.authz.annotation.RequiresGuest; -import org.apache.shiro.authz.annotation.RequiresPermissions; -import org.apache.shiro.authz.annotation.RequiresRoles; -import org.apache.shiro.authz.annotation.RequiresUser; - -import javax.ws.rs.DefaultValue; -import javax.ws.rs.GET; -import javax.ws.rs.Path; -import javax.ws.rs.Produces; -import javax.ws.rs.QueryParam; - -@Path("secure") -@Produces({"application/json","plain/text"}) -public class SecureResource { - - - @RequiresPermissions("lightsaber:requiresPermissions") - @Path("RequiresPermissions") - @GET - public String protectedByRequiresPermissions() { - return "protected"; - } - - @RequiresRoles("admin") - @Path("RequiresRoles") - @GET - public String protectedByRequiresRoles() { - return "protected"; - } - - @RequiresUser - @Path("RequiresUser") - @GET - public String protectedByRequiresUser() { - return "protected"; - } - - @RequiresGuest - @Path("RequiresGuest") - @GET - public String protectedByRequiresGuest() { - return "not protected"; - } - - @RequiresAuthentication - @Path("RequiresAuthentication") - @GET - public String protectedByRequiresAuthentication() { - return "protected"; - } - - -} diff --git a/samples/jaxrs/src/main/resources/META-INF/NOTICE b/samples/jaxrs/src/main/resources/META-INF/NOTICE deleted file mode 100644 index 9d26a95ff..000000000 --- a/samples/jaxrs/src/main/resources/META-INF/NOTICE +++ /dev/null @@ -1,15 +0,0 @@ -Apache Shiro -Copyright 2008-2020 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). - -The implementation for org.apache.shiro.util.SoftHashMap is based -on initial ideas from Dr. Heinz Kabutz's publicly posted version -available at http://www.javaspecialists.eu/archive/Issue015.html, -with continued modifications. - -Certain parts (StringUtils, IpAddressMatcher, etc.) of the source -code for this product was copied for simplicity and to reduce -dependencies from the source code developed by the Spring Framework -Project (http://www.springframework.org). diff --git a/samples/jaxrs/src/main/resources/logback.xml b/samples/jaxrs/src/main/resources/logback.xml deleted file mode 100644 index 6f20d75e9..000000000 --- a/samples/jaxrs/src/main/resources/logback.xml +++ /dev/null @@ -1,34 +0,0 @@ - - - - - - - %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n - - - - - - - - - - \ No newline at end of file diff --git a/samples/jaxrs/src/main/resources/shiro.ini b/samples/jaxrs/src/main/resources/shiro.ini deleted file mode 100644 index 54fa9498d..000000000 --- a/samples/jaxrs/src/main/resources/shiro.ini +++ /dev/null @@ -1,43 +0,0 @@ -# -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF 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. - -[main] -cacheManager = org.apache.shiro.cache.MemoryConstrainedCacheManager - -sessionManager = org.apache.shiro.web.session.mgt.DefaultWebSessionManager -sessionManager.sessionIdUrlRewritingEnabled = false - -securityManager.sessionManager = $sessionManager -securityManager.cacheManager = $cacheManager - -[urls] -/** = authcBasic[permissive] - -[users] -# format: username = password, role1, role2, ..., roleN -root = secret,admin -guest = guest,guest -presidentskroob = 12345,president -darkhelmet = ludicrousspeed,darklord,schwartz -lonestarr = vespa,goodguy,schwartz - -[roles] -# format: roleName = permission1, permission2, ..., permissionN -admin = * -schwartz = lightsaber:* -goodguy = winnebago:drive:eagle5 diff --git a/samples/jaxrs/src/main/webapp/WEB-INF/web.cxf.xml b/samples/jaxrs/src/main/webapp/WEB-INF/web.cxf.xml deleted file mode 100644 index 3e5fbe973..000000000 --- a/samples/jaxrs/src/main/webapp/WEB-INF/web.cxf.xml +++ /dev/null @@ -1,41 +0,0 @@ - - - - - - - CXFServlet - CXF Servlet - org.apache.cxf.jaxrs.servlet.CXFNonSpringJaxrsServlet - - javax.ws.rs.Application - org.apache.shiro.samples.jaxrs.SampleApplication - - 1 - - - CXFServlet - /* - - - diff --git a/samples/jaxrs/src/test/groovy/org/apache/shiro/web/jaxrs/ContainerIntegrationIT.groovy b/samples/jaxrs/src/test/groovy/org/apache/shiro/web/jaxrs/ContainerIntegrationIT.groovy deleted file mode 100644 index f55d37da5..000000000 --- a/samples/jaxrs/src/test/groovy/org/apache/shiro/web/jaxrs/ContainerIntegrationIT.groovy +++ /dev/null @@ -1,143 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one - * or more contributor license agreements. See the NOTICE file - * distributed with this work for additional information - * regarding copyright ownership. The ASF 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 org.apache.shiro.web.jaxrs - -import org.apache.shiro.testing.web.AbstractContainerIT -import org.junit.Test; - -import static com.jayway.restassured.RestAssured.* -import static org.hamcrest.Matchers.* - -public class ContainerIntegrationIT extends AbstractContainerIT { - - @Test - void testNoAuthResource() { - - get(getBaseUri() + "say") - .then() - .assertThat() - .statusCode(is(200)).and() - .body(equalTo("Hello!")) - } - - @Test - void testNoAuthResourceAsync() { - - get(getBaseUri() + "say/async") - .then() - .assertThat() - .statusCode(is(200)).and() - .body(equalTo("Hello!")) - } - - @Test - void testSecuredRequiresAuthentication() { - - get(getBaseUri() + "secure/RequiresAuthentication") - .then() - .assertThat().statusCode(is(401)) - - given() - .header("Authorization", getBasicAuthorizationHeaderValue("root", "secret")) - .when() - .get(getBaseUri() + "secure/RequiresAuthentication") - .then() - .assertThat() - .statusCode(is(200)).and() - .body(equalTo("protected")) - } - - @Test - void testSecuredRequiresUser() { - - get(getBaseUri() + "secure/RequiresUser") - .then() - .assertThat().statusCode(is(401)) - - given() - .header("Authorization", getBasicAuthorizationHeaderValue("root", "secret")) - .when() - .get(getBaseUri() + "secure/RequiresUser") - .then() - .assertThat() - .statusCode(is(200)).and() - .body(equalTo("protected")) - } - - @Test - void testSecuredRequiresRoles() { - - get(getBaseUri() + "secure/RequiresRoles") - .then() - .assertThat().statusCode(is(401)) - - given() - .header("Authorization", getBasicAuthorizationHeaderValue("guest", "guest")) - .when() - .get(getBaseUri() + "secure/RequiresRoles") - .then() - .assertThat() - .statusCode(is(403)).and() - - given() - .header("Authorization", getBasicAuthorizationHeaderValue("root", "secret")) - .when() - .get(getBaseUri() + "secure/RequiresRoles") - .then() - .assertThat() - .statusCode(is(200)).and() - .body(equalTo("protected")) - } - - @Test - void testSecuredRequiresPermissions() { - - get(getBaseUri() + "secure/RequiresPermissions") - .then() - .assertThat().statusCode(is(401)) - - given() - .header("Authorization", getBasicAuthorizationHeaderValue("guest", "guest")) - .when() - .get(getBaseUri() + "secure/RequiresPermissions") - .then() - .assertThat() - .statusCode(is(403)).and() - - given() - .header("Authorization", getBasicAuthorizationHeaderValue("lonestarr", "vespa")) - .when() - .get(getBaseUri() + "secure/RequiresPermissions") - .then() - .assertThat() - .statusCode(is(200)).and() - .body(equalTo("protected")) - } - - @Test - void testSecuredRequiresGuest() { - - get(getBaseUri() + "secure/RequiresGuest") - .then() - .assertThat() - .statusCode(is(200)).and() - .body(equalTo("not protected")) - } - -} diff --git a/samples/pom.xml b/samples/pom.xml index 3ae24a3ce..a62eff22e 100644 --- a/samples/pom.xml +++ b/samples/pom.xml @@ -48,7 +48,6 @@ guice quickstart-guice servlet-plugin - jaxrs