knox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kmin...@apache.org
Subject [2/2] git commit: KNOX-47: Replace all System.out.println and e.printStackTrace with localizable messages and resources.
Date Tue, 21 May 2013 13:11:33 GMT
KNOX-47: Replace all System.out.println and e.printStackTrace with localizable messages and resources.


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

Branch: refs/heads/master
Commit: 5cd1567c3b0842dd6eb4fec7d3c81404612da288
Parents: 9ed2c02
Author: Kevin Minder <kevin.minder@hortonworks.com>
Authored: Tue May 21 09:11:25 2013 -0400
Committer: Kevin Minder <kevin.minder@hortonworks.com>
Committed: Tue May 21 09:11:25 2013 -0400

----------------------------------------------------------------------
 .../filter/rewrite/api/UrlRewriteProcessor.java    |   21 ++--
 .../api/UrlRewriteServletContextListener.java      |    7 +-
 .../filter/rewrite/i18n/UrlRewriteMessages.java    |   41 +++++-
 .../filter/rewrite/impl/UrlRewriteContextImpl.java |    7 +-
 .../impl/UrlRewriteDeploymentContributor.java      |    5 +-
 .../rewrite/impl/UrlRewriteFunctionResolver.java   |    7 +-
 .../filter/rewrite/impl/UrlRewriteRequest.java     |    9 +-
 .../filter/rewrite/impl/UrlRewriteResponse.java    |    5 +-
 .../impl/UrlRewriteStepProcessorHolder.java        |    8 +-
 .../filter/rewrite/impl/form/FormFilterReader.java |    8 +-
 .../impl/html/HtmlUrlRewriteFilterReader.java      |    7 +-
 .../filter/rewrite/impl/json/JsonFilterReader.java |   10 +-
 .../filter/rewrite/impl/xml/XmlFilterReader.java   |   12 +-
 .../impl/xml/XmlUrlRewriteRulesExporter.java       |   12 +-
 .../provider/authn/jwt/filter/JWTToken.java        |   25 ++--
 .../provider/federation/jwt/AccessToken.java       |    8 +-
 .../federation/jwt/JWTProviderMessages.java        |   13 ++
 .../gateway/provider/federation/jwt/JWTToken.java  |    9 +-
 .../org/apache/hadoop/gateway/GatewayFilter.java   |   13 +-
 .../org/apache/hadoop/gateway/GatewayMessages.java |  103 +++++++++++++-
 .../org/apache/hadoop/gateway/GatewayServer.java   |    8 +-
 .../org/apache/hadoop/gateway/GatewayServlet.java  |   10 +-
 .../hadoop/gateway/deploy/DeploymentFactory.java   |   26 ++--
 .../gateway/dispatch/UrlConnectionDispatch.java    |   12 +-
 .../services/security/impl/AESEncryptor.java       |   40 ++---
 .../security/impl/DefaultCryptoService.java        |   54 +++-----
 .../security/impl/DefaultKeystoreService.java      |  110 +++++---------
 .../security/impl/DefaultMasterService.java        |   18 ++--
 .../topology/file/FileTopologyProvider.java        |   11 +-
 .../gateway/filter/AbstractGatewayFilter.java      |   11 +-
 .../security/AbstractIdentityAssertionFilter.java  |    8 +-
 .../hadoop/gateway/i18n/GatewaySpiMessages.java    |   33 +++++
 gateway-util-common/pom.xml                        |    7 +-
 .../gateway/i18n/GatewayUtilCommonMessages.java    |   36 +++++
 .../org/apache/hadoop/gateway/util/JsonUtils.java  |   26 ++--
 pom.xml                                            |    2 +-
 36 files changed, 480 insertions(+), 262 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteProcessor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteProcessor.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteProcessor.java
index 313c6b4..addaf36 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteProcessor.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteProcessor.java
@@ -17,6 +17,7 @@
  */
 package org.apache.hadoop.gateway.filter.rewrite.api;
 
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
 import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteContextImpl;
 import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteFunctionProcessorFactory;
 import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteFunctionResolver;
@@ -24,6 +25,7 @@ import org.apache.hadoop.gateway.filter.rewrite.impl.UrlRewriteStepProcessorHold
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteStepStatus;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.util.urltemplate.Matcher;
 import org.apache.hadoop.gateway.util.urltemplate.Resolver;
 import org.apache.hadoop.gateway.util.urltemplate.Template;
@@ -39,6 +41,8 @@ import static org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter.Direction
 
 public class UrlRewriteProcessor implements UrlRewriter {
 
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
+  
   UrlRewriteEnvironment environment;
   List<UrlRewriteStepProcessorHolder> rules = new ArrayList<UrlRewriteStepProcessorHolder>();
   Matcher<UrlRewriteStepProcessorHolder> inbound = new Matcher<UrlRewriteStepProcessorHolder>();
@@ -64,8 +68,7 @@ public class UrlRewriteProcessor implements UrlRewriter {
         processor.initialize( environment, descriptor );
         functions.put( name, processor );
       } catch( Exception e ) {
-        //TODO: Proper i18n stack trace logging.
-        e.printStackTrace();
+        LOG.failedToInitializeRewriteFunctions( e );
         // Ignore it and it won't be available as a function.
       }
     }
@@ -88,8 +91,7 @@ public class UrlRewriteProcessor implements UrlRewriter {
           outbound.add( template, ruleProcessor );
         }
       } catch( Exception e ) {
-        //TODO: Log stack trace properly.
-        e.printStackTrace();
+        LOG.failedToInitializeRewriteRules( e );
       }
     }
   }
@@ -99,18 +101,14 @@ public class UrlRewriteProcessor implements UrlRewriter {
       try {
         rule.destroy();
       } catch ( Exception e ) {
-        //TODO: Log i18n stack trace properly.
-        e.printStackTrace();
-        // Ignore it.
+        LOG.failedToDestroyRewriteRuleProcessor( e );
       }
     }
     for( UrlRewriteFunctionProcessor function : functions.values() ) {
       try {
         function.destroy();
       } catch( Exception e ) {
-        //TODO: Log i18n stack trace properly.
-        e.printStackTrace();
-        // Ignore it.
+        LOG.failedToDestroyRewriteFunctionProcessor( e );
       }
     }
   }
@@ -140,8 +138,7 @@ public class UrlRewriteProcessor implements UrlRewriter {
           outputUri = null;
         }
       } catch( Exception e ) {
-        //TODO: I18N Log stack trace properly.
-        e.printStackTrace();
+        LOG.failedToRewriteUrl( e );
         outputUri = null;
       }
     }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
index ae411f6..d673845 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteServletContextListener.java
@@ -20,6 +20,10 @@ package org.apache.hadoop.gateway.filter.rewrite.api;
 import javax.servlet.ServletContext;
 import javax.servlet.ServletContextEvent;
 import javax.servlet.ServletContextListener;
+
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
+
 import java.io.FileNotFoundException;
 import java.io.IOException;
 import java.io.InputStream;
@@ -34,6 +38,7 @@ public class UrlRewriteServletContextListener implements ServletContextListener
   public static final String DESCRIPTOR_LOCATION_INIT_PARAM_NAME = "rewriteDescriptorLocation";
   public static final String DESCRIPTOR_DEFAULT_FILE_NAME = "rewrite.xml";
   public static final String DESCRIPTOR_DEFAULT_LOCATION = "/WEB-INF/" + DESCRIPTOR_DEFAULT_FILE_NAME;
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
 
   @Override
   public void contextInitialized( ServletContextEvent event ) {
@@ -93,7 +98,7 @@ public class UrlRewriteServletContextListener implements ServletContextListener
     try {
       reader.close();
     } catch( IOException closeException ) {
-      closeException.printStackTrace();
+      LOG.failedToLoadRewriteRulesDescriptor( closeException );
     }
     return descriptor;
   }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/i18n/UrlRewriteMessages.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/i18n/UrlRewriteMessages.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/i18n/UrlRewriteMessages.java
index a4dcb56..c8fee57 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/i18n/UrlRewriteMessages.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/i18n/UrlRewriteMessages.java
@@ -20,11 +20,48 @@ package org.apache.hadoop.gateway.filter.rewrite.i18n;
 import org.apache.hadoop.gateway.i18n.messages.Message;
 import org.apache.hadoop.gateway.i18n.messages.MessageLevel;
 import org.apache.hadoop.gateway.i18n.messages.Messages;
+import org.apache.hadoop.gateway.i18n.messages.StackTrace;
 
 @Messages(logger="org.apache.hadoop.gateway")
 public interface UrlRewriteMessages {
 
-    @Message( level = MessageLevel.DEBUG, text = "Failed to parse value as URL: {0}" )
-    void failedToParseValueForUrlRewrite( String value );
+  @Message( level = MessageLevel.DEBUG, text = "Failed to parse value as URL: {0}" )
+  void failedToParseValueForUrlRewrite( String value );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to write the rules descriptor: {0}" )
+  void failedToWriteRulesDescriptor( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.DEBUG, text = "Failed to filter attribute {0}: {1}" )
+  void failedToFilterAttribute( String attributeName, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to load rewrite rules descriptor: {0}" )
+  void failedToLoadRewriteRulesDescriptor( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to initialize rewrite rules: {0}" )
+  void failedToInitializeRewriteRules( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to initialize rewrite functions: {0}" )
+  void failedToInitializeRewriteFunctions( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to destroy rewrite rule processor: {0}" )
+  void failedToDestroyRewriteRuleProcessor( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to destroy rewrite function processor: {0}" )
+  void failedToDestroyRewriteFunctionProcessor( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to rewrite URL: {0}" )
+  void failedToRewriteUrl( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to filter value {0}: {1}" )
+  void failedToFilterValue( String value, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to filter field name {0}: {1}" )
+  void failedToFilterFieldName( String fieldName, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to function {0}: {1}" )
+  void failedToInvokeRewriteFunction( String functionName, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to find values by parameter name {0}: {1}" )
+  void failedToFindValuesByParameter( String parameterName, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
 
 }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteContextImpl.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteContextImpl.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteContextImpl.java
index 227ba1f..75963eb 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteContextImpl.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteContextImpl.java
@@ -19,8 +19,10 @@ package org.apache.hadoop.gateway.filter.rewrite.impl;
 
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteResolver;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.util.urltemplate.Params;
 import org.apache.hadoop.gateway.util.urltemplate.Template;
 
@@ -32,6 +34,8 @@ import java.util.Set;
 
 public class UrlRewriteContextImpl implements UrlRewriteContext {
 
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
+
   private UrlRewriteEnvironment environment;
   private UrlRewriteResolver resolver;
   private ContextParameters params;
@@ -103,8 +107,7 @@ public class UrlRewriteContextImpl implements UrlRewriteContext {
             values = environment.resolve( name ); // Try to fine the name in the environment.
           }
         } catch( Exception e ) {
-          //TODO: Proper i18n logging.
-          e.printStackTrace();
+          LOG.failedToFindValuesByParameter( name, e );
           // Ignore it and return null.
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteDeploymentContributor.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteDeploymentContributor.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteDeploymentContributor.java
index f004188..b6e0bc4 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteDeploymentContributor.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteDeploymentContributor.java
@@ -25,6 +25,8 @@ 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.UrlRewriteServletContextListener;
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteServletFilter;
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.topology.Provider;
 import org.apache.hadoop.gateway.topology.Service;
 import org.jboss.shrinkwrap.api.asset.StringAsset;
@@ -37,6 +39,7 @@ public class UrlRewriteDeploymentContributor extends ProviderDeploymentContribut
 
   private static final String PROVIDER_ROLE_NAME = "rewrite";
   private static final String PROVIDER_IMPL_NAME = "url-rewrite";
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
 
   @Override
   public String getRole() {
@@ -62,7 +65,7 @@ public class UrlRewriteDeploymentContributor extends ProviderDeploymentContribut
     try {
       UrlRewriteRulesDescriptorFactory.store( descriptor, "xml", writer );
     } catch( IOException e ) {
-      e.printStackTrace();
+      LOG.failedToWriteRulesDescriptor( e );
     }
     String asset = writer.toString();
     context.getWebArchive().addAsWebInfResource(

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteFunctionResolver.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteFunctionResolver.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteFunctionResolver.java
index 6457e69..0fd8b22 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteFunctionResolver.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteFunctionResolver.java
@@ -17,9 +17,11 @@
  */
 package org.apache.hadoop.gateway.filter.rewrite.impl;
 
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteFunctionProcessor;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteResolver;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.util.urltemplate.Resolver;
 
 import java.util.List;
@@ -28,6 +30,8 @@ import java.util.StringTokenizer;
 
 public class UrlRewriteFunctionResolver implements UrlRewriteResolver {
 
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
+
   private Map<String,UrlRewriteFunctionProcessor> functions;
   private Resolver delegate;
   private enum TokenType { FUNCTION, DIRECT_PARAMETER, INDIRECT_PARAMETER}
@@ -80,8 +84,7 @@ public class UrlRewriteFunctionResolver implements UrlRewriteResolver {
         try {
           value = resolver.resolve( context, parameter );
         } catch( Exception e ) {
-          //TODO: Proper i18n stack trace logging.
-          e.printStackTrace();
+          LOG.failedToInvokeRewriteFunction( function, e );
           // Ignore it and use the original parameter values.
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
index 17c02d1..aba384a 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteRequest.java
@@ -22,6 +22,8 @@ import org.apache.hadoop.gateway.filter.GatewayRequestWrapper;
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteServletContextListener;
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteStreamFilterFactory;
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.util.urltemplate.Parser;
 import org.apache.hadoop.gateway.util.urltemplate.Resolver;
 import org.apache.hadoop.gateway.util.urltemplate.Template;
@@ -40,6 +42,8 @@ import java.util.List;
 
 public class UrlRewriteRequest extends GatewayRequestWrapper implements Resolver {
 
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
+
   private UrlRewriter rewriter;
 
   /**
@@ -63,8 +67,7 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements Resolver
     try {
       urlTemplate = Parser.parse( urlString.toString() );
     } catch( URISyntaxException e ) {
-      //TODO: Proper I18 stack logging.
-      e.printStackTrace();
+      LOG.failedToParseValueForUrlRewrite( urlString.toString() );
       // Shouldn't be possible given that the URL is constructed from parts of an existing URL.
       urlTemplate = null;
     }
@@ -125,7 +128,7 @@ public class UrlRewriteRequest extends GatewayRequestWrapper implements Resolver
       Template output = rewriter.rewrite( this, input, UrlRewriter.Direction.IN );
       value = output.toString();
     } catch( URISyntaxException e ) {
-      e.printStackTrace();
+      LOG.failedToParseValueForUrlRewrite( value );
     }
     return value;
   }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
index 98c4652..cbc10f3 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteResponse.java
@@ -22,6 +22,8 @@ import org.apache.hadoop.gateway.filter.ResponseStreamer;
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteServletContextListener;
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteStreamFilterFactory;
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.util.Urls;
 import org.apache.hadoop.gateway.util.urltemplate.Params;
 import org.apache.hadoop.gateway.util.urltemplate.Parser;
@@ -49,6 +51,7 @@ import java.util.Set;
 public class UrlRewriteResponse extends GatewayResponseWrapper implements Params, ResponseStreamer {
 
   private static final Set<String> IGNORE_HEADER_NAMES = new HashSet<String>();
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
   static {
     IGNORE_HEADER_NAMES.add( "Content-Length" );
   }
@@ -90,7 +93,7 @@ public class UrlRewriteResponse extends GatewayResponseWrapper implements Params
       Template output = rewriter.rewrite( this, input, UrlRewriter.Direction.OUT );
       value = output.toString();
     } catch( URISyntaxException e ) {
-      e.printStackTrace();
+      LOG.failedToParseValueForUrlRewrite( value );
     }
     return value;
   }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java
index 552336a..7650831 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/UrlRewriteStepProcessorHolder.java
@@ -21,9 +21,11 @@ import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteEnvironment;
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFlowDescriptor;
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteStepDescriptor;
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteStepFlow;
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteContext;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteStepProcessor;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteStepStatus;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 
 import java.util.ArrayList;
 import java.util.Iterator;
@@ -31,6 +33,8 @@ import java.util.List;
 
 public class UrlRewriteStepProcessorHolder implements UrlRewriteStepProcessor {
 
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
+
   private boolean isCondition;
   private UrlRewriteStepDescriptor descriptor;
   private UrlRewriteStepProcessor processor;
@@ -220,8 +224,8 @@ public class UrlRewriteStepProcessorHolder implements UrlRewriteStepProcessor {
       try {
         processor.destroy();
       } catch( Exception e ) {
-        //TODO: Log stack properly.
-        e.printStackTrace();
+        // Maybe it makes sense to throw exception
+        LOG.failedToDestroyRewriteRuleProcessor( e );
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormFilterReader.java
index 85dc257..f22a600 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormFilterReader.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/form/FormFilterReader.java
@@ -21,8 +21,13 @@ import java.io.IOException;
 import java.io.Reader;
 import java.io.StringWriter;
 
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
+
 public class FormFilterReader extends Reader {
 
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
+
   private int offset;
   private StringWriter writer;
   private StringBuffer buffer;
@@ -72,8 +77,7 @@ public class FormFilterReader extends Reader {
     try {
       pair.setValue( filterValue( pair.getName(), pair.getValue() ) );
     } catch( Exception e ) {
-      //TODO: Log a proper i18n error
-      e.printStackTrace();
+      LOG.failedToFilterValue( pair.getValue(), e );
       // Write original value.
     }
     generator.writePair( pair );

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteFilterReader.java
index eab6d73..fea9d07 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteFilterReader.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/html/HtmlUrlRewriteFilterReader.java
@@ -18,6 +18,8 @@
 package org.apache.hadoop.gateway.filter.rewrite.impl.html;
 
 import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriter;
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.util.urltemplate.Parser;
 import org.apache.hadoop.gateway.util.urltemplate.Resolver;
 import org.apache.hadoop.gateway.util.urltemplate.Template;
@@ -28,6 +30,8 @@ import java.net.URISyntaxException;
 
 public class HtmlUrlRewriteFilterReader extends HtmlFilterReader {
 
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
+  
   private Resolver resolver;
   private UrlRewriter rewriter;
   private UrlRewriter.Direction direction;
@@ -49,8 +53,7 @@ public class HtmlUrlRewriteFilterReader extends HtmlFilterReader {
         value = output.toString();
       }
     } catch( URISyntaxException e ) {
-      //TODO: Proper i18n logging of stack trace.
-      e.printStackTrace();
+      LOG.failedToParseValueForUrlRewrite( value );
     }
     return value;
   }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/json/JsonFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/json/JsonFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/json/JsonFilterReader.java
index e08d133..73ba2eb 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/json/JsonFilterReader.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/json/JsonFilterReader.java
@@ -17,6 +17,8 @@
  */
 package org.apache.hadoop.gateway.filter.rewrite.impl.json;
 
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.codehaus.jackson.JsonFactory;
 import org.codehaus.jackson.JsonGenerator;
 import org.codehaus.jackson.JsonParser;
@@ -28,6 +30,8 @@ import java.io.StringWriter;
 
 public class JsonFilterReader extends Reader {
 
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
+  
   private int offset;
   private JsonParser parser;
   private JsonGenerator generator;
@@ -141,8 +145,7 @@ public class JsonFilterReader extends Reader {
     try {
       name = filterFieldName( name );
     } catch( Exception e ) {
-      //TODO: Log a proper i18n error
-      e.printStackTrace();
+      LOG.failedToFilterFieldName( name, e );
       // Write original name.
     }
     generator.writeFieldName( name );
@@ -154,8 +157,7 @@ public class JsonFilterReader extends Reader {
     try {
       value = filterValueString( name, value );
     } catch( Exception e ) {
-      //TODO: Log a proper i18n error
-      e.printStackTrace();
+      LOG.failedToFilterValue( value, e );
       // Write original value.
     }
     generator.writeString( value );

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlFilterReader.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
index f2cc9f7..7eca699 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlFilterReader.java
@@ -26,6 +26,10 @@ import net.htmlparser.jericho.StreamedSource;
 import net.htmlparser.jericho.Tag;
 
 import javax.xml.namespace.QName;
+
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
+
 import java.io.IOException;
 import java.io.Reader;
 import java.io.StringWriter;
@@ -36,6 +40,8 @@ import java.util.Stack;
 
 public abstract class XmlFilterReader extends Reader {
 
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
+  
   private Stack<Element> stack;
   private Reader reader;
   private StreamedSource parser;
@@ -150,8 +156,7 @@ public abstract class XmlFilterReader extends Reader {
         outputValue = inputValue;
       }
     } catch ( Exception e ) {
-      //TODO: Log the exception.
-      e.printStackTrace();
+      LOG.failedToFilterAttribute( attribute.getName(), e );
     }
     writer.write( " " );
     writer.write( attribute.getName() );
@@ -175,8 +180,7 @@ public abstract class XmlFilterReader extends Reader {
         outputValue = inputValue;
       }
     } catch ( Exception e ) {
-      //TODO: Log the exception.
-      e.printStackTrace();
+      LOG.failedToFilterValue( inputValue, e );
     }
     writer.write( outputValue );
   }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporter.java
----------------------------------------------------------------------
diff --git a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporter.java b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporter.java
index e15d7c2..df24c4a 100644
--- a/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporter.java
+++ b/gateway-provider-rewrite/src/main/java/org/apache/hadoop/gateway/filter/rewrite/impl/xml/XmlUrlRewriteRulesExporter.java
@@ -23,7 +23,9 @@ import org.apache.hadoop.gateway.filter.rewrite.api.UrlRewriteFunctionDescriptor
 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.UrlRewriteStepDescriptor;
+import org.apache.hadoop.gateway.filter.rewrite.i18n.UrlRewriteMessages;
 import org.apache.hadoop.gateway.filter.rewrite.spi.UrlRewriteRulesExporter;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.w3c.dom.Attr;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
@@ -47,6 +49,8 @@ import java.lang.reflect.InvocationTargetException;
 
 public class XmlUrlRewriteRulesExporter implements UrlRewriteRulesExporter, XmlRewriteRulesTags {
 
+  private static final UrlRewriteMessages LOG = MessagesFactory.get( UrlRewriteMessages.class );
+  
   @Override
   public String getFormat() {
     return "xml";
@@ -93,13 +97,13 @@ public class XmlUrlRewriteRulesExporter implements UrlRewriteRulesExporter, XmlR
     } catch( TransformerException e ) {
       throw new IOException( e );
     } catch( InvocationTargetException e ) {
-      e.printStackTrace();
+      LOG.failedToWriteRulesDescriptor( e );
     } catch( NoSuchMethodException e ) {
-      e.printStackTrace();
+      LOG.failedToWriteRulesDescriptor( e );
     } catch( IntrospectionException e ) {
-      e.printStackTrace();
+      LOG.failedToWriteRulesDescriptor( e );
     } catch( IllegalAccessException e ) {
-      e.printStackTrace();
+      LOG.failedToWriteRulesDescriptor( e );
     }
   }
 

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/authn/jwt/filter/JWTToken.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/authn/jwt/filter/JWTToken.java b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/authn/jwt/filter/JWTToken.java
index d8544a3..b8e2ff1 100644
--- a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/authn/jwt/filter/JWTToken.java
+++ b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/authn/jwt/filter/JWTToken.java
@@ -21,6 +21,8 @@ import java.io.UnsupportedEncodingException;
 import java.text.MessageFormat;
 
 import org.apache.commons.codec.binary.Base64;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
+import org.apache.hadoop.gateway.provider.federation.jwt.JWTProviderMessages;
 
 import com.jayway.jsonpath.JsonPath;
 
@@ -31,6 +33,7 @@ public class JWTToken {
   public static final String ISSUER = "iss";
   public static final String AUDIENCE = "aud";
   public static final String EXPIRES = "exp";
+  private static final JWTProviderMessages LOG = MessagesFactory.get( JWTProviderMessages.class );
 
   public String header = null;
   public String claims = null;
@@ -43,8 +46,7 @@ public class JWTToken {
       this.claims = new String(claims, "UTF-8");
       this.payload = signature;
     } catch (UnsupportedEncodingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.unsupportedEncoding( e );
     }
   }
 
@@ -65,15 +67,14 @@ public class JWTToken {
       sb.append(".");
       sb.append(Base64.encodeBase64URLSafeString(claims.getBytes("UTF-8")));
     } catch (UnsupportedEncodingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.unsupportedEncoding( e );
     }
     
     return sb.toString();
   }
 
   public String toString() {
-    System.out.println("Rendering JWT token for the wire");
+    
     StringBuffer sb = new StringBuffer();
     try {
       sb.append(Base64.encodeBase64URLSafeString(header.getBytes("UTF-8")));
@@ -82,11 +83,10 @@ public class JWTToken {
       sb.append(".");
       sb.append(Base64.encodeBase64URLSafeString(payload));
     } catch (UnsupportedEncodingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.unsupportedEncoding( e );
     }
     
-    System.out.println("Returning JWT token for the wire: " + sb.toString());
+    LOG.renderingJWTTokenForTheWire(sb.toString());
     return sb.toString();
   }
   
@@ -100,12 +100,13 @@ public class JWTToken {
 
   public static JWTToken parseToken(String wireToken) {
     JWTToken token = null;
-    System.out.println("token off the wire: " + wireToken);
+    LOG.parsingToken(wireToken);
     String[] parts = wireToken.split("\\.");
     token = new JWTToken(Base64.decodeBase64(parts[0]), Base64.decodeBase64(parts[1]), Base64.decodeBase64(parts[2]));
-    System.out.println("header: " + token.header);
-    System.out.println("claims: " + token.claims);
-    System.out.println("payload: " + new String(token.payload));
+    
+    LOG.printTokenHeader( token.header );
+    LOG.printTokenClaims( token.claims );
+    LOG.printTokenPayload( token.payload );
     
     return token;
   }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/AccessToken.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/AccessToken.java b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/AccessToken.java
index 219abbd..f765e8e 100644
--- a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/AccessToken.java
+++ b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/AccessToken.java
@@ -20,12 +20,14 @@ package org.apache.hadoop.gateway.provider.federation.jwt;
 import java.io.UnsupportedEncodingException;
 
 import org.apache.commons.codec.binary.Base64;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.services.security.CryptoService;
 import org.apache.hadoop.gateway.services.security.EncryptionResult;
 
 public class AccessToken {
   private static final String ENCRYPT_ACCESS_TOKENS = "encrypt_access_tokens";
   private static final String GATEWAY = "__gateway";
+  private static final JWTProviderMessages LOG = MessagesFactory.get( JWTProviderMessages.class );
   
   private CryptoService crypto = null;
   private String tokenStr = null;
@@ -50,8 +52,7 @@ public class AccessToken {
           Base64.encodeBase64URLSafeString(result.salt) + "+" + 
           Base64.encodeBase64URLSafeString(result.cipher);
     } catch (UnsupportedEncodingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.unsupportedEncoding( e );
     }
     return tokenStr;
   }
@@ -67,8 +68,7 @@ public class AccessToken {
       token = new AccessToken(crypto, claimz[0], Long.parseLong(claimz[1]));
       token.setTokenStr(wireToken);
     } catch (UnsupportedEncodingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.unsupportedEncoding( e );
     }
     return token;
   }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/JWTProviderMessages.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/JWTProviderMessages.java b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/JWTProviderMessages.java
index f2234bc..1222790 100644
--- a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/JWTProviderMessages.java
+++ b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/JWTProviderMessages.java
@@ -20,6 +20,7 @@ package org.apache.hadoop.gateway.provider.federation.jwt;
 import org.apache.hadoop.gateway.i18n.messages.Message;
 import org.apache.hadoop.gateway.i18n.messages.MessageLevel;
 import org.apache.hadoop.gateway.i18n.messages.Messages;
+import org.apache.hadoop.gateway.i18n.messages.StackTrace;
 
 /**
  *
@@ -33,4 +34,16 @@ public interface JWTProviderMessages {
   @Message( level = MessageLevel.DEBUG, text = "Parsing JWT Token from the wire: {0}" )
   void parsingToken(String wireToken);
 
+  @Message( level = MessageLevel.DEBUG, text = "header: {0}" )
+  void printTokenHeader( String header );
+
+  @Message( level = MessageLevel.DEBUG, text = "claims: {0}" )
+  void printTokenClaims( String claims );
+
+  @Message( level = MessageLevel.DEBUG, text = "payload: {0}" )
+  void printTokenPayload( byte[] payload );
+
+  @Message( level = MessageLevel.FATAL, text = "Unsupported encoding: {0}" )
+  void unsupportedEncoding( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/JWTToken.java
----------------------------------------------------------------------
diff --git a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/JWTToken.java b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/JWTToken.java
index edc46fe..9adf46e 100644
--- a/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/JWTToken.java
+++ b/gateway-provider-security-jwt/src/main/java/org/apache/hadoop/gateway/provider/federation/jwt/JWTToken.java
@@ -45,8 +45,7 @@ public class JWTToken {
       this.claims = new String(claims, "UTF-8");
       this.payload = signature;
     } catch (UnsupportedEncodingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      log.unsupportedEncoding( e );
     }
   }
 
@@ -67,8 +66,7 @@ public class JWTToken {
       sb.append(".");
       sb.append(Base64.encodeBase64URLSafeString(claims.getBytes("UTF-8")));
     } catch (UnsupportedEncodingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      log.unsupportedEncoding( e );
     }
     
     return sb.toString();
@@ -83,8 +81,7 @@ public class JWTToken {
       sb.append(".");
       sb.append(Base64.encodeBase64URLSafeString(payload));
     } catch (UnsupportedEncodingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      log.unsupportedEncoding( e );
     }
     
     log.renderingJWTTokenForTheWire(sb.toString());

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayFilter.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayFilter.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayFilter.java
index 24dca4c..17ef5b9 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayFilter.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayFilter.java
@@ -18,6 +18,7 @@
 package org.apache.hadoop.gateway;
 
 import org.apache.hadoop.gateway.filter.AbstractGatewayFilter;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.util.urltemplate.Matcher;
 import org.apache.hadoop.gateway.util.urltemplate.Parser;
 import org.apache.hadoop.gateway.util.urltemplate.Template;
@@ -50,6 +51,8 @@ public class GatewayFilter implements Filter {
     public void doFilter( ServletRequest servletRequest, ServletResponse servletResponse ) throws IOException, ServletException {
     }
   };
+  
+  private static final GatewayMessages LOG = MessagesFactory.get( GatewayMessages.class );
 
   private Set<Holder> holders;
   private Matcher<Chain> chains;
@@ -94,19 +97,19 @@ public class GatewayFilter implements Filter {
       try {
         chain.doFilter( servletRequest, servletResponse );
       } catch( IOException e ) {
-        e.printStackTrace(); //TODO: Proper I18N exception logging.
+        LOG.failedToExecuteFilter( e );
         throw e;
       } catch( ServletException e ) {
-        e.printStackTrace(); //TODO: Proper I18N exception logging.
+        LOG.failedToExecuteFilter( e );
         throw e;
       } catch( RuntimeException e ) {
-        e.printStackTrace(); //TODO: Proper I18N exception logging.
+        LOG.failedToExecuteFilter( e );
         throw e;
       } catch( ThreadDeath e ) {
-        e.printStackTrace(); //TODO: Proper I18N exception logging.
+        LOG.failedToExecuteFilter( e );
         throw e;
       } catch( Throwable e ) {
-        e.printStackTrace(); //TODO: Proper I18N exception logging.
+        LOG.failedToExecuteFilter( e );
         throw new ServletException( e );
       }
     } else {

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayMessages.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayMessages.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayMessages.java
index eb3e3dc..dd2e975 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayMessages.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayMessages.java
@@ -84,7 +84,7 @@ public interface GatewayMessages {
   void redeployedTopology( String clusterName );
 
   @Message( level = MessageLevel.ERROR, text = "Failed to deploy topology {0}: {1}" )
-  void failedToDeployTopology( String name, @StackTrace(level=MessageLevel.DEBUG) Exception e );
+  void failedToDeployTopology( String name, @StackTrace(level=MessageLevel.DEBUG) Throwable e );
 
   @Message( level = MessageLevel.ERROR, text = "Failed to undeploy topology {0}: {1}" )
   void failedToUndeployTopology( String name, @StackTrace(level=MessageLevel.DEBUG) Exception e );
@@ -146,4 +146,105 @@ public interface GatewayMessages {
   @Message( level = MessageLevel.WARN, text = "Connection exception dispatching request: {0} {1}" )
   void dispatchServiceConnectionException( URI uri, @StackTrace(level=MessageLevel.DEBUG) Exception e );
 
+  @Message( level = MessageLevel.DEBUG, text = "Signature verified: {0}" )
+  void signatureVerified( boolean verified );
+
+  @Message( level = MessageLevel.DEBUG, text = "Apache Hadoop Gateway {0} ({1})" )
+  void gatewayVersionMessage( String version, String hash );
+
+  @Message( level = MessageLevel.DEBUG, text = "Loading from persistent master: {0}" )
+  void loadingFromPersistentMaster( String tag );
+
+  @Message( level = MessageLevel.DEBUG, text = "ALIAS: {0}" )
+  void printClusterAlias( String alias );
+
+  @Message( level = MessageLevel.DEBUG, text = "MASTER SERVICE == NULL: {0}" )
+  void printMasterServiceIsNull( boolean masterServiceIsNull );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to inject service {0}: {1}" )
+  void failedToInjectService( String serviceName, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to finalize contribution: {0}" )
+  void failedToFinalizeContribution( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to contribute service [name={0}, role={1}]: {2}" )
+  void failedToContributeService( String name, String role, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to contribute provider [name={0}, role={1}]: {2}" )
+  void failedToContributeProvider( String name, String role, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to initialize contribution: {0}" )
+  void failedToInitializeContribution( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to initialize servlet instace: {0}" )
+  void failedToInitializeServletInstace( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to execute filter: {0}" )
+  void failedToExecuteFilter( @StackTrace( level = MessageLevel.DEBUG ) Throwable t );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to load topology {0}: {1}")
+  void failedToLoadTopology( String fileName, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to handle topology events: {0}" )
+  void failedToHandleTopologyEvents( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to reload topologies: {0}" )
+  void failedToReloadTopologies( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.FATAL, text = "Unsupported encoding: {0}" )
+  void unsupportedEncoding( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to persist master secret: {0}" )
+  void failedToPersistMasterSecret( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to encrypt master secret: {0}" )
+  void failedToEncryptMasterSecret( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to initialize master service from persistent master {0}: {1}" )
+  void failedToInitializeFromPersistentMaster( String masterFileName, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to encode passphrase: {0}" )
+  void failedToEncodePassphrase( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to verify signature: {0}")
+  void failedToVerifySignature( @StackTrace(level=MessageLevel.DEBUG) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to sign the data: {0}")
+  void failedToSignData( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to decrypt password for cluster {0}: {1}" )
+  void failedToDecryptPasswordForCluster( String clusterName, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to encrypt password for cluster {0}: {1}")
+  void failedToEncryptPasswordForCluster( String clusterName, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+  
+  @Message( level = MessageLevel.ERROR, text = "Failed to create keystore [filename={0}, type={1}]: {2}" )
+  void failedToCreateKeystore( String fileName, String keyStoreType, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to load keystore [filename={0}, type={1}]: {2}" )
+  void failedToLoadKeystore( String fileName, String keyStoreType, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to add key for cluster {0}: {1}" )
+  void failedToAddKeyForCluster( String clusterName, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to add credential for cluster {0}: {1}" )
+  void failedToAddCredentialForCluster( String clusterName, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+  
+  @Message( level = MessageLevel.ERROR, text = "Failed to get key for Gateway {0}: {1}" )
+  void failedToGetKeyForGateway( String alias, @StackTrace( level=MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to get credential for cluster {0}: {1}" )
+  void failedToGetCredentialForCluster( String clusterName, @StackTrace(level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to get key for cluster {0}: {1}" )
+  void failedToGetKeyForCluster( String clusterName, @StackTrace(level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to add self signed certificate for Gateway {0}: {1}" )
+  void failedToAddSeflSignedCertForGateway( String alias, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to generate secret key from password: {0}" )
+  void failedToGenerateKeyFromPassword( @StackTrace( level = MessageLevel.DEBUG ) Exception e );
+
+  @Message( level = MessageLevel.ERROR, text = "Failed to establish connection to {0}: {1}" )
+  void failedToEstablishConnectionToUrl( String url, @StackTrace( level = MessageLevel.DEBUG ) Exception e );
 }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayServer.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayServer.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayServer.java
index d3cbc67..84e8586 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayServer.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayServer.java
@@ -97,8 +97,7 @@ public class GatewayServer {
     } catch( ParseException e ) {
       log.failedToParseCommandLine( e );
     } catch (ServiceLifecycleException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      log.failedToStartGateway( e );
     }
   }
 
@@ -266,7 +265,7 @@ public class GatewayServer {
     jetty.start();
     }
     catch (IOException e) {
-      e.printStackTrace();
+      log.failedToStartGateway( e );
       throw e;
     }
 
@@ -371,8 +370,7 @@ public class GatewayServer {
                 //log.redeployedTopology( topology.getName() );
               }
             } catch( Throwable e ) {
-              //TODO: This needs proper i18n logging
-              e.printStackTrace();
+              log.failedToDeployTopology( topology.getName(), e );
             }
           }
         }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayServlet.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayServlet.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayServlet.java
index 655ae2c..d0b5a40 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayServlet.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/GatewayServlet.java
@@ -19,6 +19,7 @@ package org.apache.hadoop.gateway;
 
 import org.apache.hadoop.gateway.descriptor.GatewayDescriptor;
 import org.apache.hadoop.gateway.descriptor.GatewayDescriptorFactory;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.i18n.resources.ResourcesFactory;
 
 import javax.servlet.Filter;
@@ -42,6 +43,7 @@ public class GatewayServlet implements Servlet {
   public static final String GATEWAY_DESCRIPTOR_LOCATION_PARAM = "gatewayDescriptorLocation";
 
   private static final GatewayResources res = ResourcesFactory.get( GatewayResources.class );
+  private static final GatewayMessages LOG = MessagesFactory.get( GatewayMessages.class );
 
   private FilterConfigAdapter filterConfig;
   private volatile GatewayFilter filter;
@@ -81,10 +83,10 @@ public class GatewayServlet implements Servlet {
         filter.init( filterConfig );
       }
     } catch( ServletException e ) {
-      e.printStackTrace();
+      LOG.failedToInitializeServletInstace( e );
       throw e;
     } catch( RuntimeException e ) {
-      e.printStackTrace();
+      LOG.failedToInitializeServletInstace( e );
       throw e;
     }
   }
@@ -101,10 +103,10 @@ public class GatewayServlet implements Servlet {
       try {
         f.doFilter( servletRequest, servletResponse );
       } catch( IOException e ) {
-        e.printStackTrace();
+        LOG.failedToExecuteFilter( e );
         throw e;
       } catch( ServletException e ) {
-        e.printStackTrace();
+        LOG.failedToExecuteFilter( e );
         throw e;
       }
     } else {

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
index e5a3778..2ade641 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/deploy/DeploymentFactory.java
@@ -184,8 +184,7 @@ public abstract class DeploymentFactory {
           }
           contributor.initializeContribution( context );
         } catch( Exception e ) {
-          //TODO: I18N message.
-          e.printStackTrace();
+          log.failedToInitializeContribution( e );
         }
       }
     }
@@ -197,8 +196,7 @@ public abstract class DeploymentFactory {
           }
           contributor.initializeContribution( context );
         } catch( Exception e ) {
-          //TODO: I18N message.
-          e.printStackTrace();
+          log.failedToInitializeContribution( e );
         }
       }
     }
@@ -218,8 +216,8 @@ public abstract class DeploymentFactory {
         } catch (NoSuchMethodException e) {
           // TODO: eliminate the possibility of this being thrown up front
         } catch (Exception e) {
-          // TODO Auto-generated catch block
-          e.printStackTrace();
+          // Maybe it makes sense to throw exception
+          log.failedToInjectService( serviceName, e );
         }
       }
     }
@@ -236,8 +234,8 @@ public abstract class DeploymentFactory {
         try {
           contributor.contributeProvider( context, provider );
         } catch( Exception e ) {
-          //TODO: I18N message.
-          e.printStackTrace();
+          // Maybe it makes sense to throw exception
+          log.failedToContributeProvider( provider.getName(), provider.getRole(), e );
         }
       }
     }
@@ -247,8 +245,8 @@ public abstract class DeploymentFactory {
         try {
           contributor.contributeService( context, service );
         } catch( Exception e ) {
-          //TODO: I18N message.
-          e.printStackTrace();
+          // Maybe it makes sense to throw exception
+          log.failedToContributeService( service.getName(), service.getRole(), e );
         }
       }
     }
@@ -306,8 +304,8 @@ public abstract class DeploymentFactory {
           try {
             contributor.finalizeContribution( context );
           } catch( Exception e ) {
-            //TODO: I18N message.
-            e.printStackTrace();
+            // Maybe it makes sense to throw exception
+            log.failedToFinalizeContribution( e );
           }
         }
       }
@@ -316,8 +314,8 @@ public abstract class DeploymentFactory {
           try {
             contributor.finalizeContribution( context );
           } catch( Exception e ) {
-            //TODO: I18N message.
-            e.printStackTrace();
+            // Maybe it makes sense to throw exception
+            log.failedToFinalizeContribution( e );
           }
         }
       }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
index b0642e8..b315048 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/dispatch/UrlConnectionDispatch.java
@@ -18,6 +18,8 @@
 package org.apache.hadoop.gateway.dispatch;
 
 import org.apache.commons.io.IOUtils;
+import org.apache.hadoop.gateway.GatewayMessages;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.util.urltemplate.Parser;
 import org.apache.hadoop.gateway.util.urltemplate.Resolver;
 import org.apache.hadoop.gateway.util.urltemplate.Rewriter;
@@ -44,6 +46,8 @@ import java.util.Enumeration;
  */
 public class UrlConnectionDispatch extends AbstractGatewayDispatch {
 
+  private static final GatewayMessages LOG = MessagesFactory.get( GatewayMessages.class );
+
   @Override
   public void doGet( URI url, HttpServletRequest request, HttpServletResponse response ) throws IOException, URISyntaxException {
     String sourcePathInfo = request.getPathInfo();
@@ -85,9 +89,9 @@ public class UrlConnectionDispatch extends AbstractGatewayDispatch {
         paramStr.append( "&" );
       }
     }
-
+    String urlStr = targetUri.toString() + paramStr.toString();
     try {
-      URL clientUrl = new URL( targetUri.toString() + paramStr.toString() );
+      URL clientUrl = new URL( urlStr );
       //System.out.println( "Resolved query: " + clientUrl );
       AuthenticatedURL.Token token = new AuthenticatedURL.Token();
       KerberosAuthenticator authenticator = new KerberosAuthenticator();
@@ -105,10 +109,10 @@ public class UrlConnectionDispatch extends AbstractGatewayDispatch {
       }
     } catch( AuthenticationException e ) {
       response.sendError( HttpServletResponse.SC_UNAUTHORIZED );
-      e.printStackTrace();
+      LOG.failedToEstablishConnectionToUrl( urlStr, e );
     } catch( FileNotFoundException e ) {
       response.sendError( HttpServletResponse.SC_NOT_FOUND );
-      e.printStackTrace();
+      LOG.failedToEstablishConnectionToUrl( urlStr, e );
     }
 
   }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/AESEncryptor.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/AESEncryptor.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/AESEncryptor.java
index 4c161cd..2d7c8ba 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/AESEncryptor.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/AESEncryptor.java
@@ -33,6 +33,8 @@ import javax.crypto.spec.IvParameterSpec;
 import javax.crypto.spec.PBEKeySpec;
 import javax.crypto.spec.SecretKeySpec;
 
+import org.apache.hadoop.gateway.GatewayMessages;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.services.security.EncryptionResult;
 
 public class AESEncryptor {
@@ -44,6 +46,8 @@ public class AESEncryptor {
 //  };
   private static final int ITERATION_COUNT = 65536;
   private static final int KEY_LENGTH = 128;
+  private static final GatewayMessages LOG = MessagesFactory.get( GatewayMessages.class );
+  
   private Cipher ecipher;
   private Cipher dcipher;
   private SecretKey secret;
@@ -67,20 +71,15 @@ public class AESEncryptor {
         byte[] iv = ecipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV();
         dcipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(iv));
       } catch (NoSuchAlgorithmException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToEncodePassphrase( e );
       } catch (NoSuchPaddingException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToEncodePassphrase( e );
       } catch (InvalidKeyException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToEncodePassphrase( e );
       } catch (InvalidParameterSpecException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToEncodePassphrase( e );
       } catch (InvalidAlgorithmParameterException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToEncodePassphrase( e );
       }
   }
   
@@ -95,20 +94,15 @@ public class AESEncryptor {
       byte[] iv = ecipher.getParameters().getParameterSpec(IvParameterSpec.class).getIV();
       dcipher.init(Cipher.DECRYPT_MODE, secret, new IvParameterSpec(iv));
     } catch (NoSuchAlgorithmException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToEncodePassphrase( e );
     } catch (NoSuchPaddingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToEncodePassphrase( e );
     } catch (InvalidKeyException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToEncodePassphrase( e );
     } catch (InvalidParameterSpecException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToEncodePassphrase( e );
     } catch (InvalidAlgorithmParameterException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToEncodePassphrase( e );
     }
   }
 
@@ -124,11 +118,9 @@ public class AESEncryptor {
       KeySpec spec = new PBEKeySpec(passPhrase.toCharArray(), salt, ITERATION_COUNT, KEY_LENGTH);
       key = factory.generateSecret(spec);
     } catch (NoSuchAlgorithmException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToGenerateKeyFromPassword( e );
     } catch (InvalidKeySpecException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToGenerateKeyFromPassword( e );
     }
     
     return key;

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultCryptoService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultCryptoService.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultCryptoService.java
index 7d1e1f9..f8323bc 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultCryptoService.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultCryptoService.java
@@ -19,7 +19,6 @@ package org.apache.hadoop.gateway.services.security.impl;
 
 import java.io.UnsupportedEncodingException;
 import java.security.InvalidKeyException;
-import java.security.Key;
 import java.security.KeyStoreException;
 import java.security.NoSuchAlgorithmException;
 import java.security.PrivateKey;
@@ -27,8 +26,9 @@ import java.security.Signature;
 import java.security.SignatureException;
 import java.util.Map;
 
-import org.apache.commons.codec.binary.Base64;
+import org.apache.hadoop.gateway.GatewayMessages;
 import org.apache.hadoop.gateway.config.GatewayConfig;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.services.security.AliasService;
 import org.apache.hadoop.gateway.services.security.CryptoService;
 import org.apache.hadoop.gateway.services.security.EncryptionResult;
@@ -38,7 +38,8 @@ import org.apache.hadoop.gateway.services.ServiceLifecycleException;
 
 public class DefaultCryptoService implements CryptoService {
   private static final String GATEWAY_IDENTITY_PASSPHRASE = "gateway-identity-passphrase";
-  
+  private static final GatewayMessages LOG = MessagesFactory.get( GatewayMessages.class ); 
+
   private AliasService as = null;
   private KeystoreService ks = null;
 
@@ -85,14 +86,11 @@ public class DefaultCryptoService implements CryptoService {
         aes = new AESEncryptor(new String(password));
         return aes.encrypt(clear);
       } catch (NoSuchAlgorithmException e1) {
-        // TODO Auto-generated catch block
-        e1.printStackTrace();
+        LOG.failedToEncryptPasswordForCluster( clusterName, e1 );
       } catch (InvalidKeyException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToEncryptPasswordForCluster( clusterName, e );
       } catch (Exception e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToEncryptPasswordForCluster( clusterName, e );
       }
     }
     return null;
@@ -103,8 +101,7 @@ public class DefaultCryptoService implements CryptoService {
     try {
       return decryptForCluster(clusterName, alias, cipherText.getBytes("UTF8"), null, null);
     } catch (UnsupportedEncodingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.unsupportedEncoding( e );
     }
     return null;
   }
@@ -117,8 +114,7 @@ public class DefaultCryptoService implements CryptoService {
       try {
         return aes.decrypt(salt, iv, cipherText);
       } catch (Exception e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToDecryptPasswordForCluster( clusterName, e );
       }
     }
     return null;
@@ -133,22 +129,17 @@ public class DefaultCryptoService implements CryptoService {
       sig.update(signed.getBytes("UTF-8"));
       verified = sig.verify(signature);
     } catch (SignatureException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToVerifySignature( e );
     } catch (NoSuchAlgorithmException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToVerifySignature( e );
     } catch (InvalidKeyException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToVerifySignature( e );
     } catch (KeyStoreException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToVerifySignature( e );
     } catch (UnsupportedEncodingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToVerifySignature( e );
     }
-    System.out.println("Signature verified: " + verified);  
+    LOG.signatureVerified( verified );
     return verified;
   }
 
@@ -162,20 +153,15 @@ public class DefaultCryptoService implements CryptoService {
       signature.update(payloadToSign.getBytes("UTF-8"));
       return signature.sign();
     } catch (NoSuchAlgorithmException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToSignData( e );
     } catch (InvalidKeyException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToSignData( e );
     } catch (SignatureException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToSignData( e );
     } catch (UnsupportedEncodingException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToSignData( e );
     } catch (KeystoreServiceException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToSignData( e );
     }
     return null;
   }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultKeystoreService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultKeystoreService.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultKeystoreService.java
index 6670fb5..f776286 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultKeystoreService.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultKeystoreService.java
@@ -40,7 +40,9 @@ import java.util.Map;
 
 import javax.crypto.spec.SecretKeySpec;
 
+import org.apache.hadoop.gateway.GatewayMessages;
 import org.apache.hadoop.gateway.config.GatewayConfig;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.services.ServiceLifecycleException;
 import org.apache.hadoop.gateway.services.security.KeystoreService;
 import org.apache.hadoop.gateway.services.security.KeystoreServiceException;
@@ -63,6 +65,7 @@ public class DefaultKeystoreService implements KeystoreService {
   private static final String TEST_CERT_DN = "CN=hadoop.gateway,OU=Test,O=Hadoop,L=Test,ST=Test,C=US";
   private static final String CREDENTIALS_SUFFIX = "-credentials.jceks";
   private static final String GATEWAY_KEYSTORE = "gateway.jks";
+  private static GatewayMessages LOG = MessagesFactory.get( GatewayMessages.class );
   
   private MasterService masterService;
   private String keyStoreDir;
@@ -117,14 +120,11 @@ public class DefaultKeystoreService implements KeystoreService {
       
       writeKeystoreToFile(privateKS, new File( keyStoreDir + GATEWAY_KEYSTORE  ));
     } catch (NoSuchAlgorithmException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToAddSeflSignedCertForGateway( alias, e );
     } catch (GeneralSecurityException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToAddSeflSignedCertForGateway( alias, e );
     } catch (IOException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToAddSeflSignedCertForGateway( alias, e );
     }  
   }
   
@@ -180,20 +180,15 @@ public class DefaultKeystoreService implements KeystoreService {
       ks.load( null, null );  
       ks.store( out, masterService.getMasterSecret() );
     } catch (KeyStoreException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToCreateKeystore( filename, keystoreType, e );
     } catch (NoSuchAlgorithmException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToCreateKeystore( filename, keystoreType, e );
     } catch (CertificateException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToCreateKeystore( filename, keystoreType, e );
     } catch (FileNotFoundException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToCreateKeystore( filename, keystoreType, e );
     } catch (IOException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToCreateKeystore( filename, keystoreType, e );
     }
   }
   
@@ -203,10 +198,8 @@ public class DefaultKeystoreService implements KeystoreService {
     try {
       return isKeystoreAvailable(keyStoreFile, "JCEKS");
     } catch (KeyStoreException e) {
-      e.printStackTrace();
       throw new KeystoreServiceException(e);
     } catch (IOException e) {
-      // TODO Auto-generated catch block
       throw new KeystoreServiceException(e);
     }
   }
@@ -233,25 +226,21 @@ public class DefaultKeystoreService implements KeystoreService {
         keyStore.load( input, masterService.getMasterSecret() );
         return true;
       } catch (NoSuchAlgorithmException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
       } catch (CertificateException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
       } catch (IOException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
         throw e;
       } catch (KeyStoreException e) {
-        e.printStackTrace();
+        LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
         throw e;
       }
       finally {
           try {
             input.close();
           } catch (IOException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
           }
       }
     }
@@ -266,14 +255,11 @@ public class DefaultKeystoreService implements KeystoreService {
       try {
         key = ks.getKey(alias, passphrase);
       } catch (UnrecoverableKeyException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToGetKeyForGateway( alias, e );
       } catch (KeyStoreException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToGetKeyForGateway( alias, e );
       } catch (NoSuchAlgorithmException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToGetKeyForGateway( alias, e );
       }
     }
     return key;
@@ -289,17 +275,13 @@ public class DefaultKeystoreService implements KeystoreService {
     try {
       credStore = loadKeyStore( keyStoreFile, masterService.getMasterSecret(), storeType);
     } catch (CertificateException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
     } catch (KeyStoreException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
     } catch (NoSuchAlgorithmException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
     } catch (IOException e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToLoadKeystore( keyStoreFile.getName(), storeType, e );
     }
     return credStore;
   }
@@ -355,17 +337,13 @@ public class DefaultKeystoreService implements KeystoreService {
         final File  keyStoreFile = new File( keyStoreDir + clusterName + CREDENTIALS_SUFFIX  );
         writeKeystoreToFile(ks, keyStoreFile);
       } catch (KeyStoreException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToAddCredentialForCluster( clusterName, e );
       } catch (NoSuchAlgorithmException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToAddCredentialForCluster( clusterName, e );
       } catch (CertificateException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToAddCredentialForCluster( clusterName, e );
       } catch (IOException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToAddCredentialForCluster( clusterName, e );
       }
     }
   }
@@ -378,14 +356,11 @@ public class DefaultKeystoreService implements KeystoreService {
       try {
         credential = new String(ks.getKey(alias, masterService.getMasterSecret()).getEncoded()).toCharArray();
       } catch (UnrecoverableKeyException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToGetCredentialForCluster( clusterName, e );
       } catch (KeyStoreException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToGetCredentialForCluster( clusterName, e );
       } catch (NoSuchAlgorithmException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToGetCredentialForCluster( clusterName, e );
       }
     }
     return credential;
@@ -397,18 +372,15 @@ public class DefaultKeystoreService implements KeystoreService {
     KeyStore ks = getCredentialStoreForCluster(clusterName);
     if (ks != null) {
       try {
-        System.out.println("ALIAS: " + alias);
-        System.out.println("MASTER SERVICE == NULL: " + (masterService == null));
+        LOG.printClusterAlias( alias );
+        LOG.printMasterServiceIsNull( masterService == null );
         key = ks.getKey(alias, masterService.getMasterSecret()).getEncoded();
       } catch (UnrecoverableKeyException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToGetKeyForCluster( clusterName, e );
       } catch (KeyStoreException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToGetKeyForCluster( clusterName, e );
       } catch (NoSuchAlgorithmException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToGetKeyForCluster( clusterName, e );
       }
     }
     return key;
@@ -424,17 +396,13 @@ public class DefaultKeystoreService implements KeystoreService {
         final File  keyStoreFile = new File( keyStoreDir + clusterName + CREDENTIALS_SUFFIX  );
         writeKeystoreToFile(ks, keyStoreFile);
       } catch (KeyStoreException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToAddKeyForCluster( clusterName, e );
       } catch (NoSuchAlgorithmException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToAddKeyForCluster( clusterName, e );
       } catch (CertificateException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToAddKeyForCluster( clusterName, e );
       } catch (IOException e) {
-        // TODO Auto-generated catch block
-        e.printStackTrace();
+        LOG.failedToAddKeyForCluster( clusterName, e );
       }
     }
   }

http://git-wip-us.apache.org/repos/asf/incubator-knox/blob/5cd1567c/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultMasterService.java
----------------------------------------------------------------------
diff --git a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultMasterService.java b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultMasterService.java
index bd31695..12ff406 100644
--- a/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultMasterService.java
+++ b/gateway-server/src/main/java/org/apache/hadoop/gateway/services/security/impl/DefaultMasterService.java
@@ -20,7 +20,9 @@ package org.apache.hadoop.gateway.services.security.impl;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.net.ntp.TimeStamp;
+import org.apache.hadoop.gateway.GatewayMessages;
 import org.apache.hadoop.gateway.config.GatewayConfig;
+import org.apache.hadoop.gateway.i18n.messages.MessagesFactory;
 import org.apache.hadoop.gateway.services.ServiceLifecycleException;
 import org.apache.hadoop.gateway.services.security.EncryptionResult;
 import org.apache.hadoop.gateway.services.security.MasterService;
@@ -37,6 +39,7 @@ public class DefaultMasterService implements MasterService {
 
   private static final String MASTER_PASSPHRASE = "masterpassphrase";
   private static final String MASTER_PERSISTENCE_TAG = "#1.0# " + TimeStamp.getCurrentTime().toDateString();
+  private static final GatewayMessages LOG = MessagesFactory.get( GatewayMessages.class );
   private char[] master = null;
   private AESEncryptor aes = new AESEncryptor(MASTER_PASSPHRASE);
 
@@ -140,8 +143,8 @@ public class DefaultMasterService implements MasterService {
       // restrict os permissions to only the user running this process
       chmod("600", masterFile);
     } catch (IOException e) {
-      // TODO log appropriate message that the master secret has not been persisted
-      e.printStackTrace();
+
+      LOG.failedToPersistMasterSecret( e );
     }
   }
 
@@ -150,9 +153,8 @@ public class DefaultMasterService implements MasterService {
     try {
       return aes.encrypt(new String(master));
     } catch (Exception e) {
-      // TODO log failed encryption attempt
       // need to ensure that we don't persist now
-      e.printStackTrace();
+      LOG.failedToEncryptMasterSecret( e );
     }
     return null;
   }
@@ -161,8 +163,7 @@ public class DefaultMasterService implements MasterService {
     try {
       List<String> lines = FileUtils.readLines(masterFile, "UTF8");
       String tag = lines.get(0);
-      // TODO: log - if appropriate - at least at finest level
-      System.out.println("Loading from persistent master: " + tag);
+      LOG.loadingFromPersistentMaster( tag );
       String line = new String(Base64.decodeBase64(lines.get(1)));
       String[] parts = line.split("::");
 //System.out.println("salt: " + parts[0] + " : " + Base64.decodeBase64(parts[0]));
@@ -170,11 +171,10 @@ public class DefaultMasterService implements MasterService {
 //System.out.println("cipher: " + parts[2]);
       this.master = new String(aes.decrypt(Base64.decodeBase64(parts[0]), Base64.decodeBase64(parts[1]), Base64.decodeBase64(parts[2])), "UTF8").toCharArray();
     } catch (IOException e) {
-      e.printStackTrace();
+      LOG.failedToInitializeFromPersistentMaster( masterFile.getName(), e );
       throw e;
     } catch (Exception e) {
-      // TODO Auto-generated catch block
-      e.printStackTrace();
+      LOG.failedToInitializeFromPersistentMaster( masterFile.getName(), e );
       throw e;
     }
   }


Mime
View raw message