StandardCredentialsProvider - Scoped, Global

Use StandardCredentialsProvider API to retrieve credential information.

You can use this API in scoped applications, or within the global scope. In scoped scripts, use the sn_cc namespace identifier.

This function retrieves credential information by sys ID and by given credential attributes.

//Get a single credential

      var provider = new sn_cc.StandardCredentialsProvider();
      var credential = provider.getCredentialByID("put a sys_id here");
      var userName = credential.getAttribute("user_name");
      var password = credential.getAttribute("password");
      //using getAttribute for new keys in extended tables, for example 
      //cloud management credential has the "user_public_key" attribute
      var userPublicKey = credential.getAttribute("user_public_key");


//Get a list of SSH credentials

      var provider = new sn_cc.StandardCredentialsProvider();
      var credentials = provider.getCredentials(["ssh"]);
      for (var i = 0; i < credentials.length; i++) {
      	var credential = credentials[i];
             gs.info(credential.getAttribute("name"));
      }

StandardCredentialsProvider - StandardCredentialsProvider()

Use StardardCredentialsProvider() to retrieve credential information.

Table 1. Parameters
Name Type Description
None

Scoped StandardCredentialsProvider - getCredentials(String)

This function returns an array of all credentials that match the given types and tags.

Table 2. Parameters
Name Type Description
types String Types is an array of credential type names. For example, ["ssh", "windows"]
Note: If types are null or empty, any match returns a credential. If types are specified, the credentials whose type matches one of the types returns.
handles String Handles is a comma-separated list of handle names. For example, "ssh,jdbc"
Table 3. Returns
Type Description
StandardCredential Information about the ConnInfo...
var provider = new sn_cc.StandardCredentialsProvider();
         var credentials = provider.getCredentials(["ssh"]);
         for (var i = 0; i < credentials.length; i++) {
      	var credential = credentials[i];
             gs.info(credential.getAttribute("name"));
      }

Scoped StandardCredentialsProvider - getCredentialByID(String)

This function retrieves a credential object identified by the given sys ID.

Table 4. Parameters
Name Type Description
sys ID String A string representing the sys ID of the credential record.
Table 5. Returns
Type Description
StandardCredential A credential.
var provider = new sn_cc.StandardCredentialsProvider();
         var credentials = provider.getCredentials(["ssh"]);
         for (var i = 0; i < credentials.length; i++) {
      	var credential = credentials[i];
             gs.info(credential.getAttribute("name"));
      }