diff --git a/CASA/micasad/verbs/ObjectSerialization.cs b/CASA/micasad/verbs/ObjectSerialization.cs index ef3e756b..480dceca 100644 --- a/CASA/micasad/verbs/ObjectSerialization.cs +++ b/CASA/micasad/verbs/ObjectSerialization.cs @@ -234,15 +234,15 @@ namespace sscs.verbs case MiCasaRequestReply.VERB_CREATE_POLICY_DIR: { return DoCreatePolicyDir(ssStore, wo); - } - case MiCasaRequestReply.VERB_GET_CREATE_TIME: - { - return DoGetCreateTime(ssStore, wo); - } - case MiCasaRequestReply.VERB_GET_MODIFIED_TIME: - { - return DoGetModifiedTime(ssStore, wo); - } + } + case MiCasaRequestReply.VERB_GET_CREATE_TIME: + { + return DoGetCreateTime(ssStore, wo); + } + case MiCasaRequestReply.VERB_GET_MODIFIED_TIME: + { + return DoGetModifiedTime(ssStore, wo); + } default: @@ -262,80 +262,80 @@ namespace sscs.verbs } return wo; - } - - - private WrappedObject DoGetModifiedTime(SecretStore ssStore, WrappedObject wo) - { - return DoGetTimeStamp(ssStore, wo, false); - } - - private WrappedObject DoGetCreateTime(SecretStore ssStore, WrappedObject wo) - { - return DoGetTimeStamp(ssStore, wo, true); - } - - private WrappedObject DoGetTimeStamp(SecretStore ssStore, WrappedObject wo, bool bGetCreateTime) - { - string keychainID = wo.GetKeychainID(); - string secretID = wo.GetSecretID(); - string keyID = wo.GetKeyID(); - - KeyChain keyChain; - - if (keychainID != null) - keyChain = ssStore.GetKeyChain(keychainID); - else - keyChain = ssStore.GetKeyChainDefault(); - - Secret secret = null; - DateTime dt = new DateTime(0); - - if (keyChain.CheckIfSecretExists(secretID) == false) - { - wo.SetError(constants.RetCodes.FAILURE, "Secret does not exist"); - } - else - { - secret = keyChain.GetSecret(secretID); - if (keyID != null) - { - KeyValue kv = secret.GetKeyValue(keyID); - if (kv != null) - { - if (bGetCreateTime) - { - dt = kv.CreatedTime; - } - else - { - dt = kv.ModifiedTime; - } - } - else - { - wo.SetError(constants.RetCodes.FAILURE, "Secret does not exist"); - } - } - else - { - if (bGetCreateTime) - { - dt = secret.CreatedTime; - } - else - { - dt = secret.ModifiedTime; - } - } - } - - if (dt != null) - { - wo.SetObject(dt); - wo.SetError(constants.RetCodes.SUCCESS, null); - } - return wo; + } + + + private WrappedObject DoGetModifiedTime(SecretStore ssStore, WrappedObject wo) + { + return DoGetTimeStamp(ssStore, wo, false); + } + + private WrappedObject DoGetCreateTime(SecretStore ssStore, WrappedObject wo) + { + return DoGetTimeStamp(ssStore, wo, true); + } + + private WrappedObject DoGetTimeStamp(SecretStore ssStore, WrappedObject wo, bool bGetCreateTime) + { + string keychainID = wo.GetKeychainID(); + string secretID = wo.GetSecretID(); + string keyID = wo.GetKeyID(); + + KeyChain keyChain; + + if (keychainID != null) + keyChain = ssStore.GetKeyChain(keychainID); + else + keyChain = ssStore.GetKeyChainDefault(); + + Secret secret = null; + DateTime dt = new DateTime(0); + + if (keyChain.CheckIfSecretExists(secretID) == false) + { + wo.SetError(constants.RetCodes.FAILURE, "Secret does not exist"); + } + else + { + secret = keyChain.GetSecret(secretID); + if (keyID != null) + { + KeyValue kv = secret.GetKeyValue(keyID); + if (kv != null) + { + if (bGetCreateTime) + { + dt = kv.CreatedTime; + } + else + { + dt = kv.ModifiedTime; + } + } + else + { + wo.SetError(constants.RetCodes.FAILURE, "Secret does not exist"); + } + } + else + { + if (bGetCreateTime) + { + dt = secret.CreatedTime; + } + else + { + dt = secret.ModifiedTime; + } + } + } + + if (dt.Ticks > 0) + { + wo.SetObject(dt); + wo.SetError(constants.RetCodes.SUCCESS, null); + } + return wo; } private WrappedObject DoCreatePolicyDir(SecretStore ssStore, WrappedObject wo)