AddAuditEntry() public method

public AddAuditEntry ( SecretAuditEntry entry ) : void
entry SecretAuditEntry
return void
Exemplo n.º 1
0
        public override async Task Write(Secret secret, string clientOperation)
        {
            // Try to read the secret
            var existingSecret = await UnauditedReadSecret(secret.Name, GetFileName(secret.Name));

            // Try to undelete the secret, in case a deleted form exists
            if (existingSecret == null && await Undelete(secret.Name, clientOperation))
            {
                existingSecret = await UnauditedReadSecret(secret.Name, GetFileName(secret.Name));
            }

            if (existingSecret != null)
            {
                // Copy the new data and add audit records
                existingSecret.AddAuditEntry(await SecretAuditEntry.CreateForLocalUser(clientOperation, SecretAuditAction.Changed, existingSecret.Value));
                existingSecret.Update(secret);

                // Now resave the existing secret instead
                secret = existingSecret;
            }
            else
            {
                // Add an audit record
                secret.AddAuditEntry(await SecretAuditEntry.CreateForLocalUser(clientOperation, SecretAuditAction.Created));
            }

            // Write the secret
            await UnauditedWriteSecret(secret);
        }
Exemplo n.º 2
0
        public override async Task Write(Secret secret, string clientOperation)
        {
            // Try to read the secret
            var existingSecret = await UnauditedReadSecret(secret.Name, GetFileName(secret.Name));
            
            // Try to undelete the secret, in case a deleted form exists
            if (existingSecret == null && await Undelete(secret.Name, clientOperation))
            {
                existingSecret = await UnauditedReadSecret(secret.Name, GetFileName(secret.Name));
            }

            if (existingSecret != null)
            {
                // Copy the new data and add audit records
                existingSecret.AddAuditEntry(await SecretAuditEntry.CreateForLocalUser(clientOperation, SecretAuditAction.Changed, existingSecret.Value));
                existingSecret.Update(secret);

                // Now resave the existing secret instead
                secret = existingSecret;
            }
            else
            {
                // Add an audit record
                secret.AddAuditEntry(await SecretAuditEntry.CreateForLocalUser(clientOperation, SecretAuditAction.Created));
            }

            // Write the secret
            await UnauditedWriteSecret(secret);
        }