Author: reto
Date: Fri Nov 7 19:01:09 2014
New Revision: 1637433
URL: http://svn.apache.org/r1637433
Log:
STANBOL-1335: applied patch Cristian Petroaca
Added:
stanbol/trunk/commons/cors/ (with props)
stanbol/trunk/commons/cors/pom.xml
stanbol/trunk/commons/cors/src/
stanbol/trunk/commons/cors/src/license/
stanbol/trunk/commons/cors/src/license/THIRD-PARTY.properties
stanbol/trunk/commons/cors/src/main/
stanbol/trunk/commons/cors/src/main/java/
stanbol/trunk/commons/cors/src/main/java/org/
stanbol/trunk/commons/cors/src/main/java/org/apache/
stanbol/trunk/commons/cors/src/main/java/org/apache/stanbol/
stanbol/trunk/commons/cors/src/main/java/org/apache/stanbol/commons/
stanbol/trunk/commons/cors/src/main/java/org/apache/stanbol/commons/cors/
stanbol/trunk/commons/cors/src/main/java/org/apache/stanbol/commons/cors/StanbolCorsFilter.java
Removed:
stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/CorsConstants.java
stanbol/trunk/commons/web/base/src/main/java/org/apache/stanbol/commons/web/base/CorsHelper.java
stanbol/trunk/commons/web/base/src/test/java/org/apache/stanbol/commons/web/base/CorsAccessControlAllowMethodTest.java
Modified:
stanbol/trunk/commons/pom.xml
stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml
Propchange: stanbol/trunk/commons/cors/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Nov 7 19:01:09 2014
@@ -0,0 +1 @@
+target
Added: stanbol/trunk/commons/cors/pom.xml
URL:
http://svn.apache.org/viewvc/stanbol/trunk/commons/cors/pom.xml?rev=1637433&view=auto
==============================================================================
--- stanbol/trunk/commons/cors/pom.xml (added)
+++ stanbol/trunk/commons/cors/pom.xml Fri Nov 7 19:01:09 2014
@@ -0,0 +1,109 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <parent>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>stanbol-parent</artifactId>
+ <version>6-SNAPSHOT</version>
+ <relativePath>../../parent</relativePath>
+ </parent>
+
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.cors</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ <packaging>bundle</packaging>
+
+ <name>Apache Stanbol Commons Cors Filter</name>
+ <description>Allows clients to perform Cross Origin requests to the Stanbol
Server</description>
+ <scm>
+ <connection>
+ scm:svn:http://svn.apache.org/repos/asf/stanbol/trunk/commons/cors
+ </connection>
+ <developerConnection>
+ scm:svn:https://svn.apache.org/repos/asf/stanbol/trunk/commons/cors
+ </developerConnection>
+ <url>http://stanbol.apache.org/</url>
+ </scm>
+
+ <build>
+ <!-- make it an OSGi bundle -->
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-scr-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package />
+ <Import-Package>
+ javax.servlet.*; version="[2.5.0,4.0.0)",
+ *
+ </Import-Package>
+
<Embed-Dependency>java-property-utils,cors-filter;scope=compile|runtime</Embed-Dependency>
+ </instructions>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>commons-io</groupId>
+ <artifactId>commons-io</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+
+ <!-- OSGi tax -->
+ <dependency>
+ <groupId>org.osgi</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.scr.annotations</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>com.thetransactioncompany</groupId>
+ <artifactId>cors-filter</artifactId>
+ <version>2.2.1</version>
+ </dependency>
+
+ <dependency>
+ <groupId>com.thetransactioncompany</groupId>
+ <artifactId>java-property-utils</artifactId>
+ <version>1.9.1</version>
+ </dependency>
+ </dependencies>
+
+</project>
Added: stanbol/trunk/commons/cors/src/license/THIRD-PARTY.properties
URL:
http://svn.apache.org/viewvc/stanbol/trunk/commons/cors/src/license/THIRD-PARTY.properties?rev=1637433&view=auto
==============================================================================
--- stanbol/trunk/commons/cors/src/license/THIRD-PARTY.properties (added)
+++ stanbol/trunk/commons/cors/src/license/THIRD-PARTY.properties Fri Nov 7
19:01:09 2014
@@ -0,0 +1,22 @@
+# Generated by org.codehaus.mojo.license.AddThirdPartyMojo
+#-------------------------------------------------------------------------------
+# Already used licenses in project :
+# - Apache Software License
+# - Apache Software License, Version 2.0
+# - BSD License
+# - Common Development And Distribution License (CDDL), Version 1.0
+# - Common Development And Distribution License (CDDL), Version 1.1
+# - Common Public License, Version 1.0
+# - Eclipse Public License, Version 1.0
+# - GNU General Public License (GPL), Version 2 with classpath exception
+# - GNU Lesser General Public License (LGPL)
+# - GNU Lesser General Public License (LGPL), Version 2.1
+# - MIT License
+# - Public Domain License
+#-------------------------------------------------------------------------------
+# Please fill the missing licenses for dependencies :
+#
+#
+#Thu Dec 13 13:45:34 CET 2012
+javax.servlet--servlet-api--2.5=Common Development And Distribution License
(CDDL), Version 1.0
+org.osgi--org.osgi.core--4.1.0=The Apache Software License, Version 2.0
Added:
stanbol/trunk/commons/cors/src/main/java/org/apache/stanbol/commons/cors/StanbolCorsFilter.java
URL:
http://svn.apache.org/viewvc/stanbol/trunk/commons/cors/src/main/java/org/apache/stanbol/commons/cors/StanbolCorsFilter.java?rev=1637433&view=auto
==============================================================================
---
stanbol/trunk/commons/cors/src/main/java/org/apache/stanbol/commons/cors/StanbolCorsFilter.java
(added)
+++
stanbol/trunk/commons/cors/src/main/java/org/apache/stanbol/commons/cors/StanbolCorsFilter.java
Fri Nov 7 19:01:09 2014
@@ -0,0 +1,75 @@
+/*
+ * 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.stanbol.commons.cors;
+
+import java.io.IOException;
+import java.util.Properties;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+
+import com.thetransactioncompany.cors.CORSConfiguration;
+import com.thetransactioncompany.cors.CORSConfigurationException;
+import com.thetransactioncompany.cors.CORSFilter;
+
+/**
+ * Wraps a {@link CorsFilter} in order to provide CORS support.
+ * @author Cristian Petroaca
+ *
+ */
+@Component(immediate = true)
+@Service(Filter.class)
+@Property(name = "pattern", value = ".*")
+public class StanbolCorsFilter implements Filter {
+ private static CORSFilter corsFilter;
+
+ public StanbolCorsFilter() throws CORSConfigurationException {
+ Properties props = new Properties();
+ props.put("cors.allowGenericHttpRequests", true);
+ props.put("cors.allowOrigin", "*");
+ props.put("cors.allowSubdomains", true);
+ props.put("cors.supportedMethods", "GET, POST, HEAD, OPTIONS");
+ props.put("cors.supportedHeaders", "*");
+ props.put("cors.supportsCredentials", true);
+ props.put("cors.maxAge", 1800);
+
+ corsFilter = new CORSFilter(new CORSConfiguration(props));
+ }
+
+ @Override
+ public void init(FilterConfig filterConfig) throws ServletException {
+ //NOOP
+ }
+
+ @Override
+ public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
+ corsFilter.doFilter(request, response, chain);
+ }
+
+ @Override
+ public void destroy() {
+ corsFilter.destroy();
+ }
+}
Modified: stanbol/trunk/commons/pom.xml
URL:
http://svn.apache.org/viewvc/stanbol/trunk/commons/pom.xml?rev=1637433&r1=1637432&r2=1637433&view=diff
==============================================================================
--- stanbol/trunk/commons/pom.xml (original)
+++ stanbol/trunk/commons/pom.xml Fri Nov 7 19:01:09 2014
@@ -71,6 +71,7 @@
<module>freemarker</module>
<module>ldpathtemplate</module>
<module>httpqueryheaders</module> <!-- allows CORS with MS Internet
Explorer -->
+ <module>cors</module>
<!-- DataFile Provider -->
<module>stanboltools/datafileprovider</module>
Modified:
stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml
URL:
http://svn.apache.org/viewvc/stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml?rev=1637433&r1=1637432&r2=1637433&view=diff
==============================================================================
---
stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml
(original)
+++
stanbol/trunk/launchers/bundlelists/stanbolcommons/src/main/bundles/list.xml
Fri Nov 7 19:01:09 2014
@@ -27,6 +27,11 @@
<!-- HTTP service and Http related Utilities -->
<startLevel level="6">
+ <bundle>
+ <groupId>org.apache.stanbol</groupId>
+ <artifactId>org.apache.stanbol.commons.cors</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </bundle>
<!-- Allows to parse Http Headers as QueryParameter -->
<bundle>
<groupId>org.apache.stanbol</groupId>