public override bool Equals(object obj) { if (this == obj) { return(true); } if (!(obj is MasterKey)) { return(false); } MasterKey other = (MasterKey)obj; if (this.GetKeyId() != other.GetKeyId()) { return(false); } if (!this.GetBytes().Equals(other.GetBytes())) { return(false); } return(true); }
/// <exception cref="System.IO.IOException"/> public virtual void Recover() { lock (this) { NMStateStoreService.RecoveredContainerTokensState state = stateStore.LoadContainerTokensState (); MasterKey key = state.GetCurrentMasterKey(); if (key != null) { base.currentMasterKey = new MasterKeyData(key, CreateSecretKey(((byte[])key.GetBytes ().Array()))); } key = state.GetPreviousMasterKey(); if (key != null) { previousMasterKey = new MasterKeyData(key, CreateSecretKey(((byte[])key.GetBytes( ).Array()))); } // restore the serial number from the current master key if (base.currentMasterKey != null) { base.serialNo = base.currentMasterKey.GetMasterKey().GetKeyId() + 1; } foreach (KeyValuePair <ContainerId, long> entry in state.GetActiveTokens()) { ContainerId containerId = entry.Key; long expTime = entry.Value; IList <ContainerId> containerList = recentlyStartedContainerTracker[expTime]; if (containerList == null) { containerList = new AList <ContainerId>(); recentlyStartedContainerTracker[expTime] = containerList; } if (!containerList.Contains(containerId)) { containerList.AddItem(containerId); } } } }
public virtual void SetMasterKey(MasterKey masterKeyRecord) { lock (this) { // Update keys only if the key has changed. if (base.currentMasterKey == null || base.currentMasterKey.GetMasterKey().GetKeyId () != masterKeyRecord.GetKeyId()) { Log.Info("Rolling master-key for container-tokens, got key with id " + masterKeyRecord .GetKeyId()); if (base.currentMasterKey != null) { UpdatePreviousMasterKey(base.currentMasterKey); } UpdateCurrentMasterKey(new MasterKeyData(masterKeyRecord, CreateSecretKey(((byte[] )masterKeyRecord.GetBytes().Array())))); } } }
public virtual void Recover(RMStateStore.RMState state) { if (state.GetAMRMTokenSecretManagerState() != null) { // recover the current master key MasterKey currentKey = state.GetAMRMTokenSecretManagerState().GetCurrentMasterKey (); this.currentMasterKey = new MasterKeyData(currentKey, CreateSecretKey(((byte[])currentKey .GetBytes().Array()))); // recover the next master key if not null MasterKey nextKey = state.GetAMRMTokenSecretManagerState().GetNextMasterKey(); if (nextKey != null) { this.nextMasterKey = new MasterKeyData(nextKey, CreateSecretKey(((byte[])nextKey. GetBytes().Array()))); this.timer.Schedule(new AMRMTokenSecretManager.NextKeyActivator(this), this.activationDelay ); } } }
/// <exception cref="System.IO.IOException"/> public virtual void Recover() { lock (this) { NMStateStoreService.RecoveredNMTokensState state = stateStore.LoadNMTokensState(); MasterKey key = state.GetCurrentMasterKey(); if (key != null) { base.currentMasterKey = new MasterKeyData(key, CreateSecretKey(((byte[])key.GetBytes ().Array()))); } key = state.GetPreviousMasterKey(); if (key != null) { previousMasterKey = new MasterKeyData(key, CreateSecretKey(((byte[])key.GetBytes( ).Array()))); } // restore the serial number from the current master key if (base.currentMasterKey != null) { base.serialNo = base.currentMasterKey.GetMasterKey().GetKeyId() + 1; } foreach (KeyValuePair <ApplicationAttemptId, MasterKey> entry in state.GetApplicationMasterKeys ()) { key = entry.Value; oldMasterKeys[entry.Key] = new MasterKeyData(key, CreateSecretKey(((byte[])key.GetBytes ().Array()))); } // reconstruct app to app attempts map appToAppAttemptMap.Clear(); foreach (ApplicationAttemptId attempt in oldMasterKeys.Keys) { ApplicationId app = attempt.GetApplicationId(); IList <ApplicationAttemptId> attempts = appToAppAttemptMap[app]; if (attempts == null) { attempts = new AList <ApplicationAttemptId>(); appToAppAttemptMap[app] = attempts; } attempts.AddItem(attempt); } } }