@Parameters public static Collection<Object[]> data() { Collection<Object[]> params = new ArrayList<Object[]>(); for (QualityOfProtection qop : QualityOfProtection.values()) { params.add(new Object[]{ new QualityOfProtection[]{qop},qop, null }); } params.add(new Object[]{ new QualityOfProtection[]{ QualityOfProtection.PRIVACY,QualityOfProtection.AUTHENTICATION }, QualityOfProtection.PRIVACY, null}); params.add(new Object[]{ new QualityOfProtection[]{ QualityOfProtection.PRIVACY,QualityOfProtection.AUTHENTICATION }, QualityOfProtection.AUTHENTICATION , "org.apache.hadoop.ipc.TestSaslRPC$AuthSaslPropertiesResolver" }); return params; }
static Map<String, String> getSaslProperties(Configuration conf) { Map<String, String> saslProps =new TreeMap<String, String>(); String[] qop = conf.getStrings(HADOOP_RPC_PROTECTION_NON_WHITELIST, QualityOfProtection.PRIVACY.toString()); for (int i=0; i < qop.length; i++) { qop[i] = QualityOfProtection.valueOf( StringUtils.toUpperCase(qop[i])).getSaslQop(); } saslProps.put(Sasl.QOP, StringUtils.join(",", qop)); saslProps.put(Sasl.SERVER_AUTH, "true"); return saslProps; }
@Override public void setConf(Configuration conf) { this.conf = conf; properties = new TreeMap<String,String>(); String[] qop = conf.getTrimmedStrings( CommonConfigurationKeysPublic.HADOOP_RPC_PROTECTION, QualityOfProtection.AUTHENTICATION.toString()); for (int i=0; i < qop.length; i++) { qop[i] = QualityOfProtection.valueOf( StringUtils.toUpperCase(qop[i])).getSaslQop(); } properties.put(Sasl.QOP, StringUtils.join(",", qop)); properties.put(Sasl.SERVER_AUTH, "true"); }
public TestSaslRPC(QualityOfProtection[] qop, QualityOfProtection expectedQop, String saslPropertiesResolver) { this.qop=qop; this.expectedQop = expectedQop; this.saslPropertiesResolver = saslPropertiesResolver; }
static String getQOPNames (QualityOfProtection[] qops){ StringBuilder sb = new StringBuilder(); int i = 0; for (QualityOfProtection qop:qops){ sb.append(org.apache.hadoop.util.StringUtils.toLowerCase(qop.name())); if (++i < qops.length){ sb.append(","); } } return sb.toString(); }
/** * Creates SASL properties required for an encrypted SASL negotiation. * * @param encryptionAlgorithm to use for SASL negotation * @return properties of encrypted SASL negotiation */ public static Map<String, String> createSaslPropertiesForEncryption( String encryptionAlgorithm) { Map<String, String> saslProps = Maps.newHashMapWithExpectedSize(3); saslProps.put(Sasl.QOP, QualityOfProtection.PRIVACY.getSaslQop()); saslProps.put(Sasl.SERVER_AUTH, "true"); saslProps.put("com.sun.security.sasl.digest.cipher", encryptionAlgorithm); return saslProps; }
static Map<String, String> getSaslProperties(Configuration conf) { Map<String, String> saslProps =new TreeMap<String, String>(); String[] qop = conf.getStrings(HADOOP_RPC_PROTECTION_NON_WHITELIST, QualityOfProtection.PRIVACY.toString()); for (int i=0; i < qop.length; i++) { qop[i] = QualityOfProtection.valueOf(qop[i].toUpperCase()).getSaslQop(); } saslProps.put(Sasl.QOP, StringUtils.join(",", qop)); saslProps.put(Sasl.SERVER_AUTH, "true"); return saslProps; }
@Override public void setConf(Configuration conf) { this.conf = conf; properties = new TreeMap<String,String>(); String[] qop = conf.getTrimmedStrings( CommonConfigurationKeysPublic.HADOOP_RPC_PROTECTION, QualityOfProtection.AUTHENTICATION.toString()); for (int i=0; i < qop.length; i++) { qop[i] = QualityOfProtection.valueOf(qop[i].toUpperCase()).getSaslQop(); } properties.put(Sasl.QOP, StringUtils.join(",", qop)); properties.put(Sasl.SERVER_AUTH, "true"); }
static String getQOPNames (QualityOfProtection[] qops){ StringBuilder sb = new StringBuilder(); int i = 0; for (QualityOfProtection qop:qops){ sb.append(qop.name().toLowerCase()); if (++i < qops.length){ sb.append(","); } } return sb.toString(); }
@Parameters public static Collection<Object[]> data() { Collection<Object[]> params = new ArrayList<Object[]>(); for (QualityOfProtection qop : QualityOfProtection.values()) { params.add(new Object[]{ qop }); } return params; }
private void doDigestRpc(Server server, TestTokenSecretManager sm) throws Exception { final UserGroupInformation current = UserGroupInformation.getCurrentUser(); addr = NetUtils.getConnectAddress(server); TestTokenIdentifier tokenId = new TestTokenIdentifier(new Text(current .getUserName())); Token<TestTokenIdentifier> token = new Token<TestTokenIdentifier>(tokenId, sm); SecurityUtil.setTokenService(token, addr); current.addToken(token); TestRpcService proxy = null; try { proxy = getClient(addr, conf); AuthMethod authMethod = convert( proxy.getAuthMethod(null, newEmptyRequest())); assertEquals(TOKEN, authMethod); //QOP must be auth assertEquals(expectedQop.saslQop, RPC.getConnectionIdForProxy(proxy).getSaslQop()); int n = 0; for (Connection connection : server.getConnections()) { // only qop auth should dispose of the sasl server boolean hasServer = (connection.saslServer != null); assertTrue("qop:" + expectedQop + " hasServer:" + hasServer, (expectedQop == QualityOfProtection.AUTHENTICATION) ^ hasServer); n++; } assertTrue(n > 0); proxy.ping(null, newEmptyRequest()); } finally { stop(server, proxy); } }
private static Map<String, String> createSaslPropertiesForEncryption(String encryptionAlgorithm) { Map<String, String> saslProps = Maps.newHashMapWithExpectedSize(3); saslProps.put(Sasl.QOP, QualityOfProtection.PRIVACY.getSaslQop()); saslProps.put(Sasl.SERVER_AUTH, "true"); saslProps.put("com.sun.security.sasl.digest.cipher", encryptionAlgorithm); return saslProps; }