sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bdelacre...@apache.org
Subject svn commit: r1662624 - in /sling/whiteboard/bdelacretaz/redirect-as-is: ./ src/ src/main/ src/main/java/ src/main/java/org/ src/main/java/org/apache/ src/main/java/org/apache/sling/ src/main/java/org/apache/sling/extensions/ src/main/java/org/apache/sl...
Date Fri, 27 Feb 2015 02:37:49 GMT
Author: bdelacretaz
Date: Fri Feb 27 02:37:48 2015
New Revision: 1662624

URL: http://svn.apache.org/r1662624
Log:
SLING-3374 - filter that sets Location header directly, to avoid host/scheme in redirects

Added:
    sling/whiteboard/bdelacretaz/redirect-as-is/   (with props)
    sling/whiteboard/bdelacretaz/redirect-as-is/pom.xml
    sling/whiteboard/bdelacretaz/redirect-as-is/src/
    sling/whiteboard/bdelacretaz/redirect-as-is/src/main/
    sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/
    sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/
    sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/
    sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/
    sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/
    sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/
    sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/impl/
    sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/impl/RedirectAsIsFilter.java
    sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/impl/RedirectResponseWrapper.java

Propchange: sling/whiteboard/bdelacretaz/redirect-as-is/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Feb 27 02:37:48 2015
@@ -0,0 +1,15 @@
+target
+bin
+*.iml
+*.ipr
+*.iws
+.settings
+.project
+.classpath
+.externalToolBuilders
+maven-eclipse.xml
+derby.log
+jackrabbit
+sling
+
+

Added: sling/whiteboard/bdelacretaz/redirect-as-is/pom.xml
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/redirect-as-is/pom.xml?rev=1662624&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/redirect-as-is/pom.xml (added)
+++ sling/whiteboard/bdelacretaz/redirect-as-is/pom.xml Fri Feb 27 02:37:48 2015
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.sling</groupId>
+        <artifactId>sling</artifactId>
+        <version>18</version>
+    </parent>
+    
+    <groupId>org.apache.sling</groupId>
+    <artifactId>org.apache.sling.extensions.redirectasis</artifactId>
+    <version>0.9.9-SNAPSHOT</version>
+    <packaging>bundle</packaging>
+    <name>Apache Sling Redirect-as-is Filter</name>
+    
+    <build>
+        <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>
+                        <Private-Package>org.apache.sling.extensions.redirectasis.*</Private-Package>
+                    </instructions>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+    
+    <dependencies>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.core</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.osgi</groupId>
+            <artifactId>org.osgi.compendium</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.sling</groupId>
+            <artifactId>org.apache.sling.api</artifactId>
+            <version>2.1.0</version>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.felix</groupId>
+            <artifactId>org.apache.felix.scr.annotations</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>javax.servlet</groupId>
+            <artifactId>servlet-api</artifactId>
+            <scope>provided</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-simple</artifactId>
+            <scope>provided</scope>
+        </dependency>
+    </dependencies>
+</project>

Added: sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/impl/RedirectAsIsFilter.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/impl/RedirectAsIsFilter.java?rev=1662624&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/impl/RedirectAsIsFilter.java
(added)
+++ sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/impl/RedirectAsIsFilter.java
Fri Feb 27 02:37:48 2015
@@ -0,0 +1,51 @@
+/*
+ * 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.sling.extensions.redirectasis.impl;
+
+import java.io.IOException;
+
+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 javax.servlet.http.HttpServletResponse;
+
+import org.apache.felix.scr.annotations.Component;
+import org.apache.felix.scr.annotations.Properties;
+import org.apache.felix.scr.annotations.Property;
+import org.apache.felix.scr.annotations.Service;
+
+@Component
+@Service(value=Filter.class)
+@Properties({
+    @Property(name="pattern", value="/content/.*")
+})
+public class RedirectAsIsFilter implements Filter {
+
+    public void init(FilterConfig filterConfig) throws ServletException {
+    }
+
+    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
+        final RedirectResponseWrapper w = new RedirectResponseWrapper((HttpServletResponse)response);
+        chain.doFilter(request, w);
+    }
+
+    public void destroy() {
+    }
+}

Added: sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/impl/RedirectResponseWrapper.java
URL: http://svn.apache.org/viewvc/sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/impl/RedirectResponseWrapper.java?rev=1662624&view=auto
==============================================================================
--- sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/impl/RedirectResponseWrapper.java
(added)
+++ sling/whiteboard/bdelacretaz/redirect-as-is/src/main/java/org/apache/sling/extensions/redirectasis/impl/RedirectResponseWrapper.java
Fri Feb 27 02:37:48 2015
@@ -0,0 +1,35 @@
+/*
+ * 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.sling.extensions.redirectasis.impl;
+
+import java.io.IOException;
+
+import javax.servlet.http.HttpServletResponse;
+import javax.servlet.http.HttpServletResponseWrapper;
+
+class RedirectResponseWrapper extends HttpServletResponseWrapper {
+
+    RedirectResponseWrapper(HttpServletResponse wrappedResponse) {
+        super(wrappedResponse);
+    }
+    
+     @Override
+    public void sendRedirect(String location) throws IOException {
+        setHeader("Location", location);
+        setStatus(302);
+    }
+}



Mime
View raw message