JavaScript-1.5 Reference

JSPrincipals Data Structure

Summary

Defines security information for an object or script.

Syntax

typedef struct JSPrincipals {
    char *codebase;
    void *(*getPrincipalArray)(JSContext *cx,
       struct JSPrincipals *);
    JSBool (*globalPrivilegesEnabled)(JSContext *cx,
       struct JSPrincipals *);
    uintN refcount;
    void (*destroy)(JSContext *cx, struct JSPrincipals *);
} JSPrincipals;
NameTypeDescription
*codebasecharPointer to the codebase for the principal.
*getPrincipalArrayvoidPointer to the function that returns an array of principal definitions.
*globalPrivilegesEnabledJSBoolFlag indicating whether principals are enabled globally.
refcountuintNReference count for the principals. Each reference to a principal increments refcount by one. As principals references are dropped, call the destroy method to decrement the reference count and free the principals if they are no longer needed.
*destroyvoidPointer to the function that decrements the reference count and possibly frees the principals if they are no longer in use.

Description

JSPrincipals is a structure that defines the connection to security data for an object or script. Security data is defined independently of the JS engine, but is passed to the engine through the JSPrincipals structure. This structure is passed as an argument to versions of API calls that compile and evaluate scripts and functions that depend on a security model. Some examples of security-enhanced API call are JS_CompileScriptForPrincipals, JS_CompileFunctionForPrincipals, and JS_EvaluateScriptForPrincipals.

codebase points to the common codebase for this object or script. Only objects and scripts that share a common codebase can interact.

getPrincipalArray is a pointer to the function that retrieves the principals for this object or script.

globalPrivilegesEnabled is a flag that indicates whether principals are enabled globally.

refcount is used to maintain active principals. Each time an object is referenced, refcount must be increased by one. Each time an object is dereferenced, refcount must be decremented by one. When refcount is zero, the principals are no longer in use and are destroyed. Use the JSPRINCIPALS_HOLD macro to increment refcount, and use JS_PRINCIPALS_DROP to decrement refcount.

See Also

Groups [ Data Structure ]
Documents [ LXR ID Search ]
Entries [ JSPRINCIPALS_DROP | JSPRINCIPALS_HOLD | JS_CompileFunctionForPrincipals | JS_CompileScriptForPrincipals | JS_CompileUCFunctionForPrincipals | JS_CompileUCScriptForPrincipals | JS_EvaluateScriptForPrincipals ]

This page was generated by APIDOC