[jboss-cvs] JBossAS SVN: r94467 - in projects/metadata/web/trunk: src/main/java/org/jboss/metadata/annotation/creator/web and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Wed Oct 7 11:33:48 EDT 2009
Author: remy.maucherat at jboss.com
Date: 2009-10-07 11:33:48 -0400 (Wed, 07 Oct 2009)
New Revision: 94467
Added:
projects/metadata/web/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/ServletSecurityProcessor.java
Modified:
projects/metadata/web/trunk/.classpath
projects/metadata/web/trunk/pom.xml
projects/metadata/web/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/WebComponentProcessor.java
projects/metadata/web/trunk/src/main/java/org/jboss/metadata/web/spec/WebCommonMetaData.java
projects/metadata/web/trunk/src/test/java/org/jboss/test/metadata/annotation/web/AnnotationWebUnitTestCase.java
Log:
- Add the @ServletSecurity implementation.
Modified: projects/metadata/web/trunk/.classpath
===================================================================
--- projects/metadata/web/trunk/.classpath 2009-10-07 15:25:24 UTC (rev 94466)
+++ projects/metadata/web/trunk/.classpath 2009-10-07 15:33:48 UTC (rev 94467)
@@ -1,50 +1,51 @@
-<classpath>
- <classpathentry kind="src" path="src/test/java" output="target/tests-classes" including="**/*.java"/>
- <classpathentry kind="src" path="src/test/resources" output="target/tests-classes" excluding="**/*.java"/>
- <classpathentry kind="src" path="src/main/java" including="**/*.java"/>
- <classpathentry kind="src" path="src/main/resources" excluding="**/*.java"/>
- <classpathentry kind="output" path="target/classes"/>
- <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1.1/activation-1.1.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
- <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" sourcepath="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar" sourcepath="M2_REPO/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/gnu-getopt/getopt/1.0.13/getopt-1.0.13.jar"/>
- <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.14.GA/jboss-common-core-2.2.14.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.14.GA/jboss-common-core-2.2.14.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.CR1/jboss-ejb-api-3.0.0.CR1.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/1.0.0/jboss-ejb3-ext-api-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/1.0.0/jboss-ejb3-ext-api-1.0.0-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxws/3.0.1-native-2.0.4.GA/jboss-jaxws-3.0.1-native-2.0.4.GA.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.GA/jboss-jms-api-1.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.GA/jboss-jms-api-1.1.0.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.0.GA/jboss-mdr-2.0.0.GA.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-security-spi/2.0.3.SP1/jboss-security-spi-2.0.3.SP1.jar" sourcepath="M2_REPO/org/jboss/security/jboss-security-spi/2.0.3.SP1/jboss-security-spi-2.0.3.SP1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-server-manager/1.0.2.GA/jboss-server-manager-1.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-server-manager/1.0.2.GA/jboss-server-manager-1.0.2.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/test/jboss-test/1.1.4.GA/jboss-test-1.1.4.GA.jar" sourcepath="M2_REPO/org/jboss/test/jboss-test/1.1.4.GA/jboss-test-1.1.4.GA-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.CR1/jboss-transaction-api-1.0.1.CR1.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-vfs/2.0.0.CR1/jboss-vfs-2.0.0.CR1.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/security/jbosssx-client/2.0.3.SP1/jbosssx-client-2.0.3.SP1.jar" sourcepath="M2_REPO/org/jboss/security/jbosssx-client/2.0.3.SP1/jbosssx-client-2.0.3.SP1-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/ws/jbossws-spi/1.0.6.GA/jbossws-spi-1.0.6.GA.jar"/>
- <classpathentry kind="var" path="M2_REPO/jboss/web/servlet-api/3.0.0.alpha-3/servlet-api-3.0.0.alpha-3.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.2.Beta1/jbossxb-2.0.2.Beta1.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.2.Beta1/jbossxb-2.0.2.Beta1-sources.jar">
- <attributes>
- <attribute value="jar:file:/C:/Users/avoka/.m2/repository/org/jboss/jbossxb/2.0.2.Beta1/jbossxb-2.0.2.Beta1-javadoc.jar!/" name="javadoc_location"/>
- </attributes>
- </classpathentry>
- <classpathentry kind="var" path="M2_REPO/org/jboss/naming/jnp-client/5.0.1.GA/jnp-client-5.0.1.GA.jar"/>
- <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
- <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/metadata/metadata-common/2.0.0-SNAPSHOT/metadata-common-2.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/metadata/metadata-common/2.0.0-SNAPSHOT/metadata-common-2.0.0-SNAPSHOT-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/org/jboss/metadata/metadata-common/2.0.0-SNAPSHOT/metadata-common-2.0.0-SNAPSHOT-tests.jar" sourcepath="M2_REPO/org/jboss/metadata/metadata-common/2.0.0-SNAPSHOT/metadata-common-2.0.0-SNAPSHOT-test-sources.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
- <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"/>
- <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry including="**/*.java" kind="src" output="target/tests-classes" path="src/test/java"/>
+ <classpathentry excluding="**/*.java" kind="src" output="target/tests-classes" path="src/test/resources"/>
+ <classpathentry including="**/*.java" kind="src" path="src/main/java"/>
+ <classpathentry excluding="**/*.java" kind="src" path="src/main/resources"/>
+ <classpathentry kind="var" path="M2_REPO/javax/activation/activation/1.1.1/activation-1.1.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant/1.7.0/ant-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-junit/1.7.0/ant-junit-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/apache/ant/ant-launcher/1.7.0/ant-launcher-1.7.0.jar"/>
+ <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1.jar" sourcepath="M2_REPO/dom4j/dom4j/1.6.1/dom4j-1.6.1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/wutka-dtdparser/dtdparser121/1.2.1/dtdparser121-1.2.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA.jar" sourcepath="M2_REPO/org/hibernate/ejb3-persistence/1.0.2.GA/ejb3-persistence-1.0.2.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/gnu-getopt/getopt/1.0.13/getopt-1.0.13.jar"/>
+ <classpathentry kind="var" path="M2_REPO/sun-jaxb/jaxb-api/2.1.4/jaxb-api-2.1.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-common-core/2.2.14.GA/jboss-common-core-2.2.14.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-common-core/2.2.14.GA/jboss-common-core-2.2.14.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-ejb-api/3.0.0.CR1/jboss-ejb-api-3.0.0.CR1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/1.0.0/jboss-ejb3-ext-api-1.0.0.jar" sourcepath="M2_REPO/org/jboss/ejb3/jboss-ejb3-ext-api/1.0.0/jboss-ejb3-ext-api-1.0.0-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxrpc/1.0.4.GA/jboss-jaxrpc-1.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/jbossws/jboss-jaxws/3.0.1-native-2.0.4.GA/jboss-jaxws-3.0.1-native-2.0.4.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.GA/jboss-jms-api-1.1.0.GA.jar" sourcepath="M2_REPO/org/jboss/javaee/jboss-jms-api/1.1.0.GA/jboss-jms-api-1.1.0.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-log4j/2.0.5.GA/jboss-logging-log4j-2.0.5.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA.jar" sourcepath="M2_REPO/org/jboss/logging/jboss-logging-spi/2.0.5.GA/jboss-logging-spi-2.0.5.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-mdr/2.0.0.GA/jboss-mdr-2.0.0.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/profiler/jvmti/jboss-profiler-jvmti/1.0.0.CR5/jboss-profiler-jvmti-1.0.0.CR5.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jboss-reflect/2.0.2.GA/jboss-reflect-2.0.2.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/security/jboss-security-spi/2.0.3.SP1/jboss-security-spi-2.0.3.SP1.jar" sourcepath="M2_REPO/org/jboss/security/jboss-security-spi/2.0.3.SP1/jboss-security-spi-2.0.3.SP1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jbossas/jboss-server-manager/1.0.2.GA/jboss-server-manager-1.0.2.GA.jar" sourcepath="M2_REPO/org/jboss/jbossas/jboss-server-manager/1.0.2.GA/jboss-server-manager-1.0.2.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/test/jboss-test/1.1.4.GA/jboss-test-1.1.4.GA.jar" sourcepath="M2_REPO/org/jboss/test/jboss-test/1.1.4.GA/jboss-test-1.1.4.GA-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/javaee/jboss-transaction-api/1.0.1.CR1/jboss-transaction-api-1.0.1.CR1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jboss-vfs/2.0.0.CR1/jboss-vfs-2.0.0.CR1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/security/jbosssx-client/2.0.3.SP1/jbosssx-client-2.0.3.SP1.jar" sourcepath="M2_REPO/org/jboss/security/jbosssx-client/2.0.3.SP1/jbosssx-client-2.0.3.SP1-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/ws/jbossws-spi/1.0.6.GA/jbossws-spi-1.0.6.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/jboss/web/servlet-api/3.0.0.alpha-6/servlet-api-3.0.0.alpha-6.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/jbossxb/2.0.2.Beta1/jbossxb-2.0.2.Beta1.jar" sourcepath="M2_REPO/org/jboss/jbossxb/2.0.2.Beta1/jbossxb-2.0.2.Beta1-sources.jar">
+ <attributes>
+ <attribute name="javadoc_location" value="jar:file:/C:/Users/avoka/.m2/repository/org/jboss/jbossxb/2.0.2.Beta1/jbossxb-2.0.2.Beta1-javadoc.jar!/"/>
+ </attributes>
+ </classpathentry>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/naming/jnp-client/5.0.1.GA/jnp-client-5.0.1.GA.jar"/>
+ <classpathentry kind="var" path="M2_REPO/junit/junit/4.4/junit-4.4.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-log4j/log4j/1.2.14/log4j-1.2.14.jar"/>
+ <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14.jar" sourcepath="M2_REPO/log4j/log4j/1.2.14/log4j-1.2.14-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/metadata/metadata-common/2.0.0-SNAPSHOT/metadata-common-2.0.0-SNAPSHOT.jar" sourcepath="M2_REPO/org/jboss/metadata/metadata-common/2.0.0-SNAPSHOT/metadata-common-2.0.0-SNAPSHOT-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/org/jboss/metadata/metadata-common/2.0.0-SNAPSHOT/metadata-common-2.0.0-SNAPSHOT-tests.jar" sourcepath="M2_REPO/org/jboss/metadata/metadata-common/2.0.0-SNAPSHOT/metadata-common-2.0.0-SNAPSHOT-test-sources.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xercesImpl/2.9.1/xercesImpl-2.9.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/apache-xerces/xml-apis/2.9.1/xml-apis-2.9.1.jar"/>
+ <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"/>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+ <classpathentry kind="output" path="target/classes"/>
</classpath>
Modified: projects/metadata/web/trunk/pom.xml
===================================================================
--- projects/metadata/web/trunk/pom.xml 2009-10-07 15:25:24 UTC (rev 94466)
+++ projects/metadata/web/trunk/pom.xml 2009-10-07 15:33:48 UTC (rev 94467)
@@ -120,7 +120,7 @@
<dependency>
<groupId>jboss.web</groupId>
<artifactId>servlet-api</artifactId>
- <version>3.0.0.alpha-3</version>
+ <version>3.0.0.alpha-6</version>
</dependency>
Added: projects/metadata/web/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/ServletSecurityProcessor.java
===================================================================
--- projects/metadata/web/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/ServletSecurityProcessor.java (rev 0)
+++ projects/metadata/web/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/ServletSecurityProcessor.java 2009-10-07 15:33:48 UTC (rev 94467)
@@ -0,0 +1,211 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2007, Red Hat Middleware LLC, and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.metadata.annotation.creator.web;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.AnnotatedElement;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+
+import javax.servlet.annotation.HttpConstraint;
+import javax.servlet.annotation.HttpMethodConstraint;
+import javax.servlet.annotation.MultipartConfig;
+import javax.servlet.annotation.ServletSecurity;
+import javax.servlet.annotation.ServletSecurity.EmptyRoleSemantic;
+import javax.servlet.annotation.ServletSecurity.TransportGuarantee;
+
+import org.jboss.metadata.annotation.creator.AbstractFinderUser;
+import org.jboss.metadata.annotation.creator.Creator;
+import org.jboss.metadata.annotation.creator.Processor;
+import org.jboss.metadata.annotation.creator.ProcessorUtils;
+import org.jboss.metadata.annotation.finder.AnnotationFinder;
+import org.jboss.metadata.web.spec.AnnotationMetaData;
+import org.jboss.metadata.web.spec.AnnotationsMetaData;
+import org.jboss.metadata.web.spec.AuthConstraintMetaData;
+import org.jboss.metadata.web.spec.MultipartConfigMetaData;
+import org.jboss.metadata.web.spec.SecurityConstraintMetaData;
+import org.jboss.metadata.web.spec.TransportGuaranteeType;
+import org.jboss.metadata.web.spec.UserDataConstraintMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionMetaData;
+import org.jboss.metadata.web.spec.WebResourceCollectionsMetaData;
+
+/**
+ * Processor for servlet @ServletSecurity
+ * @author Remy Maucherat
+ * @version $Revision: 67218 $
+ */
+public class ServletSecurityProcessor extends AbstractFinderUser
+ implements Processor<AnnotationsMetaData, Class<?>>, Creator<Class<?>, List<SecurityConstraintMetaData>>
+{
+ public ServletSecurityProcessor(AnnotationFinder<AnnotatedElement> finder)
+ {
+ super(finder);
+ }
+
+ public void process(AnnotationsMetaData metaData, Class<?> type)
+ {
+ ServletSecurity annotation = finder.getAnnotation(type, ServletSecurity.class);
+ if(annotation == null)
+ return;
+
+ List<SecurityConstraintMetaData> securityConstraints = create(type);
+ AnnotationMetaData annotationMD = metaData.get(type.getName());
+ if (annotationMD == null)
+ {
+ annotationMD = new AnnotationMetaData();
+ annotationMD.setClassName(type.getName());
+ metaData.add(annotationMD);
+ }
+ annotationMD.setSecurityConstraints(securityConstraints);
+ }
+
+ public List<SecurityConstraintMetaData> create(Class<?> element)
+ {
+ ServletSecurity servletSecurity = finder.getAnnotation(element, ServletSecurity.class);
+ if (servletSecurity == null)
+ return null;
+
+ HttpConstraint httpConstraint = servletSecurity.value();
+ HttpMethodConstraint[] httpMethodConstraints = servletSecurity.httpMethodConstraints();
+
+ List<SecurityConstraintMetaData> metaData = new ArrayList<SecurityConstraintMetaData>();
+
+ ArrayList<String> methodOmissions = new ArrayList<String>();
+ boolean classPA = httpConstraint.value().equals(EmptyRoleSemantic.PERMIT);
+ boolean classDA = httpConstraint.value().equals(EmptyRoleSemantic.DENY);
+ boolean classTP = httpConstraint.transportGuarantee().equals(TransportGuarantee.CONFIDENTIAL);
+ String[] classRA = httpConstraint.rolesAllowed();
+
+ // Process method constraints
+ if (httpMethodConstraints != null && httpMethodConstraints.length > 0)
+ {
+ for (HttpMethodConstraint httpMethodConstraint : httpMethodConstraints)
+ {
+ boolean methodPA = httpMethodConstraint.emptyRoleSemantic().equals(EmptyRoleSemantic.PERMIT);
+ boolean methodDA = httpMethodConstraint.emptyRoleSemantic().equals(EmptyRoleSemantic.DENY);
+ boolean methodTP = httpMethodConstraint.transportGuarantee().equals(TransportGuarantee.CONFIDENTIAL);
+ String[] methodRA = httpMethodConstraint.rolesAllowed();
+ if (methodPA || methodDA || methodTP || methodRA != null)
+ {
+ methodOmissions.add(httpMethodConstraint.value());
+ // Define a constraint specific for the method
+ SecurityConstraintMetaData securityConstraint = new SecurityConstraintMetaData();
+ if (methodDA)
+ {
+ AuthConstraintMetaData emptyAuthConstraint = new AuthConstraintMetaData();
+ securityConstraint.setAuthConstraint(emptyAuthConstraint);
+ }
+ if (methodPA)
+ {
+ AuthConstraintMetaData allAuthConstraint = new AuthConstraintMetaData();
+ List<String> all = new ArrayList<String>();
+ all.add("*");
+ allAuthConstraint.setRoleNames(all);
+ securityConstraint.setAuthConstraint(allAuthConstraint);
+ }
+ if (methodRA != null)
+ {
+ AuthConstraintMetaData authConstraint = new AuthConstraintMetaData();
+ List<String> roleNames = new ArrayList<String>();
+ for (String role: methodRA)
+ {
+ roleNames.add(role);
+ }
+ authConstraint.setRoleNames(roleNames);
+ securityConstraint.setAuthConstraint(authConstraint);
+ }
+ if (methodTP)
+ {
+ UserDataConstraintMetaData userDataConstraint = new UserDataConstraintMetaData();
+ userDataConstraint.setTransportGuarantee(TransportGuaranteeType.CONFIDENTIAL);
+ securityConstraint.setUserDataConstraint(userDataConstraint);
+ }
+ WebResourceCollectionsMetaData webResourceCollections = new WebResourceCollectionsMetaData();
+ WebResourceCollectionMetaData webResourceCollection = new WebResourceCollectionMetaData();
+ List<String> httpMethods = new ArrayList<String>();
+ httpMethods.add(httpMethodConstraint.value());
+ webResourceCollection.setHttpMethods(httpMethods);
+ webResourceCollections.add(webResourceCollection);
+ securityConstraint.setResourceCollections(webResourceCollections);
+ metaData.add(securityConstraint);
+ }
+
+ }
+
+ }
+
+ if (classPA || classTP || classRA != null)
+ {
+ // Define a constraint for the class
+ SecurityConstraintMetaData securityConstraint = new SecurityConstraintMetaData();
+ if (classDA)
+ {
+ AuthConstraintMetaData emptyAuthConstraint = new AuthConstraintMetaData();
+ securityConstraint.setAuthConstraint(emptyAuthConstraint);
+ }
+ if (classPA)
+ {
+ AuthConstraintMetaData allAuthConstraint = new AuthConstraintMetaData();
+ List<String> all = new ArrayList<String>();
+ all.add("*");
+ allAuthConstraint.setRoleNames(all);
+ securityConstraint.setAuthConstraint(allAuthConstraint);
+ }
+ if (classRA != null)
+ {
+ AuthConstraintMetaData authConstraint = new AuthConstraintMetaData();
+ List<String> roleNames = new ArrayList<String>();
+ for (String role: classRA)
+ {
+ roleNames.add(role);
+ }
+ authConstraint.setRoleNames(roleNames);
+ securityConstraint.setAuthConstraint(authConstraint);
+ }
+ if (classTP) {
+ UserDataConstraintMetaData userDataConstraint = new UserDataConstraintMetaData();
+ userDataConstraint.setTransportGuarantee(TransportGuaranteeType.CONFIDENTIAL);
+ securityConstraint.setUserDataConstraint(userDataConstraint);
+ }
+ WebResourceCollectionsMetaData webResourceCollections = new WebResourceCollectionsMetaData();
+ WebResourceCollectionMetaData webResourceCollection = new WebResourceCollectionMetaData();
+ List<String> httpMethodOmissions = new ArrayList<String>();
+ for (String methodOmission : methodOmissions)
+ {
+ httpMethodOmissions.add(methodOmission);
+ }
+ webResourceCollection.setHttpMethodOmissions(httpMethodOmissions);
+ webResourceCollections.add(webResourceCollection);
+ securityConstraint.setResourceCollections(webResourceCollections);
+ metaData.add(securityConstraint);
+ }
+
+ return metaData;
+ }
+
+ public Collection<Class<? extends Annotation>> getAnnotationTypes()
+ {
+ return ProcessorUtils.createAnnotationSet(ServletSecurity.class);
+ }
+
+}
Modified: projects/metadata/web/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/WebComponentProcessor.java
===================================================================
--- projects/metadata/web/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/WebComponentProcessor.java 2009-10-07 15:25:24 UTC (rev 94466)
+++ projects/metadata/web/trunk/src/main/java/org/jboss/metadata/annotation/creator/web/WebComponentProcessor.java 2009-10-07 15:33:48 UTC (rev 94467)
@@ -56,8 +56,8 @@
addTypeProcessor(new DeclareRolesProcessor(finder));
// @MultipartConfig
addTypeProcessor(new MultipartConfigProcessor(finder));
- // @SecurityConstraint
- //TODO addTypeProcessor(new SecurityConstraintProcessor(finder));
+ // @ServletSecurity
+ addTypeProcessor(new ServletSecurityProcessor(finder));
}
@Override
Modified: projects/metadata/web/trunk/src/main/java/org/jboss/metadata/web/spec/WebCommonMetaData.java
===================================================================
--- projects/metadata/web/trunk/src/main/java/org/jboss/metadata/web/spec/WebCommonMetaData.java 2009-10-07 15:25:24 UTC (rev 94466)
+++ projects/metadata/web/trunk/src/main/java/org/jboss/metadata/web/spec/WebCommonMetaData.java 2009-10-07 15:33:48 UTC (rev 94467)
@@ -892,7 +892,7 @@
}
// All ENC elements except message destinations
- // The default override merge should work for these elements
+ // The default override merge applies to these elements
if (webFragmentMetaData.getJndiEnvironmentRefsGroup() != null)
{
if (getJndiEnvironmentRefsGroup() != null)
@@ -907,13 +907,13 @@
}
// Message destinations
+ // The default override merge applies to this elements
if (getMessageDestinations() == null)
{
setMessageDestinations(webFragmentMetaData.getMessageDestinations());
}
else if (webFragmentMetaData.getMessageDestinations() != null)
{
- // FIXME: this is unlikely to do the right thing
getMessageDestinations().merge((webMetaData != null) ? webMetaData.getMessageDestinations() : null,
webFragmentMetaData.getMessageDestinations());
}
Modified: projects/metadata/web/trunk/src/test/java/org/jboss/test/metadata/annotation/web/AnnotationWebUnitTestCase.java
===================================================================
--- projects/metadata/web/trunk/src/test/java/org/jboss/test/metadata/annotation/web/AnnotationWebUnitTestCase.java 2009-10-07 15:25:24 UTC (rev 94466)
+++ projects/metadata/web/trunk/src/test/java/org/jboss/test/metadata/annotation/web/AnnotationWebUnitTestCase.java 2009-10-07 15:33:48 UTC (rev 94467)
@@ -42,6 +42,7 @@
import javax.persistence.PersistenceUnit;
import javax.persistence.PersistenceUnits;
import javax.servlet.annotation.MultipartConfig;
+import javax.servlet.annotation.ServletSecurity;
import javax.servlet.annotation.WebFilter;
import javax.servlet.annotation.WebListener;
import javax.servlet.annotation.WebServlet;
@@ -489,6 +490,7 @@
typeAnnotations.add(WebServlet.class);
typeAnnotations.add(WebListener.class);
typeAnnotations.add(MultipartConfig.class);
+ typeAnnotations.add(ServletSecurity.class);
// Assert Type annotations
assertAnnotations(typeAnnotations, context.getTypeAnnotations());
More information about the jboss-cvs-commits
mailing list