You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2014/12/15 03:42:08 UTC
[2/2] ambari git commit: AMBARI-8705. Kerberos wizard: API call to
save krb5-conf configuration fails with server error. (Robert Levas via
yusaku)
AMBARI-8705. Kerberos wizard: API call to save krb5-conf configuration fails with server error. (Robert Levas via yusaku)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/74469757
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/74469757
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/74469757
Branch: refs/heads/trunk
Commit: 74469757694d1ea58f7f293865b44413d9d835fe
Parents: dbdd862
Author: Yusaku Sako <yu...@hortonworks.com>
Authored: Sun Dec 14 18:41:05 2014 -0800
Committer: Yusaku Sako <yu...@hortonworks.com>
Committed: Sun Dec 14 18:41:05 2014 -0800
----------------------------------------------------------------------
.../server/serveraction/kerberos/KDCType.java | 20 ++++++-
.../kerberos/KerberosServerAction.java | 2 +-
.../serveraction/kerberos/KDCTypeTest.java | 55 ++++++++++++++++++++
3 files changed, 75 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/74469757/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KDCType.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KDCType.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KDCType.java
index 51dcdd2..57b267d 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KDCType.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KDCType.java
@@ -18,6 +18,8 @@
package org.apache.ambari.server.serveraction.kerberos;
+import com.sun.istack.NotNull;
+
/**
* Enumerates the supported KDC types
*/
@@ -30,5 +32,21 @@ public enum KDCType {
/**
* Indicates a Microsoft Active Directory
*/
- ACTIVE_DIRECTORY
+ ACTIVE_DIRECTORY;
+
+ /**
+ * Translates a String to a KDCType.
+ * <p/>
+ * The translation logic attempts to nicely convert a String to a KDCType by replacing all '-'
+ * characters to '_' characters and converting the String to uppercase. Allowing for values like
+ * "mit_kdc" to be translated to "MIT_KDC".
+ *
+ * @param value a String value to convert to a KDCType
+ * @return A KDCType
+ * @throws java.lang.IllegalArgumentException if this enum type has no constant with the specified name
+ * @throws java.lang.NullPointerException if the value to translate is null
+ */
+ public static KDCType translate(@NotNull String value) {
+ return KDCType.valueOf(value.replace("-", "_").toUpperCase());
+ }
}
http://git-wip-us.apache.org/repos/asf/ambari/blob/74469757/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosServerAction.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosServerAction.java b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosServerAction.java
index 7a2412c..832602f 100644
--- a/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosServerAction.java
+++ b/ambari-server/src/main/java/org/apache/ambari/server/serveraction/kerberos/KerberosServerAction.java
@@ -121,7 +121,7 @@ public abstract class KerberosServerAction extends AbstractServerAction {
return ((kdcType == null) || kdcType.isEmpty())
? KDCType.MIT_KDC
- : KDCType.valueOf(kdcType.toUpperCase().replace("-", "_"));
+ : KDCType.translate(kdcType);
}
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/74469757/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KDCTypeTest.java
----------------------------------------------------------------------
diff --git a/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KDCTypeTest.java b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KDCTypeTest.java
new file mode 100644
index 0000000..2c6366f
--- /dev/null
+++ b/ambari-server/src/test/java/org/apache/ambari/server/serveraction/kerberos/KDCTypeTest.java
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.ambari.server.serveraction.kerberos;
+
+import junit.framework.Assert;
+import org.junit.Test;
+
+public class KDCTypeTest {
+
+ @Test
+ public void testTranslateExact() {
+ Assert.assertEquals(KDCType.MIT_KDC, KDCType.translate("MIT_KDC"));
+ }
+
+ @Test
+ public void testTranslateCaseInsensitive() {
+ Assert.assertEquals(KDCType.MIT_KDC, KDCType.translate("mit_kdc"));
+ }
+
+ @Test
+ public void testTranslateHyphen() {
+ Assert.assertEquals(KDCType.MIT_KDC, KDCType.translate("MIT-KDC"));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testTranslateNull() {
+ KDCType.translate(null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testTranslateEmptyString() {
+ KDCType.translate("");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testTranslateNoTranslation() {
+ KDCType.translate("NO TRANSLATION");
+ }
+}
\ No newline at end of file