ESAPI-C 1.0
The OWASP Enterprise Security API for C

properties.c File Reference

An Encrypted Properties module implementation. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "crypto.h"
#include "properties.h"
#include "log.h"
#include "user.h"

Go to the source code of this file.

Defines

#define LF   0x0A
#define CR   0x0D

Functions

char * getline (char *s, int n, FILE *f)
int putline (char *s, FILE *f)
char * get_property (map_t *map, struct esapi_ctx *ctx, const char *key)
 Get the plaintext property value for the given key from the given encrypted properties map.
char * get_property_or_default (map_t *map, struct esapi_ctx *ctx, const char *key, const char *default_value)
 Get the plaintext property value for the given key from the given encrypted properties map.
char * set_property (map_t **maph, struct esapi_ctx *ctx, const char *key, const char *value)
 Set the given property key-value pair in the given encrypted properties map.
char ** keys (map_t *map)
 Get a list of all keys in the given encrypted properties map.
void clear_properties (map_t *map)
map_tload_properties (const char *filename)
 Read encrypted properties from the given file.
void store_properties (map_t *map, const char *filename)
 Write encrypted properties to the given file.

Detailed Description

An Encrypted Properties module implementation.

Since:
January 30, 2011

Definition in file properties.c.


Function Documentation

char* get_property ( map_t ,
struct esapi_ctx ,
const char *   
)

Get the plaintext property value for the given key from the given encrypted properties map.

The property value is Base64 decoded and decrypted for the caller.

Returns:
A character array containing a plaintext property value, or NULL if the property was not found.

Definition at line 38 of file properties.c.

References esapi_decrypt(), and esapi_log_error().

Referenced by get_property_or_default().

char* get_property_or_default ( map_t ,
struct esapi_ctx ,
const char *  ,
const char *   
)

Get the plaintext property value for the given key from the given encrypted properties map.

If the property is not found, return the given default value.

Returns:
A character array containing a plaintext property value.

Definition at line 58 of file properties.c.

References get_property().

char** keys ( map_t )

Get a list of all keys in the given encrypted properties map.

Returns:
An array of character arrays each containing a property key.

Definition at line 105 of file properties.c.

References keys().

Referenced by keys().

map_t* load_properties ( const char *  )

Read encrypted properties from the given file.

Returns:
A head map_t structure pointer for the loaded properties.

Definition at line 134 of file properties.c.

References MAX_PROPERTY_LINE_LENGTH.

char* set_property ( map_t **  ,
struct esapi_ctx ,
const char *  ,
const char *   
)

Set the given property key-value pair in the given encrypted properties map.

The value is encrypted and Base64 encoded before it is added to the map.

Returns:
A character array containing the plaintext property value that was set, or NULL on a failure.

Definition at line 69 of file properties.c.

References esapi_encrypt(), and esapi_log_error().

 All Data Structures Files Functions Variables Typedefs Defines