Class DtFileOperations

java.lang.Object
org.apache.hadoop.security.token.DtFileOperations

public final class DtFileOperations extends Object
DtFileOperations is a collection of delegation token file operations.
  • Field Details

    • FORMAT_PB

      public static final String FORMAT_PB
      Use FORMAT_* as arguments to format parameters. FORMAT_PB is for protobuf output.
      See Also:
    • FORMAT_JAVA

      public static final String FORMAT_JAVA
      Use FORMAT_* as arguments to format parameters. FORMAT_JAVA is a legacy option for java serialization output.
      See Also:
  • Method Details

    • doFormattedWrite

      public static void doFormattedWrite(File f, String format, Credentials creds, Configuration conf) throws IOException
      Write out a Credentials object as a local file.
      Parameters:
      f - a local File object.
      format - a string equal to FORMAT_PB or FORMAT_JAVA.
      creds - the Credentials object to be written out.
      conf - a Configuration object passed along.
      Throws:
      IOException - raised on errors performing I/O.
    • printTokenFile

      public static void printTokenFile(File tokenFile, Text alias, Configuration conf, PrintStream out) throws IOException
      Print out a Credentials file from the local filesystem.
      Parameters:
      tokenFile - a local File object.
      alias - print only tokens matching alias (null matches all).
      conf - Configuration object passed along.
      out - print to this stream.
      Throws:
      IOException - raised on errors performing I/O.
    • printCredentials

      public static void printCredentials(Credentials creds, Text alias, PrintStream out) throws IOException
      Print out a Credentials object.
      Parameters:
      creds - the Credentials object to be printed out.
      alias - print only tokens matching alias (null matches all).
      out - print to this stream.
      Throws:
      IOException - failure to unmarshall a token identifier.
    • getTokenFile

      public static void getTokenFile(File tokenFile, String fileFormat, Text alias, Text service, String url, String renewer, Configuration conf) throws Exception
      Fetch a token from a service and save to file in the local filesystem.
      Parameters:
      tokenFile - a local File object to hold the output.
      fileFormat - a string equal to FORMAT_PB or FORMAT_JAVA, for output
      alias - overwrite service field of fetched token with this text.
      service - use a DtFetcher implementation matching this service text.
      url - pass this URL to fetcher after stripping any http/s prefix.
      renewer - pass this renewer to the fetcher.
      conf - Configuration object passed along.
      Throws:
      IOException - raised on errors performing I/O.
      Exception
    • aliasTokenFile

      public static void aliasTokenFile(File tokenFile, String fileFormat, Text alias, Text service, Configuration conf) throws Exception
      Alias a token from a file and save back to file in the local filesystem.
      Parameters:
      tokenFile - a local File object to hold the input and output.
      fileFormat - a string equal to FORMAT_PB or FORMAT_JAVA, for output
      alias - overwrite service field of fetched token with this text.
      service - only apply alias to tokens matching this service text.
      conf - Configuration object passed along.
      Throws:
      IOException - raised on errors performing I/O.
      Exception
    • appendTokenFiles

      public static void appendTokenFiles(ArrayList<File> tokenFiles, String fileFormat, Configuration conf) throws IOException
      Append tokens from list of files in local filesystem, saving to last file.
      Parameters:
      tokenFiles - list of local File objects. Last file holds the output.
      fileFormat - a string equal to FORMAT_PB or FORMAT_JAVA, for output
      conf - Configuration object passed along.
      Throws:
      IOException - raised on errors performing I/O.
    • removeTokenFromFile

      public static void removeTokenFromFile(boolean cancel, File tokenFile, String fileFormat, Text alias, Configuration conf) throws IOException, InterruptedException
      Remove a token from a file in the local filesystem, matching alias.
      Parameters:
      cancel - cancel token as well as remove from file.
      tokenFile - a local File object.
      fileFormat - a string equal to FORMAT_PB or FORMAT_JAVA, for output
      alias - remove only tokens matching alias; null matches all.
      conf - Configuration object passed along.
      Throws:
      IOException - raised on errors performing I/O.
      InterruptedException - if the thread is interrupted.
    • renewTokenFile

      public static void renewTokenFile(File tokenFile, String fileFormat, Text alias, Configuration conf) throws IOException, InterruptedException
      Renew a token from a file in the local filesystem, matching alias.
      Parameters:
      tokenFile - a local File object.
      fileFormat - a string equal to FORMAT_PB or FORMAT_JAVA, for output
      alias - renew only tokens matching alias; null matches all.
      conf - Configuration object passed along.
      Throws:
      IOException - raised on errors performing I/O.
      InterruptedException - if the thread is interrupted.
    • importTokenFile

      public static void importTokenFile(File tokenFile, String fileFormat, Text alias, String base64, Configuration conf) throws IOException
      Import a token from a base64 encoding into the local filesystem.
      Parameters:
      tokenFile - A local File object.
      fileFormat - A string equal to FORMAT_PB or FORMAT_JAVA, for output.
      alias - overwrite Service field of fetched token with this text.
      base64 - urlString Encoding of the token to import.
      conf - Configuration object passed along.
      Throws:
      IOException - Error to import the token into the file.