lookup method

Future<CredentialParams?> lookup(
  1. String? correlationId
)

Looks up component credential parameters. If credentials are configured to be retrieved from Credential store it finds a ICredentialStore and lookups credentials there.

  • correlationId (optional) transaction id to trace execution through call chain. Returrn Future that receives resolved credential. Throw error

Implementation

Future<CredentialParams?> lookup(String? correlationId) async {
  if (_credentials.isEmpty) {
    return null;
  }

  var lookupCredentials = <CredentialParams>[];

  for (var index = 0; index < _credentials.length; index++) {
    if (!_credentials[index].useCredentialStore()) {
      return _credentials[index];
    } else {
      lookupCredentials.add(_credentials[index]);
    }
  }

  CredentialParams? firstResult;
  for (var credential in lookupCredentials) {
    var result = await _lookupInStores(correlationId, credential);
    if (result != null) {
      firstResult = result;
      break;
    }
  }

  return firstResult;
}