Sun OpenSSO Enterprise 8.0 C API Reference for Application and Web Policy Agent Developers

am_resource_traits_t

Contains the functions to return resource traits that will be used to compare with a user's defined policy and evaluate the access request.

Syntax

#include "am_policy.h"
typedef struct am_resource_traits {
    am_resource_match_t (*cmp_func_ptr)(const struct am_resource_traits *rsrc_traits,
                                        const char *policy_res_name,
                                        const char *resource_name,
                                        boolean_t use_patterns);
    boolean_t (*has_patterns)(const char *resource_name);
    boolean_t (*get_resource_root)(const char *resource_name,
                                   char *root_resource_name,
                                   size_t buflength);
    boolean_t ignore_case;
    char separator;
    void (*canonicalize)(const char *resource, char **c_resource);
    void (*str_free)(void *resource_str);
} am_resource_traits_t;

Members

cmp_func_ptr

Pointer to a function that compares policy_res_name and resource_name to return one of the following values of the am_resource_match_t enumeration (defined in the <am_policy.h> header file):

typedef enum am_resource_match {
    AM_SUB_RESOURCE_MATCH,
    AM_EXACT_MATCH,
    AM_SUPER_RESOURCE_MATCH,
    AM_NO_MATCH,
    AM_EXACT_PATTERN_MATCH
} am_resource_match_t;

Tip –

cmp_func_ptr can point to am_policy_compare_urls() to evaluate URL resources.


rsrc_traits

Pointer to the resource traits structure containing data regarding a policy.

policy_res_name

Pointer to the name of the resource being protected.

resource_name

Pointer to the name of the resource being requested.

use_patterns

Based on the boolean_t defined in the <am_types.h> header file, B_TRUE indicates that the function will use or recognize patterns when comparing resources.

has_patterns

Pointer to a function that determines whether a resource has patterns and returns one of the following values of the boolean_t enumeration defined in the <am_types.h> header file:

B_TRUE

If resource_name has patterns.

B_FALSE

Otherwise.


Tip –

has_patterns can point to am_policy_resource_has_patterns() for URL resources.


resource_name

Pointer to the name of the resource being requested.

get_resource_root

Pointer to a function that extracts the root of the specified resource and returns one of the following values of the boolean_t enumeration defined in the <am_types.h> header file:

B_TRUE

If the resource root was successfully inserted into the specified root_resource_name buffer.

B_FALSE

Otherwise.


Tip –

get_resource_root can point to am_policy_get_url_resource_root() for URL resources.


resource_name

Pointer to the name of the resource being requested.

root_resource_name

Buffer to hold the resource root.

buflength

Value based on the size_t defined in the standard <stddef.h> header file that reflects the length of the root_resource_name buffer.

ignore_case

Value that takes one of the following values of the boolean_t enumeration defined in the <am_types.h> header file:

B_TRUE

Ignore case for all functions in this structure.

B_FALSE

Otherwise.

separator

Defines the resource separator. For URLs / should be used.

canonicalize

Pointer to a function that converts the specified resource name into a standard representation for comparative purposes.

resource

Pointer to a resource name. This could be the resource being requested or the resource defined in the policy.

c_resource

Output of the canonical resource name.


Note –

Memory for the canonical name must be allocated by the caller. A function to free the allocated memory must be set in str_free.


str_free

Pointer to a function to free a c_resource string after the results have been evaluated by am_policy_evaluate(). This field cannot be set to NULL.


Note –

free() should be used if canonicalize is set to the am_policy_resource_canonicalize() function.


resource_str

Pointer to the string returned in the canonicalize function.