deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject git commit: DELTASPIKE-742 improved type lookup
Date Tue, 14 Oct 2014 10:31:06 GMT
Repository: deltaspike
Updated Branches:
  refs/heads/master 307835a5b -> a8770d46b


DELTASPIKE-742 improved type lookup


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

Branch: refs/heads/master
Commit: a8770d46b09f1c4a4c0dbe7d5e40b80de3f2bfae
Parents: 307835a
Author: gpetracek <gpetracek@apache.org>
Authored: Tue Oct 14 12:28:30 2014 +0200
Committer: gpetracek <gpetracek@apache.org>
Committed: Tue Oct 14 12:28:30 2014 +0200

----------------------------------------------------------------------
 .../security/impl/util/SecurityUtils.java       |  2 +-
 .../secured/SecuredAnnotationTest.java          | 22 +++++++++++
 .../authorization/secured/SecuredBean5.java     | 36 ++++++++++++++++++
 .../secured/SecuredBeanWithStereotype3.java     | 40 ++++++++++++++++++++
 4 files changed, 99 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/deltaspike/blob/a8770d46/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/util/SecurityUtils.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/util/SecurityUtils.java
b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/util/SecurityUtils.java
index 26c9807..68c3e05 100644
--- a/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/util/SecurityUtils.java
+++ b/deltaspike/modules/security/impl/src/main/java/org/apache/deltaspike/security/impl/util/SecurityUtils.java
@@ -42,7 +42,7 @@ public abstract class SecurityUtils
     {
         Set<Annotation> securityBindingTypes = new HashSet<Annotation>();
         Class<?> cls = targetClass;
-        while (!cls.equals(Object.class))
+        while (cls != null && !cls.equals(Object.class))
         {
             for (final Annotation annotation : cls.getAnnotations())
             {

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/a8770d46/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredAnnotationTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredAnnotationTest.java
b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredAnnotationTest.java
index 21f569d..37f7616 100644
--- a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredAnnotationTest.java
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredAnnotationTest.java
@@ -74,6 +74,28 @@ public abstract class SecuredAnnotationTest
     }
 
     @Test
+    public void interceptorTestWithStereotypeWithValue()
+    {
+        SecuredBean5 testBean = BeanProvider.getContextualReference(SecuredBean5.class, false);
+
+        Assert.assertEquals("result", testBean.getResult());
+
+        try
+        {
+            testBean.getBlockedResult();
+            Assert.fail("AccessDeniedException expect, but was not thrown");
+        }
+        catch (AccessDeniedException e)
+        {
+            //expected exception
+        }
+        catch (Exception e)
+        {
+            Assert.fail("Unexpected Exception: " + e);
+        }
+    }
+
+    @Test
     public void simpleInterceptorTestOnMethods()
     {
         SecuredBean3 testBean = BeanProvider.getContextualReference(SecuredBean3.class, false);

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/a8770d46/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBean5.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBean5.java
b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBean5.java
new file mode 100644
index 0000000..7d75535
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBean5.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.deltaspike.test.security.impl.authorization.secured;
+
+import javax.enterprise.context.ApplicationScoped;
+
+@ApplicationScoped
+@SecuredBeanWithStereotype3("test")
+public class SecuredBean5
+{
+    public String getBlockedResult()
+    {
+        return "blocked result";
+    }
+
+    public String getResult()
+    {
+        return "result";
+    }
+}

http://git-wip-us.apache.org/repos/asf/deltaspike/blob/a8770d46/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype3.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype3.java
b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype3.java
new file mode 100644
index 0000000..c6fe561
--- /dev/null
+++ b/deltaspike/modules/security/impl/src/test/java/org/apache/deltaspike/test/security/impl/authorization/secured/SecuredBeanWithStereotype3.java
@@ -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.apache.deltaspike.test.security.impl.authorization.secured;
+
+import org.apache.deltaspike.security.api.authorization.Secured;
+
+import javax.enterprise.inject.Stereotype;
+import java.lang.annotation.Retention;
+import java.lang.annotation.Target;
+
+import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.TYPE;
+import static java.lang.annotation.RetentionPolicy.RUNTIME;
+
+@Stereotype
+
+@Retention(value = RUNTIME)
+@Target({TYPE, METHOD } )
+
+@Secured(TestAccessDecisionVoter.class)
+public @interface SecuredBeanWithStereotype3
+{
+    String value();
+}


Mime
View raw message