ESAPI-C 1.0
The OWASP Enterprise Security API for C

access_ref.c File Reference

An Access Reference Map module implementation. More...

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "access_ref.h"

Go to the source code of this file.

Functions

bool _unique_keys (const char *k, const char *v)
char * esapi_get_indirect_reference (const char *direct)
 Returns the indirect object reference for the given direct object reference.
char * esapi_get_direct_reference (const char *indirect)
 Returns the direct object reference (original value) for the given indirect object reference.
bool esapi_remove_indirect_reference (const char *indirect)
 Removes the indirect object reference from the map.
bool esapi_remove_direct_reference (const char *direct)
 Removes the direct object reference from the map.
bool esapi_put_reference (const char *k, const char *v)
 Adds an entry to the map.
char * esapi_get_unique_reference ()
 Return a unique token string suitable for use as an indirect reference.

Variables

map_tv_map = NULL
 Value-to-key map.
map_tk_map = NULL
 Key-to-value map.
map_ts
map_tf

Detailed Description

An Access Reference Map module implementation.

The reference implementation is based on 2 uthash hashmaps to support two-way lookups (direct-to-indirect and indirect-to-direct). The indirect reference generator produces random keys. A custom implementation might alternatively provide a generator for incrementing integer keys.

Todo:
To support more than one reference map per process, remove the global map_t variables and change all functions to take a parameter that is an array of two map_t handles.
Todo:
The put function should be replaced by an add function that take only a value param (plus the map).
Todo:
esapi_fill_random_token() does not really need an ESAPI context parameter, but its signature asks for one.
Since:
January 30, 2011

Definition in file access_ref.c.


Function Documentation

char* esapi_get_direct_reference ( const char *  )

Returns the direct object reference (original value) for the given indirect object reference.

Parameters:
Acharacter array containing an indirect object reference
Returns:
A character array containing a direct object reference

Definition at line 64 of file access_ref.c.

char* esapi_get_indirect_reference ( const char *  )

Returns the indirect object reference for the given direct object reference.

Parameters:
Acharacter array containing a direct object reference
Returns:
A character array containing an indirect object reference

Definition at line 50 of file access_ref.c.

char* esapi_get_unique_reference ( )

Return a unique token string suitable for use as an indirect reference.

Returns:
A character array containing an indirect object reference

Definition at line 131 of file access_ref.c.

References esapi_fill_random_token(), and KEY_LEN.

bool esapi_put_reference ( const char *  ,
const char *   
)

Adds an entry to the map.

The indirect reference should be obtained by calling esapi_get_unique_reference().

Parameters:
Acharacter array containing an indirect object reference
Acharacter array containing a direct object reference
See also:
esapi_get_unique_reference()

Definition at line 110 of file access_ref.c.

bool esapi_remove_direct_reference ( const char *  )

Removes the direct object reference from the map.

Parameters:
Acharacter array containing a direct object reference

Definition at line 95 of file access_ref.c.

bool esapi_remove_indirect_reference ( const char *  )

Removes the indirect object reference from the map.

Parameters:
Acharacter array containing an indirect object reference

Definition at line 78 of file access_ref.c.

 All Data Structures Files Functions Variables Typedefs Defines