You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@knox.apache.org by km...@apache.org on 2013/09/13 03:00:39 UTC

[5/5] git commit: KNOX-118: Add rewrite functions to allow use of service registry within rewrite rules. Also includes initial integration of this with Oozie.

KNOX-118: Add rewrite functions to allow use of service registry within rewrite rules.  Also includes initial integration of this with Oozie.


Project: http://git-wip-us.apache.org/repos/asf/incubator-knox/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-knox/commit/2f135e16
Tree: http://git-wip-us.apache.org/repos/asf/incubator-knox/tree/2f135e16
Diff: http://git-wip-us.apache.org/repos/asf/incubator-knox/diff/2f135e16

Branch: refs/heads/master
Commit: 2f135e165e6fbff3221e27e52e5360cbe4c6a870
Parents: 493cfa7
Author: Kevin Minder <ke...@hortonworks.com>
Authored: Thu Sep 12 21:00:24 2013 -0400
Committer: Kevin Minder <ke...@hortonworks.com>
Committed: Thu Sep 12 21:00:24 2013 -0400

----------------------------------------------------------------------
 .gitignore                                      |   1 +
 gateway-provider-hostmap-static/pom.xml         |  96 --------
 .../hostmap/api/HostmapFunctionDescriptor.java  |  50 ----
 .../impl/HostmapDeploymentContributor.java      | 100 --------
 .../hostmap/impl/HostmapFunctionProcessor.java  |  98 --------
 ...gateway.deploy.ProviderDeploymentContributor |  19 --
 ...ter.rewrite.api.UrlRewriteFunctionDescriptor |  19 --
 ...lter.rewrite.spi.UrlRewriteFunctionProcessor |  19 --
 .../api/HostmapFunctionDescriptorTest.java      |  46 ----
 .../impl/HostmapDeploymentContributorTest.java  |  84 -------
 .../impl/HostmapFunctionProcessorTest.java      | 216 -----------------
 .../empty-hostmap.txt                           |  15 --
 .../hdfs-hostmap.txt                            |  17 --
 .../HostmapFunctionProcessorTest/hostmap.txt    |  17 --
 .../pom.xml                                     |  15 +-
 .../function/UsernameFunctionProcessorTest.java | 166 ++++++++++++-
 .../UsernameFunctionProcessorTest/rewrite.xml   |  24 ++
 .../pom.xml                                     |  96 ++++++++
 .../hostmap/api/HostmapFunctionDescriptor.java  |  50 ++++
 .../impl/HostmapDeploymentContributor.java      | 100 ++++++++
 .../hostmap/impl/HostmapFunctionProcessor.java  |  98 ++++++++
 ...gateway.deploy.ProviderDeploymentContributor |  19 ++
 ...ter.rewrite.api.UrlRewriteFunctionDescriptor |  19 ++
 ...lter.rewrite.spi.UrlRewriteFunctionProcessor |  19 ++
 .../api/HostmapFunctionDescriptorTest.java      |  65 ++++++
 .../impl/HostmapDeploymentContributorTest.java  | 102 ++++++++
 .../impl/HostmapFunctionProcessorTest.java      | 234 +++++++++++++++++++
 .../empty-hostmap.txt                           |  15 ++
 .../hdfs-hostmap.txt                            |  17 ++
 .../HostmapFunctionProcessorTest/hostmap.txt    |  17 ++
 .../pom.xml                                     | 112 +++++++++
 .../api/ServiceAddressFunctionDescriptor.java   |  30 +++
 .../api/ServiceHostFunctionDescriptor.java      |  30 +++
 .../api/ServicePathFunctionDescriptor.java      |  30 +++
 .../api/ServicePortFunctionDescriptor.java      |  30 +++
 .../api/ServiceSchemeFunctionDescriptor.java    |  30 +++
 .../api/ServiceUrlFunctionDescriptor.java       |  31 +++
 .../impl/ServiceAddressFunctionProcessor.java   |  56 +++++
 .../impl/ServiceHostFunctionProcessor.java      |  50 ++++
 .../impl/ServicePathFunctionProcessor.java      |  66 ++++++
 .../impl/ServicePortFunctionProcessor.java      |  50 ++++
 .../ServiceRegistryFunctionProcessorBase.java   |  76 ++++++
 .../impl/ServiceSchemeFunctionProcessor.java    |  50 ++++
 .../impl/ServiceUrlFunctionProcessor.java       |  38 +++
 ...ter.rewrite.api.UrlRewriteFunctionDescriptor |  24 ++
 ...lter.rewrite.spi.UrlRewriteFunctionProcessor |  24 ++
 .../ServiceAddressFunctionDescriptorTest.java   |  52 +++++
 .../api/ServiceHostFunctionDescriptorTest.java  |  52 +++++
 .../api/ServicePathFunctionDescriptorTest.java  |  52 +++++
 .../api/ServicePortFunctionDescriptorTest.java  |  52 +++++
 .../ServiceSchemeFunctionDescriptorTest.java    |  52 +++++
 .../api/ServiceUrlFunctionDescriptorTest.java   |  52 +++++
 .../ServiceAddressFunctionProcessorTest.java    | 134 +++++++++++
 .../impl/ServiceHostFunctionProcessorTest.java  | 135 +++++++++++
 .../impl/ServicePathFunctionProcessorTest.java  | 135 +++++++++++
 .../impl/ServicePortFunctionProcessorTest.java  | 135 +++++++++++
 .../impl/ServiceRegistryFunctionsTest.java      | 233 ++++++++++++++++++
 .../ServiceSchemeFunctionProcessorTest.java     | 134 +++++++++++
 .../impl/ServiceUrlFunctionProcessorTest.java   | 135 +++++++++++
 .../ServiceRegistryFunctionsTest/rewrite.xml    | 101 ++++++++
 .../test-expect-body.json                       |  11 +
 .../test-expect-body.xml                        |  40 ++++
 .../test-input-body.json                        |  11 +
 .../test-input-body.xml                         |  40 ++++
 .../pom.xml                                     | 106 +++++++++
 .../SecureQueryDecodeDescriptor.java            |  38 +++
 .../securequery/SecureQueryDecodeProcessor.java |  86 +++++++
 .../SecureQueryDecryptDescriptor.java           |  38 +++
 .../SecureQueryDecryptProcessor.java            |  94 ++++++++
 .../SecureQueryDeploymentContributor.java       |  91 ++++++++
 .../SecureQueryEncodeDescriptor.java            |  38 +++
 .../securequery/SecureQueryEncodeProcessor.java |  77 ++++++
 .../SecureQueryEncryptDescriptor.java           |  38 +++
 .../SecureQueryEncryptProcessor.java            |  91 ++++++++
 ...gateway.deploy.ProviderDeploymentContributor |  19 ++
 ....filter.rewrite.api.UrlRewriteStepDescriptor |  22 ++
 ...y.filter.rewrite.spi.UrlRewriteStepProcessor |  22 ++
 .../SecureQueryDecodeDescriptorTest.java        |  35 +++
 .../SecureQueryDecodeProcessorTest.java         | 125 ++++++++++
 .../SecureQueryDeploymentContributorTest.java   |  79 +++++++
 .../SecureQueryEncodeDescriptorTest.java        |  35 +++
 .../SecureQueryEncodeProcessorTest.java         |  59 +++++
 .../filter/rewrite/api/UrlRewriteProcessor.java |   2 +-
 .../rewrite/api/UrlRewriteRulesDescriptor.java  |   2 +
 .../impl/UrlRewriteRulesDescriptorImpl.java     |  10 +
 .../rewrite/api/UrlRewriteProcessorTest.java    |  14 +-
 .../api/UrlRewriteServletFilterTest.java        |   1 -
 .../rewrite/impl/json/JsonFilterReaderTest.java |  27 +++
 .../api/UrlRewriteServletFilterTest/rewrite.xml |  29 ++-
 .../JsonFilterReaderTest/dotted-field-name.json |   6 +
 gateway-provider-secure-query/pom.xml           | 106 ---------
 .../SecureQueryDecodeDescriptor.java            |  38 ---
 .../securequery/SecureQueryDecodeProcessor.java |  86 -------
 .../SecureQueryDecryptDescriptor.java           |  38 ---
 .../SecureQueryDecryptProcessor.java            |  94 --------
 .../SecureQueryDeploymentContributor.java       |  91 --------
 .../SecureQueryEncodeDescriptor.java            |  38 ---
 .../securequery/SecureQueryEncodeProcessor.java |  77 ------
 .../SecureQueryEncryptDescriptor.java           |  38 ---
 .../SecureQueryEncryptProcessor.java            |  91 --------
 ...gateway.deploy.ProviderDeploymentContributor |  19 --
 ....filter.rewrite.api.UrlRewriteStepDescriptor |  22 --
 ...y.filter.rewrite.spi.UrlRewriteStepProcessor |  22 --
 .../SecureQueryDecodeDescriptorTest.java        |  35 ---
 .../SecureQueryDecodeProcessorTest.java         | 125 ----------
 .../SecureQueryDeploymentContributorTest.java   |  79 -------
 .../SecureQueryEncodeDescriptorTest.java        |  35 ---
 .../SecureQueryEncodeProcessorTest.java         |  59 -----
 gateway-release/pom.xml                         |   8 +-
 .../apache/hadoop/gateway/GatewayServer.java    |  41 +---
 .../apache/hadoop/gateway/GatewayServlet.java   |   1 +
 .../services/DefaultGatewayServices.java        |  22 +-
 .../gateway/services/HssoGatewayServices.java   |   4 +-
 gateway-service-oozie/pom.xml                   |  21 ++
 .../oozie/OozieDeploymentContributor.java       |  68 ++++--
 .../OozieDeploymentContributor/rewrite.xml      |  69 ++++++
 .../oozie/OozieDeploymentContributorTest.java   | 114 +++++++++
 .../gateway/services/GatewayServices.java       |   5 +-
 .../java/org/apache/hadoop/test/TestUtils.java  |   6 +
 .../hadoop/test/mock/MockRequestMatcher.java    |   2 +
 .../hadoop/gateway/GatewayBasicFuncTest.java    |  10 +-
 .../hadoop/gateway/GatewayFuncTestDriver.java   |   7 +-
 .../apache/hadoop/gateway/util/JsonPath.java    |   9 +-
 .../hadoop/gateway/util/JsonPathTest.java       | 106 +++++++++
 hsso-release/pom.xml                            |   8 +-
 pom.xml                                         |  21 +-
 126 files changed, 4958 insertions(+), 1977 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index e3099b4..df91feb 100644
--- a/.gitignore
+++ b/.gitignore
@@ -29,6 +29,7 @@ atlassian-ide-plugin.xml
 .DS_Store
 target
 install
+patch
 org.apache.hadoop.gateway.security.EmbeddedApacheDirectoryServer/
 velocity.log
 *.pyc

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/pom.xml b/gateway-provider-hostmap-static/pom.xml
deleted file mode 100644
index 612d013..0000000
--- a/gateway-provider-hostmap-static/pom.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<?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/xsd/maven-4.0.0.xsd">
-    <modelVersion>4.0.0</modelVersion>
-    <parent>
-        <groupId>org.apache.hadoop</groupId>
-        <artifactId>gateway</artifactId>
-        <version>0.3.0-SNAPSHOT</version>
-    </parent>
-    <artifactId>gateway-provider-hostmap-static</artifactId>
-
-    <name>gateway-provider-hostmap-static</name>
-    <description>An extension to the URL rewriter that provides a way to map hostnames in requests and responses.</description>
-
-    <licenses>
-        <license>
-            <name>The Apache Software License, Version 2.0</name>
-            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
-            <distribution>repo</distribution>
-        </license>
-    </licenses>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>${gateway-group}</groupId>
-            <artifactId>gateway-i18n</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${gateway-group}</groupId>
-            <artifactId>gateway-i18n-logging-log4j</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${gateway-group}</groupId>
-            <artifactId>gateway-spi</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>${gateway-group}</groupId>
-            <artifactId>gateway-provider-rewrite</artifactId>
-        </dependency>
-
-        <!-- ********** ********** ********** ********** ********** ********** -->
-        <!-- ********** Test Dependencies                           ********** -->
-        <!-- ********** ********** ********** ********** ********** ********** -->
-
-        <dependency>
-            <groupId>${gateway-group}</groupId>
-            <artifactId>gateway-test-utils</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.hamcrest</groupId>
-            <artifactId>hamcrest-core</artifactId>
-            <scope>test</scope>
-        </dependency>
-        <dependency>
-            <groupId>org.hamcrest</groupId>
-            <artifactId>hamcrest-library</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <!-- This must be after restassured otherwise is messes up the hamcrest dependencies. -->
-        <dependency>
-            <groupId>junit</groupId>
-            <artifactId>junit</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-        <dependency>
-            <groupId>org.easymock</groupId>
-            <artifactId>easymock</artifactId>
-            <scope>test</scope>
-        </dependency>
-
-    </dependencies>
-
-</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptor.java b/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptor.java
deleted file mode 100644
index 01d41b9..0000000
--- a/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptor.java
+++ /dev/null
@@ -1,50 +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.hadoop.gateway.hostmap.api;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
-
-public class HostmapFunctionDescriptor implements UrlRewriteFunctionDescriptor<HostmapFunctionDescriptor> {
-
-  public static final String FUNCTION_NAME = "hostmap";
-
-  private String configLocation;
-
-  @Override
-  public String name() {
-    return FUNCTION_NAME;
-  }
-
-  public HostmapFunctionDescriptor config( String configLocation ) {
-    this.configLocation = configLocation;
-    return this;
-  }
-
-  public String config() {
-    return configLocation;
-  }
-
-  public String getConfig() {
-    return config();
-  }
-
-  public void setConfig( String configLocation ) {
-    config( configLocation );
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributor.java b/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributor.java
deleted file mode 100644
index ba9274d..0000000
--- a/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributor.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.hadoop.gateway.hostmap.impl;
-
-import org.apache.hadoop.gateway.deploy.DeploymentContext;
-import org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor;
-import org.apache.hadoop.gateway.deploy.ProviderDeploymentContributorBase;
-import org.apache.hadoop.gateway.descriptor.FilterParamDescriptor;
-import org.apache.hadoop.gateway.descriptor.ResourceDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
-import org.apache.hadoop.gateway.hostmap.api.HostmapFunctionDescriptor;
-import org.apache.hadoop.gateway.topology.Provider;
-import org.apache.hadoop.gateway.topology.Service;
-import org.jboss.shrinkwrap.api.asset.Asset;
-import org.jboss.shrinkwrap.api.asset.StringAsset;
-
-import java.io.PrintWriter;
-import java.io.StringWriter;
-import java.util.List;
-import java.util.Map;
-
-public class HostmapDeploymentContributor
-    extends ProviderDeploymentContributorBase
-    implements ProviderDeploymentContributor {
-
-  public static final String PROVIDER_ROLE_NAME = HostmapFunctionDescriptor.FUNCTION_NAME;
-  public static final String PROVIDER_IMPL_NAME = "static";
-
-  private static final String REWRITE_ROLE_NAME = "rewrite";
-
-  @Override
-  public String getRole() {
-    return PROVIDER_ROLE_NAME;
-  }
-
-  @Override
-  public String getName() {
-    return PROVIDER_IMPL_NAME;
-  }
-
-  // Write the provider init params to the hostmap.txt file.
-  // Add the function to the rewrite descriptor providing the location of the hostmap.txt file.
-  @Override
-  public void contributeProvider( DeploymentContext context, Provider provider ) {
-    if( provider.isEnabled() ) {
-      UrlRewriteRulesDescriptor rules = context.getDescriptor( REWRITE_ROLE_NAME );
-      if( rules != null ) {
-        HostmapFunctionDescriptor func = rules.addFunction( HostmapFunctionDescriptor.FUNCTION_NAME );
-        if( func != null ) {
-          Asset asset = createAsset( provider );
-          context.getWebArchive().addAsWebInfResource(
-              asset, HostmapFunctionProcessor.DESCRIPTOR_DEFAULT_FILE_NAME );
-          func.config( HostmapFunctionProcessor.DESCRIPTOR_DEFAULT_LOCATION );
-        }
-      }
-    }
-  }
-
-  private Asset createAsset( Provider provider ) {
-    StringWriter buffer = new StringWriter();
-    PrintWriter writer = new PrintWriter( buffer );
-    for( Map.Entry<String,String> entry : provider.getParams().entrySet() ) {
-      String externalHosts = entry.getKey();
-      String internalHosts = entry.getValue();
-      writer.print( externalHosts );
-      writer.print( "=" );
-      writer.println( internalHosts ) ;
-    }
-    writer.close();
-    String string = buffer.toString();
-    Asset asset = new StringAsset( string );
-    return asset;
-  }
-
-  @Override
-  public void contributeFilter(
-      DeploymentContext context,
-      Provider provider,
-      Service service,
-      ResourceDescriptor resource,
-      List<FilterParamDescriptor> params ) {
-    // NoOp.
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessor.java b/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessor.java
deleted file mode 100644
index 9e71a4e..0000000
--- a/gateway-provider-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessor.java
+++ /dev/null
@@ -1,98 +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.hadoop.gateway.hostmap.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
-import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.hostmap.api.HostmapFunctionDescriptor;
-
-import java.io.BufferedReader;
-import java.io.InputStream;
-import java.io.InputStreamReader;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.Map;
-
-public class HostmapFunctionProcessor
-    implements UrlRewriteFunctionProcessor<HostmapFunctionDescriptor> {
-
-  public static final String DESCRIPTOR_DEFAULT_FILE_NAME = "hostmap.txt";
-  public static final String DESCRIPTOR_DEFAULT_LOCATION = "/WEB-INF/" + DESCRIPTOR_DEFAULT_FILE_NAME;
-
-  private Map<String, String> inbound = new HashMap<String, String>();
-  private Map<String, String> outbound = new HashMap<String, String>();
-
-  @Override
-  public String name() {
-    return HostmapFunctionDescriptor.FUNCTION_NAME;
-  }
-
-  @Override
-  public void initialize( UrlRewriteEnvironment environment, HostmapFunctionDescriptor descriptor ) throws Exception {
-    URL url = environment.getResource( DESCRIPTOR_DEFAULT_LOCATION );
-    if( url != null ) {
-      InputStream stream = url.openStream();
-      BufferedReader reader = new BufferedReader( new InputStreamReader( stream ) );
-      String line = reader.readLine();
-      while( line != null ) {
-        String[] lineSplit = line.split( "=" );
-        if( lineSplit.length >= 2 ) {
-          String[] externalSplit = lineSplit[ 0 ].split( "," );
-          String[] internalSplit = lineSplit[ 1 ].split( "," );
-          if( externalSplit.length >= 1 && internalSplit.length >= 1 ) {
-            for( String external : externalSplit ) {
-              inbound.put( external, internalSplit[ 0 ] );
-            }
-            for( String internal : internalSplit ) {
-              outbound.put( internal, externalSplit[ 0 ] );
-            }
-          }
-        }
-        line = reader.readLine();
-      }
-      reader.close();
-    }
-  }
-
-  @Override
-  public void destroy() throws Exception {
-  }
-
-  @Override
-  public String resolve( UrlRewriteContext context, String parameter ) throws Exception {
-    String value;
-    switch( context.getDirection() ) {
-      case IN:
-        value = inbound.get( parameter );
-        break;
-      case OUT:
-        value = outbound.get( parameter );
-        break;
-      default:
-        value = null;
-    }
-    if( value == null ) {
-      value = parameter;
-    }
-//    System.out.println( "HOSTMAP: " + parameter + "->" + value );
-    return value;
-  }
-
-}
-

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor b/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
deleted file mode 100644
index eda74c1..0000000
--- a/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
+++ /dev/null
@@ -1,19 +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.
-##########################################################################
-
-org.apache.hadoop.gateway.hostmap.impl.HostmapDeploymentContributor
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor b/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor
deleted file mode 100644
index 3e80487..0000000
--- a/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor
+++ /dev/null
@@ -1,19 +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.
-##########################################################################
-
-org.apache.hadoop.gateway.hostmap.api.HostmapFunctionDescriptor
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor b/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor
deleted file mode 100644
index 7c6619c..0000000
--- a/gateway-provider-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor
+++ /dev/null
@@ -1,19 +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.
-##########################################################################
-
-org.apache.hadoop.gateway.hostmap.impl.HostmapFunctionProcessor
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptorTest.java b/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptorTest.java
deleted file mode 100644
index 4bbe392..0000000
--- a/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptorTest.java
+++ /dev/null
@@ -1,46 +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.hadoop.gateway.hostmap.api;
-
-import org.junit.Test;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.nullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-public class HostmapFunctionDescriptorTest {
-
-  @Test
-  public void testGetAndSet() {
-    HostmapFunctionDescriptor descriptor = new HostmapFunctionDescriptor();
-
-    assertThat( descriptor.name(), is( "hostmap" ) );
-    assertThat( descriptor.config(), nullValue() );
-
-    // Test Fluent API
-    descriptor.config( "test-config-location-fluent" );
-    assertThat( descriptor.config(), is( "test-config-location-fluent" ) );
-    assertThat( descriptor.getConfig(), is( "test-config-location-fluent" ) );
-
-    // Test Bean API
-    descriptor.setConfig( "test-config-location-bean" );
-    assertThat( descriptor.config(), is( "test-config-location-bean" ) );
-    assertThat( descriptor.getConfig(), is( "test-config-location-bean" ) );
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributorTest.java b/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributorTest.java
deleted file mode 100644
index 47b482c..0000000
--- a/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributorTest.java
+++ /dev/null
@@ -1,84 +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.hadoop.gateway.hostmap.impl;
-
-import org.apache.commons.io.IOUtils;
-import org.apache.hadoop.gateway.deploy.DeploymentContext;
-import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteRulesDescriptorImpl;
-import org.apache.hadoop.gateway.hostmap.api.HostmapFunctionDescriptor;
-import org.apache.hadoop.gateway.topology.Provider;
-import org.easymock.EasyMock;
-import org.jboss.shrinkwrap.api.Node;
-import org.jboss.shrinkwrap.api.ShrinkWrap;
-import org.jboss.shrinkwrap.api.spec.WebArchive;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.util.HashMap;
-import java.util.Map;
-
-import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-public class HostmapDeploymentContributorTest {
-
-  @Test
-  public void testDeployment() throws IOException {
-    WebArchive webArchive = ShrinkWrap.create( WebArchive.class, "test-acrhive" );
-
-    UrlRewriteRulesDescriptorImpl rewriteRules = new UrlRewriteRulesDescriptorImpl();
-
-    Map<String,String> providerParams = new HashMap<String, String>();
-    providerParams.put( "test-host-external", "test-host-internal" );
-    Provider provider = new Provider();
-    provider.setEnabled( true );
-    provider.setName( "hostmap" );
-    provider.setParams(  providerParams );
-
-    DeploymentContext context = EasyMock.createNiceMock( DeploymentContext.class );
-    EasyMock.expect( context.getDescriptor( "rewrite" ) ).andReturn( rewriteRules ).anyTimes();
-    EasyMock.expect( context.getWebArchive() ).andReturn( webArchive ).anyTimes();
-    EasyMock.replay( context );
-
-    HostmapDeploymentContributor contributor = new HostmapDeploymentContributor();
-
-    assertThat( contributor.getRole(), is("hostmap") );
-    assertThat( contributor.getName(), is( "static" ) );
-
-    // Just make sure it doesn't blow up.
-    contributor.contributeFilter( null, null, null, null, null );
-
-    // Just make sure it doesn't blow up.
-    contributor.initializeContribution( context );
-
-    contributor.contributeProvider( context, provider );
-
-    HostmapFunctionDescriptor funcDesc = rewriteRules.getFunction( "hostmap" );
-    assertThat( funcDesc.config(), is( "/WEB-INF/hostmap.txt" ) );
-
-    Node node = webArchive.get( "/WEB-INF/hostmap.txt" );
-    String asset = IOUtils.toString( node.getAsset().openStream() );
-    assertThat( asset, containsString( "test-host-external=test-host-internal" ) );
-
-    // Just make sure it doesn't blow up.
-    contributor.finalizeContribution( context );
-
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest.java b/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest.java
deleted file mode 100644
index d93d6d1..0000000
--- a/gateway-provider-hostmap-static/src/test/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest.java
+++ /dev/null
@@ -1,216 +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.hadoop.gateway.hostmap.impl;
-
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteProcessor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRuleDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptorFactory;
-import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
-import org.apache.hadoop.gateway.filter.rewrite.ext.UrlRewriteActionRewriteDescriptorExt;
-import org.apache.hadoop.gateway.util.urltemplate.Parser;
-import org.apache.hadoop.gateway.util.urltemplate.Resolver;
-import org.apache.hadoop.gateway.util.urltemplate.Template;
-import org.apache.hadoop.test.TestUtils;
-import org.easymock.EasyMock;
-import org.junit.Test;
-
-import java.net.URL;
-import java.util.Arrays;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-
-public class HostmapFunctionProcessorTest {
-
-  @Test
-  public void testBasicUseCase() throws Exception {
-    URL configUrl = TestUtils.getResourceUrl( this.getClass(), "hostmap.txt" );
-
-    UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
-    EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
-    Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-inbound-host" ) ).anyTimes();
-    EasyMock.replay( environment, resolver );
-
-    UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
-    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
-    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
-    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
-    rewrite.template( "{*}://{$hostmap(host)}:{*}/{**}?{**}" );
-
-    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
-    rewriter.initialize( environment, descriptor );
-
-    Template input = Parser.parse( "test-scheme://test-inbound-host:42/test-path/test-file?test-name=test-value" );
-    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.IN, null );
-    //System.out.println( output );
-    assertThat( output, notNullValue() );
-    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-inbound-rewritten-host" ) );
-  }
-
-  @Test
-  public void testHdfsUseCase() throws Exception {
-    URL configUrl = TestUtils.getResourceUrl( this.getClass(), "hdfs-hostmap.txt" );
-
-    UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
-    EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
-    Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-internal-host" ) ).anyTimes();
-    EasyMock.replay( environment, resolver );
-
-    UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
-    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
-    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
-    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
-    rewrite.template( "{*}://test-static-host:{*}/{**}?server={$hostmap(host)}&{**}" );
-
-    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
-    rewriter.initialize( environment, descriptor );
-
-    Template input = Parser.parse(
-        "test-scheme://test-external-host:42/test-path/test-file?test-name-1=test-value-1&test-name-2=test-value-2" );
-    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.OUT, "test-rule" );
-    //System.out.println( output );
-    assertThat( output, notNullValue() );
-    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-static-host" ) );
-    assertThat( output.getQuery().get( "server" ).getFirstValue().getPattern(), is( "test-external-host" ) );
-    assertThat( output.getQuery().get( "server" ).getValues().size(), is( 1 ) );
-    assertThat( output.getQuery().get( "test-name-1" ).getFirstValue().getPattern(), is( "test-value-1" ) );
-    assertThat( output.getQuery().get( "test-name-1" ).getValues().size(), is( 1 ) );
-    assertThat( output.getQuery().get( "test-name-2" ).getFirstValue().getPattern(), is( "test-value-2" ) );
-    assertThat( output.getQuery().get( "test-name-2" ).getValues().size(), is( 1 ) );
-    assertThat( output.getQuery().size(), is( 3 ) );
-  }
-
-  @Test
-  public void testQueryToPathRewriteWithFunction() throws Exception {
-    URL configUrl = TestUtils.getResourceUrl( this.getClass(), "hdfs-hostmap.txt" );
-
-    UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
-    EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
-    Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-internal-host" ) ).anyTimes();
-    EasyMock.replay( environment, resolver );
-
-    UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
-    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
-    rule.pattern( "{*}://{host}:{*}/{**}?{qp1}&{qp2}&{**}" );
-    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
-    rewrite.template( "{*}://test-static-host:{*}/{qp1}/{qp2}/{**}?server={$hostmap(host)}&{**}" );
-
-    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
-    rewriter.initialize( environment, descriptor );
-
-    Template input = Parser.parse(
-        "test-scheme://test-external-host:42/test-path/test-file?qp1=qp1-val&qp2=qp2-val&test-name-1=test-value-1&test-name-2=test-value-2" );
-    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.OUT, "test-rule" );
-    //System.out.println( output );
-    assertThat( output, notNullValue() );
-    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-static-host" ) );
-    assertThat( output.getQuery().get( "server" ).getFirstValue().getPattern(), is( "test-external-host" ) );
-    assertThat( output.getQuery().get( "server" ).getValues().size(), is( 1 ) );
-    assertThat( output.getQuery().get( "test-name-1" ).getFirstValue().getPattern(), is( "test-value-1" ) );
-    assertThat( output.getQuery().get( "test-name-1" ).getValues().size(), is( 1 ) );
-    assertThat( output.getQuery().get( "test-name-2" ).getFirstValue().getPattern(), is( "test-value-2" ) );
-    assertThat( output.getQuery().get( "test-name-2" ).getValues().size(), is( 1 ) );
-    assertThat( output.getQuery().size(), is( 3 ) );
-  }
-
-  @Test
-  public void testUnmappedUseCase() throws Exception {
-    URL configUrl = TestUtils.getResourceUrl( this.getClass(), "hostmap.txt" );
-
-    UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
-    EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
-    Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-inbound-unmapped-host" ) ).anyTimes();
-    EasyMock.replay( environment, resolver );
-
-    UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
-    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
-    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
-    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
-    rewrite.template( "{*}://{$hostmap(host)}:{*}/{**}?{**}" );
-
-    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
-    rewriter.initialize( environment, descriptor );
-
-    Template input = Parser.parse(
-        "test-scheme://test-inbound-unmapped-host:42/test-path/test-file?test-name-1=test-value-1&test-name-2=test-value-2" );
-    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.IN, null );
-    //System.out.println( output );
-    assertThat( output, notNullValue() );
-    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-inbound-unmapped-host" ) );
-  }
-
-  @Test
-  public void testMissingFunctionUseCase() throws Exception {
-    URL configUrl = TestUtils.getResourceUrl( this.getClass(), "hostmap.txt" );
-
-    UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
-    EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
-    Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-inbound-host" ) ).anyTimes();
-    EasyMock.replay( environment, resolver );
-
-    UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
-    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
-    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
-    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
-    rewrite.template( "{*}://{$invalid-function(host)}:{*}/{**}?{**}" );
-
-    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
-    rewriter.initialize( environment, descriptor );
-
-    Template input = Parser.parse( "test-scheme://test-inbound-host:42/test-path/test-file?test-name=test-value" );
-    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.IN, null );
-    //System.out.println( output );
-    assertThat( output, notNullValue() );
-    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-inbound-host" ) );
-  }
-
-  @Test
-  public void testEmptyHostmapUseCase() throws Exception {
-    URL configUrl = TestUtils.getResourceUrl( this.getClass(), "empty-hostmap.txt" );
-
-    UrlRewriteEnvironment environment = EasyMock.createNiceMock( UrlRewriteEnvironment.class );
-    EasyMock.expect( environment.getResource( "/WEB-INF/hostmap.txt" ) ).andReturn( configUrl ).anyTimes();
-    Resolver resolver = EasyMock.createNiceMock( Resolver.class );
-    EasyMock.expect( resolver.resolve( "host" ) ).andReturn( Arrays.asList( "test-inbound-host" ) ).anyTimes();
-    EasyMock.replay( environment, resolver );
-
-    UrlRewriteRulesDescriptor descriptor = UrlRewriteRulesDescriptorFactory.create();
-    UrlRewriteRuleDescriptor rule = descriptor.addRule( "test-rule" );
-    rule.pattern( "{*}://{host}:{*}/{**}?{**}" );
-    UrlRewriteActionRewriteDescriptorExt rewrite = rule.addStep( "rewrite" );
-    rewrite.template( "{*}://{$invalid-function(host)}:{*}/{**}?{**}" );
-
-    UrlRewriteProcessor rewriter = new UrlRewriteProcessor();
-    rewriter.initialize( environment, descriptor );
-
-    Template input = Parser.parse( "test-scheme://test-inbound-host:42/test-path/test-file?test-name=test-value" );
-    Template output = rewriter.rewrite( resolver, input, UrlRewriter.Direction.IN, null );
-    //System.out.println( output );
-    assertThat( output, notNullValue() );
-    assertThat( output.getHost().getFirstValue().getPattern(), is( "test-inbound-host" ) );
-  }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/empty-hostmap.txt
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/empty-hostmap.txt b/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/empty-hostmap.txt
deleted file mode 100644
index 635f0d9..0000000
--- a/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/empty-hostmap.txt
+++ /dev/null
@@ -1,15 +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.

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/hdfs-hostmap.txt
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/hdfs-hostmap.txt b/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/hdfs-hostmap.txt
deleted file mode 100644
index 38eb607..0000000
--- a/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/hdfs-hostmap.txt
+++ /dev/null
@@ -1,17 +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.
-
-test-external-host=test-inbound-internal-host
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/hostmap.txt
----------------------------------------------------------------------
diff --git a/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/hostmap.txt b/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/hostmap.txt
deleted file mode 100644
index 576cac4..0000000
--- a/gateway-provider-hostmap-static/src/test/resources/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessorTest/hostmap.txt
+++ /dev/null
@@ -1,17 +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.
-
-test-inbound-host=test-inbound-rewritten-host
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-identity-assertion-pseudo/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-pseudo/pom.xml b/gateway-provider-identity-assertion-pseudo/pom.xml
index dd7e87c..7f2664a 100644
--- a/gateway-provider-identity-assertion-pseudo/pom.xml
+++ b/gateway-provider-identity-assertion-pseudo/pom.xml
@@ -44,22 +44,30 @@
             <groupId>commons-io</groupId>
             <artifactId>commons-io</artifactId>
         </dependency>
+
         <dependency>
             <groupId>${gateway-group}</groupId>
             <artifactId>gateway-spi</artifactId>
         </dependency>
+
         <dependency>
             <groupId>${gateway-group}</groupId>
             <artifactId>gateway-provider-rewrite</artifactId>
         </dependency>
 
         <dependency>
-            <groupId>org.apache.hadoop</groupId>
+            <groupId>${gateway-group}</groupId>
             <artifactId>gateway-test-utils</artifactId>
             <scope>test</scope>
         </dependency>
 
         <dependency>
+            <groupId>org.eclipse.jetty</groupId>
+            <artifactId>test-jetty-servlet</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
             <groupId>junit</groupId>
             <artifactId>junit</artifactId>
             <scope>test</scope>
@@ -75,6 +83,11 @@
             <artifactId>hamcrest-library</artifactId>
             <scope>test</scope>
         </dependency>
+        <dependency>
+            <groupId>org.xmlmatchers</groupId>
+            <artifactId>xml-matchers</artifactId>
+            <scope>test</scope>
+        </dependency>
 
         <dependency>
             <groupId>org.easymock</groupId>

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest.java b/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
index 3e50eaa..dab9c59 100644
--- a/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
+++ b/gateway-provider-identity-assertion-pseudo/src/test/java/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest.java
@@ -17,14 +17,45 @@
  */
 package org.apache.hadoop.gateway.identityasserter.function;
 
+import org.apache.hadoop.gateway.filter.AbstractGatewayFilter;
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteServletContextListener;
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteServletFilter;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
-import org.apache.hadoop.gateway.filter.security.AbstractIdentityAssertionBase;
 import org.apache.hadoop.gateway.security.PrimaryPrincipal;
+import org.apache.hadoop.gateway.util.urltemplate.Parser;
+import org.apache.hadoop.test.log.NoOpLogger;
+import org.apache.hadoop.test.mock.MockInteraction;
+import org.apache.hadoop.test.mock.MockServlet;
+import org.apache.http.auth.BasicUserPrincipal;
+import org.eclipse.jetty.servlet.FilterHolder;
+import org.eclipse.jetty.servlet.ServletHolder;
+import org.eclipse.jetty.testing.HttpTester;
+import org.eclipse.jetty.testing.ServletTester;
+import org.eclipse.jetty.util.ArrayQueue;
+import org.eclipse.jetty.util.log.Log;
+import org.hamcrest.core.Is;
+import org.junit.After;
 import org.junit.Test;
 
 import javax.security.auth.Subject;
+import javax.servlet.DispatcherType;
+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.HttpServletRequest;
+import java.io.IOException;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.nio.charset.Charset;
+import java.security.PrivilegedActionException;
 import java.security.PrivilegedExceptionAction;
+import java.util.EnumSet;
+import java.util.HashMap;
 import java.util.Iterator;
+import java.util.Map;
 import java.util.ServiceLoader;
 
 import static org.hamcrest.CoreMatchers.is;
@@ -34,6 +65,58 @@ import static org.junit.Assert.fail;
 
 public class UsernameFunctionProcessorTest {
 
+  private ServletTester server;
+  private HttpTester request;
+  private HttpTester response;
+  private ArrayQueue<MockInteraction> interactions;
+  private MockInteraction interaction;
+
+  private static URL getTestResource( String name ) {
+    name = UsernameFunctionProcessorTest.class.getName().replaceAll( "\\.", "/" ) + "/" + name;
+    URL url = ClassLoader.getSystemResource( name );
+    return url;
+  }
+
+  public void setUp( String username, Map<String,String> initParams ) throws Exception {
+    String descriptorUrl = getTestResource( "rewrite.xml" ).toExternalForm();
+
+    Log.setLog( new NoOpLogger() );
+
+    server = new ServletTester();
+    server.setContextPath( "/" );
+    server.getContext().addEventListener( new UrlRewriteServletContextListener() );
+    server.getContext().setInitParameter(
+        UrlRewriteServletContextListener.DESCRIPTOR_LOCATION_INIT_PARAM_NAME, descriptorUrl );
+
+    FilterHolder setupFilter = server.addFilter( SetupFilter.class, "/*", EnumSet.of( DispatcherType.REQUEST ) );
+    setupFilter.setFilter( new SetupFilter( username ) );
+    FilterHolder rewriteFilter = server.addFilter( UrlRewriteServletFilter.class, "/*", EnumSet.of( DispatcherType.REQUEST ) );
+    if( initParams != null ) {
+      for( Map.Entry<String,String> entry : initParams.entrySet() ) {
+        rewriteFilter.setInitParameter( entry.getKey(), entry.getValue() );
+      }
+    }
+    rewriteFilter.setFilter( new UrlRewriteServletFilter() );
+
+    interactions = new ArrayQueue<MockInteraction>();
+
+    ServletHolder servlet = server.addServlet( MockServlet.class, "/" );
+    servlet.setServlet( new MockServlet( "mock-servlet", interactions ) );
+
+    server.start();
+
+    interaction = new MockInteraction();
+    request = new HttpTester();
+    response = new HttpTester();
+  }
+
+  @After
+  public void tearDown() throws Exception {
+    if( server != null ) {
+      server.stop();
+    }
+  }
+
   @Test
   public void testInitialize() throws Exception {
     UsernameFunctionProcessor processor = new UsernameFunctionProcessor();
@@ -79,4 +162,85 @@ public class UsernameFunctionProcessorTest {
     fail( "Failed to find UsernameFunctionProcessor via service loader." );
   }
 
+  @Test
+  public void testRequestUrlRewriteOfUsernameViaRewriteRule() throws Exception {
+    Map<String,String> initParams = new HashMap<String,String>();
+    initParams.put( "request.url", "test-rule-username" );
+    setUp( "test-user", initParams );
+
+    String input = "<root/>";
+    String expect = "<root/>";
+
+    // Setup the server side request/response interaction.
+    interaction.expect()
+        .method( "PUT" )
+        .requestUrl( "test-output-scheme://test-input-host:777/test-output-path/test-input-path" )
+        .queryParam( "user.name", "test-user" )
+        .queryParam( "test-query-input-name", "test-query-input-value" )
+        .queryParam( "test-query-output-name", "test-query-output-value" )
+        .contentType( "text/xml" )
+        .characterEncoding( "UTF-8" )
+        .content( expect, Charset.forName( "UTF-8" ) );
+    interaction.respond()
+        .status( 200 );
+    interactions.add( interaction );
+    request.setMethod( "PUT" );
+    request.setURI( "/test-input-path?test-query-input-name=test-query-input-value" );
+    request.setVersion( "HTTP/1.1" );
+    request.setHeader( "Host", "test-input-host:777" );
+    request.setContentType( "text/xml; charset=UTF-8" );
+    request.setContent( input );
+
+    response.parse( server.getResponses( request.generate() ) );
+
+    // Test the results.
+    assertThat( response.getStatus(), Is.is( 200 ) );
+  }
+
+  private static class SetupFilter implements Filter {
+    private Subject subject;
+
+    public SetupFilter( String userName ) {
+      subject = new Subject();
+      subject.getPrincipals().add( new BasicUserPrincipal( userName ) );
+    }
+
+    @Override
+    public void init( FilterConfig filterConfig ) throws ServletException {
+    }
+
+    @Override
+    public void doFilter( final ServletRequest request, final ServletResponse response, final FilterChain chain ) throws IOException, ServletException {
+      HttpServletRequest httpRequest = ((HttpServletRequest)request);
+      StringBuffer sourceUrl = httpRequest.getRequestURL();
+      String queryString = httpRequest.getQueryString();
+      if( queryString != null ) {
+        sourceUrl.append( "?" );
+        sourceUrl.append( queryString );
+      }
+      try {
+        request.setAttribute(
+            AbstractGatewayFilter.SOURCE_REQUEST_URL_ATTRIBUTE_NAME,
+            Parser.parse( sourceUrl.toString() ) );
+      } catch( URISyntaxException e ) {
+        throw new ServletException( e );
+      }
+      try {
+        Subject.doAs( subject, new PrivilegedExceptionAction<Void>() {
+          @Override
+          public Void run() throws Exception {
+              chain.doFilter( request, response );
+              return null;
+          }
+        } );
+      } catch( PrivilegedActionException e ) {
+        throw new ServletException( e );
+      }
+    }
+
+    @Override
+    public void destroy() {
+    }
+  }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-identity-assertion-pseudo/src/test/resources/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest/rewrite.xml
----------------------------------------------------------------------
diff --git a/gateway-provider-identity-assertion-pseudo/src/test/resources/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest/rewrite.xml b/gateway-provider-identity-assertion-pseudo/src/test/resources/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest/rewrite.xml
new file mode 100644
index 0000000..cf28b92
--- /dev/null
+++ b/gateway-provider-identity-assertion-pseudo/src/test/resources/org/apache/hadoop/gateway/identityasserter/function/UsernameFunctionProcessorTest/rewrite.xml
@@ -0,0 +1,24 @@
+<!--
+  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.
+-->
+<rules>
+
+    <rule name="test-rule-username">
+        <match pattern="*://{host}:{port}/{path=**}?{**}"/>
+        <rewrite template="test-output-scheme://{host}:{port}/test-output-path/{path=**}?user.name={$username}?{**}?test-query-output-name=test-query-output-value"/>
+    </rule>
+
+</rules>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-rewrite-func-hostmap-static/pom.xml
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-hostmap-static/pom.xml b/gateway-provider-rewrite-func-hostmap-static/pom.xml
new file mode 100644
index 0000000..54fccb3
--- /dev/null
+++ b/gateway-provider-rewrite-func-hostmap-static/pom.xml
@@ -0,0 +1,96 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.hadoop</groupId>
+        <artifactId>gateway</artifactId>
+        <version>0.3.0-SNAPSHOT</version>
+    </parent>
+    <artifactId>gateway-provider-rewrite-func-hostmap-static</artifactId>
+
+    <name>gateway-provider-rewrite-func-hostmap-static</name>
+    <description>An extension to the URL rewriter that provides a way to map hostnames in requests and responses.</description>
+
+    <licenses>
+        <license>
+            <name>The Apache Software License, Version 2.0</name>
+            <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+            <distribution>repo</distribution>
+        </license>
+    </licenses>
+
+    <dependencies>
+
+        <dependency>
+            <groupId>${gateway-group}</groupId>
+            <artifactId>gateway-i18n</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${gateway-group}</groupId>
+            <artifactId>gateway-i18n-logging-log4j</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${gateway-group}</groupId>
+            <artifactId>gateway-spi</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>${gateway-group}</groupId>
+            <artifactId>gateway-provider-rewrite</artifactId>
+        </dependency>
+
+        <!-- ********** ********** ********** ********** ********** ********** -->
+        <!-- ********** Test Dependencies                           ********** -->
+        <!-- ********** ********** ********** ********** ********** ********** -->
+
+        <dependency>
+            <groupId>${gateway-group}</groupId>
+            <artifactId>gateway-test-utils</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-core</artifactId>
+            <scope>test</scope>
+        </dependency>
+        <dependency>
+            <groupId>org.hamcrest</groupId>
+            <artifactId>hamcrest-library</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <!-- This must be after restassured otherwise is messes up the hamcrest dependencies. -->
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.easymock</groupId>
+            <artifactId>easymock</artifactId>
+            <scope>test</scope>
+        </dependency>
+
+    </dependencies>
+
+</project>
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptor.java b/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptor.java
new file mode 100644
index 0000000..01d41b9
--- /dev/null
+++ b/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/api/HostmapFunctionDescriptor.java
@@ -0,0 +1,50 @@
+/**
+ * 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.hadoop.gateway.hostmap.api;
+
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor;
+
+public class HostmapFunctionDescriptor implements UrlRewriteFunctionDescriptor<HostmapFunctionDescriptor> {
+
+  public static final String FUNCTION_NAME = "hostmap";
+
+  private String configLocation;
+
+  @Override
+  public String name() {
+    return FUNCTION_NAME;
+  }
+
+  public HostmapFunctionDescriptor config( String configLocation ) {
+    this.configLocation = configLocation;
+    return this;
+  }
+
+  public String config() {
+    return configLocation;
+  }
+
+  public String getConfig() {
+    return config();
+  }
+
+  public void setConfig( String configLocation ) {
+    config( configLocation );
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributor.java b/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributor.java
new file mode 100644
index 0000000..ba9274d
--- /dev/null
+++ b/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapDeploymentContributor.java
@@ -0,0 +1,100 @@
+/**
+ * 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.hadoop.gateway.hostmap.impl;
+
+import org.apache.hadoop.gateway.deploy.DeploymentContext;
+import org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor;
+import org.apache.hadoop.gateway.deploy.ProviderDeploymentContributorBase;
+import org.apache.hadoop.gateway.descriptor.FilterParamDescriptor;
+import org.apache.hadoop.gateway.descriptor.ResourceDescriptor;
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteRulesDescriptor;
+import org.apache.hadoop.gateway.hostmap.api.HostmapFunctionDescriptor;
+import org.apache.hadoop.gateway.topology.Provider;
+import org.apache.hadoop.gateway.topology.Service;
+import org.jboss.shrinkwrap.api.asset.Asset;
+import org.jboss.shrinkwrap.api.asset.StringAsset;
+
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.List;
+import java.util.Map;
+
+public class HostmapDeploymentContributor
+    extends ProviderDeploymentContributorBase
+    implements ProviderDeploymentContributor {
+
+  public static final String PROVIDER_ROLE_NAME = HostmapFunctionDescriptor.FUNCTION_NAME;
+  public static final String PROVIDER_IMPL_NAME = "static";
+
+  private static final String REWRITE_ROLE_NAME = "rewrite";
+
+  @Override
+  public String getRole() {
+    return PROVIDER_ROLE_NAME;
+  }
+
+  @Override
+  public String getName() {
+    return PROVIDER_IMPL_NAME;
+  }
+
+  // Write the provider init params to the hostmap.txt file.
+  // Add the function to the rewrite descriptor providing the location of the hostmap.txt file.
+  @Override
+  public void contributeProvider( DeploymentContext context, Provider provider ) {
+    if( provider.isEnabled() ) {
+      UrlRewriteRulesDescriptor rules = context.getDescriptor( REWRITE_ROLE_NAME );
+      if( rules != null ) {
+        HostmapFunctionDescriptor func = rules.addFunction( HostmapFunctionDescriptor.FUNCTION_NAME );
+        if( func != null ) {
+          Asset asset = createAsset( provider );
+          context.getWebArchive().addAsWebInfResource(
+              asset, HostmapFunctionProcessor.DESCRIPTOR_DEFAULT_FILE_NAME );
+          func.config( HostmapFunctionProcessor.DESCRIPTOR_DEFAULT_LOCATION );
+        }
+      }
+    }
+  }
+
+  private Asset createAsset( Provider provider ) {
+    StringWriter buffer = new StringWriter();
+    PrintWriter writer = new PrintWriter( buffer );
+    for( Map.Entry<String,String> entry : provider.getParams().entrySet() ) {
+      String externalHosts = entry.getKey();
+      String internalHosts = entry.getValue();
+      writer.print( externalHosts );
+      writer.print( "=" );
+      writer.println( internalHosts ) ;
+    }
+    writer.close();
+    String string = buffer.toString();
+    Asset asset = new StringAsset( string );
+    return asset;
+  }
+
+  @Override
+  public void contributeFilter(
+      DeploymentContext context,
+      Provider provider,
+      Service service,
+      ResourceDescriptor resource,
+      List<FilterParamDescriptor> params ) {
+    // NoOp.
+  }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessor.java b/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessor.java
new file mode 100644
index 0000000..9e71a4e
--- /dev/null
+++ b/gateway-provider-rewrite-func-hostmap-static/src/main/java/org/apache/hadoop/gateway/hostmap/impl/HostmapFunctionProcessor.java
@@ -0,0 +1,98 @@
+/**
+ * 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.hadoop.gateway.hostmap.impl;
+
+import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
+import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
+import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
+import org.apache.hadoop.gateway.hostmap.api.HostmapFunctionDescriptor;
+
+import java.io.BufferedReader;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
+
+public class HostmapFunctionProcessor
+    implements UrlRewriteFunctionProcessor<HostmapFunctionDescriptor> {
+
+  public static final String DESCRIPTOR_DEFAULT_FILE_NAME = "hostmap.txt";
+  public static final String DESCRIPTOR_DEFAULT_LOCATION = "/WEB-INF/" + DESCRIPTOR_DEFAULT_FILE_NAME;
+
+  private Map<String, String> inbound = new HashMap<String, String>();
+  private Map<String, String> outbound = new HashMap<String, String>();
+
+  @Override
+  public String name() {
+    return HostmapFunctionDescriptor.FUNCTION_NAME;
+  }
+
+  @Override
+  public void initialize( UrlRewriteEnvironment environment, HostmapFunctionDescriptor descriptor ) throws Exception {
+    URL url = environment.getResource( DESCRIPTOR_DEFAULT_LOCATION );
+    if( url != null ) {
+      InputStream stream = url.openStream();
+      BufferedReader reader = new BufferedReader( new InputStreamReader( stream ) );
+      String line = reader.readLine();
+      while( line != null ) {
+        String[] lineSplit = line.split( "=" );
+        if( lineSplit.length >= 2 ) {
+          String[] externalSplit = lineSplit[ 0 ].split( "," );
+          String[] internalSplit = lineSplit[ 1 ].split( "," );
+          if( externalSplit.length >= 1 && internalSplit.length >= 1 ) {
+            for( String external : externalSplit ) {
+              inbound.put( external, internalSplit[ 0 ] );
+            }
+            for( String internal : internalSplit ) {
+              outbound.put( internal, externalSplit[ 0 ] );
+            }
+          }
+        }
+        line = reader.readLine();
+      }
+      reader.close();
+    }
+  }
+
+  @Override
+  public void destroy() throws Exception {
+  }
+
+  @Override
+  public String resolve( UrlRewriteContext context, String parameter ) throws Exception {
+    String value;
+    switch( context.getDirection() ) {
+      case IN:
+        value = inbound.get( parameter );
+        break;
+      case OUT:
+        value = outbound.get( parameter );
+        break;
+      default:
+        value = null;
+    }
+    if( value == null ) {
+      value = parameter;
+    }
+//    System.out.println( "HOSTMAP: " + parameter + "->" + value );
+    return value;
+  }
+
+}
+

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor b/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
new file mode 100644
index 0000000..eda74c1
--- /dev/null
+++ b/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.deploy.ProviderDeploymentContributor
@@ -0,0 +1,19 @@
+##########################################################################
+# 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.
+##########################################################################
+
+org.apache.hadoop.gateway.hostmap.impl.HostmapDeploymentContributor
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor b/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor
new file mode 100644
index 0000000..3e80487
--- /dev/null
+++ b/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor
@@ -0,0 +1,19 @@
+##########################################################################
+# 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.
+##########################################################################
+
+org.apache.hadoop.gateway.hostmap.api.HostmapFunctionDescriptor
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/2f135e16/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor b/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor
new file mode 100644
index 0000000..7c6619c
--- /dev/null
+++ b/gateway-provider-rewrite-func-hostmap-static/src/main/resources/META-INF/services/org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor
@@ -0,0 +1,19 @@
+##########################################################################
+# 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.
+##########################################################################
+
+org.apache.hadoop.gateway.hostmap.impl.HostmapFunctionProcessor
\ No newline at end of file