gpt4 book ai didi

org.apache.hadoop.security.WhitelistBasedResolver类的使用及代码示例

转载 作者:知者 更新时间:2024-03-25 00:33:05 32 4
gpt4 key购买 nike

本文整理了Java中org.apache.hadoop.security.WhitelistBasedResolver类的一些代码示例,展示了WhitelistBasedResolver类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WhitelistBasedResolver类的具体详情如下:
包路径:org.apache.hadoop.security.WhitelistBasedResolver
类名称:WhitelistBasedResolver

WhitelistBasedResolver介绍

[英]An implementation of the SaslPropertiesResolver. Uses a white list of IPs. If the connection's IP address is in the list of IP addresses, the salProperties will be unchanged. If the connection's IP is not in the list of IP addresses, then QOP for the connection will be restricted to "hadoop.rpc.protection.non-whitelist" Uses 3 IPList implementations together to form an aggregate whitelist. 1. ConstantIPList - to check against a set of hardcoded IPs 2. Fixed IP List - to check against a list of IP addresses which are specified externally, but will not change over runtime. 3. Variable IP List - to check against a list of IP addresses which are specified externally and could change during runtime. A connection IP address will checked against these 3 IP Lists in the order specified above. Once a match is found , the IP address is determined to be in whitelist. The behavior can be configured using a bunch of configuration parameters.
[中]SaslPropertiesResolver的一个实现。使用IP的白名单。如果连接的IP地址在IP地址列表中,则属性将保持不变。如果连接的IP不在IP地址列表中,那么连接的QOP将被限制为“hadoop.rpc.protection.non whitelist”使用3个IPList实现一起形成一个聚合的白名单。1.ConstantIPList-对照一组硬编码IP进行检查2。固定IP列表-对照外部指定的IP地址列表进行检查,但在运行时不会更改。3.可变IP列表-对照外部指定的IP地址列表进行检查,这些地址在运行时可能会更改。将按照上面指定的顺序,根据这3个IP列表检查连接IP地址。一旦找到匹配项,IP地址就被确定在白名单中。可以使用一组配置参数来配置行为。

代码示例

代码示例来源:origin: org.apache.hadoop/hadoop-common

/**
 * Identify the Sasl Properties to be used for a connection with a client.
 * @param clientAddress client's address
 * @return the sasl properties to be used for the connection.
 */
@Override
public Map<String, String> getServerProperties(InetAddress clientAddress) {
 if (clientAddress == null) {
  return saslProps;
 }
 return  whiteList.isIn(clientAddress.getHostAddress())?getDefaultProperties():saslProps;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

public Map<String, String> getServerProperties(String clientAddress) throws UnknownHostException {
 if (clientAddress == null) {
  return saslProps;
 }
 return getServerProperties(InetAddress.getByName(clientAddress));
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

static Map<String, String> getSaslProperties(Configuration conf) {
  return getSaslProperties(conf, HADOOP_RPC_PROTECTION_NON_WHITELIST,
    QualityOfProtection.PRIVACY);
 }
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

public void testFixedVariableAndLocalWhiteList() throws IOException {
 String[] fixedIps = {"10.119.103.112", "10.221.102.0/23"};
 TestFileBasedIPList.createFileWithEntries ("fixedwhitelist.txt", fixedIps);
 String[] variableIps = {"10.222.0.0/16", "10.113.221.221"};
 TestFileBasedIPList.createFileWithEntries ("variablewhitelist.txt", variableIps);
 Configuration conf = new Configuration();
 conf.set(WhitelistBasedResolver.HADOOP_SECURITY_SASL_FIXEDWHITELIST_FILE ,
   "fixedwhitelist.txt");
 conf.setBoolean(WhitelistBasedResolver.HADOOP_SECURITY_SASL_VARIABLEWHITELIST_ENABLE,
   true);
 conf.setLong(WhitelistBasedResolver.HADOOP_SECURITY_SASL_VARIABLEWHITELIST_CACHE_SECS,
   1);
 conf.set(WhitelistBasedResolver.HADOOP_SECURITY_SASL_VARIABLEWHITELIST_FILE ,
   "variablewhitelist.txt");
 WhitelistBasedResolver wqr = new WhitelistBasedResolver ();
 wqr.setConf(conf);
 assertEquals (wqr.getDefaultProperties(),
   wqr.getServerProperties(InetAddress.getByName("10.119.103.112")));
 assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.119.103.113"));
 assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("10.221.103.121"));
 assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.221.104.0"));
 assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("10.222.103.121"));
 assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.223.104.0"));
 assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("10.113.221.221"));
 assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.113.221.222"));
 assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("127.0.0.1"));
 TestFileBasedIPList.removeFile("fixedwhitelist.txt");
 TestFileBasedIPList.removeFile("variablewhitelist.txt");
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

"variablewhitelist.txt");
WhitelistBasedResolver wqr = new WhitelistBasedResolver();
wqr.setConf(conf);
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties((InetAddress)null));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties((String)null));

代码示例来源:origin: ch.cern.hadoop/hadoop-common

public void testFixedVariableAndLocalWhiteList() throws IOException {
 String[] fixedIps = {"10.119.103.112", "10.221.102.0/23"};
 TestFileBasedIPList.createFileWithEntries ("fixedwhitelist.txt", fixedIps);
 String[] variableIps = {"10.222.0.0/16", "10.113.221.221"};
 TestFileBasedIPList.createFileWithEntries ("variablewhitelist.txt", variableIps);
 Configuration conf = new Configuration();
 conf.set(WhitelistBasedResolver.HADOOP_SECURITY_SASL_FIXEDWHITELIST_FILE ,
   "fixedwhitelist.txt");
 conf.setBoolean(WhitelistBasedResolver.HADOOP_SECURITY_SASL_VARIABLEWHITELIST_ENABLE,
   true);
 conf.setLong(WhitelistBasedResolver.HADOOP_SECURITY_SASL_VARIABLEWHITELIST_CACHE_SECS,
   1);
 conf.set(WhitelistBasedResolver.HADOOP_SECURITY_SASL_VARIABLEWHITELIST_FILE ,
   "variablewhitelist.txt");
 WhitelistBasedResolver wqr = new WhitelistBasedResolver ();
 wqr.setConf(conf);
 assertEquals (wqr.getDefaultProperties(),
   wqr.getServerProperties(InetAddress.getByName("10.119.103.112")));
 assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.119.103.113"));
 assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("10.221.103.121"));
 assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.221.104.0"));
 assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("10.222.103.121"));
 assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.223.104.0"));
 assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("10.113.221.221"));
 assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.113.221.222"));
 assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("127.0.0.1"));
 TestFileBasedIPList.removeFile("fixedwhitelist.txt");
 TestFileBasedIPList.removeFile("variablewhitelist.txt");
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

"variablewhitelist.txt");
WhitelistBasedResolver wqr = new WhitelistBasedResolver();
wqr.setConf(conf);
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties((InetAddress)null));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties((String)null));

代码示例来源:origin: ch.cern.hadoop/hadoop-common

"variablewhitelist.txt");
WhitelistBasedResolver wqr = new WhitelistBasedResolver();
wqr.setConf(conf);
assertEquals (wqr.getDefaultProperties(),
  wqr.getServerProperties(InetAddress.getByName("10.119.103.112")));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.119.103.113"));
assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("10.221.103.121"));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.221.104.0"));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.222.103.121"));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.223.104.0"));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.113.221.221"));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.113.221.222"));
assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("127.0.0.1"));;

代码示例来源:origin: io.hops/hadoop-common

public Map<String, String> getServerProperties(String clientAddress) throws UnknownHostException {
 if (clientAddress == null) {
  return saslProps;
 }
 return getServerProperties(InetAddress.getByName(clientAddress));
}

代码示例来源:origin: io.hops/hadoop-common

/**
 * Identify the Sasl Properties to be used for a connection with a client.
 * @param clientAddress client's address
 * @return the sasl properties to be used for the connection.
 */
@Override
public Map<String, String> getServerProperties(InetAddress clientAddress) {
 if (clientAddress == null) {
  return saslProps;
 }
 return  whiteList.isIn(clientAddress.getHostAddress())?getDefaultProperties():saslProps;
}

代码示例来源:origin: org.apache.hadoop/hadoop-common

@Override
public void setConf(Configuration conf) {
 super.setConf(conf);
 String fixedFile = conf.get(HADOOP_SECURITY_SASL_FIXEDWHITELIST_FILE,
   FIXEDWHITELIST_DEFAULT_LOCATION);
 String variableFile = null;
 long expiryTime = 0;
 if (conf.getBoolean(HADOOP_SECURITY_SASL_VARIABLEWHITELIST_ENABLE, false)) {
  variableFile = conf.get(HADOOP_SECURITY_SASL_VARIABLEWHITELIST_FILE,
    VARIABLEWHITELIST_DEFAULT_LOCATION);
  expiryTime =
   conf.getLong(HADOOP_SECURITY_SASL_VARIABLEWHITELIST_CACHE_SECS,3600) * 1000;
 }
 whiteList = new CombinedIPWhiteList(fixedFile,variableFile,expiryTime);
 this.saslProps = getSaslProperties(conf);
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

"variablewhitelist.txt");
WhitelistBasedResolver wqr = new WhitelistBasedResolver();
wqr.setConf(conf);
assertEquals (wqr.getDefaultProperties(),
  wqr.getServerProperties(InetAddress.getByName("10.119.103.112")));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.119.103.113"));
assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("10.221.103.121"));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.221.104.0"));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.222.103.121"));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.223.104.0"));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.113.221.221"));
assertEquals (SASL_PRIVACY_PROPS, wqr.getServerProperties("10.113.221.222"));
assertEquals (wqr.getDefaultProperties(), wqr.getServerProperties("127.0.0.1"));;

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

public Map<String, String> getServerProperties(String clientAddress) throws UnknownHostException {
 if (clientAddress == null) {
  return saslProps;
 }
 return getServerProperties(InetAddress.getByName(clientAddress));
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

/**
 * Identify the Sasl Properties to be used for a connection with a client.
 * @param clientAddress client's address
 * @return the sasl properties to be used for the connection.
 */
@Override
public Map<String, String> getServerProperties(InetAddress clientAddress) {
 if (clientAddress == null) {
  return saslProps;
 }
 return  whiteList.isIn(clientAddress.getHostAddress())?getDefaultProperties():saslProps;
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

@Override
public void setConf(Configuration conf) {
 super.setConf(conf);
 String fixedFile = conf.get(HADOOP_SECURITY_SASL_FIXEDWHITELIST_FILE,
   FIXEDWHITELIST_DEFAULT_LOCATION);
 String variableFile = null;
 long expiryTime = 0;
 if (conf.getBoolean(HADOOP_SECURITY_SASL_VARIABLEWHITELIST_ENABLE, false)) {
  variableFile = conf.get(HADOOP_SECURITY_SASL_VARIABLEWHITELIST_FILE,
    VARIABLEWHITELIST_DEFAULT_LOCATION);
  expiryTime =
   conf.getLong(HADOOP_SECURITY_SASL_VARIABLEWHITELIST_CACHE_SECS,3600) * 1000;
 }
 whiteList = new CombinedIPWhiteList(fixedFile,variableFile,expiryTime);
 this.saslProps = getSaslProperties(conf);
}

代码示例来源:origin: ch.cern.hadoop/hadoop-common

public Map<String, String> getServerProperties(String clientAddress) throws UnknownHostException {
 if (clientAddress == null) {
  return saslProps;
 }
 return getServerProperties(InetAddress.getByName(clientAddress));
}

代码示例来源:origin: com.github.jiayuhan-it/hadoop-common

/**
 * Identify the Sasl Properties to be used for a connection with a client.
 * @param clientAddress client's address
 * @return the sasl properties to be used for the connection.
 */
@Override
public Map<String, String> getServerProperties(InetAddress clientAddress) {
 if (clientAddress == null) {
  return saslProps;
 }
 return  whiteList.isIn(clientAddress.getHostAddress())?getDefaultProperties():saslProps;
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

@Override
public void setConf(Configuration conf) {
 super.setConf(conf);
 String fixedFile = conf.get(HADOOP_SECURITY_SASL_FIXEDWHITELIST_FILE,
   FIXEDWHITELIST_DEFAULT_LOCATION);
 String variableFile = null;
 long expiryTime = 0;
 if (conf.getBoolean(HADOOP_SECURITY_SASL_VARIABLEWHITELIST_ENABLE, false)) {
  variableFile = conf.get(HADOOP_SECURITY_SASL_VARIABLEWHITELIST_FILE,
    VARIABLEWHITELIST_DEFAULT_LOCATION);
  expiryTime =
   conf.getLong(HADOOP_SECURITY_SASL_VARIABLEWHITELIST_CACHE_SECS,3600) * 1000;
 }
 whiteList = new CombinedIPWhiteList(fixedFile,variableFile,expiryTime);
 this.saslProps = getSaslProperties(conf);
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

public Map<String, String> getServerProperties(String clientAddress) throws UnknownHostException {
 if (clientAddress == null) {
  return saslProps;
 }
 return getServerProperties(InetAddress.getByName(clientAddress));
}

代码示例来源:origin: io.prestosql.hadoop/hadoop-apache

/**
 * Identify the Sasl Properties to be used for a connection with a client.
 * @param clientAddress client's address
 * @return the sasl properties to be used for the connection.
 */
@Override
public Map<String, String> getServerProperties(InetAddress clientAddress) {
 if (clientAddress == null) {
  return saslProps;
 }
 return  whiteList.isIn(clientAddress.getHostAddress())?getDefaultProperties():saslProps;
}

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com