Defines | Functions

certificates.c File Reference

Certificate management functions. More...

#include <string.h>
#include <unistd.h>
#include <assert.h>
#include <libxml/tree.h>
#include <sqlite3.h>
#include <eurephia_nullsafe.h>
#include <eurephia_context.h>
#include <eurephia_log.h>
#include <eurephia_xml.h>
#include <eurephia_values.h>
#include <eurephiadb_session_struct.h>
#include <eurephiadb_mapping.h>
#include <passwd.h>
#include <eurephiadb_driver.h>
#include "../sqlite.h"
#include "../fieldmapping.h"
Include dependency graph for certificates.c:

Go to the source code of this file.

Defines

#define FMAP_CERTS

Functions

static xmlDoc * certificate_list (eurephiaCTX *ctx, eDBfieldMap *srch_map, const char *sortkeys)
static xmlDoc * certificate_add (eurephiaCTX *ctx, eDBfieldMap *crtinf_map)
static xmlDoc * certificate_delete (eurephiaCTX *ctx, eDBfieldMap *crtinf_map)
xmlDoc * eDBadminCertificate (eurephiaCTX *ctx, xmlDoc *qryxml)

Detailed Description

Certificate management functions.

Author:
David Sommerseth <dazo@users.sourceforge.net>
Date:
2009-09-13

Definition in file certificates.c.


Define Documentation

#define FMAP_CERTS

fieldmapping.h: Include declaration of tbl_sqlite_certs

Definition at line 55 of file certificates.c.


Function Documentation

static xmlDoc* certificate_add ( eurephiaCTX ctx,
eDBfieldMap crtinf_map 
) [static]

Internal function. Registers a new certificate and saves it in the database

Parameters:
ctx eurephiaCTX
crtinf_map eDBfieldMap containing certificate info to be registered
Returns:
Returns an eurephia ResultMsg XML document with a result string. On fatal errors, NULL is returned

< Messages intended when debugging. Only for log level > 10

< The context is used via the eurephiadm console utility

< The context is used via a web based utility

< Alias for LOG_CRITICAL

< Operation failed and might have been aborted. Log level always 0

< Alias for LOG_FATAL

< Operation failed and cannot continue. Log level always < 2

Definition at line 136 of file certificates.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static xmlDoc* certificate_delete ( eurephiaCTX ctx,
eDBfieldMap crtinf_map 
) [static]

Internal function. Deletes one or more certificates from the database

Parameters:
ctx eurephiaCTX
crtinf_map eDBfieldMap with information about certificate(s) to delete
Returns:
Returns an eurephia ResultMsg XML document with a result string. On fatal errors, NULL is returned

< Messages intended when debugging. Only for log level > 10

< The context is used via the eurephiadm console utility

< The context is used via a web based utility

< Alias for LOG_CRITICAL

< Operation failed and might have been aborted. Log level always 0

< Alias for LOG_FATAL

< Operation failed and cannot continue. Log level always < 2

Definition at line 193 of file certificates.c.

Here is the call graph for this function:

Here is the caller graph for this function:

static xmlDoc* certificate_list ( eurephiaCTX ctx,
eDBfieldMap srch_map,
const char *  sortkeys 
) [static]

Internal function. Retrieves info about one or more certificates

Parameters:
ctx eurephiaCTX
srch_map eDBfieldMap defining the query
sortkeys String containing the sort order of the fields
Returns:
Returns a valid xmlDoc containing the query, or a eurephia XML document with an error message.

< Messages intended when debugging. Only for log level > 10

< Alias for LOG_ERROR, in case it is not defined

< API errors but not sever, program can continue to run

Definition at line 69 of file certificates.c.

Here is the call graph for this function:

Here is the caller graph for this function:

xmlDoc* eDBadminCertificate ( eurephiaCTX ctx,
xmlDoc *  qryxml 
)

Function for listing, registering new or deleting certificates in the database

Version:
API version level 2
Parameters:
ctx eurephiaCTX
qryxml XML document with information about the operation

Skeleton of an XML document used for eDBadminCertificate()

    <eurephia format="1">
      <certificates mode="{list|register|delete}">
        <fieldMapping table="certificates">
            <{field name}>{field value}</{field name}>
            ...
            <{field name}>{field value}</{field name}>
        </fieldMapping>
        [<sortkeys>{field name}[, {field name}...]</sortkeys>]
      </certificates>
    </eurephia>

Valid field names are: depth, digest, common_name, org, email and certid. For list and delete mode, all field names can be used to narrow the search query. In register mode all fields are required, except certid which must not be given.

The sortkeys tag will only be used in list mode, and it takes a list of comma separated field names.

Returns:
When mode is "list", it will return an XML document with all found certificates, otherwise NULL. If mode is "register" or "delete" an eurephia ResultMsg XML document will be returned with the result of the operation, or NULL on fatal errors.

Skeleton of a result document from a "list" mode query.

 <eurephia format="1">
    <certificates certificates={number of found certs}">
        <certificate certid="{int}" depth="{int}" registered="{date+time}">
            <digest>{SHA1 digest of cert}</digest>
            <common_name>{(CN) common name of cert}</common_name>
            <organisation>{(O) organisation name of cert}</organisation>
            <email>{(emailAddr) e-mail address found in cert}</email>
        </certificate>
    </certificates>
 </eurephia>
See also:
eurephiaXML_CreateDoc(), eurephiaXML_ParseResultMsg(), eurephiaXML_getRoot()

< Messages intended when debugging. Only for log level > 10

< The context is used via the eurephiadm console utility

< The context is used via a web based utility

< Alias for LOG_CRITICAL

< Operation failed and might have been aborted. Log level always 0

< Alias for LOG_CRITICAL

< Operation failed and might have been aborted. Log level always 0

< Alias for LOG_ERROR, in case it is not defined

< API errors but not sever, program can continue to run

< Alias for LOG_ERROR, in case it is not defined

< API errors but not sever, program can continue to run

< Alias for LOG_ERROR, in case it is not defined

< API errors but not sever, program can continue to run

Definition at line 236 of file certificates.c.

Here is the call graph for this function:

 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines