You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by rl...@apache.org on 2015/03/11 17:43:27 UTC

ambari git commit: AMBARI-10016. Kerberos: Run ambari-server using non-root causes issues with AD velocity engine (rlevas)

Repository: ambari
Updated Branches:
  refs/heads/trunk d84898e59 -> 1c78b2015


AMBARI-10016. Kerberos: Run ambari-server using non-root causes issues with AD velocity engine (rlevas)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/1c78b201
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1c78b201
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1c78b201

Branch: refs/heads/trunk
Commit: 1c78b20151f12d2714da2e033db672fe5f080ced
Parents: d84898e
Author: Robert Levas <rl...@hortonworks.com>
Authored: Wed Mar 11 12:43:10 2015 -0400
Committer: Robert Levas <rl...@hortonworks.com>
Committed: Wed Mar 11 12:43:25 2015 -0400

----------------------------------------------------------------------
 .../kerberos/ADKerberosOperationHandler.java       | 17 ++---------------
 1 file changed, 2 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1c78b201/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandler.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandler.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandler.java
index faa813c..38a7563 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandler.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/ADKerberosOperationHandler.java
@@ -25,7 +25,7 @@ import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.velocity.VelocityContext;
-import org.apache.velocity.app.VelocityEngine;
+import org.apache.velocity.app.Velocity;
 import org.apache.velocity.exception.MethodInvocationException;
 import org.apache.velocity.exception.ParseErrorException;
 import org.apache.velocity.exception.ResourceNotFoundException;
@@ -115,12 +115,6 @@ public class ADKerberosOperationHandler extends KerberosOperationHandler {
   private SearchControls searchControls = null;
 
   /**
-   * VelocityEngine used to process the "create principal template" that is expected to generate
-   * a JSON structure declaring the attributes of the Active Directory account
-   */
-  private VelocityEngine velocityEngine = null;
-
-  /**
    * The Gson instance to use to convert the template-generated JSON structure to a Map of attribute
    * names to values.
    */
@@ -183,9 +177,6 @@ public class ADKerberosOperationHandler extends KerberosOperationHandler {
 
     this.createTemplate = kerberosConfiguration.get(KERBEROS_ENV_CREATE_ATTRIBUTES_TEMPLATE);
 
-    this.velocityEngine = new VelocityEngine();
-    this.velocityEngine.init();
-
     this.gson = new Gson();
 
     setOpen(true);
@@ -199,7 +190,6 @@ public class ADKerberosOperationHandler extends KerberosOperationHandler {
   @Override
   public void close() throws KerberosOperationException {
     this.searchControls = null;
-    this.velocityEngine = null;
 
     this.gson = null;
 
@@ -515,9 +505,6 @@ public class ADKerberosOperationHandler extends KerberosOperationHandler {
   protected Map<String, Object> processCreateTemplate(Map<String, Object> context)
       throws KerberosOperationException {
 
-    if (velocityEngine == null) {
-      throw new KerberosOperationException("The Velocity Engine must not be null");
-    }
     if (gson == null) {
       throw new KerberosOperationException("The JSON parser must not be null");
     }
@@ -543,7 +530,7 @@ public class ADKerberosOperationHandler extends KerberosOperationHandler {
     }
 
     try {
-      if (velocityEngine.evaluate(new VelocityContext(context), stringWriter, "Active Directory principal create template", template)) {
+      if (Velocity.evaluate(new VelocityContext(context), stringWriter, "Active Directory principal create template", template)) {
         String json = stringWriter.toString();
         Type type = new TypeToken<Map<String, Object>>() {
         }.getType();