OScript API/Built-in Package Index |
The built-in functions in the Secrets package allow you to store and retrieve secrets in storages that are managed by Content Server. There are two types of secrets: local and global. In general, local secrets apply to specific Content Server hosts only. However, not all secrets stored with PutLocal() are really local. Whether a specific secret is really local should be determined case by case according to the nature of that secret. For example, the Content Server database password is not local in nature; its change requires restarting all Content Server hosts after the change has been synchronized among them. The Web Administrator password is not local as well; otherwise the Content Server administrators have to use different passwords on different hosts to configure the same Content Server system. This is no different from the settings in the opentext.ini file. Some are local and some are not. If not really local to a specific host, then a change will require synchronization and restarting all hosts afterwards.
Depending on the running environment, some secrets may be read only. For example, not all secrets can be stored or updated using this
package's Put() and PutLocal() methods in the container environment. Overall, the methods for global secrets are similar to
CAPI's IniDelete()
, IniGet()
and IniPut()
and the methods for local secrets are similar to the corresponding functions provided by
$KERNEL.SystemPreferences
. The big differences are that secret values are of type String rather than Dynamic; section and keyword are
always case sensitive, even for the local versions; and the return value is Undefined if there is no secret for the section/keyword specified.
Most importantly, the passed secret is automatically encrypted when stored and decrypted before it is returned. It is guaranteed that the
retrieved secret is exactly the same as it was passed into the Put() or PutLocal() method.
The major functionalities offered in the Secrets package are the following:
The majority of these functions require a pair of String parameters, section and keyword, and for each of these parameters, the content of the String is limited as follows:
Checks if "OTHOME/config/secrets/key.bin" has the correct content. Internal use only.
Deletes one global secret for the keyword in the section specified.
Deletes one local secret for the keyword in the section specified.
Retrieves one global secret from the global secret storage.
Retrieves a RecArray
with one row for each key (that is, each section/keyword combination) defined in the underlying secret storages for both local and global secrets.
Retrieves one local secret from the local secret storage.
Tests if the global secret for the specified section/keyword is read only or not.
Tests if the local secret for the specified section/keyword is read only or not.
Stores one secret in the global secret storage.
Stores one secret in the local secret storage.
Inserts into the KSecrets
table a certain string for checking if "OTHOME/config/secrets/key.bin" has the correct content. Internal use only.
Checks if a string would be valid as a Secrets section or keyword name.
Checks if the KSecrets
table has a certain string used to check if "OTHOME/config/secrets/key.bin" has the correct content. If so, this function
tries to decrypt the string. If an error occurs while checking or decrypting, or the decrypted value is not as expected, this function logs a message informing the
user to copy over the key.bin of the original instance and restart Content Server, then causes the Content Server service to stop. If the string is not in KSecrets,
this function instead checks if key.bin has the correct content by checking if it can decrypt all the values in KSecrets. If so, it inserts the string into KSecrets.
Warning: This function is not intended for general use. It is for internal use only. This function accesses the database associated with the login parameter; misuse could render the system inoperative.
The CAPILOGIN object.
Integer 0
Deletes one global secret for the section/keyword specified. Does nothing if there is not such a secret.
The CAPILOGIN object.
A string specifying the section to affect in the secret storage.
A string specifying the keyword to delete from the specified section.
An Integer 0 if successful, an error otherwise.
Deletes one local secret for the section/keyword specified. Does nothing if there is not such a secret.
A string specifying the section to affect in the secret storage.
A string specifying the keyword to delete from the specified section.
An Integer 0 if successful, an error otherwise.
Retrieves one global secret, if any, from the global secret storage for the section/keyword specified.
The CAPILOGIN object.
A string specifying the section in which the keyword is located.
A string specifying the keyword to retrieve one secret.
The string value of the secret for the given keyword in the specified section if successful; Undefined if not existing; or an error otherwise.
Retrieves a RecArray with one row for each key (that is, each section/keyword combination) defined in the underlying secret storages for both local and global secrets. The columns included are 'Section' and 'Keyword' (both String values), 'Global' (Boolean value, true if global, false if local), and 'ReadOnly' (Boolean value). No values are returned.
The CAPILOGIN object.
The RecArray value with one row for each secret stored in the underlying secret storages, local and global.
Dynamic result Dynamic rec Object prgCtx Assoc checkVal = $LLIApi.PrgSession.GetPrgCtx( 'Admin' ) if ( checkVal.ok ) prgCtx = checkVal.pSession result = Secrets.GetKeys( prgCtx.fDbConnect.fLogin ) if( IsNotError( result ) ) for rec in result Echo( rec ) end end end
Output:
16:55:06,168 INFO R<'Section'='a','Keyword'='b1','Global'=true,'ReadOnly'=false> 16:55:06,168 INFO R<'Section'='general','Keyword'='AdminPwd','Global'=false,'ReadOnly'=false> 16:55:06,168 INFO R<'Section'='dbconnection:main','Keyword'='password','Global'=false,'ReadOnly'=false> 16:55:06,168 INFO R<'Section'='a','Keyword'='b2','Global'=false,'ReadOnly'=false> 16:55:06,168 INFO R<'Section'='another','Keyword'='k1','Global'=false,'ReadOnly'=false>
Retrieves one local secret, if any, from the local secret storage for the section/keyword specified.
A string specifying the section in which the keyword is located.
A string specifying the keyword to retrieve one secret.
The string value of the secret for the given keyword in the specified section if successful; Undefined if not existing; or an error otherwise.
Dynamic result result = Secrets.GetLocal('general', 'AdminPwd') Echo( result ) result = Secrets.GetLocal('general', 'adminpwd') // Note that section and keyword are case sensitive! Echo( result )
Output:
21:21:33,822 INFO 1$UDe8fmYyXeyMXnAvfBo0KOmRUpuERThKjqccm|Rm4Z56wFHjg0cBm0nxqrTvjOWz0GBxJqR9JHr|U|BmX6w6fg==$EynFthPsK5ZWGzff34Ui7YV0bYItSSzX5pKDquHgK|Ld6q06KmqOOCd+lfZJr2rSeqNuvyAcyeTw70qkw4Pg|w== 21:21:33,823 INFO ?
Tests if the global secret for the specified section/keyword is read only or not.
The CAPILOGIN object.
A string specifying the section in which the keyword is located.
A string specifying the keyword to be tested.
TRUE if the secret is read only; FALSE if it is writable; Undefined if not existing; or an error otherwise.
Tests if the local secret for the specified section/keyword is read only or not.
A string specifying the section in which the keyword is located.
A string specifying the keyword to be tested.
TRUE if the secret is read only; FALSE if it is writable; Undefined if not existing; or an error otherwise.
Stores one secret with the specified section/keyword in the global secret storage.
The CAPILOGIN object.
A string specifying the section in which the keyword is located.
A string specifying the keyword to store the secret.
A string specifying the plaintext value of the secret.
An Integer 0 if successful; an error otherwise.
Stores one secret with the specified section/keyword in the local secret storage.
A string specifying the section in which the keyword is located.
A string specifying the keyword to store the secret.
A string specifying the plaintext value of the secret.
An Integer 0 if successful; an error otherwise.
Inserts into the KSecrets
table a certain string for checking if "OTHOME/config/secrets/key.bin" has the correct content.
Warning: This function is not intended for general use. It is for internal use only. This function accesses the database associated with the login parameter; misuse could render the system inoperative.
The CAPILOGIN object.
An Integer 0 if successful; an error otherwise.
Checks if a string would be valid as a Secrets section or keyword name, given the limitations listed above in the Secrets class description. This does not check if the name is currently in use, only if it could be used.
The name for a Secrets section or keyword.
TRUE if the input name meets the limitations, FALSE otherwise.
Copyright © 2023 OpenText Corporation. All rights reserved. |