support passwords in config file being encrypted
diff --git a/src/com/google/enterprise/adaptor/ad/AdAdaptor.java b/src/com/google/enterprise/adaptor/ad/AdAdaptor.java
index 52e1b22..104b569 100644
--- a/src/com/google/enterprise/adaptor/ad/AdAdaptor.java
+++ b/src/com/google/enterprise/adaptor/ad/AdAdaptor.java
@@ -82,16 +82,18 @@
 
   @Override
   public void init(AdaptorContext context) throws Exception {
-    namespace = context.getConfig().getValue("adaptor.namespace");
+    Config config = context.getConfig();
+    namespace = config.getValue("adaptor.namespace");
     log.config("common namespace: " + namespace);
-    defaultUser = context.getConfig().getValue("ad.defaultUser");
-    defaultPassword = context.getConfig().getValue("ad.defaultPassword");
+    defaultUser = config.getValue("ad.defaultUser");
+    defaultPassword = context.getSensitiveValueDecoder().decodeValue(
+        config.getValue("ad.defaultPassword"));
     feedBuiltinGroups = Boolean.parseBoolean(
-        context.getConfig().getValue("ad.feedBuiltinGroups"));
+        config.getValue("ad.feedBuiltinGroups"));
     // register for incremental pushes
     context.setPollingIncrementalLister(this);
     List<Map<String, String>> serverConfigs
-        = context.getConfig().getListOfConfigs("ad.servers");
+        = config.getListOfConfigs("ad.servers");
     servers.clear();  // in case init gets called again
     for (Map<String, String> singleServerConfig : serverConfigs) {
       String host = singleServerConfig.get("host");
@@ -115,7 +117,8 @@
       if (principal.isEmpty()) {
         throw new IllegalStateException("user not specified for host " + host);
       }
-      String passwd = singleServerConfig.get("password");
+      String passwd = context.getSensitiveValueDecoder().decodeValue(
+          singleServerConfig.get("password"));
       if (null == passwd) {
         passwd = defaultPassword;
       }
@@ -130,7 +133,7 @@
       dup.put("password", "XXXXXX");  // hide password
       log.log(Level.CONFIG, "AD server spec: {0}", dup);
     }
-    localizedStrings = context.getConfig().getValuesWithPrefix("ad.localized.");
+    localizedStrings = config.getValuesWithPrefix("ad.localized.");
   }
 
   /**
diff --git a/test/com/google/enterprise/adaptor/TestHelper.java b/test/com/google/enterprise/adaptor/TestHelper.java
index 0c3b41f..3ca5a5f 100644
--- a/test/com/google/enterprise/adaptor/TestHelper.java
+++ b/test/com/google/enterprise/adaptor/TestHelper.java
@@ -17,8 +17,8 @@
 /**
  * Utility methods for tests.
  *
- * <p>This code is needed (as part of this package, and not the <code>ad</code>
- * subclass) to work around visibility issues on the <code>Config</code> class.
+ * <p>This code lives in adaptor package instead of adaptor.ad package
+ * to work around visibility of <code>Config</code> class.
  */
 public class TestHelper {
   // Prevent instantiation
@@ -28,6 +28,14 @@
     config.setValue(key, value);
   }
 
+  private static final SensitiveValueDecoder SENSITIVE_VALUE_DECODER
+      = new SensitiveValueDecoder() {
+    @Override
+    public String decodeValue(String notEncodedDuringTesting) {
+      return notEncodedDuringTesting;
+    }
+  };
+
   public static AdaptorContext createConfigAdaptorContext(final Config config) {
     return new WrapperAdaptor.WrapperAdaptorContext(null) {
       @Override
@@ -39,6 +47,11 @@
       public void setPollingIncrementalLister(PollingIncrementalLister lister) {
         // do nothing
       }
+
+      @Override
+      public SensitiveValueDecoder getSensitiveValueDecoder() {
+        return SENSITIVE_VALUE_DECODER;
+      }
     };
   }
 }