private void AddAll(Org.Apache.Hadoop.Security.Credentials other, bool overwrite) { foreach (KeyValuePair <Text, byte[]> secret in other.secretKeysMap) { Text key = secret.Key; if (!secretKeysMap.Contains(key) || overwrite) { secretKeysMap[key] = secret.Value; } } foreach (KeyValuePair <Text, Org.Apache.Hadoop.Security.Token.Token <object> > token in other.tokenMap) { Text key = token.Key; if (!tokenMap.Contains(key) || overwrite) { tokenMap[key] = token.Value; } } }
/// <summary> /// Convenience method for reading a token storage file, and loading the Tokens /// therein in the passed UGI /// </summary> /// <param name="filename"/> /// <param name="conf"/> /// <exception cref="System.IO.IOException"/> public static Org.Apache.Hadoop.Security.Credentials ReadTokenStorageFile(FilePath filename, Configuration conf) { DataInputStream @in = null; Org.Apache.Hadoop.Security.Credentials credentials = new Org.Apache.Hadoop.Security.Credentials (); try { @in = new DataInputStream(new BufferedInputStream(new FileInputStream(filename))); credentials.ReadTokenStorageStream(@in); return(credentials); } catch (IOException ioe) { throw new IOException("Exception reading " + filename, ioe); } finally { IOUtils.Cleanup(Log, @in); } }
/// <summary> /// Convenience method for reading a token storage file, and loading the Tokens /// therein in the passed UGI /// </summary> /// <param name="filename"/> /// <param name="conf"/> /// <exception cref="System.IO.IOException"/> public static Org.Apache.Hadoop.Security.Credentials ReadTokenStorageFile(Path filename , Configuration conf) { FSDataInputStream @in = null; Org.Apache.Hadoop.Security.Credentials credentials = new Org.Apache.Hadoop.Security.Credentials (); try { @in = filename.GetFileSystem(conf).Open(filename); credentials.ReadTokenStorageStream(@in); @in.Close(); return(credentials); } catch (IOException ioe) { throw new IOException("Exception reading " + filename, ioe); } finally { IOUtils.Cleanup(Log, @in); } }
/// <summary>Create a copy of the given credentials</summary> /// <param name="credentials">to copy</param> public Credentials(Org.Apache.Hadoop.Security.Credentials credentials) { this.AddAll(credentials); }
/// <summary>Copy all of the credentials from one credential object into another.</summary> /// <remarks> /// Copy all of the credentials from one credential object into another. /// Existing secrets and tokens are not overwritten. /// </remarks> /// <param name="other">the credentials to copy</param> public virtual void MergeAll(Org.Apache.Hadoop.Security.Credentials other) { AddAll(other, false); }
/// <summary>Copy all of the credentials from one credential object into another.</summary> /// <remarks> /// Copy all of the credentials from one credential object into another. /// Existing secrets and tokens are overwritten. /// </remarks> /// <param name="other">the credentials to copy</param> public virtual void AddAll(Org.Apache.Hadoop.Security.Credentials other) { AddAll(other, true); }