JS_SetPrincipalsTranscoder

  • Revision slug: SpiderMonkey/JSAPI_Reference/JS_SetPrincipalsTranscoder
  • Revision title: JS_SetPrincipalsTranscoder
  • Revision id: 138864
  • Created:
  • Creator: Jorend
  • Is current revision? No
  • Comment 21 words added

Revision Content

{{ deprecated_header() }}

Set the runtime-wide principals transcoder callback. This function is deprecated. In SpiderMonkey 1.8.1 or later, use JS_SetRuntimeSecurityCallbacks instead.

Syntax

JSPrincipalsTranscoder JS_SetPrincipalsTranscoder(JSRuntime *rt,
                                                  JSPrincipalsTranscoder px);
Name Type Description
rt JSRuntime * The runtime to configure.
px JSPrincipalsTranscoder The new principals transcoder.

Callback syntax

typedef JSBool (*JSPrincipalsTranscoder)(JSXDRState *xdr,
                                         JSPrincipals **principalsp);
Name Type Description
xdr JSXDRState * The XDR reader/writer.
principalsp JSPrincipals ** If xdr->mode == JSXDR_DECODE, this is an out parameter: on success, *principalsp receives the deserialized principals. Otherwise xdr->mode == JSXDR_ENCODE, and *principalsp points to the JSPrincipals object to be serialized.

Description

JS_SetPrincipalsTranscoder sets a runtime-wide callback which the JavaScript engine uses to serialize and deserialize principals.

Each script function is associated with principals, which poses a problem for XDR. The application provides the JSPrincipals objects, so it must also provide a JSPrincipalsTranscoder if it intends to serialize or deserialize principals.

The callback XDR-encodes or -decodes a principals instance, based on whether xdr->mode is JSXDR_ENCODE, in which case *principalsp should be encoded; or JSXDR_DECODE, in which case implementations must return a held (via JSPRINCIPALS_HOLD), non-null *principalsp out parameter. Return JS_TRUE on success, JS_FALSE on any error, which the implementation must have reported.

JS_SetPrincipalsTranscoder returns the previous principals transcoder.

{{ LXRSearch("ident", "i", "JS_SetPrincipalsTranscoder") }}

Revision Source

<p>{{ deprecated_header() }}</p>
<p>Set the runtime-wide principals transcoder callback. This function is deprecated. In SpiderMonkey 1.8.1 or later, use <a class="internal" href="/En/SpiderMonkey/JSAPI%20Reference/JS%20GetSecurityCallbacks" title="En/SpiderMonkey/JSAPI Reference/JS GetSecurityCallbacks"><code>JS_SetRuntimeSecurityCallbacks</code></a> instead.</p>
<h2 name="Syntax">Syntax</h2>
<pre class="eval">JSPrincipalsTranscoder <strong>JS_SetPrincipalsTranscoder</strong>(<a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSRuntime</a> *rt,
                                                  JSPrincipalsTranscoder px);
</pre>
<table class="fullwidth-table"> <tbody> <tr> <th>Name</th> <th>Type</th> <th>Description</th> </tr> <tr> <td><code>rt</code></td> <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSRuntime" title="en/JSRuntime">JSRuntime</a> *</code></td> <td>The runtime to configure.</td> </tr> <tr> <td><code>px</code></td> <td><code>JSPrincipalsTranscoder</code></td> <td>The new principals transcoder.</td> </tr> </tbody>
</table>
<h2 name="Callback_syntax">Callback syntax</h2>
<pre class="eval">typedef <a href="/En/SpiderMonkey/JSAPI_Reference/JSBool" title="en/JSBool">JSBool</a> (*<strong>JSPrincipalsTranscoder</strong>)(<a href="/en/JSXDRState" title="en/JSXDRState">JSXDRState</a> *xdr,
                                         <a href="/en/SpiderMonkey/JSAPI_Reference/JSPrincipals" title="en/JSPrincipals">JSPrincipals</a> **principalsp);
</pre>
<table class="fullwidth-table"> <tbody> <tr> <th>Name</th> <th>Type</th> <th>Description</th> </tr> <tr> <td><code>xdr</code></td> <td><code><a href="/en/JSXDRState" title="en/JSXDRState">JSXDRState</a> *</code></td> <td>The XDR reader/writer.</td> </tr> <tr> <td><code>principalsp</code></td> <td><code><a href="/en/SpiderMonkey/JSAPI_Reference/JSPrincipals" title="en/JSPrincipals">JSPrincipals</a> **</code></td> <td>If <code>xdr-&gt;mode == JSXDR_DECODE</code>, this is an out parameter: on success, <code>*principalsp</code> receives the deserialized principals. Otherwise <code>xdr-&gt;mode == JSXDR_ENCODE</code>, and <code>*principalsp</code> points to the <code>JSPrincipals</code> object to be serialized.</td> </tr> </tbody>
</table>
<h2 name="Description">Description</h2>
<p><code>JS_SetPrincipalsTranscoder</code> sets a runtime-wide callback which the JavaScript engine uses to serialize and deserialize principals.</p>
<p>Each script function is associated with principals, which poses a problem for <a href="/en/XDR" title="en/XDR">XDR</a>. The application provides the <code>JSPrincipals</code> objects, so it must also provide a <code>JSPrincipalsTranscoder</code> if it intends to serialize or deserialize principals.</p>
<p>The callback XDR-encodes or -decodes a principals instance, based on whether <code>xdr-&gt;mode</code> is <code>JSXDR_ENCODE</code>, in which case <code>*principalsp</code> should be encoded; or <code>JSXDR_DECODE</code>, in which case implementations must return a held (via <code><a href="/en/SpiderMonkey/JSAPI_Reference/JSPRINCIPALS_HOLD" title="en/JSPRINCIPALS_HOLD">JSPRINCIPALS_HOLD</a></code>), non-null <code>*principalsp</code> out parameter. Return <code>JS_TRUE</code> on success, <code>JS_FALSE</code> on any error, which the implementation must have reported.</p>
<p><code>JS_SetPrincipalsTranscoder</code> returns the previous principals transcoder.</p>
<p>{{ LXRSearch("ident", "i", "JS_SetPrincipalsTranscoder") }}</p>
Revert to this revision