An X.509 certificate revocation list (CRL) record.
Represents an X.509 certificate revocation list record loaded from a database.
示例#1
0
        /// <summary>
        /// Gets the database command to insert the specified CRL record.
        /// </summary>
        /// <remarks>
        /// Gets the database command to insert the specified CRL record.
        /// </remarks>
        /// <returns>The database command.</returns>
        /// <param name="record">The CRL record.</param>
        protected override DbCommand GetInsertCommand(X509CrlRecord record)
        {
            var statement = new StringBuilder("INSERT INTO CRLS(");
            var variables = new StringBuilder("VALUES(");
            var columns   = X509CrlRecord.ColumnNames;
            var command   = connection.CreateCommand();

            for (int i = 1; i < columns.Length; i++)
            {
                if (i > 1)
                {
                    statement.Append(", ");
                    variables.Append(", ");
                }

                var value    = GetValue(record, columns[i]);
                var variable = "@" + columns[i];

                command.AddParameterWithValue(variable, value);
                statement.Append(columns[i]);
                variables.Append(variable);
            }

            statement.Append(')');
            variables.Append(')');

            command.CommandText = statement + " " + variables;
            command.CommandType = CommandType.Text;

            return(command);
        }
        X509CrlRecord LoadCrlRecord(DbDataReader reader, X509CrlParser parser, ref byte[] buffer)
        {
            var record = new X509CrlRecord();

            for (int i = 0; i < reader.FieldCount; i++)
            {
                switch (reader.GetName(i).ToUpperInvariant())
                {
                case "CRL":
                    record.Crl = DecodeX509Crl(reader, parser, i, ref buffer);
                    break;

                case "THISUPDATE":
                    record.ThisUpdate = DateTime.SpecifyKind(reader.GetDateTime(i), DateTimeKind.Utc);
                    break;

                case "NEXTUPDATE":
                    record.NextUpdate = DateTime.SpecifyKind(reader.GetDateTime(i), DateTimeKind.Utc);
                    break;

                case "DELTA":
                    record.IsDelta = reader.GetBoolean(i);
                    break;

                case "ID":
                    record.Id = reader.GetInt32(i);
                    break;
                }
            }

            return(record);
        }
示例#3
0
        /// <summary>
        /// Gets the database command to update the specified CRL record.
        /// </summary>
        /// <returns>The database command.</returns>
        /// <param name="record">The CRL record.</param>
        protected override IDbCommand GetUpdateCommand(X509CrlRecord record)
        {
            var statement = new StringBuilder("UPDATE CRLS SET ");
            var columns   = X509CrlRecord.ColumnNames;
            var command   = sqlite.CreateCommand();

            for (int i = 1; i < columns.Length; i++)
            {
                var value    = GetValue(record, columns[i]);
                var variable = "@" + columns[i];

                if (i > 1)
                {
                    statement.Append(", ");
                }

                statement.Append(columns[i]);
                statement.Append(" = ");
                statement.Append(variable);

                command.Parameters.AddWithValue(variable, value);
            }

            statement.Append(" WHERE ID = @ID");
            command.Parameters.AddWithValue("@ID", record.Id);

            command.CommandText = statement.ToString();
            command.CommandType = CommandType.Text;

            return(command);
        }
示例#4
0
        /// <summary>
        /// Gets the database command to delete the specified CRL record.
        /// </summary>
        /// <remarks>
        /// Gets the database command to delete the specified CRL record.
        /// </remarks>
        /// <returns>The database command.</returns>
        /// <param name="record">The record.</param>
        protected override DbCommand GetDeleteCommand(X509CrlRecord record)
        {
            var command = connection.CreateCommand();

            command.CommandText = "DELETE FROM CRLS WHERE ID = @ID";
            command.AddParameterWithValue("@ID", record.Id);
            command.CommandType = CommandType.Text;

            return(command);
        }
        /// <summary>
        /// Update the specified CRL record.
        /// </summary>
        /// <remarks>
        /// Updates the specified fields of the record in the database.
        /// </remarks>
        /// <param name="record">The CRL record.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="record"/> is <c>null</c>.
        /// </exception>
        public void Update(X509CrlRecord record)
        {
            if (record == null)
            {
                throw new ArgumentNullException(nameof(record));
            }

            using (var command = GetUpdateCommand(record))
                command.ExecuteNonQuery();
        }
示例#6
0
        /// <summary>
        /// Add the specified CRL record.
        /// </summary>
        /// <remarks>
        /// Adds the specified CRL record to the database.
        /// </remarks>
        /// <param name="record">The CRL record.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="record"/> is <c>null</c>.
        /// </exception>
        public void Add(X509CrlRecord record)
        {
            if (record == null)
            {
                throw new ArgumentNullException(nameof(record));
            }

            using (var command = GetInsertCommand(record)) {
                command.ExecuteNonQuery();
            }
        }
        /// <summary>
        /// Remove the specified CRL record.
        /// </summary>
        /// <remarks>
        /// Removes the specified CRL record from the database.
        /// </remarks>
        /// <param name="record">The CRL record.</param>
        /// <exception cref="System.ArgumentNullException">
        /// <paramref name="record"/> is <c>null</c>.
        /// </exception>
        public void Remove(X509CrlRecord record)
        {
            if (record == null)
            {
                throw new ArgumentNullException("record");
            }

            using (var command = GetDeleteCommand(record)) {
                command.ExecuteNonQuery();
            }
        }
        /// <summary>
        /// Gets the value for the specified column.
        /// </summary>
        /// <remarks>
        /// Gets the value for the specified column.
        /// </remarks>
        /// <returns>The value.</returns>
        /// <param name="record">The CRL record.</param>
        /// <param name="columnName">The column name.</param>
        /// <exception cref="System.ArgumentException">
        /// <paramref name="columnName"/> is not a known column name.
        /// </exception>
        protected static object GetValue(X509CrlRecord record, string columnName)
        {
            switch (columnName)
            {
            //case "ID": return record.Id;
            case "DELTA": return(record.IsDelta);

            case "ISSUERNAME": return(record.IssuerName);

            case "THISUPDATE": return(record.ThisUpdate);

            case "NEXTUPDATE": return(record.NextUpdate);

            case "CRL": return(record.Crl.GetEncoded());

            default: throw new ArgumentException(string.Format("Unknown column name: {0}", columnName), nameof(columnName));
            }
        }
示例#9
0
        /// <summary>
        /// Gets the value for the specified column.
        /// </summary>
        /// <returns>The value.</returns>
        /// <param name="record">The CRL record.</param>
        /// <param name="columnName">The column name.</param>
        protected static object GetValue(X509CrlRecord record, string columnName)
        {
            switch (columnName)
            {
            case "ID": return(record.Id);

            case "DELTA": return(record.IsDelta);

            case "ISSUERNAME": return(record.IssuerName);

            case "THISUPDATE": return(record.ThisUpdate);

            case "NEXTUPDATE": return(record.NextUpdate);

            case "CRL": return(record.Crl.GetEncoded());

            default: throw new ArgumentOutOfRangeException("columnName");
            }
        }
示例#10
0
		/// <summary>
		/// Gets the database command to update the specified CRL record.
		/// </summary>
		/// <remarks>
		/// Gets the database command to update the specified CRL record.
		/// </remarks>
		/// <returns>The database command.</returns>
		/// <param name="record">The CRL record.</param>
		protected override DbCommand GetUpdateCommand (X509CrlRecord record)
		{
			var statement = new StringBuilder ("UPDATE CRLS SET ");
			var columns = X509CrlRecord.ColumnNames;
			var command = connection.CreateCommand ();

			for (int i = 1; i < columns.Length; i++) {
				var value = GetValue (record, columns[i]);
				var variable = "@" + columns[i];

				if (i > 1)
					statement.Append (", ");

				statement.Append (columns[i]);
				statement.Append (" = ");
				statement.Append (variable);

				command.AddParameterWithValue (variable, value);
			}

			statement.Append (" WHERE ID = @ID");
			command.AddParameterWithValue ("@ID", record.Id);

			command.CommandText = statement.ToString ();
			command.CommandType = CommandType.Text;

			return command;
		}
示例#11
0
 static object GetValue(X509CrlRecord record, string columnName)
 {
     switch (columnName) {
     case "ID": return record.Id;
     case "DELTA": return record.IsDelta;
     case "ISSUERNAME": return record.IssuerName;
     case "THISUPDATE": return record.ThisUpdate;
     case "NEXTUPDATE": return record.NextUpdate;
     case "CRL": return record.Crl.GetEncoded ();
     default: throw new ArgumentOutOfRangeException ();
     }
 }
示例#12
0
        SqliteCommand GetDeleteCommand(X509CrlRecord record)
        {
            var command = sqlite.CreateCommand ();

            command.CommandText = "DELETE FROM CRLS WHERE ID = @ID";
            command.Parameters.AddWithValue ("@ID", record.Id);
            command.CommandType = CommandType.Text;

            return command;
        }
示例#13
0
		/// <summary>
		/// Update the specified CRL record.
		/// </summary>
		/// <remarks>
		/// Updates the specified fields of the record in the database.
		/// </remarks>
		/// <param name="record">The CRL record.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="record"/> is <c>null</c>.
		/// </exception>
		public void Update (X509CrlRecord record)
		{
			if (record == null)
				throw new ArgumentNullException ("record");

			using (var command = GetUpdateCommand (record)) {
				command.ExecuteNonQuery ();
			}
		}
示例#14
0
		/// <summary>
		/// Gets the database command to update the specified CRL record.
		/// </summary>
		/// <remarks>
		/// Gets the database command to update the specified CRL record.
		/// </remarks>
		/// <returns>The database command.</returns>
		/// <param name="record">The CRL record.</param>
		protected abstract IDbCommand GetUpdateCommand (X509CrlRecord record);
示例#15
0
		/// <summary>
		/// Gets the database command to insert the specified CRL record.
		/// </summary>
		/// <remarks>
		/// Gets the database command to insert the specified CRL record.
		/// </remarks>
		/// <returns>The database command.</returns>
		/// <param name="record">The CRL record.</param>
		protected abstract IDbCommand GetInsertCommand (X509CrlRecord record);
示例#16
0
		/// <summary>
		/// Gets the value for the specified column.
		/// </summary>
		/// <remarks>
		/// Gets the value for the specified column.
		/// </remarks>
		/// <returns>The value.</returns>
		/// <param name="record">The CRL record.</param>
		/// <param name="columnName">The column name.</param>
		/// <exception cref="System.ArgumentException">
		/// <paramref name="columnName"/> is not a known column name.
		/// </exception>
		protected static object GetValue (X509CrlRecord record, string columnName)
		{
			switch (columnName) {
			case "ID": return record.Id;
			case "DELTA": return record.IsDelta;
			case "ISSUERNAME": return record.IssuerName;
			case "THISUPDATE": return record.ThisUpdate;
			case "NEXTUPDATE": return record.NextUpdate;
			case "CRL": return record.Crl.GetEncoded ();
			default: throw new ArgumentException (string.Format ("Unknown column name: {0}", columnName), "columnName");
			}
		}
示例#17
0
		X509CrlRecord LoadCrlRecord (IDataRecord reader, X509CrlParser parser, ref byte[] buffer)
		{
			var record = new X509CrlRecord ();

			for (int i = 0; i < reader.FieldCount; i++) {
				switch (reader.GetName (i).ToUpperInvariant ()) {
				case "CRL":
					record.Crl = DecodeX509Crl (reader, parser, i, ref buffer);
					break;
				case "THISUPDATE":
					record.ThisUpdate = reader.GetDateTime (i);
					break;
				case "NEXTUPDATE":
					record.NextUpdate = reader.GetDateTime (i);
					break;
				case "DELTA":
					record.IsDelta = reader.GetBoolean (i);
					break;
				case "ID":
					record.Id = reader.GetInt32 (i);
					break;
				}
			}

			return record;
		}
 /// <summary>
 /// Gets the database command to delete the specified CRL record.
 /// </summary>
 /// <remarks>
 /// Gets the database command to delete the specified CRL record.
 /// </remarks>
 /// <returns>The database command.</returns>
 /// <param name="record">The record.</param>
 protected abstract IDbCommand GetDeleteCommand(X509CrlRecord record);
 /// <summary>
 /// Gets the database command to insert the specified CRL record.
 /// </summary>
 /// <remarks>
 /// Gets the database command to insert the specified CRL record.
 /// </remarks>
 /// <returns>The database command.</returns>
 /// <param name="record">The CRL record.</param>
 protected abstract DbCommand GetInsertCommand(X509CrlRecord record);
示例#20
0
		/// <summary>
		/// Gets the database command to insert the specified CRL record.
		/// </summary>
		/// <remarks>
		/// Gets the database command to insert the specified CRL record.
		/// </remarks>
		/// <returns>The database command.</returns>
		/// <param name="record">The CRL record.</param>
		protected override DbCommand GetInsertCommand (X509CrlRecord record)
		{
			var statement = new StringBuilder ("INSERT INTO CRLS(");
			var variables = new StringBuilder ("VALUES(");
			var columns = X509CrlRecord.ColumnNames;
			var command = connection.CreateCommand ();

			for (int i = 1; i < columns.Length; i++) {
				if (i > 1) {
					statement.Append (", ");
					variables.Append (", ");
				}

				var value = GetValue (record, columns[i]);
				var variable = "@" + columns[i];

				command.AddParameterWithValue (variable, value);
				statement.Append (columns[i]);
				variables.Append (variable);
			}

			statement.Append (')');
			variables.Append (')');

			command.CommandText = statement + " " + variables;
			command.CommandType = CommandType.Text;

			return command;
		}
示例#21
0
		/// <summary>
		/// Gets the database command to delete the specified CRL record.
		/// </summary>
		/// <remarks>
		/// Gets the database command to delete the specified CRL record.
		/// </remarks>
		/// <returns>The database command.</returns>
		/// <param name="record">The record.</param>
		protected override DbCommand GetDeleteCommand (X509CrlRecord record)
		{
			var command = connection.CreateCommand ();

			command.CommandText = "DELETE FROM CRLS WHERE ID = @ID";
			command.AddParameterWithValue ("@ID", record.Id);
			command.CommandType = CommandType.Text;

			return command;
		}
示例#22
0
		/// <summary>
		/// Gets the database command to delete the specified CRL record.
		/// </summary>
		/// <remarks>
		/// Gets the database command to delete the specified CRL record.
		/// </remarks>
		/// <returns>The database command.</returns>
		/// <param name="record">The record.</param>
		protected abstract DbCommand GetDeleteCommand (X509CrlRecord record);
 /// <summary>
 /// Gets the database command to update the specified CRL record.
 /// </summary>
 /// <remarks>
 /// Gets the database command to update the specified CRL record.
 /// </remarks>
 /// <returns>The database command.</returns>
 /// <param name="record">The CRL record.</param>
 protected abstract DbCommand GetUpdateCommand(X509CrlRecord record);
		/// <summary>
		/// Remove the specified CRL record.
		/// </summary>
		/// <remarks>
		/// Removes the specified CRL record from the database.
		/// </remarks>
		/// <param name="record">The CRL record.</param>
		/// <exception cref="System.ArgumentNullException">
		/// <paramref name="record"/> is <c>null</c>.
		/// </exception>
		public void Remove (X509CrlRecord record)
		{
			if (record == null)
				throw new ArgumentNullException (nameof (record));

			using (var command = GetDeleteCommand (record)) {
				command.ExecuteNonQuery ();
			}
		}