[OpenAMJS](openamjs.md) ====== OpenAMJS is a JavaScript wrapper around the ForgeRock OpenAM REST APIs. Initially it is leveraging the Authentication and SSO API's but it can be extended to cover the whole set of APIs, inclulding Authorization, OAuth2, OIDC, UMA, STS, etc. This wrapper is not supported nor endorsed by ForgeRock, but the community is welcome to develop it further. ### Table of contents - [authenticate](#authenticateoptions) - [authenticateSimple](#authenticatesimpleoptions) - [authNRedirect](#authnredirectoptions) - [createCookie](#createcookiename-value-hours-domainname) - [debug](#debugmessage--undefined) - [deleteCookie](#deletecookiename-domainname) - [getCookie](#getcookiename--string) - [getIdentityAttributes](#getidentityattributesoptions--json) - [getLocal](#getlocalstoragekey--type) - [getMyURL](#getmyurl--string) - [getMyURLDir](#getmyurldir--string) - [isSessionValid](#issessionvalidtokenid--boolean) - [isUserAuthenticated](#isuserauthenticated--boolean) - [logout](#logoutoptionsopt--undefined) - [openamConfig](#openamconfigoptions--openamconfig) - [removeAlllocal](#removealllocal--undefined) - [storeLocal](#storelocalstoragekey-data) ### Methods #### authenticate(options) Authenticates an identity using any authentication module The version of the AM should support the /json/authenticate endpoint. ##### Parameters:
Name Type Description
options Object The configuration object to use
 The options object is a JSON object, here an example.  
 {
    module: "DataStore",                                         // optional
    service: "ldapService",                                      // optional
    realm: "/",                                                  // optional
    headers: "http://ap.example.com:8880/exampleNRO02.html",     // optional
    data: objectData                                             // optional
 }   
Properties
Name Type Attributes Default Description
module String <optional>
OpenAM realm default The Authentication module to use in the left side of the login box.
service String <optional>
OpenAM realm default The Authentication service chain to use in the left side of the login box. Notice that service takes precedence over module.
realm String <optional>
The one configured in openam.js Realm where the authentication will take place
headers Object Object containing the credentials passed as headers
data Object <optional>
{} The payload to be submitted to the authentication module
Source: - [openam.js](openam.js.html), [line 759](openam.js.html#line759) #### authenticateSimple(options) Authenticates an identity using a one state authentication module by using the values submitted either in the form containing username and password or by using credentials submitted in the headers object. The version of the AM should support the /json/authenticate endpoint. The realm, module or service can be specified but only modules and services with one state are supported. ##### Parameters:
Name Type Description
options Object The configuration object to use
 The options object is a JSON object, here an example.  
 {
    module: "DataStore",                                         // optional
    service: "ldapService",                                      // optional
    username: 'usernameField',                                   // optional
    password: 'passwordField',                                   // optional
    headers: myHeaders,                                          // optional
    realm: "/",                                                  // optional
    gotoURL: "https://app.example.com:8080/mypath",              // optional
    gotoOnFail: "https://app.example.com:8080/failed",           // optional
 }   
Properties
Name Type Attributes Default Description
module String <optional>
OpenAM realm default The Authentication module to use in the left side of the login box.
service String <optional>
OpenAM realm default The Authentication service chain to use in the left side of the login box. Notice that service takes precedence over module.
username String <optional>
'username' The id of the field that contains the username in the form. Either username and password or headers must be specified.
password String <optional>
'password' The id of the field that contains the password in the form. Either username and password or headers must be specified.
headers Object Object containing the credentials passed as headers
realm String <optional>
The one configured in openam.js Realm where the authentication will take place
headers Object <optional>
Object containing the credentials passed as headers. Either username and password or headers must be specified.
gotoURL String <optional>
Current page The URL to go to after a successful authentication.
gotoOnFail String <optional>
Current page The URL to go to after an authentication event has failed.
Source: - [openam.js](openam.js.html), [line 914](openam.js.html#line914) #### authNRedirect(options) Redirects for authentication to an OpenAM using the Authentication module specified ##### Parameters:
Name Type Description
options Object The configuration object to use
 The options object is a JSON object, here an example.  
 {
    openam: myOpenAMConfigObject,
    module: "DataStore",                                         // optional
    service: "ldapService",                                      // optional
    gotoURL: "http://ap.example.com:8880/exampleNRO02.html",     // optional
    gotoOnFail: "http://ap.example.com:8880/exampleNRO02.html",  // optional
    classic: false,                                              // optional
    windowed: true                                               // optional
 }   
Properties
Name Type Attributes Default Description
openam Object | String The OpenAM Configuration Object. This is a mandatory attribute. See openam.js documentation for more information
module String <optional>
OpenAM realm default The Authentication module to use in the left side of the login box.
service String <optional>
OpenAM realm default The Authentication service chain to use in the left side of the login box. Notice that service takes precedence over module.
gotoURL String <optional>
Current page The URL to go to after a successful authentication.
gotoOnFail String <optional>
Current page The URL to go to after an authentication event has failed.
classic String <optional>
false Boolean attribute to specify if we are using the classic UI (true) or the XUI (false). Default is to use the XUI.
windowed String <optional>
true Boolean attribute to specify if the redirect will happen in a pop-up window or not.
Source: - [openam.js](openam.js.html), [line 595](openam.js.html#line595) #### createCookie(name, value, hours, domainName) Create a Cookie for the domain specified in domainName ##### Parameters: | Name | Type | Description | |--------------|--------------------------------------|--------------------------------------------| | `name` | type | Name of the cookie to be created | | `value` | type | Value for the cookie | | `hours` | type | Time that the cookie will exist | | `domainName` | type | Domain in which the cookie will be created | Source: - [openam.js](openam.js.html), [line 80](openam.js.html#line80) #### debug(message) → {undefined} Displays a message in the browser's console (if possible) ##### Parameters: | Name | Type | Description | |-----------|--------------------------------------|-----------------------------------| | `message` | type | Message to display in the console | Source: - [openam.js](openam.js.html), [line 232](openam.js.html#line232) ##### Returns: Type undefined #### deleteCookie(name, domainName) Deletes the coookie ##### Parameters: | Name | Type | Description | |--------------|--------------------------------------|----------------------------------| | `name` | type | Name of the cookie to be deleted | | `domainName` | type | Domain where the cookie resides | Source: - [openam.js](openam.js.html), [line 109](openam.js.html#line109) #### getCookie(name) → {String} Get's the value of the cookie specified ##### Parameters: | Name | Type | Description | |--------|--------------------------------------|---------------------------------------------------------| | `name` | type | The name of the coookie whose value we want to retrieve | Source: - [openam.js](openam.js.html), [line 114](openam.js.html#line114) ##### Returns: The value of the cookie Type String #### getIdentityAttributes(options) → {JSON} Obtains the values of the profile attributes specified as a comma separated list ##### Parameters:
Name Type Description
options Object The configuration object to get the attributes
 The options object is a JSON object, here an example.  
 {
    attributes: "cn, givenName,sn,mail",          
    realm: "/",                          // optional
    prettyprint: true                    // optional
 }   
Properties
Name Type Attributes Default Description
attributes String Comma separated list of attributes
realm String <optional>
The one configured in openam.js Realm where the identity resides.
prettyprint Boolean <optional>
false Return formatted with pretty print(true or false)
Source: - [openam.js](openam.js.html), [line 1021](openam.js.html#line1021) ##### Returns: - Returns the value of the profile attributes requested from the OpenAM Type JSON #### getLocal(storageKey) → {type} Gets the value stored in the Local session store. Using the key specified by ##### Parameters: | Name | Type | Description | |--------------|--------------------------------------|---------------------------------| | `storageKey` | type | The key of the value to retrive | Source: - [openam.js](openam.js.html), [line 137](openam.js.html#line137) ##### Returns: data The value of the value retrieved Type type #### getMyURL() → {String} Gets the URL of the page running the script Source: - [openam.js](openam.js.html), [line 67](openam.js.html#line67) ##### Returns: Type String #### getMyURLDir() → {String} Gets the path/dir of the page running the script Source: - [openam.js](openam.js.html), [line 55](openam.js.html#line55) ##### Returns: Type String #### isSessionValid(tokenId) → {Boolean} Checks if the session that the tokenID represents is valid ##### Parameters: | Name | Type | Description | |-----------|----------------------------------------|--------------------------------------------------------| | `tokenId` | String | The SSO Token ID (a.k.a the identifier of the session) | Source: - [openam.js](openam.js.html), [line 708](openam.js.html#line708) ##### Returns: - True if the session is valid Type Boolean #### isUserAuthenticated() → {Boolean} Checks if a user is authenticated Source: - [openam.js](openam.js.html), [line 692](openam.js.html#line692) ##### Returns: - True if a user is authenticated Type Boolean #### logout(optionsopt) → {undefined} Log out the user from the OpenAM ##### Parameters:
Name Type Attributes Description
options Object <optional>
The object describing the options for the logout
 The options object is a JSON object, here an example.  
 {
    gotoURL: "https://app.example.com:8080/mypath",              // optional
    gotoOnFail: "https://app.example.com:8080/failed",           // optional
 }   
Properties
Name Type Attributes Default Description
gotoURL String <optional>
Current page The URL to go to after a successful authentication.
gotoOnFail String <optional>
Current page The URL to go to after an authentication event has failed.
Source: - [openam.js](openam.js.html), [line 1121](openam.js.html#line1121) ##### Returns: Type undefined #### openamConfig(options) → {[openamConfig](global.html#openamConfig)} OpenAM Configuration instance ##### Parameters:
Name Type Description
options Object The OpenAM Configuration JSON object.
 Here an example.  
 {
      baseurl: "http://openam1.example.com:8080/openam",
      realm: "/",                                        // optional    
      cachetime: 3,                                      // optional 
      debugenabled: true                                 // optional
 }   
Properties
Name Type Attributes Default Description
baseurl String The URL where OpenAM is running, example: "https://openam.example.com:443/openam"
realm String <optional>
The default realm for the baseurl used Name of the realm to be used, example: "/"
cachetime String <optional>
3 Time in minutes the session valid response and attributes are cached in the session store (if possible). To disable caching set the time to 0. Example of caching for 3 minutes: 3
debugenabled String <optional>
false Enable debug, works for some browser, not for all. Example: true
Source: - [openam.js](openam.js.html), [line 336](openam.js.html#line336) ##### Returns: An instance of the OpenAM Configuration. Type [openamConfig](global.html#openamConfig) #### removeAlllocal() → {undefined} Removes the whole local session storage Source: - [openam.js](openam.js.html), [line 215](openam.js.html#line215) ##### Returns: Type undefined #### storeLocal(storageKey, data) Stores a value "data" in the key "storageKey" in the local session storage ##### Parameters: | Name | Type | Description | |--------------|--------------------------------------|---------------------------------------| | `storageKey` | type | The key to be used to store the value | | `data` | type | The value of the data to be stored | Source: - [openam.js](openam.js.html), [line 178](openam.js.html#line178) Documentation generated by [JSDoc 3.4.0](https://github.com/jsdoc3/jsdoc) and converted to markdown with [pandoc 1.17.0.3](https://github.com/jgm/pandoc) and some Patience.