-
Notifications
You must be signed in to change notification settings - Fork 8.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
HADOOP-19306. Support user defined auth Callback in SaslRpcServer. (#…
- Loading branch information
Showing
15 changed files
with
291 additions
and
112 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 0 additions & 45 deletions
45
...-common-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslConstants.java
This file was deleted.
Oops, something went wrong.
75 changes: 75 additions & 0 deletions
75
...-project/hadoop-common/src/main/java/org/apache/hadoop/security/SaslMechanismFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one | ||
* or more contributor license agreements. See the NOTICE file | ||
* distributed with this work for additional information | ||
* regarding copyright ownership. The ASF licenses this file | ||
* to you under the Apache License, Version 2.0 (the | ||
* "License"); you may not use this file except in compliance | ||
* with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.apache.hadoop.security; | ||
|
||
import org.apache.hadoop.HadoopIllegalArgumentException; | ||
import org.apache.hadoop.classification.InterfaceAudience; | ||
import org.apache.hadoop.classification.InterfaceStability; | ||
import org.apache.hadoop.conf.Configuration; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_SASL_MECHANISM_DEFAULT; | ||
import static org.apache.hadoop.fs.CommonConfigurationKeysPublic.HADOOP_SECURITY_SASL_MECHANISM_KEY; | ||
|
||
/** | ||
* SASL related constants. | ||
*/ | ||
@InterfaceAudience.LimitedPrivate({"HDFS", "MapReduce", "YARN", "HBase"}) | ||
@InterfaceStability.Evolving | ||
public final class SaslMechanismFactory { | ||
static final Logger LOG = LoggerFactory.getLogger(SaslMechanismFactory.class); | ||
|
||
private static final String SASL_MECHANISM_ENV = "HADOOP_SASL_MECHANISM"; | ||
private static final String SASL_MECHANISM; | ||
|
||
static { | ||
// env | ||
final String envValue = System.getenv(SASL_MECHANISM_ENV); | ||
LOG.debug("{} = {} (env)", SASL_MECHANISM_ENV, envValue); | ||
|
||
// conf | ||
final Configuration conf = new Configuration(false); | ||
final String confValue = conf.get(HADOOP_SECURITY_SASL_MECHANISM_KEY, | ||
HADOOP_SECURITY_SASL_MECHANISM_DEFAULT); | ||
LOG.debug("{} = {} (conf)", HADOOP_SECURITY_SASL_MECHANISM_KEY, confValue); | ||
|
||
if (envValue != null && confValue != null) { | ||
if (!envValue.equals(confValue)) { | ||
throw new HadoopIllegalArgumentException("SASL Mechanism mismatched: env " | ||
+ SASL_MECHANISM_ENV + " is " + envValue + " but conf " | ||
+ HADOOP_SECURITY_SASL_MECHANISM_KEY + " is " + confValue); | ||
} | ||
} | ||
|
||
SASL_MECHANISM = envValue != null ? envValue | ||
: confValue != null ? confValue | ||
: HADOOP_SECURITY_SASL_MECHANISM_DEFAULT; | ||
LOG.debug("SASL_MECHANISM = {} (effective)", SASL_MECHANISM); | ||
} | ||
|
||
public static String getMechanism() { | ||
return SASL_MECHANISM; | ||
} | ||
|
||
public static boolean isDefaultMechanism(String mechanism) { | ||
return HADOOP_SECURITY_SASL_MECHANISM_DEFAULT.equals(mechanism); | ||
} | ||
|
||
private SaslMechanismFactory() {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.