Author: rmannibucau
Date: Fri Jun 14 07:00:59 2013
New Revision: 1492968
URL: http://svn.apache.org/r1492968
Log:
TOMEE-977 jaxrs+rest sample
Added:
tomee/tomee/trunk/examples/rest-jaas/
tomee/tomee/trunk/examples/rest-jaas/pom.xml
tomee/tomee/trunk/examples/rest-jaas/src/
tomee/tomee/trunk/examples/rest-jaas/src/main/
tomee/tomee/trunk/examples/rest-jaas/src/main/java/
tomee/tomee/trunk/examples/rest-jaas/src/main/java/org/
tomee/tomee/trunk/examples/rest-jaas/src/main/java/org/superbiz/
tomee/tomee/trunk/examples/rest-jaas/src/main/java/org/superbiz/jaxrs/
tomee/tomee/trunk/examples/rest-jaas/src/main/java/org/superbiz/jaxrs/jaas/
tomee/tomee/trunk/examples/rest-jaas/src/main/java/org/superbiz/jaxrs/jaas/JAASSecuredRestEndpoint.java
tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/
tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/
tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/groups.properties
tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/login.config
tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/server.xml
tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/users.properties
tomee/tomee/trunk/examples/rest-jaas/src/main/webapp/
tomee/tomee/trunk/examples/rest-jaas/src/main/webapp/WEB-INF/
tomee/tomee/trunk/examples/rest-jaas/src/main/webapp/WEB-INF/web.xml
Modified:
tomee/tomee/trunk/examples/pom.xml
Modified: tomee/tomee/trunk/examples/pom.xml
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/examples/pom.xml?rev=1492968&r1=1492967&r2=1492968&view=diff
==============================================================================
--- tomee/tomee/trunk/examples/pom.xml (original)
+++ tomee/tomee/trunk/examples/pom.xml Fri Jun 14 07:00:59 2013
@@ -101,6 +101,7 @@
<module>resources-declared-in-webapp</module>
<module>rest-applicationcomposer-mockito</module>
<module>rest-applicationcomposer</module>
+ <module>rest-jaas</module>
<module>rest-on-ejb</module>
<module>rest-example</module>
<module>rest-example-with-application</module>
Added: tomee/tomee/trunk/examples/rest-jaas/pom.xml
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/examples/rest-jaas/pom.xml?rev=1492968&view=auto
==============================================================================
--- tomee/tomee/trunk/examples/rest-jaas/pom.xml (added)
+++ tomee/tomee/trunk/examples/rest-jaas/pom.xml Fri Jun 14 07:00:59 2013
@@ -0,0 +1,120 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+ 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.superbiz</groupId>
+ <artifactId>rest-jaas</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <packaging>war</packaging>
+ <name>OpenEJB :: Examples :: JAXRS and JAAS</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>javaee-api</artifactId>
+ <version>6.0-5</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.openejb</groupId>
+ <artifactId>tomee-catalina</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-catalina</artifactId>
+ <version>7.0.41</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.0</version>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.openejb.maven</groupId>
+ <artifactId>tomee-maven-plugin</artifactId>
+ <version>1.6.0-SNAPSHOT</version>
+ <configuration>
+ <systemVariables>
+
<java.security.auth.login.config>${project.build.directory}/apache-tomee/conf/login.config</java.security.auth.login.config>
+ </systemVariables>
+ <context>ROOT</context>
+ <tomeeClassifier>jaxrs</tomeeClassifier>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-war-plugin</artifactId>
+ <version>2.3</version>
+ <configuration>
+ <failOnMissingWebXml>false</failOnMissingWebXml>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <repositories>
+ <repository>
+ <id>apache-m2-snapshot</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </repository>
+ </repositories>
+ <pluginRepositories>
+ <pluginRepository>
+ <id>apache-m2-snapshot-plugin</id>
+ <name>Apache Snapshot Repository</name>
+ <url>http://repository.apache.org/snapshots</url>
+ </pluginRepository>
+ </pluginRepositories>
+
+ <!--
+ This section allows you to configure where to publish libraries for sharing.
+ It is not required and may be deleted. For more information see:
+ http://maven.apache.org/plugins/maven-deploy-plugin/
+ -->
+ <distributionManagement>
+ <repository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/repo/</url>
+ </repository>
+ <snapshotRepository>
+ <id>localhost</id>
+ <url>file://${basedir}/target/snapshot-repo/</url>
+ </snapshotRepository>
+ </distributionManagement>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+</project>
Added:
tomee/tomee/trunk/examples/rest-jaas/src/main/java/org/superbiz/jaxrs/jaas/JAASSecuredRestEndpoint.java
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/examples/rest-jaas/src/main/java/org/superbiz/jaxrs/jaas/JAASSecuredRestEndpoint.java?rev=1492968&view=auto
==============================================================================
---
tomee/tomee/trunk/examples/rest-jaas/src/main/java/org/superbiz/jaxrs/jaas/JAASSecuredRestEndpoint.java
(added)
+++
tomee/tomee/trunk/examples/rest-jaas/src/main/java/org/superbiz/jaxrs/jaas/JAASSecuredRestEndpoint.java
Fri Jun 14 07:00:59 2013
@@ -0,0 +1,40 @@
+/**
+ * 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.superbiz.jaxrs.jaas;
+
+import javax.annotation.Resource;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Lock;
+import javax.ejb.LockType;
+import javax.ejb.SessionContext;
+import javax.ejb.Singleton;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("rest")
+@Singleton @Lock(LockType.READ)
+public class JAASSecuredRestEndpoint {
+ @Resource
+ private SessionContext ctx;
+
+ @GET
+ @Path("jaas")
+ @RolesAllowed("superUser")
+ public String getPrincipalName() {
+ return ctx.getCallerPrincipal().getName();
+ }
+}
Added:
tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/groups.properties
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/groups.properties?rev=1492968&view=auto
==============================================================================
--- tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/groups.properties
(added)
+++ tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/groups.properties
Fri Jun 14 07:00:59 2013
@@ -0,0 +1,2 @@
+admin=tomee,adminOnly
+superUser=tomee
Added: tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/login.config
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/login.config?rev=1492968&view=auto
==============================================================================
--- tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/login.config
(added)
+++ tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/login.config Fri
Jun 14 07:00:59 2013
@@ -0,0 +1,6 @@
+PropertiesLoginModule {
+ org.apache.openejb.core.security.jaas.PropertiesLoginModule required
+ Debug=false
+ UsersFile="users.properties"
+ GroupsFile="groups.properties";
+};
Added: tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/server.xml
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/server.xml?rev=1492968&view=auto
==============================================================================
--- tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/server.xml (added)
+++ tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/server.xml Fri Jun
14 07:00:59 2013
@@ -0,0 +1,36 @@
+<?xml version='1.0' encoding='utf-8'?>
+<!--
+ 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.
+-->
+<Server port="8005" shutdown="SHUTDOWN">
+ <Listener className="org.apache.tomee.catalina.ServerListener" />
+ <Listener className="org.apache.catalina.security.SecurityListener" />
+
+ <Service name="Catalina">
+ <Connector port="8080" protocol="HTTP/1.1" />
+ <Engine name="Catalina" defaultHost="localhost">
+
+ <Realm className="org.apache.catalina.realm.JAASRealm"
appName="PropertiesLoginModule"
+
userClassNames="org.apache.openejb.core.security.jaas.UserPrincipal"
+
roleClassNames="org.apache.openejb.core.security.jaas.GroupPrincipal">
+ </Realm>
+
+ <Host name="localhost" appBase="webapps" />
+ </Engine>
+ </Service>
+</Server>
Added: tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/users.properties
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/users.properties?rev=1492968&view=auto
==============================================================================
--- tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/users.properties
(added)
+++ tomee/tomee/trunk/examples/rest-jaas/src/main/tomee/conf/users.properties
Fri Jun 14 07:00:59 2013
@@ -0,0 +1,2 @@
+tomee=tomee
+adminOnly=adminOnly
Added: tomee/tomee/trunk/examples/rest-jaas/src/main/webapp/WEB-INF/web.xml
URL:
http://svn.apache.org/viewvc/tomee/tomee/trunk/examples/rest-jaas/src/main/webapp/WEB-INF/web.xml?rev=1492968&view=auto
==============================================================================
--- tomee/tomee/trunk/examples/rest-jaas/src/main/webapp/WEB-INF/web.xml (added)
+++ tomee/tomee/trunk/examples/rest-jaas/src/main/webapp/WEB-INF/web.xml Fri
Jun 14 07:00:59 2013
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+-->
+<web-app xmlns="http://java.sun.com/xml/ns/javaee"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
+ version="3.0">
+ <login-config>
+ <auth-method>BASIC</auth-method>
+ <realm-name>PropertiesLoginModule</realm-name>
+ </login-config>
+
+ <security-constraint>
+ <web-resource-collection>
+ <web-resource-name>Secured REST Service with JAAS</web-resource-name>
+ <url-pattern>/rest/*</url-pattern>
+ </web-resource-collection>
+ <auth-constraint>
+ <role-name>*</role-name> <!-- we'll use JAAS so don't filter too much
here -->
+ </auth-constraint>
+ </security-constraint>
+
+ <security-role>
+ <role-name>admin</role-name>
+ </security-role>
+ <security-role>
+ <role-name>superUser</role-name>
+ </security-role>
+</web-app>