You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2015/09/25 12:42:40 UTC
[05/33] tomee git commit: Align SNAPSHOT versions & reformat examples
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/MovieTest.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/MovieTest.java b/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/MovieTest.java
index 3dba45b..6a5b404 100644
--- a/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/MovieTest.java
+++ b/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/MovieTest.java
@@ -1,154 +1,152 @@
-/**
- * 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.injection.secure;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.annotation.Resource;
-import javax.ejb.EJB;
-import javax.ejb.EJBAccessException;
-import javax.ejb.SessionContext;
-import javax.ejb.embeddable.EJBContainer;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import java.util.List;
-import java.util.Properties;
-
-//START SNIPPET: code
-public class MovieTest {
-
- @EJB
- private UserInfo userInfo;
-
- @EJB
- private Movies movies;
-
- private EJBContainer container;
-
- @Before
- public void setUp() throws Exception {
- // Uncomment this line to set the login/logout functionality on Debug
- //System.setProperty("log4j.category.OpenEJB.security", "debug");
-
- Properties p = new Properties();
- p.put("movieDatabase", "new://Resource?type=DataSource");
- p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
- p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
-
- this.container = EJBContainer.createEJBContainer(p);
- this.container.getContext().bind("inject", this);
- }
-
- @After
- public void tearDown() {
- this.container.close();
- }
-
- @Test
- public void testAsManager() throws Exception {
- Properties p = new Properties();
- p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
- p.put(Context.SECURITY_PRINCIPAL, "jane");
- p.put(Context.SECURITY_CREDENTIALS, "waterfall");
-
- InitialContext context = new InitialContext(p);
- Assert.assertEquals("Wrong user", "jane", userInfo.getUserName());
- Assert.assertTrue("jane is supposed to be a Manager", userInfo.isCallerInRole("Manager"));
- Assert.assertTrue("jane is supposed to be an Employee", userInfo.isCallerInRole("Employee"));
-
- try {
- movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
- movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
- movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
-
- List<Movie> list = movies.getMovies();
- Assert.assertEquals("List.size()", 3, list.size());
-
- for (Movie movie : list) {
- movies.deleteMovie(movie);
- }
-
- Assert.assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
- } finally {
- context.close();
- }
- }
-
- @Test
- public void testAsEmployee() throws Exception {
- Properties p = new Properties();
- p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
- p.put(Context.SECURITY_PRINCIPAL, "joe");
- p.put(Context.SECURITY_CREDENTIALS, "cool");
-
- InitialContext context = new InitialContext(p);
- Assert.assertEquals("Wrong user", "joe", userInfo.getUserName());
- Assert.assertTrue("joe is supposed to be an Employee", userInfo.isCallerInRole("Employee"));
-
-
- try {
- movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
- movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
- movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
-
- List<Movie> list = movies.getMovies();
- Assert.assertEquals("List.size()", 3, list.size());
-
- for (Movie movie : list) {
- try {
- movies.deleteMovie(movie);
- Assert.fail("Employees should not be allowed to delete");
- } catch (EJBAccessException e) {
- // Good, Employees cannot delete things
- }
- }
-
- // The list should still be three movies long
- Assert.assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
- } finally {
- context.close();
- }
- }
-
- @Test
- public void testUnauthenticated() throws Exception {
- try {
- movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
- Assert.fail("Unauthenticated users should not be able to add movies. User: " + userInfo.getUserName());
- } catch (EJBAccessException e) {
- // Good, guests cannot add things
- }
-
- try {
- movies.deleteMovie(null);
- Assert.fail("Unauthenticated users should not be allowed to delete");
- } catch (EJBAccessException e) {
- // Good, Unauthenticated users cannot delete things
- }
-
- try {
- // Read access should be allowed
- movies.getMovies();
- } catch (EJBAccessException e) {
- Assert.fail("Read access should be allowed");
- }
- }
-}
-//END SNIPPET: code
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MovieTest {
+
+ @EJB
+ private UserInfo userInfo;
+
+ @EJB
+ private Movies movies;
+
+ private EJBContainer container;
+
+ @Before
+ public void setUp() throws Exception {
+ // Uncomment this line to set the login/logout functionality on Debug
+ //System.setProperty("log4j.category.OpenEJB.security", "debug");
+
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ this.container = EJBContainer.createEJBContainer(p);
+ this.container.getContext().bind("inject", this);
+ }
+
+ @After
+ public void tearDown() {
+ this.container.close();
+ }
+
+ @Test
+ public void testAsManager() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put(Context.SECURITY_PRINCIPAL, "jane");
+ p.put(Context.SECURITY_CREDENTIALS, "waterfall");
+
+ InitialContext context = new InitialContext(p);
+ Assert.assertEquals("Wrong user", "jane", userInfo.getUserName());
+ Assert.assertTrue("jane is supposed to be a Manager", userInfo.isCallerInRole("Manager"));
+ Assert.assertTrue("jane is supposed to be an Employee", userInfo.isCallerInRole("Employee"));
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ Assert.assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testAsEmployee() throws Exception {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.put(Context.SECURITY_PRINCIPAL, "joe");
+ p.put(Context.SECURITY_CREDENTIALS, "cool");
+
+ InitialContext context = new InitialContext(p);
+ Assert.assertEquals("Wrong user", "joe", userInfo.getUserName());
+ Assert.assertTrue("joe is supposed to be an Employee", userInfo.isCallerInRole("Employee"));
+
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ Assert.fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ Assert.assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ Assert.fail("Unauthenticated users should not be able to add movies. User: " + userInfo.getUserName());
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ Assert.fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+ movies.getMovies();
+ } catch (EJBAccessException e) {
+ Assert.fail("Read access should be allowed");
+ }
+ }
+}
+//END SNIPPET: code
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/UserInfo.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/UserInfo.java b/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/UserInfo.java
index 100af66..341239a 100644
--- a/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/UserInfo.java
+++ b/examples/testing-security-2/src/test/java/org/superbiz/injection/secure/UserInfo.java
@@ -1,36 +1,36 @@
-/**
- * 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.injection.secure;
-
-import javax.annotation.Resource;
-import javax.ejb.SessionContext;
-import javax.ejb.Stateless;
-
-@Stateless
-public class UserInfo {
- @Resource
- private SessionContext sessionContext;
-
- public String getUserName() {
- return sessionContext.getCallerPrincipal().getName();
- }
-
- public boolean isCallerInRole(String role) {
- return sessionContext.isCallerInRole(role);
- }
-}
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+import javax.annotation.Resource;
+import javax.ejb.SessionContext;
+import javax.ejb.Stateless;
+
+@Stateless
+public class UserInfo {
+ @Resource
+ private SessionContext sessionContext;
+
+ public String getUserName() {
+ return sessionContext.getCallerPrincipal().getName();
+ }
+
+ public boolean isCallerInRole(String role) {
+ return sessionContext.isCallerInRole(role);
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movie.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movie.java b/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movie.java
index b5df45c..73fdf33 100644
--- a/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movie.java
+++ b/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movie.java
@@ -1,61 +1,61 @@
-/**
- * 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.injection.secure;
-
-import javax.persistence.Entity;
-
-@Entity
-public class Movie {
-
- private String director;
- private String title;
- private int year;
-
- public Movie() {
- }
-
- public Movie(String director, String title, int year) {
- this.director = director;
- this.title = title;
- this.year = year;
- }
-
- public String getDirector() {
- return director;
- }
-
- public void setDirector(String director) {
- this.director = director;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public int getYear() {
- return year;
- }
-
- public void setYear(int year) {
- this.year = year;
- }
-
-}
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movies.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movies.java b/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movies.java
index b3ba8e8..100598b 100644
--- a/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movies.java
+++ b/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/Movies.java
@@ -1,55 +1,55 @@
-/**
- * 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.injection.secure;
-
-//START SNIPPET: code
-
-import javax.annotation.security.PermitAll;
-import javax.annotation.security.RolesAllowed;
-import javax.ejb.Stateful;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceContextType;
-import javax.persistence.Query;
-import java.util.List;
-
-@Stateful
-public class Movies {
-
- @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
- private EntityManager entityManager;
-
- @RolesAllowed({"Employee", "Manager"})
- public void addMovie(Movie movie) throws Exception {
- entityManager.persist(movie);
- }
-
- @RolesAllowed({"Manager"})
- public void deleteMovie(Movie movie) throws Exception {
- entityManager.remove(movie);
- }
-
- @PermitAll
- @TransactionAttribute(TransactionAttributeType.SUPPORTS)
- public List<Movie> getMovies() throws Exception {
- Query query = entityManager.createQuery("SELECT m from Movie as m");
- return query.getResultList();
- }
-}
-//END SNIPPET: code
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+//START SNIPPET: code
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/MyLoginProvider.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/MyLoginProvider.java b/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/MyLoginProvider.java
index a21c43e..bdf9540 100644
--- a/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/MyLoginProvider.java
+++ b/examples/testing-security-3/src/main/java/org/superbiz/injection/secure/MyLoginProvider.java
@@ -1,39 +1,39 @@
-/**
- * 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.injection.secure;
-
-import org.apache.openejb.core.security.jaas.LoginProvider;
-
-import javax.security.auth.login.FailedLoginException;
-import java.util.Arrays;
-import java.util.List;
-
-public class MyLoginProvider implements LoginProvider {
-
- @Override
- public List<String> authenticate(String user, String password) throws FailedLoginException {
- if ("paul".equals(user) && "michelle".equals(password)) {
- return Arrays.asList("Manager", "rockstar", "beatle");
- }
-
- if ("eddie".equals(user) && "jump".equals(password)) {
- return Arrays.asList("Employee", "rockstar", "vanhalen");
- }
-
- throw new FailedLoginException("Bad user or password!");
- }
-}
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+import org.apache.openejb.core.security.jaas.LoginProvider;
+
+import javax.security.auth.login.FailedLoginException;
+import java.util.Arrays;
+import java.util.List;
+
+public class MyLoginProvider implements LoginProvider {
+
+ @Override
+ public List<String> authenticate(String user, String password) throws FailedLoginException {
+ if ("paul".equals(user) && "michelle".equals(password)) {
+ return Arrays.asList("Manager", "rockstar", "beatle");
+ }
+
+ if ("eddie".equals(user) && "jump".equals(password)) {
+ return Arrays.asList("Employee", "rockstar", "vanhalen");
+ }
+
+ throw new FailedLoginException("Bad user or password!");
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-3/src/test/java/org/superbiz/injection/secure/MovieTest.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-3/src/test/java/org/superbiz/injection/secure/MovieTest.java b/examples/testing-security-3/src/test/java/org/superbiz/injection/secure/MovieTest.java
index 18f505a..a939525 100644
--- a/examples/testing-security-3/src/test/java/org/superbiz/injection/secure/MovieTest.java
+++ b/examples/testing-security-3/src/test/java/org/superbiz/injection/secure/MovieTest.java
@@ -1,157 +1,157 @@
-/**
- * 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.injection.secure;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.ejb.EJB;
-import javax.ejb.EJBAccessException;
-import javax.ejb.embeddable.EJBContainer;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.List;
-import java.util.Properties;
-
-//START SNIPPET: code
-public class MovieTest {
-
- @EJB
- private Movies movies;
-
- private EJBContainer container;
-
- private Context getContext(String user, String pass) throws NamingException {
- Properties p = new Properties();
- p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
- p.setProperty("openejb.authentication.realmName", "ServiceProviderLogin");
- p.put(Context.SECURITY_PRINCIPAL, user);
- p.put(Context.SECURITY_CREDENTIALS, pass);
- return new InitialContext(p);
- }
-
- @Before
- public void setUp() throws Exception {
- Properties p = new Properties();
- p.put("movieDatabase", "new://Resource?type=DataSource");
- p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
- p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
-
- this.container = EJBContainer.createEJBContainer(p);
- this.container.getContext().bind("inject", this);
- }
-
- @After
- public void tearDown() {
- this.container.close();
- }
-
- @Test
- public void testAsManager() throws Exception {
- final Context context = getContext("paul", "michelle");
-
- try {
- movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
- movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
- movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
-
- List<Movie> list = movies.getMovies();
- Assert.assertEquals("List.size()", 3, list.size());
-
- for (Movie movie : list) {
- movies.deleteMovie(movie);
- }
-
- Assert.assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
- } finally {
- context.close();
- }
- }
-
- @Test
- public void testAsEmployee() throws Exception {
- final Context context = getContext("eddie", "jump");
-
- try {
- movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
- movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
- movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
-
- List<Movie> list = movies.getMovies();
- Assert.assertEquals("List.size()", 3, list.size());
-
- for (Movie movie : list) {
- try {
- movies.deleteMovie(movie);
- Assert.fail("Employees should not be allowed to delete");
- } catch (EJBAccessException e) {
- // Good, Employees cannot delete things
- }
- }
-
- // The list should still be three movies long
- Assert.assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
- } finally {
- context.close();
- }
- }
-
- @Test
- public void testUnauthenticated() throws Exception {
- try {
- movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
- Assert.fail("Unauthenticated users should not be able to add movies");
- } catch (EJBAccessException e) {
- // Good, guests cannot add things
- }
-
- try {
- movies.deleteMovie(null);
- Assert.fail("Unauthenticated users should not be allowed to delete");
- } catch (EJBAccessException e) {
- // Good, Unauthenticated users cannot delete things
- }
-
- try {
- // Read access should be allowed
- movies.getMovies();
- } catch (EJBAccessException e) {
- Assert.fail("Read access should be allowed");
- }
- }
-
- @Test
- public void testLoginFailure() throws NamingException {
- try {
- getContext("eddie", "panama");
- Assert.fail("supposed to have a login failure here");
- } catch (javax.naming.AuthenticationException e) {
- //expected
- }
-
- try {
- getContext("jimmy", "foxylady");
- Assert.fail("supposed to have a login failure here");
- } catch (javax.naming.AuthenticationException e) {
- //expected
- }
- }
-}
-//END SNIPPET: code
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MovieTest {
+
+ @EJB
+ private Movies movies;
+
+ private EJBContainer container;
+
+ private Context getContext(String user, String pass) throws NamingException {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.setProperty("openejb.authentication.realmName", "ServiceProviderLogin");
+ p.put(Context.SECURITY_PRINCIPAL, user);
+ p.put(Context.SECURITY_CREDENTIALS, pass);
+ return new InitialContext(p);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ this.container = EJBContainer.createEJBContainer(p);
+ this.container.getContext().bind("inject", this);
+ }
+
+ @After
+ public void tearDown() {
+ this.container.close();
+ }
+
+ @Test
+ public void testAsManager() throws Exception {
+ final Context context = getContext("paul", "michelle");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ Assert.assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testAsEmployee() throws Exception {
+ final Context context = getContext("eddie", "jump");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ Assert.fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ Assert.assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ Assert.fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ Assert.fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+ movies.getMovies();
+ } catch (EJBAccessException e) {
+ Assert.fail("Read access should be allowed");
+ }
+ }
+
+ @Test
+ public void testLoginFailure() throws NamingException {
+ try {
+ getContext("eddie", "panama");
+ Assert.fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+
+ try {
+ getContext("jimmy", "foxylady");
+ Assert.fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+ }
+}
+//END SNIPPET: code
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/LoginBean.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/LoginBean.java b/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/LoginBean.java
index 7c88fff..4ee61a6 100644
--- a/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/LoginBean.java
+++ b/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/LoginBean.java
@@ -1,39 +1,39 @@
-/**
- * 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.injection.secure;
-
-import javax.ejb.Stateless;
-import javax.security.auth.login.FailedLoginException;
-import java.util.Arrays;
-import java.util.List;
-
-@Stateless
-public class LoginBean {
-
- public List<String> authenticate(String user, String password) throws FailedLoginException {
- if ("paul".equals(user) && "michelle".equals(password)) {
- return Arrays.asList("Manager", "rockstar", "beatle");
- }
-
- if ("eddie".equals(user) && "jump".equals(password)) {
- return Arrays.asList("Employee", "rockstar", "vanhalen");
- }
-
- throw new FailedLoginException("Bad user or password!");
- }
-}
-
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+import javax.ejb.Stateless;
+import javax.security.auth.login.FailedLoginException;
+import java.util.Arrays;
+import java.util.List;
+
+@Stateless
+public class LoginBean {
+
+ public List<String> authenticate(String user, String password) throws FailedLoginException {
+ if ("paul".equals(user) && "michelle".equals(password)) {
+ return Arrays.asList("Manager", "rockstar", "beatle");
+ }
+
+ if ("eddie".equals(user) && "jump".equals(password)) {
+ return Arrays.asList("Employee", "rockstar", "vanhalen");
+ }
+
+ throw new FailedLoginException("Bad user or password!");
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movie.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movie.java b/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movie.java
index b5df45c..73fdf33 100644
--- a/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movie.java
+++ b/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movie.java
@@ -1,61 +1,61 @@
-/**
- * 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.injection.secure;
-
-import javax.persistence.Entity;
-
-@Entity
-public class Movie {
-
- private String director;
- private String title;
- private int year;
-
- public Movie() {
- }
-
- public Movie(String director, String title, int year) {
- this.director = director;
- this.title = title;
- this.year = year;
- }
-
- public String getDirector() {
- return director;
- }
-
- public void setDirector(String director) {
- this.director = director;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public int getYear() {
- return year;
- }
-
- public void setYear(int year) {
- this.year = year;
- }
-
-}
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movies.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movies.java b/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movies.java
index b3ba8e8..100598b 100644
--- a/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movies.java
+++ b/examples/testing-security-4/src/main/java/org/superbiz/injection/secure/Movies.java
@@ -1,55 +1,55 @@
-/**
- * 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.injection.secure;
-
-//START SNIPPET: code
-
-import javax.annotation.security.PermitAll;
-import javax.annotation.security.RolesAllowed;
-import javax.ejb.Stateful;
-import javax.ejb.TransactionAttribute;
-import javax.ejb.TransactionAttributeType;
-import javax.persistence.EntityManager;
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceContextType;
-import javax.persistence.Query;
-import java.util.List;
-
-@Stateful
-public class Movies {
-
- @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
- private EntityManager entityManager;
-
- @RolesAllowed({"Employee", "Manager"})
- public void addMovie(Movie movie) throws Exception {
- entityManager.persist(movie);
- }
-
- @RolesAllowed({"Manager"})
- public void deleteMovie(Movie movie) throws Exception {
- entityManager.remove(movie);
- }
-
- @PermitAll
- @TransactionAttribute(TransactionAttributeType.SUPPORTS)
- public List<Movie> getMovies() throws Exception {
- Query query = entityManager.createQuery("SELECT m from Movie as m");
- return query.getResultList();
- }
-}
-//END SNIPPET: code
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+//START SNIPPET: code
+
+import javax.annotation.security.PermitAll;
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Stateful;
+import javax.ejb.TransactionAttribute;
+import javax.ejb.TransactionAttributeType;
+import javax.persistence.EntityManager;
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @PersistenceContext(unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+ private EntityManager entityManager;
+
+ @RolesAllowed({"Employee", "Manager"})
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @RolesAllowed({"Manager"})
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @PermitAll
+ @TransactionAttribute(TransactionAttributeType.SUPPORTS)
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-4/src/test/java/org/superbiz/injection/secure/MovieTest.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-4/src/test/java/org/superbiz/injection/secure/MovieTest.java b/examples/testing-security-4/src/test/java/org/superbiz/injection/secure/MovieTest.java
index 0e3654b..ec18a2f 100644
--- a/examples/testing-security-4/src/test/java/org/superbiz/injection/secure/MovieTest.java
+++ b/examples/testing-security-4/src/test/java/org/superbiz/injection/secure/MovieTest.java
@@ -1,161 +1,161 @@
-/**
- * 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.injection.secure;
-
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-
-import javax.ejb.EJB;
-import javax.ejb.EJBAccessException;
-import javax.ejb.embeddable.EJBContainer;
-import javax.naming.Context;
-import javax.naming.InitialContext;
-import javax.naming.NamingException;
-import java.util.List;
-import java.util.Properties;
-
-//START SNIPPET: code
-public class MovieTest {
-
- @EJB
- private Movies movies;
-
- private EJBContainer container;
-
- private Context getContext(String user, String pass) throws NamingException {
- Properties p = new Properties();
- p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
- p.setProperty("openejb.authentication.realmName", "ScriptLogin");
- p.put(Context.SECURITY_PRINCIPAL, user);
- p.put(Context.SECURITY_CREDENTIALS, pass);
-
- return new InitialContext(p);
- }
-
- @Before
- public void setUp() throws Exception {
- final ClassLoader ctxCl = Thread.currentThread().getContextClassLoader();
- System.setProperty("openejb.ScriptLoginModule.scriptURI", ctxCl.getResource("loginscript.js").toExternalForm());
-
- Properties p = new Properties();
- p.put("movieDatabase", "new://Resource?type=DataSource");
- p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
- p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
-
- this.container = EJBContainer.createEJBContainer(p);
- this.container.getContext().bind("inject", this);
- }
-
- @After
- public void tearDown() {
- this.container.close();
- }
-
- @Test
- public void testAsManager() throws Exception {
- final Context context = getContext("paul", "michelle");
-
- try {
- movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
- movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
- movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
-
- List<Movie> list = movies.getMovies();
- Assert.assertEquals("List.size()", 3, list.size());
-
- for (Movie movie : list) {
- movies.deleteMovie(movie);
- }
-
- Assert.assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
- } finally {
- context.close();
- }
- }
-
- @Test
- public void testAsEmployee() throws Exception {
- final Context context = getContext("eddie", "jump");
-
- try {
- movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
- movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
- movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
-
- List<Movie> list = movies.getMovies();
- Assert.assertEquals("List.size()", 3, list.size());
-
- for (Movie movie : list) {
- try {
- movies.deleteMovie(movie);
- Assert.fail("Employees should not be allowed to delete");
- } catch (EJBAccessException e) {
- // Good, Employees cannot delete things
- }
- }
-
- // The list should still be three movies long
- Assert.assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
- } finally {
- context.close();
- }
- }
-
- @Test
- public void testUnauthenticated() throws Exception {
- try {
- movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
- Assert.fail("Unauthenticated users should not be able to add movies");
- } catch (EJBAccessException e) {
- // Good, guests cannot add things
- }
-
- try {
- movies.deleteMovie(null);
- Assert.fail("Unauthenticated users should not be allowed to delete");
- } catch (EJBAccessException e) {
- // Good, Unauthenticated users cannot delete things
- }
-
- try {
- // Read access should be allowed
- movies.getMovies();
- } catch (EJBAccessException e) {
- Assert.fail("Read access should be allowed");
- }
- }
-
- @Test
- public void testLoginFailure() throws NamingException {
- try {
- getContext("eddie", "panama");
- Assert.fail("supposed to have a login failure here");
- } catch (javax.naming.AuthenticationException e) {
- //expected
- }
-
- try {
- getContext("jimmy", "foxylady");
- Assert.fail("supposed to have a login failure here");
- } catch (javax.naming.AuthenticationException e) {
- //expected
- }
- }
-}
-//END SNIPPET: code
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import javax.ejb.EJB;
+import javax.ejb.EJBAccessException;
+import javax.ejb.embeddable.EJBContainer;
+import javax.naming.Context;
+import javax.naming.InitialContext;
+import javax.naming.NamingException;
+import java.util.List;
+import java.util.Properties;
+
+//START SNIPPET: code
+public class MovieTest {
+
+ @EJB
+ private Movies movies;
+
+ private EJBContainer container;
+
+ private Context getContext(String user, String pass) throws NamingException {
+ Properties p = new Properties();
+ p.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.openejb.core.LocalInitialContextFactory");
+ p.setProperty("openejb.authentication.realmName", "ScriptLogin");
+ p.put(Context.SECURITY_PRINCIPAL, user);
+ p.put(Context.SECURITY_CREDENTIALS, pass);
+
+ return new InitialContext(p);
+ }
+
+ @Before
+ public void setUp() throws Exception {
+ final ClassLoader ctxCl = Thread.currentThread().getContextClassLoader();
+ System.setProperty("openejb.ScriptLoginModule.scriptURI", ctxCl.getResource("loginscript.js").toExternalForm());
+
+ Properties p = new Properties();
+ p.put("movieDatabase", "new://Resource?type=DataSource");
+ p.put("movieDatabase.JdbcDriver", "org.hsqldb.jdbcDriver");
+ p.put("movieDatabase.JdbcUrl", "jdbc:hsqldb:mem:moviedb");
+
+ this.container = EJBContainer.createEJBContainer(p);
+ this.container.getContext().bind("inject", this);
+ }
+
+ @After
+ public void tearDown() {
+ this.container.close();
+ }
+
+ @Test
+ public void testAsManager() throws Exception {
+ final Context context = getContext("paul", "michelle");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ movies.deleteMovie(movie);
+ }
+
+ Assert.assertEquals("Movies.getMovies()", 0, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testAsEmployee() throws Exception {
+ final Context context = getContext("eddie", "jump");
+
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ movies.addMovie(new Movie("Joel Coen", "Fargo", 1996));
+ movies.addMovie(new Movie("Joel Coen", "The Big Lebowski", 1998));
+
+ List<Movie> list = movies.getMovies();
+ Assert.assertEquals("List.size()", 3, list.size());
+
+ for (Movie movie : list) {
+ try {
+ movies.deleteMovie(movie);
+ Assert.fail("Employees should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Employees cannot delete things
+ }
+ }
+
+ // The list should still be three movies long
+ Assert.assertEquals("Movies.getMovies()", 3, movies.getMovies().size());
+ } finally {
+ context.close();
+ }
+ }
+
+ @Test
+ public void testUnauthenticated() throws Exception {
+ try {
+ movies.addMovie(new Movie("Quentin Tarantino", "Reservoir Dogs", 1992));
+ Assert.fail("Unauthenticated users should not be able to add movies");
+ } catch (EJBAccessException e) {
+ // Good, guests cannot add things
+ }
+
+ try {
+ movies.deleteMovie(null);
+ Assert.fail("Unauthenticated users should not be allowed to delete");
+ } catch (EJBAccessException e) {
+ // Good, Unauthenticated users cannot delete things
+ }
+
+ try {
+ // Read access should be allowed
+ movies.getMovies();
+ } catch (EJBAccessException e) {
+ Assert.fail("Read access should be allowed");
+ }
+ }
+
+ @Test
+ public void testLoginFailure() throws NamingException {
+ try {
+ getContext("eddie", "panama");
+ Assert.fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+
+ try {
+ getContext("jimmy", "foxylady");
+ Assert.fail("supposed to have a login failure here");
+ } catch (javax.naming.AuthenticationException e) {
+ //expected
+ }
+ }
+}
+//END SNIPPET: code
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movie.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movie.java b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movie.java
index b5df45c..73fdf33 100644
--- a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movie.java
+++ b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movie.java
@@ -1,61 +1,61 @@
-/**
- * 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.injection.secure;
-
-import javax.persistence.Entity;
-
-@Entity
-public class Movie {
-
- private String director;
- private String title;
- private int year;
-
- public Movie() {
- }
-
- public Movie(String director, String title, int year) {
- this.director = director;
- this.title = title;
- this.year = year;
- }
-
- public String getDirector() {
- return director;
- }
-
- public void setDirector(String director) {
- this.director = director;
- }
-
- public String getTitle() {
- return title;
- }
-
- public void setTitle(String title) {
- this.title = title;
- }
-
- public int getYear() {
- return year;
- }
-
- public void setYear(int year) {
- this.year = year;
- }
-
-}
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+import javax.persistence.Entity;
+
+@Entity
+public class Movie {
+
+ private String director;
+ private String title;
+ private int year;
+
+ public Movie() {
+ }
+
+ public Movie(String director, String title, int year) {
+ this.director = director;
+ this.title = title;
+ this.year = year;
+ }
+
+ public String getDirector() {
+ return director;
+ }
+
+ public void setDirector(String director) {
+ this.director = director;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public void setTitle(String title) {
+ this.title = title;
+ }
+
+ public int getYear() {
+ return year;
+ }
+
+ public void setYear(int year) {
+ this.year = year;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movies.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movies.java b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movies.java
index deee414..13b2b45 100644
--- a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movies.java
+++ b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/Movies.java
@@ -1,53 +1,53 @@
-/**
- * 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.injection.secure;
-
-//START SNIPPET: code
-
-import org.superbiz.injection.secure.api.AddPermission;
-import org.superbiz.injection.secure.api.DeletePermission;
-import org.superbiz.injection.secure.api.MovieUnit;
-import org.superbiz.injection.secure.api.ReadPermission;
-
-import javax.ejb.Stateful;
-import javax.persistence.EntityManager;
-import javax.persistence.Query;
-import java.util.List;
-
-@Stateful
-public class Movies {
-
- @MovieUnit
- private EntityManager entityManager;
-
- @AddPermission
- public void addMovie(Movie movie) throws Exception {
- entityManager.persist(movie);
- }
-
- @DeletePermission
- public void deleteMovie(Movie movie) throws Exception {
- entityManager.remove(movie);
- }
-
- @ReadPermission
- public List<Movie> getMovies() throws Exception {
- Query query = entityManager.createQuery("SELECT m from Movie as m");
- return query.getResultList();
- }
-}
-//END SNIPPET: code
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure;
+
+//START SNIPPET: code
+
+import org.superbiz.injection.secure.api.AddPermission;
+import org.superbiz.injection.secure.api.DeletePermission;
+import org.superbiz.injection.secure.api.MovieUnit;
+import org.superbiz.injection.secure.api.ReadPermission;
+
+import javax.ejb.Stateful;
+import javax.persistence.EntityManager;
+import javax.persistence.Query;
+import java.util.List;
+
+@Stateful
+public class Movies {
+
+ @MovieUnit
+ private EntityManager entityManager;
+
+ @AddPermission
+ public void addMovie(Movie movie) throws Exception {
+ entityManager.persist(movie);
+ }
+
+ @DeletePermission
+ public void deleteMovie(Movie movie) throws Exception {
+ entityManager.remove(movie);
+ }
+
+ @ReadPermission
+ public List<Movie> getMovies() throws Exception {
+ Query query = entityManager.createQuery("SELECT m from Movie as m");
+ return query.getResultList();
+ }
+}
+//END SNIPPET: code
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/AddPermission.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/AddPermission.java b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/AddPermission.java
index 2f22414..843ae62 100644
--- a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/AddPermission.java
+++ b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/AddPermission.java
@@ -1,37 +1,37 @@
-/**
- * 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.injection.secure.api;
-
-import javax.annotation.security.RolesAllowed;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Metatype
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-
-public @interface AddPermission {
-
- public static interface $ {
-
- @AddPermission
- @RolesAllowed({"Employee", "Manager"})
- public void method();
- }
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure.api;
+
+import javax.annotation.security.RolesAllowed;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface AddPermission {
+
+ public static interface $ {
+
+ @AddPermission
+ @RolesAllowed({"Employee", "Manager"})
+ public void method();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/DeletePermission.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/DeletePermission.java b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/DeletePermission.java
index dd69028..0c3f783 100644
--- a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/DeletePermission.java
+++ b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/DeletePermission.java
@@ -1,37 +1,37 @@
-/**
- * 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.injection.secure.api;
-
-import javax.annotation.security.RolesAllowed;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Metatype
-@Target(ElementType.METHOD)
-@Retention(RetentionPolicy.RUNTIME)
-
-public @interface DeletePermission {
-
- public static interface $ {
-
- @DeletePermission
- @RolesAllowed("Manager")
- public void method();
- }
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure.api;
+
+import javax.annotation.security.RolesAllowed;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.METHOD)
+@Retention(RetentionPolicy.RUNTIME)
+
+public @interface DeletePermission {
+
+ public static interface $ {
+
+ @DeletePermission
+ @RolesAllowed("Manager")
+ public void method();
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/Metatype.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/Metatype.java b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/Metatype.java
index eb08d38..341108d 100644
--- a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/Metatype.java
+++ b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/Metatype.java
@@ -1,29 +1,29 @@
-/**
- * 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.injection.secure.api;
-
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Metatype
-@Target(ElementType.ANNOTATION_TYPE)
-@Retention(RetentionPolicy.RUNTIME)
-public @interface Metatype {
-
-}
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure.api;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Metatype {
+
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/f9f1b8ad/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/MovieUnit.java
----------------------------------------------------------------------
diff --git a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/MovieUnit.java b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/MovieUnit.java
index 795a4cf..81a89ef 100644
--- a/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/MovieUnit.java
+++ b/examples/testing-security-meta/src/main/java/org/superbiz/injection/secure/api/MovieUnit.java
@@ -1,33 +1,33 @@
-/**
- * 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.injection.secure.api;
-
-import javax.persistence.PersistenceContext;
-import javax.persistence.PersistenceContextType;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-@Metatype
-@Target({ElementType.METHOD, ElementType.FIELD})
-@Retention(RetentionPolicy.RUNTIME)
-
-@PersistenceContext(name = "movie-unit", unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
-public @interface MovieUnit {
-
-}
+/**
+ * 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
+ * <p/>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p/>
+ * 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.injection.secure.api;
+
+import javax.persistence.PersistenceContext;
+import javax.persistence.PersistenceContextType;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Metatype
+@Target({ElementType.METHOD, ElementType.FIELD})
+@Retention(RetentionPolicy.RUNTIME)
+
+@PersistenceContext(name = "movie-unit", unitName = "movie-unit", type = PersistenceContextType.EXTENDED)
+public @interface MovieUnit {
+
+}