本文整理了Java中org.apache.hadoop.security.authentication.util.KerberosName.getServiceName()
方法的一些代码示例,展示了KerberosName.getServiceName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。KerberosName.getServiceName()
方法的具体详情如下:
包路径:org.apache.hadoop.security.authentication.util.KerberosName
类名称:KerberosName
方法名:getServiceName
[英]Get the first component of the name.
[中]获取名称的第一个组件。
代码示例来源:origin: apache/hive
@Override
public String getServiceName() {
return kerberosName.getServiceName();
}
代码示例来源:origin: apache/accumulo
clientConf.setProperty(
org.apache.accumulo.core.client.ClientConfiguration.ClientProperty.KERBEROS_SERVER_PRIMARY,
krbName.getServiceName());
代码示例来源:origin: com.facebook.presto.hive/hive-apache
@Override
public String getServiceName() {
return kerberosName.getServiceName();
}
代码示例来源:origin: org.apache.hive.shims/hive-shims-0.23
@Override
public String getServiceName() {
return kerberosName.getServiceName();
}
代码示例来源:origin: com.github.hyukjinkwon.shims/hive-shims-0.23
@Override
public String getServiceName() {
return kerberosName.getServiceName();
}
代码示例来源:origin: org.spark-project.hive.shims/hive-shims-0.23
@Override
public String getServiceName() {
return kerberosName.getServiceName();
}
代码示例来源:origin: org.apache.accumulo/accumulo-core
protected static Map<String,String> getProperties(AccumuloConfiguration conf) {
final Map<String,String> clientProperties = new HashMap<>();
// Servers will only have the full principal in their configuration -- parse the
// primary and realm from it.
final String serverPrincipal = conf.get(Property.GENERAL_KERBEROS_PRINCIPAL);
final KerberosName krbName;
try {
krbName = new KerberosName(serverPrincipal);
clientProperties.put(ClientProperty.KERBEROS_SERVER_PRIMARY.getKey(),
krbName.getServiceName());
} catch (Exception e) {
// bad value or empty, assume we're not using kerberos
}
HashSet<String> clientKeys = new HashSet<>();
for (ClientProperty prop : ClientProperty.values()) {
clientKeys.add(prop.getKey());
}
String key;
for (Entry<String,String> entry : conf) {
key = entry.getKey();
if (clientKeys.contains(key)) {
clientProperties.put(key, entry.getValue());
}
}
return clientProperties;
}
代码示例来源:origin: hopshadoop/hops
KerberosName kerbName = new KerberosName(spnegoPrincipal);
if (kerbName.getHostName() != null
&& kerbName.getServiceName() != null
&& kerbName.getServiceName().equals("HTTP")) {
boolean added = serverPrincipalMap.put(kerbName.getHostName(),
spnegoPrincipal);
代码示例来源:origin: io.hops/hadoop-auth
KerberosName kerbName = new KerberosName(spnegoPrincipal);
if (kerbName.getHostName() != null
&& kerbName.getServiceName() != null
&& kerbName.getServiceName().equals("HTTP")) {
boolean added = serverPrincipalMap.put(kerbName.getHostName(),
spnegoPrincipal);
代码示例来源:origin: co.cask.cdap/cdap-app-fabric
/**
* Executes a program without blocking until its completion.
*/
public void execute(final ProgramId id, Map<String, String> sysArgs, Map<String, String> userArgs) throws Exception {
String originalUserId = SecurityRequestContext.getUserId();
try {
// if the program has a namespace user configured then set that user in the security request context.
// See: CDAP-7396
String nsPrincipal = namespaceQueryAdmin.get(id.getNamespaceId()).getConfig().getPrincipal();
if (nsPrincipal != null && SecurityUtil.isKerberosEnabled(cConf)) {
SecurityRequestContext.setUserId(new KerberosName(nsPrincipal).getServiceName());
}
lifecycleService.runInternal(id, userArgs, sysArgs, false);
} catch (ProgramNotFoundException | ApplicationNotFoundException e) {
throw new TaskExecutionException(String.format(UserMessages.getMessage(UserErrors.PROGRAM_NOT_FOUND), id),
e, false);
} finally {
SecurityRequestContext.setUserId(originalUserId);
}
}
}
代码示例来源:origin: cdapio/cdap
/**
* Executes a program without blocking until its completion.
*/
public void execute(final ProgramId id, Map<String, String> sysArgs, Map<String, String> userArgs) throws Exception {
String originalUserId = SecurityRequestContext.getUserId();
try {
// if the program has a namespace user configured then set that user in the security request context.
// See: CDAP-7396
String nsPrincipal = namespaceQueryAdmin.get(id.getNamespaceId()).getConfig().getPrincipal();
if (nsPrincipal != null && SecurityUtil.isKerberosEnabled(cConf)) {
SecurityRequestContext.setUserId(new KerberosName(nsPrincipal).getServiceName());
}
lifecycleService.runInternal(id, userArgs, sysArgs, false);
} catch (ProgramNotFoundException | ApplicationNotFoundException e) {
throw new TaskExecutionException(String.format(UserMessages.getMessage(UserErrors.PROGRAM_NOT_FOUND), id),
e, false);
} finally {
SecurityRequestContext.setUserId(originalUserId);
}
}
}
代码示例来源:origin: io.hops/hadoop-auth
@Test
public void testParsing() throws Exception {
final String principalNameFull = "HTTP/abc.com@EXAMPLE.COM";
final String principalNameWoRealm = "HTTP/abc.com";
final String principalNameWoHost = "HTTP@EXAMPLE.COM";
final KerberosName kerbNameFull = new KerberosName(principalNameFull);
Assert.assertEquals("HTTP", kerbNameFull.getServiceName());
Assert.assertEquals("abc.com", kerbNameFull.getHostName());
Assert.assertEquals("EXAMPLE.COM", kerbNameFull.getRealm());
final KerberosName kerbNamewoRealm = new KerberosName(principalNameWoRealm);
Assert.assertEquals("HTTP", kerbNamewoRealm.getServiceName());
Assert.assertEquals("abc.com", kerbNamewoRealm.getHostName());
Assert.assertEquals(null, kerbNamewoRealm.getRealm());
final KerberosName kerbNameWoHost = new KerberosName(principalNameWoHost);
Assert.assertEquals("HTTP", kerbNameWoHost.getServiceName());
Assert.assertEquals(null, kerbNameWoHost.getHostName());
Assert.assertEquals("EXAMPLE.COM", kerbNameWoHost.getRealm());
}
代码示例来源:origin: hopshadoop/hops
@Test
public void testParsing() throws Exception {
final String principalNameFull = "HTTP/abc.com@EXAMPLE.COM";
final String principalNameWoRealm = "HTTP/abc.com";
final String principalNameWoHost = "HTTP@EXAMPLE.COM";
final KerberosName kerbNameFull = new KerberosName(principalNameFull);
Assert.assertEquals("HTTP", kerbNameFull.getServiceName());
Assert.assertEquals("abc.com", kerbNameFull.getHostName());
Assert.assertEquals("EXAMPLE.COM", kerbNameFull.getRealm());
final KerberosName kerbNamewoRealm = new KerberosName(principalNameWoRealm);
Assert.assertEquals("HTTP", kerbNamewoRealm.getServiceName());
Assert.assertEquals("abc.com", kerbNamewoRealm.getHostName());
Assert.assertEquals(null, kerbNamewoRealm.getRealm());
final KerberosName kerbNameWoHost = new KerberosName(principalNameWoHost);
Assert.assertEquals("HTTP", kerbNameWoHost.getServiceName());
Assert.assertEquals(null, kerbNameWoHost.getHostName());
Assert.assertEquals("EXAMPLE.COM", kerbNameWoHost.getRealm());
}
内容来源于网络,如有侵权,请联系作者删除!