You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2015/03/17 14:15:00 UTC

tomee git commit: we are sometimes too lazy

Repository: tomee
Updated Branches:
  refs/heads/master dd50c21b7 -> dfeca89c7


we are sometimes too lazy


Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/dfeca89c
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/dfeca89c
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/dfeca89c

Branch: refs/heads/master
Commit: dfeca89c78833f055e97dc6954f52bcb9bbad36c
Parents: dd50c21
Author: Romain Manni-Bucau <rm...@apache.org>
Authored: Tue Mar 17 14:14:51 2015 +0100
Committer: Romain Manni-Bucau <rm...@apache.org>
Committed: Tue Mar 17 14:14:51 2015 +0100

----------------------------------------------------------------------
 .../tests/realm/CdiEventRealmIntegTest.java     | 33 ---------------
 .../tests/realm/MultiAuthenticator.java         | 42 ++++++++++++++++++++
 .../arquillian/tests/realm/MyService.java       | 36 +++++++++++++++++
 3 files changed, 78 insertions(+), 33 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tomee/blob/dfeca89c/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/CdiEventRealmIntegTest.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/CdiEventRealmIntegTest.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/CdiEventRealmIntegTest.java
index 2a4d384..82c9e7d 100644
--- a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/CdiEventRealmIntegTest.java
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/CdiEventRealmIntegTest.java
@@ -85,37 +85,4 @@ public class CdiEventRealmIntegTest
 
         assertEquals(401, val.getStatus());
     }
-
-
-    @Path("/test")
-    @Singleton
-    public static class MyService {
-        @Inject
-        private MultiAuthenticator authenticator;
-
-        @GET
-        @RolesAllowed("admin")
-        public String hello() {
-            return authenticator.isStacked() ? "ok" : "ko";
-        }
-    }
-
-    @RequestScoped
-    public static class MultiAuthenticator {
-        private boolean stacked = false;
-
-        public void authenticate(@Observes final UserPasswordAuthenticationEvent event) {
-            if (!"secret".equals(event.getCredential())) return; // not authenticated
-            event.setPrincipal(new GenericPrincipal(event.getUsername(), "", Arrays.asList(event.getUsername())));
-        }
-
-        public void stacked(@Observes final UserPasswordAuthenticationEvent event) {
-            stacked = true;
-        }
-
-        public boolean isStacked() {
-            return stacked;
-        }
-    }
-
 }

http://git-wip-us.apache.org/repos/asf/tomee/blob/dfeca89c/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/MultiAuthenticator.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/MultiAuthenticator.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/MultiAuthenticator.java
new file mode 100644
index 0000000..0124b07
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/MultiAuthenticator.java
@@ -0,0 +1,42 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ */
+package org.apache.openejb.arquillian.tests.realm;
+
+import org.apache.catalina.realm.GenericPrincipal;
+import org.apache.tomee.catalina.realm.event.UserPasswordAuthenticationEvent;
+
+import java.util.Arrays;
+import javax.enterprise.context.RequestScoped;
+import javax.enterprise.event.Observes;
+
+@RequestScoped
+public class MultiAuthenticator {
+    private boolean stacked = false;
+
+    public void authenticate(@Observes final UserPasswordAuthenticationEvent event) {
+        if (!"secret".equals(event.getCredential())) return; // not authenticated
+        event.setPrincipal(new GenericPrincipal(event.getUsername(), "", Arrays.asList(event.getUsername())));
+    }
+
+    public void stacked(@Observes final UserPasswordAuthenticationEvent event) {
+        stacked = true;
+    }
+
+    public boolean isStacked() {
+        return stacked;
+    }
+}

http://git-wip-us.apache.org/repos/asf/tomee/blob/dfeca89c/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/MyService.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/MyService.java b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/MyService.java
new file mode 100644
index 0000000..ae4dee5
--- /dev/null
+++ b/arquillian/arquillian-tomee-tests/arquillian-tomee-webprofile-tests/src/test/java/org/apache/openejb/arquillian/tests/realm/MyService.java
@@ -0,0 +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.apache.openejb.arquillian.tests.realm;
+
+import javax.annotation.security.RolesAllowed;
+import javax.ejb.Singleton;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+
+@Path("/test")
+@Singleton
+public class MyService {
+    @Inject
+    private MultiAuthenticator authenticator;
+
+    @GET
+    @RolesAllowed("admin")
+    public String hello() {
+        return authenticator.isStacked() ? "ok" : "ko";
+    }
+}