Options
All
  • Public
  • Public/Protected
  • All
Menu

Class CredentialParams

Contains credentials to authenticate against external services. They are used together with connection parameters, but usually stored in a separate store, protected from unauthorized access.

Configuration parameters

  • store_key: key to retrieve parameters from credential store
  • username: user name
  • user: alternative to username
  • password: user password
  • pass: alternative to password
  • access_id: application access id
  • client_id: alternative to access_id
  • access_key: application secret key
  • client_key: alternative to access_key
  • secret_key: alternative to access_key

In addition to standard parameters CredentialParams may contain any number of custom parameters

see

ConfigParams

see

ConnectionParams

see

CredentialResolver

see

ICredentialStore

Example

let credential = CredentialParams.fromTuples(
    "user", "jdoe",
    "pass", "pass123",
    "pin", "321"
);

let username = credential.getUsername();             // Result: "jdoe"
let password = credential.getPassword();             // Result: "pass123"
let pin = credential.getAsNullableString("pin");     // Result: 321

Hierarchy

  • ConfigParams
    • CredentialParams

Index

Constructors

constructor

  • Creates a new credential parameters and fills it with values.

    Parameters

    • Default value values: any = null

      (optional) an object to be converted into key-value pairs to initialize these credentials.

    Returns CredentialParams

Methods

addSection

  • addSection(section: string, sectionParams: ConfigParams): void
  • Adds 'sectionParams' to this ConfigParams object under the section named 'section'.

    Parameters

    • section: string

      name of the section, under which 'sectionParams' is to be added. The keys of 'sectionParams' will be renamed to "(section).<key's name>", when added to this ConfigParams object.

    • sectionParams: ConfigParams

      ConfigParams that are to be added under the section named 'section'.

    Returns void

append

  • append(map: any): void
  • Parameters

    • map: any

      map of items to append to this StringValueMap.

    Returns void

clear

  • clear(): any
  • Removes all values from this StringValueMap.

    Returns any

clone

  • clone(): any
  • Returns any

    a clone of this object.

get

  • get(key: string): string
  • Parameters

    • key: string

      key of the item to retrieve from this StringValueMap.

    Returns string

    the item stored by the given key.

getAccessId

  • getAccessId(): string
  • Gets the application access id. The value can be stored in parameters "access_id" pr "client_id"

    Returns string

    the application access id.

getAccessKey

  • getAccessKey(): string
  • Gets the application secret key. The value can be stored in parameters "access_key", "client_key" or "secret_key".

    Returns string

    the application secret key.

getAsArray

  • getAsArray(key: string): AnyValueArray
  • see

    [[AnyValueArray]]

    see

    [[AnyValueArray.fromValue]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns AnyValueArray

    the item with the given key as an AnyValueArray object.

getAsArrayWithDefault

  • getAsArrayWithDefault(key: string, defaultValue: AnyValueArray): AnyValueArray
  • see

    [[AnyValueArray]]

    see

    getAsNullableArray

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: AnyValueArray

      value to use if the item with the given key cannot be converted into an AnyValueArray.

    Returns AnyValueArray

    the item with the given key as an AnyValueArray object or 'defaultValue', if conversion is not possible.

getAsBoolean

  • getAsBoolean(key: string): boolean
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns boolean

    the item with the given key as a boolean (or false as the default).

getAsBooleanWithDefault

  • getAsBooleanWithDefault(key: string, defaultValue: boolean): boolean
  • see

    [[BooleanConverter.toBooleanWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: boolean

      value to return if conversion is not possible.

    Returns boolean

    the item with the given key as a boolean or the defaultValue (if conversion is not possible).

getAsDateTime

  • getAsDateTime(key: string): Date
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns Date

    the item with the given key as a Datetime (or null as the default).

getAsDateTimeWithDefault

  • getAsDateTimeWithDefault(key: string, defaultValue: Date): Date
  • see

    [[DateTimeConverter.toDateTimeWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: Date

      value to return if conversion is not possible.

    Returns Date

    the item with the given key as a Datetime or the defaultValue (if conversion is not possible).

getAsDouble

  • getAsDouble(key: string): number
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a double (or 0 as the default).

getAsDoubleWithDefault

  • getAsDoubleWithDefault(key: string, defaultValue: number): number
  • see

    [[DoubleConverter.toDoubleWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: number

      value to return if conversion is not possible.

    Returns number

    the item with the given key as a double or the defaultValue (if conversion is not possible).

getAsFloat

  • getAsFloat(key: string): number
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a float (or 0 as the default).

getAsFloatWithDefault

  • getAsFloatWithDefault(key: string, defaultValue: number): number
  • see

    [[FloatConverter.toFloatWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: number

      value to return if conversion is not possible.

    Returns number

    the item with the given key as a float or the defaultValue (if conversion is not possible).

getAsInteger

  • getAsInteger(key: string): number
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as an integer (or 0 as the default).

getAsIntegerWithDefault

  • getAsIntegerWithDefault(key: string, defaultValue: number): number
  • see

    [[IntegerConverter.toIntegerWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: number

      value to return if conversion is not possible.

    Returns number

    the item with the given key as an integer or the defaultValue (if conversion is not possible).

getAsLong

  • getAsLong(key: string): number
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a long (or 0 as the default).

getAsLongWithDefault

  • getAsLongWithDefault(key: string, defaultValue: number): number
  • see

    [[LongConverter.toLongWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: number

      value to return if conversion is not possible.

    Returns number

    the item with the given key as a long or the defaultValue (if conversion is not possible).

getAsMap

  • getAsMap(key: string): AnyValueMap
  • see

    fromValue

    Parameters

    • key: string

      key of the item to retrieve.

    Returns AnyValueMap

    the item with the given key as an AnyValueMap object.

getAsMapWithDefault

  • getAsMapWithDefault(key: string, defaultValue: AnyValueMap): AnyValueMap
  • Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: AnyValueMap

      value to use if the item with the given key cannot be converted into an AnyValueMap.

    Returns AnyValueMap

    the item with the given key as an AnyValueMap object or 'defaultValue', if conversion is not possible.

getAsNullableArray

  • getAsNullableArray(key: string): AnyValueArray
  • see

    [[AnyValueArray]]

    see

    [[AnyValueArray.fromValue]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns AnyValueArray

    the item with the given key as a nullable AnyValueArray object (returns null if the item with the given key is null).

getAsNullableBoolean

  • getAsNullableBoolean(key: string): boolean
  • see

    [[BooleanConverter.toNullableBoolean]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns boolean

    the item with the given key as a nullable boolean.

getAsNullableDateTime

  • getAsNullableDateTime(key: string): Date
  • see

    [[DateTimeConverter.toNullableDateTime]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns Date

    the item with the given key as a nullable Datetime.

getAsNullableDouble

  • getAsNullableDouble(key: string): number
  • see

    [[DoubleConverter.toNullableDouble]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a nullable double.

getAsNullableFloat

  • getAsNullableFloat(key: string): number
  • see

    [[FloatConverter.toNullableFloat]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a nullable float.

getAsNullableInteger

  • getAsNullableInteger(key: string): number
  • see

    [[IntegerConverter.toNullableInteger]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a nullable integer.

getAsNullableLong

  • getAsNullableLong(key: string): number
  • see

    [[LongConverter.toNullableLong]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns number

    the item with the given key as a nullable long.

getAsNullableMap

  • getAsNullableMap(key: string): AnyValueMap
  • see

    fromValue

    Parameters

    • key: string

      key of the item to retrieve.

    Returns AnyValueMap

    the item with the given key as a nullable AnyValueMap object (returns null if the item with the given key is null).

getAsNullableString

  • getAsNullableString(key: string): string
  • see

    [[StringConverter.toNullableString]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns string

    the item with the given key as a nullable string.

getAsNullableType

  • getAsNullableType<T>(type: TypeCode, key: string): T
  • Converts the item with the given key into a nullable object of type 'type' using [[TypeConverter.toNullableType]] and returns it.

    see

    [[TypeConverter.toNullableType]]

    Type parameters

    • T

    Parameters

    • type: TypeCode

      the TypeCode to be used in TypeConverter.toNullableType(TypeCode, value);

    • key: string

      key of the item to retrieve.

    Returns T

    the item with the given key as a nullable object of type 'type'.

getAsObject

  • getAsObject(key?: string): any
  • Parameters

    • Optional key: string

      key of the item to retrieve.

    Returns any

    the item with the given key without any conversions or all items (if 'key' is undefined or omitted).

getAsString

  • getAsString(key: string): string
  • Parameters

    • key: string

      key of the item to retrieve.

    Returns string

    the item with the given key as a string (or null as the default).

getAsStringWithDefault

  • getAsStringWithDefault(key: string, defaultValue: string): string
  • see

    [[StringConverter.toStringWithDefault]]

    Parameters

    • key: string

      key of the item to retrieve.

    • defaultValue: string

      value to return if conversion is not possible.

    Returns string

    the item with the given key as a string or the defaultValue (if conversion is not possible).

getAsType

  • getAsType<T>(type: TypeCode, key: string): T
  • Converts the item with the given key into an object of type 'type' using [[TypeConverter.toTypeWithDefault]] and returns it.

    see

    getAsTypeWithDefault

    Type parameters

    • T

    Parameters

    • type: TypeCode

      the TypeCode to be used in TypeConverter.toTypeWithDefault(TypeCode, value, null);

    • key: string

      key of the item to retrieve.

    Returns T

    the item with the given key as an object of type 'type' (or null as the default).

getAsTypeWithDefault

  • getAsTypeWithDefault<T>(type: TypeCode, key: string, defaultValue: T): T
  • Converts the item with the given key into an object of type 'type' using [[TypeConverter.toTypeWithDefault]] and returns it.

    see

    [[TypeConverter.toTypeWithDefault]]

    Type parameters

    • T

    Parameters

    • type: TypeCode

      the TypeCode to be used in TypeConverter.toTypeWithDefault(TypeCode, value, defaultValue);

    • key: string
    • defaultValue: T

      value to return if conversion is not possible.

    Returns T

    the item with the given key as an object of type 'type' or the defaultValue, if conversion is not possible.

getAsValue

  • getAsValue(key: string): AnyValue
  • see

    [[AnyValue]]

    see

    [[AnyValue.constructor]]

    Parameters

    • key: string

      key of the item to retrieve.

    Returns AnyValue

    the item with the given key as an AnyValue object.

getKeys

  • getKeys(): string[]
  • Returns string[]

    all of the keys that are contained in this StringValueMap as a list of strings.

getPassword

  • getPassword(): string
  • Get the user password. The value can be stored in parameters "password" or "pass".

    Returns string

    the user password.

getSection

  • getSection(section: string): ConfigParams
  • Parameters

    • section: string

      name of the section to retrieve configuration parameters from.

    Returns ConfigParams

    all configuration parameters that belong to the section named 'section'.

    Example key "Section-1.Subsection-1-1.Key-1-1-1" contains the section named "Section-1". Calling getSection("Section-1") would return a ConfigParams object containing the key "Subsection-1-1.Key-1-1-1"

getSectionNames

  • getSectionNames(): string[]
  • Returns string[]

    the names of all sections that are present in this object's complex keys.

    Example key "Section-1.Subsection-1-1.Key-1-1-1" contains the section named "Section-1".

getStoreKey

  • getStoreKey(): string
  • Gets the key to retrieve these credentials from [[CredentialStore]]. If this key is null, than all parameters are already present.

    see

    useCredentialStore

    Returns string

    the store key to retrieve credentials.

getUsername

  • getUsername(): string
  • Gets the user name. The value can be stored in parameters "username" or "user".

    Returns string

    the user name.

length

  • length(): number
  • Returns number

    the number of key-value pairs stored in this StringValueMap.

override

  • override(configParams: ConfigParams): ConfigParams
  • Overrides the configuration parameters stored in this object with the ones in 'configParams'. If a configuration is already set in this ConfigParams object, it will be overwritten by the value in 'configParams' with the same key.

    see

    setDefaults

    Parameters

    • configParams: ConfigParams

      configuration parameters to override the parameters of this object with.

    Returns ConfigParams

    ConfigParams object with overridden parameters.

put

  • put(key: string, value: any): any
  • Parameters

    • key: string

      the key by which to insert the given value.

    • value: any

      the value to insert into this StringValueMap by the given key.

    Returns any

remove

  • remove(key: string): void
  • Parameters

    • key: string

      key of the item to remove.

    Returns void

setAccessId

  • setAccessId(value: string): void
  • Sets the application access id.

    Parameters

    • value: string

      a new application access id.

    Returns void

setAccessKey

  • setAccessKey(value: string): void
  • Sets the application secret key.

    Parameters

    • value: string

      a new application secret key.

    Returns void

setAsObject

  • setAsObject(key: any, value?: any): void
  • see

    [[MapConverter.toMap]]

    Parameters

    • key: any

      the key by which to set the 'value' passed.

    • Optional value: any

      the value to set in this StringValueMap with the given 'key'. If 'key' is omitted, then this StringValueMap will be set (cleared and filled anew) using 'value'. In this case 'value' will be converted to a map using "MapConverter.toMap(value)" and set to this StringValueMap.

    Returns void

setDefaults

  • setDefaults(defaultConfigParams: ConfigParams): ConfigParams
  • Sets the default configurations for this ConfigParams object, based on the default configuration parameters passed in 'defaultConfigParams'. If a configuration is already set in this ConfigParams object, it will not be overwritten by the default value in 'defaultConfigParams' with the same key.

    see

    override

    Parameters

    • defaultConfigParams: ConfigParams

      the default configuration parameters to use.

    Returns ConfigParams

    this ConfigParams object with the newly set defaults.

setPassword

  • setPassword(value: string): void

setStoreKey

  • setStoreKey(value: string): void
  • Sets the key to retrieve these parameters from [[CredentialStore]].

    Parameters

    • value: string

      a new key to retrieve credentials.

    Returns void

setUsername

  • setUsername(value: string): void

toString

  • toString(): string
  • Returns string

    this StringValueMap as a semicolon-separated values string.

    Example: "key1=value1;key2;key3=value3".

useCredentialStore

  • useCredentialStore(): boolean
  • Checks if these credential parameters shall be retrieved from [[CredentialStore]]. The credential parameters are redirected to [[CredentialStore]] when store_key parameter is set.

    see

    getStoreKey

    Returns boolean

    true if credentials shall be retrieved from [[CredentialStore]]

Static fromConfig

  • Retrieves a single CredentialParams from configuration parameters from "credential" section. If "credentials" section is present instead, then is returns only the first credential element.

    see

    manyFromConfig

    Parameters

    • config: ConfigParams

      ConfigParams, containing a section named "credential(s)".

    Returns CredentialParams

    the generated CredentialParams object.

Static fromMaps

  • fromMaps(...maps: any[]): StringValueMap
  • Static method for creating a StringValueMap using the maps passed as parameters.

    Parameters

    • Rest ...maps: any[]

      the maps passed to this method to create a StringValueMap with.

    Returns StringValueMap

    the StringValueMap created.

Static fromString

  • Creates a new CredentialParams object filled with key-value pairs serialized as a string.

    Parameters

    • line: string

      a string with serialized key-value pairs as "key1=value1;key2=value2;..." Example: "Key1=123;Key2=ABC;Key3=2016-09-16T00:00:00.00Z"

    Returns CredentialParams

    a new CredentialParams object.

Static fromTuples

  • Creates a new CredentialParams object filled with provided key-value pairs called tuples. Tuples parameters contain a sequence of key1, value1, key2, value2, ... pairs.

    Parameters

    • Rest ...tuples: any[]

      the tuples to fill a new CredentialParams object.

    Returns CredentialParams

    a new CredentialParams object.

Static fromTuplesArray

  • fromTuplesArray(tuples: any[]): StringValueMap
  • Static method for creating a StringValueMap from an array of tuples.

    Parameters

    • tuples: any[]

      the key-value tuples array to initialize the new StringValueMap with.

    Returns StringValueMap

    the StringValueMap created and filled by the 'tuples' array provided.

Static fromValue

  • fromValue(value: any): ConfigParams
  • Static method that creates a ConfigParams object based on the values that are stored in the 'value' object's properties.

    see

    [[RecursiveObjectReader.getProperties]]

    Parameters

    • value: any

      configuration parameters in the form of an object with properties.

    Returns ConfigParams

    generated ConfigParams.

Static manyFromConfig

  • Retrieves all CredentialParams from configuration parameters from "credentials" section. If "credential" section is present instead, than it returns a list with only one CredentialParams.

    Parameters

    • config: ConfigParams

      a configuration parameters to retrieve credentials

    Returns CredentialParams[]

    a list of retrieved CredentialParams

Static mergeConfigs

  • mergeConfigs(...configs: ConfigParams[]): ConfigParams
  • Static method that can merge two or more ConfigParams into one.

    see

    [[StringValueMap.fromMaps]]

    Parameters

    • Rest ...configs: ConfigParams[]

      the ConfigParams that are to be merged into one ConfigParams object. The order in which the ConfigParams are passed to this method is important, as it regulates which values to keep in the case of identical complex keys (the ConfigParams passed later/last override the values of other ConfigParams with the same key).

    Returns ConfigParams

    merged ConfigParams.

Generated using TypeDoc