# WSSO scripting language

## Scripting language

The scripting language is fully compatible with ECMAScript 3rd edition plus a small set of new objects and methods.

Before running the script, Soffid WSSO will create some global variables referring to the request of the user agent and content generated by the application server.

Here are the functions and classes implemented:

### Global Functions

<div class="wiki-content" id="bkmrk-debug-text%3A-string-s"><div class="wiki-content"><div class="table-wrap"><table class="confluenceTable"><colgroup><col></col><col></col><col></col></colgroup><tbody><tr><td class="confluenceTd">debug

</td><td class="confluenceTd">text: string

</td><td class="confluenceTd">Sends a message to the apache log file

</td></tr><tr><td class="confluenceTd">env

</td><td class="confluenceTd">text: string

returns string

</td><td class="confluenceTd">Gets the value of an environment variable

</td></tr><tr><td class="confluenceTd">logout

</td><td class="confluenceTd"></td><td class="confluenceTd">Log out of Web Single Sign on session.

Any further access to a protected resource will ask the user for credentials.

</td></tr></tbody></table>

</div></div></div>### Global objects

<div class="wiki-content" id="bkmrk-request-contains-a%C2%A0r"><div class="wiki-content"><div class="table-wrap"><table class="confluenceTable"><colgroup><col></col><col></col></colgroup><tbody><tr><td class="confluenceTd">request

</td><td class="confluenceTd">Contains a **Request** object referring the request made by the user agent.

</td></tr><tr><td class="confluenceTd">response

</td><td class="confluenceTd">Contains a **Response** object referring the data generated by the application server

</td></tr><tr><td class="confluenceTd">secretStore

</td><td class="confluenceTd">Contains the secrets of the user, including account names and passwords.

</td></tr><tr><td class="confluenceTd">document

</td><td class="confluenceTd">Contains a **Document** object referring the generated page.

</td></tr></tbody></table>

</div></div></div>### secretStore object

The object is available from authenticated requests and provides access to the secrets of the user. Any usage of secretStore object on an anonymous request will produce an undefined value

<div class="wiki-content" id="bkmrk-getsecret-text%3A-stri"><div class="wiki-content"><div class="table-wrap"><table class="confluenceTable"><colgroup><col></col><col></col><col></col></colgroup><tbody><tr><td class="confluenceTd">getSecret

</td><td class="confluenceTd">text: string

returns string

</td><td class="confluenceTd">Gets the value of a secret

</td></tr><tr><td class="confluenceTd">getAccounts

</td><td class="confluenceTd">system: string

return: array

</td><td class="confluenceTd">Returns the list of accounts that the user is allowed to use on a particular system

</td></tr><tr><td class="confluenceTd">getAccounts

</td><td class="confluenceTd">system: string

returns string

</td><td class="confluenceTd">Returns the first account that the user is allowed to use on a particular system.

</td></tr><tr><td class="confluenceTd">getPassword

</td><td class="confluenceTd">system: string

account: string

returns string

</td><td class="confluenceTd">Returns the actual password for the specifieds account and system.

</td></tr></tbody></table>

</div></div></div>### Request class

The Request class encapsulates the request made by the browser and forwarded to the application server.

#### Attributes

<div class="wiki-content" id="bkmrk-method-string-used-m"><div class="wiki-content"><div class="table-wrap"><table class="confluenceTable" style="width: 100%;"><colgroup><col style="width: 11.3681%;"></col><col style="width: 9.52189%;"></col><col style="width: 79.11%;"></col></colgroup><tbody><tr><td class="confluenceTd">method

</td><td class="confluenceTd">string

</td><td class="confluenceTd">Used method (POST, GET or others)

</td></tr><tr><td class="confluenceTd">url

</td><td class="confluenceTd">string

</td><td class="confluenceTd">Contains the requested URL, including scheme, host and port

</td></tr><tr><td class="confluenceTd">headers

</td><td class="confluenceTd">Array

</td><td class="confluenceTd">Headers sent with the request.

</td></tr><tr><td class="confluenceTd">content

</td><td class="confluenceTd">String

</td><td class="confluenceTd">Data posted by the user agent on POST requests. Due to memory usage limits, its content may not be complete.

</td></tr><tr><td class="confluenceTd">params

</td><td class="confluenceTd">Array

</td><td class="confluenceTd">Array containing the request parameters.

</td></tr></tbody></table>

</div></div></div>#### Methods

<div class="wiki-content" id="bkmrk-clone-returns-reques"><div class="wiki-content"><div class="table-wrap"><table class="confluenceTable"><colgroup><col></col><col></col><col></col></colgroup><tbody><tr><td class="confluenceTd">clone

</td><td class="confluenceTd">returns Request

</td><td class="confluenceTd">Create a new request from the current.

The current response will be canceled and a new request will be processed

</td></tr></tbody></table>

</div></div></div>### Response class

The class encapsulates the request response sent by the server application.

#### Attributes

<div class="wiki-content" id="bkmrk-document-document-do"><div class="wiki-content"><div class="table-wrap"><table class="confluenceTable"><colgroup><col></col><col></col><col></col></colgroup><tbody><tr><td class="confluenceTd">document

</td><td class="confluenceTd">Document

</td><td class="confluenceTd">Document generated by the server

</td></tr><tr><td class="confluenceTd">headers

</td><td class="confluenceTd">Array

</td><td class="confluenceTd">Vector header with the request

</td></tr></tbody></table>

</div></div></div>### Document class

Contains the page generated by the application server. Thus, scripts can access the website and its DOM tree in runtime. The document object implements a subset of the standard DOM HtmlDocument.

#### Attributes

<div class="wiki-content" id="bkmrk-url-string-full-url-"><div class="wiki-content"><div class="table-wrap"><table class="confluenceTable"><colgroup><col></col><col></col><col></col></colgroup><tbody><tr><td class="confluenceTd">url

</td><td class="confluenceTd">string

</td><td class="confluenceTd">Full URL of the document.

</td></tr><tr><td class="confluenceTd">title

</td><td class="confluenceTd">string

</td><td class="confluenceTd">Title of document.

</td></tr><tr><td class="confluenceTd">cookie

</td><td class="confluenceTd">string

</td><td class="confluenceTd">Contains the cookies sent by the user agent

</td></tr><tr><td class="confluenceTd">anchors

</td><td class="confluenceTd">Collection

</td><td class="confluenceTd">Contains elements with tag A.

</td></tr><tr><td class="confluenceTd">forms

</td><td class="confluenceTd">Collection

</td><td class="confluenceTd">Contains elements with tag FORM.

</td></tr><tr><td class="confluenceTd">images

</td><td class="confluenceTd">Collection

</td><td class="confluenceTd">Contains elements with tag IMG.

</td></tr><tr><td class="confluenceTd">links

</td><td class="confluenceTd">Collection

</td><td class="confluenceTd">Contains elements with tags A and AREA.

</td></tr><tr><td class="confluenceTd">documentElement

</td><td class="confluenceTd">Item

</td><td class="confluenceTd">Contains the root element, usually and HTML tag element.

</td></tr><tr><td class="confluenceTd">content

</td><td class="confluenceTd">string

</td><td class="confluenceTd">Full content of the document in string format

</td></tr></tbody></table>

</div></div></div>#### Methods

<div class="wiki-content" id="bkmrk-getelementbyid-id%3A-s"><div class="wiki-content"><div class="table-wrap"><table class="confluenceTable"><colgroup><col></col><col></col><col></col></colgroup><tbody><tr><td class="confluenceTd">getElementById

</td><td class="confluenceTd">id: string

Element returns

</td><td class="confluenceTd">Find the first element with the specified ID

</td></tr><tr><td class="confluenceTd">getElementsByTagName

</td><td class="confluenceTd">tag: string

returns Collection

</td><td class="confluenceTd">Find all elements with the specified tag

</td></tr></tbody></table>

</div></div></div>### Element class

Obtained from the document object, implements a subset of the DOM class HtmlElement.

#### Attributes

<div class="wiki-content" id="bkmrk-childnodes-collectio"><div class="wiki-content"><div class="table-wrap"><table class="confluenceTable"><colgroup><col></col><col></col><col></col></colgroup><tbody><tr><td class="confluenceTd">childNodes

</td><td class="confluenceTd">Collection

</td><td class="confluenceTd">The vector containing children elements

</td></tr><tr><td class="confluenceTd">disabled

</td><td class="confluenceTd">boolean

</td><td class="confluenceTd">Indicator of whether the element is disabled or not

</td></tr><tr><td class="confluenceTd">id

</td><td class="confluenceTd">string

</td><td class="confluenceTd">The id attribute of the element

</td></tr><tr><td class="confluenceTd">tagName

</td><td class="confluenceTd">string

</td><td class="confluenceTd">Tag of the element

</td></tr><tr><td class="confluenceTd">parentNode

</td><td class="confluenceTd">Item

</td><td class="confluenceTd">Parent element

</td></tr></tbody></table>

</div></div></div>#### Methods

<div class="wiki-content" id="bkmrk-getattribute-name%3A-s"><div class="wiki-content"><div class="table-wrap"><table class="confluenceTable"><colgroup><col></col><col></col><col></col></colgroup><tbody><tr><td class="confluenceTd">getAttribute

</td><td class="confluenceTd">name: string

returns string

</td><td class="confluenceTd">Returns the value of the specified attribute name.

</td></tr><tr><td class="confluenceTd">setAttribute

</td><td class="confluenceTd">name: string

value: string

</td><td class="confluenceTd">Ses the value of the specified attribute.

</td></tr><tr><td class="confluenceTd">removeAttribute

</td><td class="confluenceTd">name: string

</td><td class="confluenceTd">Remove the specified attribute

</td></tr><tr><td class="confluenceTd">setText

</td><td class="confluenceTd">value: string

</td><td class="confluenceTd">Changes the inner content of the element

</td></tr><tr><td class="confluenceTd">getText

</td><td class="confluenceTd">returns

string

</td><td class="confluenceTd">Gets the element inner content.

</td></tr><tr><td class="confluenceTd">getElementsByTagName

</td><td class="confluenceTd">tag: string

returns Collection

</td><td class="confluenceTd">Find all children's elements with the specified tag

</td></tr><tr><td class="confluenceTd">addChild

</td><td class="confluenceTd">tag: string

before: element (opt)

returns element

</td><td class="confluenceTd">Creates a new item with the specified tag.

If a node is specified, the new element will be ordered just before the specified item in the child list

</td></tr><tr><td class="confluenceTd">remove

</td><td class="confluenceTd"></td><td class="confluenceTd">Removes the node from the document

</td></tr></tbody></table>

</div></div></div>### Collection class

The document object implements a subset of the standard DOM HTMLCollection

#### Attributes

<div class="wiki-content" id="bkmrk-length-long-number-o"><div class="wiki-content"><div class="table-wrap"><table class="confluenceTable"><colgroup><col></col><col></col><col></col></colgroup><tbody><tr><td class="confluenceTd">length

</td><td class="confluenceTd">Long

</td><td class="confluenceTd">Number of items in the collection

</td></tr></tbody></table>

</div></div></div>#### Methods

<div class="wiki-content" id="bkmrk-item-id%3A-long-return"><div class="table-wrap"><table class="confluenceTable"><colgroup><col></col><col></col><col></col></colgroup><tbody><tr><td class="confluenceTd">item

</td><td class="confluenceTd">id: long

returns Element

</td><td class="confluenceTd">Gets the n-position element within the collection. The first element is numbered as 0.

</td></tr><tr><td class="confluenceTd">namedItem

</td><td class="confluenceTd">id: string

returns Element

</td><td class="confluenceTd">Search for an item with the given name. First, search for an element with a matching id attribute. If none is found, search for an element with a matching name attribute.

</td></tr></tbody></table>

</div></div>