/// <exception cref="System.IO.IOException"/> public override void StoreTokenMasterKey(DelegationKey key) { if (Log.IsDebugEnabled()) { Log.Debug("Storing master key " + key.GetKeyId()); } Path keyPath = new Path(tokenKeysStatePath, TokenMasterKeyFilePrefix + key.GetKeyId ()); if (fs.Exists(keyPath)) { throw new IOException(keyPath + " already exists"); } ByteArrayOutputStream memStream = new ByteArrayOutputStream(); DataOutputStream dataStream = new DataOutputStream(memStream); try { key.Write(dataStream); dataStream.Close(); dataStream = null; } finally { IOUtils.Cleanup(Log, dataStream); } CreateNewFile(keyPath, memStream.ToByteArray()); }
/// <exception cref="System.IO.IOException"/> protected internal override void StoreRMDTMasterKeyState(DelegationKey masterKey) { string dbKey = GetRMDTMasterKeyNodeKey(masterKey); if (Log.IsDebugEnabled()) { Log.Debug("Storing token master key to " + dbKey); } ByteArrayOutputStream os = new ByteArrayOutputStream(); DataOutputStream @out = new DataOutputStream(os); try { masterKey.Write(@out); } finally { @out.Close(); } try { db.Put(JniDBFactory.Bytes(dbKey), os.ToByteArray()); } catch (DBException e) { throw new IOException(e); } }
/// <exception cref="System.IO.IOException"/> public override void StoreTokenMasterKey(DelegationKey masterKey) { if (Log.IsDebugEnabled()) { Log.Debug("Storing master key " + masterKey.GetKeyId()); } ByteArrayOutputStream memStream = new ByteArrayOutputStream(); DataOutputStream dataStream = new DataOutputStream(memStream); try { masterKey.Write(dataStream); dataStream.Close(); dataStream = null; } finally { IOUtils.Cleanup(Log, dataStream); } string dbKey = GetTokenMasterKeyDatabaseKey(masterKey); try { db.Put(JniDBFactory.Bytes(dbKey), memStream.ToByteArray()); } catch (DBException e) { throw new IOException(e); } }
/// <exception cref="System.Exception"/> protected internal override void StoreRMDTMasterKeyState(DelegationKey masterKey) { lock (this) { Path nodeCreatePath = GetNodePath(rmDTSecretManagerRoot, DelegationKeyPrefix + masterKey .GetKeyId()); ByteArrayOutputStream os = new ByteArrayOutputStream(); using (DataOutputStream fsOut = new DataOutputStream(os)) { Log.Info("Storing RMDelegationKey_" + masterKey.GetKeyId()); masterKey.Write(fsOut); WriteFileWithRetries(nodeCreatePath, os.ToByteArray(), true); } } }
/// <exception cref="System.IO.IOException"/> private static byte[] BuildTokenMasterKeyData(DelegationKey key) { ByteArrayOutputStream memStream = new ByteArrayOutputStream(); DataOutputStream dataStream = new DataOutputStream(memStream); try { key.Write(dataStream); dataStream.Close(); } finally { IOUtils.Cleanup(Log, dataStream); } return(memStream.ToByteArray()); }