Java 类org.apache.hadoop.security.HadoopKerberosName 实例源码

项目:drill    文件:BitConnectionConfig.java   
public Map<String, ?> getSaslClientProperties(final DrillbitEndpoint remoteEndpoint,
                                              final Map<String, String> overrides) throws IOException {
  final DrillProperties properties = DrillProperties.createEmpty();

  final UserGroupInformation loginUser = UserGroupInformation.getLoginUser();
  if (loginUser.getAuthenticationMethod() == UserGroupInformation.AuthenticationMethod.KERBEROS) {
    final HadoopKerberosName loginPrincipal = new HadoopKerberosName(loginUser.getUserName());
    if (!useLoginPrincipal) {
      properties.setProperty(DrillProperties.SERVICE_PRINCIPAL,
          KerberosUtil.getPrincipalFromParts(loginPrincipal.getShortName(),
              remoteEndpoint.getAddress(),
              loginPrincipal.getRealm()));
    } else {
      properties.setProperty(DrillProperties.SERVICE_PRINCIPAL, loginPrincipal.toString());
    }
  }

  properties.merge(overrides);
  return properties.stringPropertiesAsMap();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TokenCache.java   
/**
 * get delegation tokens for a specific FS
 * @param fs
 * @param credentials
 * @param p
 * @param conf
 * @throws IOException
 */
private static void obtainTokensForNamenodesInternal(FileSystem fs,
    Credentials credentials, Configuration conf) throws IOException {
  HadoopKerberosName jtKrbName = new HadoopKerberosName(conf.get(JobTracker.JT_USER_NAME, ""));
  String delegTokenRenewer = jtKrbName.getShortName();

  mergeBinaryTokens(credentials, conf);

  final Token<?> tokens[] = fs.addDelegationTokens(delegTokenRenewer,
                                                   credentials);
  if (tokens != null) {
    for (Token<?> token : tokens) {
      LOG.info("Got dt for " + fs.getUri() + "; "+token);
    }
  }
}
项目:hadoop-plus    文件:AbstractDelegationTokenIdentifier.java   
public AbstractDelegationTokenIdentifier(Text owner, Text renewer, Text realUser) {
  if (owner == null) {
    this.owner = new Text();
  } else {
    this.owner = owner;
  }
  if (renewer == null) {
    this.renewer = new Text();
  } else {
    HadoopKerberosName renewerKrbName = new HadoopKerberosName(renewer.toString());
    try {
      this.renewer = new Text(renewerKrbName.getShortName());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
  if (realUser == null) {
    this.realUser = new Text();
  } else {
    this.realUser = realUser;
  }
  issueDate = 0;
  maxDate = 0;
}
项目:hadoop-TCP    文件:AbstractDelegationTokenIdentifier.java   
public AbstractDelegationTokenIdentifier(Text owner, Text renewer, Text realUser) {
  if (owner == null) {
    this.owner = new Text();
  } else {
    this.owner = owner;
  }
  if (renewer == null) {
    this.renewer = new Text();
  } else {
    HadoopKerberosName renewerKrbName = new HadoopKerberosName(renewer.toString());
    try {
      this.renewer = new Text(renewerKrbName.getShortName());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
  if (realUser == null) {
    this.realUser = new Text();
  } else {
    this.realUser = realUser;
  }
  issueDate = 0;
  maxDate = 0;
}
项目:hardfs    文件:AbstractDelegationTokenIdentifier.java   
public AbstractDelegationTokenIdentifier(Text owner, Text renewer, Text realUser) {
  if (owner == null) {
    this.owner = new Text();
  } else {
    this.owner = owner;
  }
  if (renewer == null) {
    this.renewer = new Text();
  } else {
    HadoopKerberosName renewerKrbName = new HadoopKerberosName(renewer.toString());
    try {
      this.renewer = new Text(renewerKrbName.getShortName());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
  if (realUser == null) {
    this.realUser = new Text();
  } else {
    this.realUser = realUser;
  }
  issueDate = 0;
  maxDate = 0;
}
项目:hadoop-on-lustre2    文件:AbstractDelegationTokenIdentifier.java   
public AbstractDelegationTokenIdentifier(Text owner, Text renewer, Text realUser) {
  if (owner == null) {
    this.owner = new Text();
  } else {
    this.owner = owner;
  }
  if (renewer == null) {
    this.renewer = new Text();
  } else {
    HadoopKerberosName renewerKrbName = new HadoopKerberosName(renewer.toString());
    try {
      this.renewer = new Text(renewerKrbName.getShortName());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
  if (realUser == null) {
    this.realUser = new Text();
  } else {
    this.realUser = realUser;
  }
  issueDate = 0;
  maxDate = 0;
}
项目:hanoi-hadoop-2.0.0-cdh    文件:TokenCache.java   
/**
 * get delegation tokens for a specific FS
 * @param fs
 * @param credentials
 * @param p
 * @param conf
 * @throws IOException
 */
private static void obtainTokensForNamenodesInternal(FileSystem fs,
    Credentials credentials, Configuration conf) throws IOException {
  HadoopKerberosName jtKrbName = new HadoopKerberosName(conf.get(JobTracker.JT_USER_NAME, ""));
  String delegTokenRenewer = jtKrbName.getShortName();

  mergeBinaryTokens(credentials, conf);

  final Token<?> tokens[] = fs.addDelegationTokens(delegTokenRenewer,
                                                   credentials);
  if (tokens != null) {
    for (Token<?> token : tokens) {
      LOG.info("Got dt for " + fs.getUri() + "; "+token);
    }
  }
}
项目:hadoop-oss    文件:AbstractDelegationTokenIdentifier.java   
public void setRenewer(Text renewer) {
  if (renewer == null) {
    this.renewer = new Text();
  } else {
    HadoopKerberosName renewerKrbName = new HadoopKerberosName(renewer.toString());
    try {
      this.renewer = new Text(renewerKrbName.getShortName());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
}
项目:hadoop    文件:TestSecureLogins.java   
@Test
public void testValidKerberosName() throws Throwable {

  new HadoopKerberosName(ZOOKEEPER).getShortName();
  new HadoopKerberosName(ZOOKEEPER_LOCALHOST).getShortName();
  new HadoopKerberosName(ZOOKEEPER_REALM).getShortName();
  // standard rules don't pick this up
  // new HadoopKerberosName(ZOOKEEPER_LOCALHOST_REALM).getShortName();
}
项目:hadoop    文件:AbstractDelegationTokenIdentifier.java   
public void setRenewer(Text renewer) {
  if (renewer == null) {
    this.renewer = new Text();
  } else {
    HadoopKerberosName renewerKrbName = new HadoopKerberosName(renewer.toString());
    try {
      this.renewer = new Text(renewerKrbName.getShortName());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
}
项目:aliyun-oss-hadoop-fs    文件:TestSecureLogins.java   
@Test
public void testValidKerberosName() throws Throwable {

  new HadoopKerberosName(ZOOKEEPER).getShortName();
  new HadoopKerberosName(ZOOKEEPER_LOCALHOST).getShortName();
  new HadoopKerberosName(ZOOKEEPER_REALM).getShortName();
  // standard rules don't pick this up
  // new HadoopKerberosName(ZOOKEEPER_LOCALHOST_REALM).getShortName();
}
项目:aliyun-oss-hadoop-fs    文件:AbstractDelegationTokenIdentifier.java   
public void setRenewer(Text renewer) {
  if (renewer == null) {
    this.renewer = new Text();
  } else {
    HadoopKerberosName renewerKrbName = new HadoopKerberosName(renewer.toString());
    try {
      this.renewer = new Text(renewerKrbName.getShortName());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
}
项目:big-c    文件:TestSecureLogins.java   
@Test
public void testValidKerberosName() throws Throwable {

  new HadoopKerberosName(ZOOKEEPER).getShortName();
  new HadoopKerberosName(ZOOKEEPER_LOCALHOST).getShortName();
  new HadoopKerberosName(ZOOKEEPER_REALM).getShortName();
  // standard rules don't pick this up
  // new HadoopKerberosName(ZOOKEEPER_LOCALHOST_REALM).getShortName();
}
项目:big-c    文件:AbstractDelegationTokenIdentifier.java   
public void setRenewer(Text renewer) {
  if (renewer == null) {
    this.renewer = new Text();
  } else {
    HadoopKerberosName renewerKrbName = new HadoopKerberosName(renewer.toString());
    try {
      this.renewer = new Text(renewerKrbName.getShortName());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
}
项目:drill    文件:AbstractServerConnection.java   
@Override
public void finalizeSaslSession() throws IOException {
  final String authorizationID = getSaslServer().getAuthorizationID();
  final String remoteShortName = new HadoopKerberosName(authorizationID).getShortName();
  final String localShortName = UserGroupInformation.getLoginUser().getShortUserName();
  if (!localShortName.equals(remoteShortName)) {
    throw new SaslException(String.format("'primary' part of remote drillbit's service principal " +
        "does not match with this drillbit's. Expected: '%s' Actual: '%s'", localShortName, remoteShortName));
  }
  getLogger().debug("Authenticated connection for {}", authorizationID);
}
项目:drill    文件:UserServer.java   
@Override
public void finalizeSaslSession() throws IOException {
  final String authorizationID = getSaslServer().getAuthorizationID();
  final String userName = new HadoopKerberosName(authorizationID).getShortName();
  logger.debug("Created session for {}", userName);
  finalizeSession(userName);
}
项目:hadoop-2.6.0-cdh5.4.3    文件:TestSecureLogins.java   
@Test
public void testValidKerberosName() throws Throwable {

  new HadoopKerberosName(ZOOKEEPER).getShortName();
  new HadoopKerberosName(ZOOKEEPER_LOCALHOST).getShortName();
  new HadoopKerberosName(ZOOKEEPER_REALM).getShortName();
  // standard rules don't pick this up
  // new HadoopKerberosName(ZOOKEEPER_LOCALHOST_REALM).getShortName();
}
项目:hadoop-2.6.0-cdh5.4.3    文件:AbstractDelegationTokenIdentifier.java   
public void setRenewer(Text renewer) {
  if (renewer == null) {
    this.renewer = new Text();
  } else {
    HadoopKerberosName renewerKrbName = new HadoopKerberosName(renewer.toString());
    try {
      this.renewer = new Text(renewerKrbName.getShortName());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
}
项目:hops    文件:TestSecureLogins.java   
@Test
public void testValidKerberosName() throws Throwable {

  new HadoopKerberosName(ZOOKEEPER).getShortName();
  new HadoopKerberosName(ZOOKEEPER_LOCALHOST).getShortName();
  new HadoopKerberosName(ZOOKEEPER_REALM).getShortName();
  // standard rules don't pick this up
  // new HadoopKerberosName(ZOOKEEPER_LOCALHOST_REALM).getShortName();
}
项目:hops    文件:AbstractDelegationTokenIdentifier.java   
public void setRenewer(Text renewer) {
  if (renewer == null) {
    this.renewer = new Text();
  } else {
    HadoopKerberosName renewerKrbName = new HadoopKerberosName(renewer.toString());
    try {
      this.renewer = new Text(renewerKrbName.getShortName());
    } catch (IOException e) {
      throw new RuntimeException(e);
    }
  }
}