Java Code Examples for org.apache.hadoop.security.Credentials#readFields()

The following examples show how to use org.apache.hadoop.security.Credentials#readFields() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UgiDoAs.java    From components with Apache License 2.0 6 votes vote down vote up
private final UserGroupInformation getUgi() {
    // If the UGI has not been created, create it from the credentials, and don't inherit from the current or
    // login user.
    if (ugi == null) {
        // If the UGI has not been initialized, then create a new one with the credentials.
        try (DataInputStream in = new DataInputStream(new ByteArrayInputStream(credentials))) {
            Credentials cred = new Credentials();
            cred.readFields(in);
            ugi = UserGroupInformation.createRemoteUser(principal, SaslRpcServer.AuthMethod.KERBEROS);
            ugi.addCredentials(cred);
        } catch (IOException e) {
            throw TalendRuntimeException.createUnexpectedException(e);
        }
    }
    return ugi;
}
 
Example 2
Source File: ContainerTask.java    From incubator-tez with Apache License 2.0 5 votes vote down vote up
@Override
public void readFields(DataInput in) throws IOException {
  shouldDie = in.readBoolean();
  boolean taskComing = in.readBoolean();
  if (taskComing) {
    taskSpec = new TaskSpec();
    taskSpec.readFields(in);
  }
  int numAdditionalResources = in.readInt();
  additionalResources = Maps.newHashMap();
  if (numAdditionalResources != -1) {
    for (int i = 0 ; i < numAdditionalResources ; i++) {
      String resourceName = in.readUTF();
      TezLocalResource localResource = new TezLocalResource();
      localResource.readFields(in);
      additionalResources.put(resourceName, localResource);
    }
  }
  credentialsChanged = in.readBoolean();
  if (credentialsChanged) {
    boolean hasCredentials = in.readBoolean();
    if (hasCredentials) {
      credentials = new Credentials();
      credentials.readFields(in);
    }
  }
}
 
Example 3
Source File: ContainerTask.java    From tez with Apache License 2.0 5 votes vote down vote up
@Override
public void readFields(DataInput in) throws IOException {
  shouldDie = in.readBoolean();
  boolean taskComing = in.readBoolean();
  if (taskComing) {
    taskSpec = new TaskSpec();
    taskSpec.readFields(in);
  }
  int numAdditionalResources = in.readInt();
  additionalResources = Maps.newHashMap();
  if (numAdditionalResources != -1) {
    for (int i = 0 ; i < numAdditionalResources ; i++) {
      String resourceName = in.readUTF();
      TezLocalResource localResource = new TezLocalResource();
      localResource.readFields(in);
      additionalResources.put(resourceName, localResource);
    }
  }
  credentialsChanged = in.readBoolean();
  if (credentialsChanged) {
    boolean hasCredentials = in.readBoolean();
    if (hasCredentials) {
      credentials = new Credentials();
      credentials.readFields(in);
    }
  }
}