|
@@ -19,12 +19,10 @@
|
|
package org.apache.hadoop.security.authorize;
|
|
package org.apache.hadoop.security.authorize;
|
|
|
|
|
|
import java.net.InetAddress;
|
|
import java.net.InetAddress;
|
|
-import java.net.InetSocketAddress;
|
|
|
|
import java.net.UnknownHostException;
|
|
import java.net.UnknownHostException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Collection;
|
|
import java.util.Collection;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
-import java.util.HashSet;
|
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
import java.util.Map.Entry;
|
|
import java.util.Map.Entry;
|
|
|
|
|
|
@@ -44,7 +42,6 @@ public class ProxyUsers {
|
|
private static final String CONF_GROUPS = ".groups";
|
|
private static final String CONF_GROUPS = ".groups";
|
|
private static final String CONF_HADOOP_PROXYUSER = "hadoop.proxyuser.";
|
|
private static final String CONF_HADOOP_PROXYUSER = "hadoop.proxyuser.";
|
|
private static final String CONF_HADOOP_PROXYUSER_RE = "hadoop\\.proxyuser\\.";
|
|
private static final String CONF_HADOOP_PROXYUSER_RE = "hadoop\\.proxyuser\\.";
|
|
- public static final String CONF_HADOOP_PROXYSERVERS = "hadoop.proxyservers";
|
|
|
|
|
|
|
|
private static boolean init = false;
|
|
private static boolean init = false;
|
|
//list of users, groups and hosts per proxyuser
|
|
//list of users, groups and hosts per proxyuser
|
|
@@ -54,8 +51,6 @@ public class ProxyUsers {
|
|
new HashMap<String, Collection<String>>();
|
|
new HashMap<String, Collection<String>>();
|
|
private static Map<String, Collection<String>> proxyHosts =
|
|
private static Map<String, Collection<String>> proxyHosts =
|
|
new HashMap<String, Collection<String>>();
|
|
new HashMap<String, Collection<String>>();
|
|
- private static Collection<String> proxyServers =
|
|
|
|
- new HashSet<String>();
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* reread the conf and get new values for "hadoop.proxyuser.*.groups/users/hosts"
|
|
* reread the conf and get new values for "hadoop.proxyuser.*.groups/users/hosts"
|
|
@@ -75,7 +70,6 @@ public class ProxyUsers {
|
|
proxyGroups.clear();
|
|
proxyGroups.clear();
|
|
proxyHosts.clear();
|
|
proxyHosts.clear();
|
|
proxyUsers.clear();
|
|
proxyUsers.clear();
|
|
- proxyServers.clear();
|
|
|
|
|
|
|
|
// get all the new keys for users
|
|
// get all the new keys for users
|
|
String regex = CONF_HADOOP_PROXYUSER_RE+"[^.]*\\"+CONF_USERS;
|
|
String regex = CONF_HADOOP_PROXYUSER_RE+"[^.]*\\"+CONF_USERS;
|
|
@@ -103,22 +97,8 @@ public class ProxyUsers {
|
|
proxyHosts.put(entry.getKey(),
|
|
proxyHosts.put(entry.getKey(),
|
|
StringUtils.getTrimmedStringCollection(entry.getValue()));
|
|
StringUtils.getTrimmedStringCollection(entry.getValue()));
|
|
}
|
|
}
|
|
-
|
|
|
|
- // trusted proxy servers such as http proxies
|
|
|
|
- for (String host : conf.getTrimmedStrings(CONF_HADOOP_PROXYSERVERS)) {
|
|
|
|
- InetSocketAddress addr = new InetSocketAddress(host, 0);
|
|
|
|
- if (!addr.isUnresolved()) {
|
|
|
|
- proxyServers.add(addr.getAddress().getHostAddress());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
init = true;
|
|
init = true;
|
|
- }
|
|
|
|
-
|
|
|
|
- public static synchronized boolean isProxyServer(String remoteAddr) {
|
|
|
|
- if(!init) {
|
|
|
|
- refreshSuperUserGroupsConfiguration();
|
|
|
|
- }
|
|
|
|
- return proxyServers.contains(remoteAddr);
|
|
|
|
|
|
+ ProxyServers.refresh(conf);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|