Return-Path: X-Original-To: apmail-marmotta-commits-archive@minotaur.apache.org Delivered-To: apmail-marmotta-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 47470FCD2 for ; Mon, 8 Apr 2013 10:51:54 +0000 (UTC) Received: (qmail 85883 invoked by uid 500); 8 Apr 2013 10:51:52 -0000 Delivered-To: apmail-marmotta-commits-archive@marmotta.apache.org Received: (qmail 85756 invoked by uid 500); 8 Apr 2013 10:51:51 -0000 Mailing-List: contact commits-help@marmotta.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@marmotta.apache.org Delivered-To: mailing list commits@marmotta.apache.org Received: (qmail 85627 invoked by uid 99); 8 Apr 2013 10:51:50 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Apr 2013 10:51:50 +0000 X-ASF-Spam-Status: No, hits=-2002.4 required=5.0 tests=ALL_TRUSTED,RP_MATCHES_RCVD X-Spam-Check-By: apache.org Received: from [140.211.11.3] (HELO mail.apache.org) (140.211.11.3) by apache.org (qpsmtpd/0.29) with SMTP; Mon, 08 Apr 2013 10:51:48 +0000 Received: (qmail 85113 invoked by uid 99); 8 Apr 2013 10:51:28 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 08 Apr 2013 10:51:28 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 3332950AC5; Mon, 8 Apr 2013 10:51:28 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: tkurz@apache.org To: commits@marmotta.incubator.apache.org Date: Mon, 08 Apr 2013 10:51:32 -0000 Message-Id: In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [5/8] git commit: deleted some files only used for testing X-Virus-Checked: Checked by ClamAV on apache.org deleted some files only used for testing Project: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/commit/c8d07165 Tree: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/tree/c8d07165 Diff: http://git-wip-us.apache.org/repos/asf/incubator-marmotta/diff/c8d07165 Branch: refs/heads/master Commit: c8d071656a257093b99d0f5ead64fb20db654fa1 Parents: fc74e3c Author: tkurz Authored: Mon Apr 8 11:50:58 2013 +0200 Committer: tkurz Committed: Mon Apr 8 11:50:58 2013 +0200 ---------------------------------------------------------------------- .../platform/core/filters/MarmottaCorsFilter.java | 100 --------------- .../marmotta/platform/core/util/CorsHandler.java | 90 ------------- 2 files changed, 0 insertions(+), 190 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c8d07165/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/MarmottaCorsFilter.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/MarmottaCorsFilter.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/MarmottaCorsFilter.java deleted file mode 100644 index 8828135..0000000 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/filters/MarmottaCorsFilter.java +++ /dev/null @@ -1,100 +0,0 @@ -/* - * 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.marmotta.platform.core.filters; - -import org.apache.marmotta.platform.core.api.config.ConfigurationService; -import org.apache.marmotta.platform.core.api.modules.MarmottaHttpFilter; -import org.apache.marmotta.platform.core.events.ConfigurationChangedEvent; -import org.apache.marmotta.platform.core.util.CorsHandler; - -import javax.enterprise.context.ApplicationScoped; -import javax.enterprise.event.Observes; -import javax.inject.Inject; -import javax.servlet.*; -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.io.IOException; -import java.util.HashMap; -import java.util.Map; - -/** - * ... - *

- * Author: Thomas Kurz (tkurz@apache.org) - */ -@ApplicationScoped -public class MarmottaCorsFilter implements MarmottaHttpFilter { - - public static Map options; - - @Inject - ConfigurationService configurationService; - - @Override - public void init(FilterConfig filterConfig) throws ServletException { - initializeOptions(); - } - - public void configChanged(@Observes ConfigurationChangedEvent event) { - if (event.getKeys().contains("kiwi.allow_origin") - || event.getKeys().contains("kiwi.allow_methods")) { - initializeOptions(); - } - } - - private void initializeOptions() { - options = new HashMap(); - options.put("Access-Control-Allow-Origin",configurationService.getStringConfiguration("kiwi.allow_origin","*")); - options.put("Access-Control-Allow-Methods", configurationService.getStringConfiguration("kiwi.allow_methods","POST, PUT, GET, DELETE, HEAD")); - } - - @Override - public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { - if(response instanceof HttpServletResponse) { - HttpServletResponse resp = (HttpServletResponse)response; - HttpServletRequest req = (HttpServletRequest)request; - - String origin = req.getHeader("Origin"); - - if(origin != null) { - CorsHandler.run(req,resp,options); - } - - if(req.getMethod().equalsIgnoreCase("OPTIONS")) { - resp.setStatus(200); - } - } - chain.doFilter(request,response); - } - - @Override - public void destroy() { - // - } - - @Override - public String getPattern() { - return "^/.*"; - } - - @Override - public int getPriority() { - return 0; - } -} http://git-wip-us.apache.org/repos/asf/incubator-marmotta/blob/c8d07165/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CorsHandler.java ---------------------------------------------------------------------- diff --git a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CorsHandler.java b/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CorsHandler.java deleted file mode 100644 index abd6b61..0000000 --- a/platform/marmotta-core/src/main/java/org/apache/marmotta/platform/core/util/CorsHandler.java +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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.marmotta.platform.core.util; - -import org.apache.commons.lang.StringUtils; - -import javax.servlet.http.HttpServletRequest; -import javax.servlet.http.HttpServletResponse; -import java.util.List; -import java.util.Map; - -/** - * ... - *

- * Author: Thomas Kurz (tkurz@apache.org) - */ -public class CorsHandler { - - private static final String[] CORS_HEADERS= { - "Access-Control-Allow-Origin", - "Access-Control-Expose-Headers", - "Access-Control-Max-Age", - "Access-Control-Allow-Credentials", - "Access-Control-Allow-Methods", - "Access-Control-Allow-Headers"}; - - /** - * This method sets the response headers for CORS request. The options may contain following fields: - *

    - *
  • - * "Access-Control-Allow-Origin" : List<String> | "*" - *
  • - *
  • - * "Access-Control-Expose-Headers" : List<String> - *
  • - *
  • - * "Access-Control-Max-Age" : long - *
  • - *
  • - * "Access-Control-Allow-Credentials" : boolean - *
  • - *
  • - * "Access-Control-Allow-Methods" : List<String> - *
  • - *
  • - * "Access-Control-Allow-Headers" : List<String> - *
  • - *
- * @param request the HTTP servlet request - * @param response the HTTP servlet response - * @param options the options - */ - public static void run(HttpServletRequest request, HttpServletResponse response, Map options) { - - //remove all existing cors headers - for(String header : CORS_HEADERS) { - response.setHeader(header,null); - } - - //add headers from options - for(String key : options.keySet()) { - response.addHeader(key,buildHeader(options.get(key))); - } - - } - - private static String buildHeader(Object value) { - if(value instanceof List) { - return StringUtils.join((List)value,","); - } - return value.toString(); - } - -}