Makes the client out of either the envorinment,
Credentials object or associative array


@param ctx: Credential | array | Envorinement
540250
protected function make($ctx)
    {
      // ENV or raw args      
      if (!is_object($ctx)) {
        $this->user_id = $ctx['BANDWIDTH_USER_ID'];
        $this->token = $ctx['BANDWIDTH_API_TOKEN'];
        $this->secret = $ctx['BANDWIDTH_API_SECRET'];
        $this->application_id = $ctx->get('BANDWIDTH_APPLICATION_ID');
      } else {
        $this->user_id = $ctx->get('BANDWIDTH_USER_ID');
        $this->token = $ctx->get('BANDWIDTH_API_TOKEN');
        $this->secret = $ctx->get('BANDWIDTH_API_SECRET');
        $this->application_id = $ctx->get('BANDWIDTH_APPLICATION_ID');
      }

      if (!isset($this->user_id)
         ||!isset($this->token)
         ||!isset($this->secret))
              throw new \CatapultApiException("Credentials were improperly configured");

      $this->started = TRUE;

      return (self::$CLIENT = new RESTClient($this->user_id, array($this->token, $this->secret), $this->application_id));
    }
778621
public static void putAuthenticationResultBuilder(final AuthenticationResultBuilder builder, final RequestContext ctx) {
        ctx.getConversationScope().put(PARAMETER_AUTHENTICATION_RESULT_BUILDER, builder);
    }
1206029
private static Set<Credential> sanitizeCredentials(final Credential[] credentials) {
        if (credentials != null && credentials.length > 0) {
            return Arrays.stream(credentials)
                .filter(Objects::nonNull)
                .collect(Collectors.toCollection(LinkedHashSet::new));
        }
        return new HashSet<>(0);
    }
23166
public static function make($name, $credentials = [])
    {
        if (!$name && !$credentials) {
            return null;
        }

        try {
            $cacheName = (empty($name)) ? self::CACHE_DEFAULT_TYPE : $name;
            $c         = '\\' . __NAMESPACE__ . '\\' . ucfirst($cacheName);
            // check if the class exists or can be loaded
            if (!class_exists($c, true)) {
                throw new CacheException(_('The Cache is not implemented or not installed:') . $c, self::ERROR_CACHE_MISSING, Error::SEVERITY_CRIT, __FILE__, __LINE__);
            }

            /**
             * @var CacheTrait $cache
             */
            $cache = new $c($credentials);

            if ($cache->isConnected() == false) {
                throw new CacheException(_('The Cache could not establish connection:') . $c, self::ERROR_CACHE_MISSING, Error::SEVERITY_CRIT, __FILE__, __LINE__);
            }

        } catch (CacheException $e) {
            throw $e;
        }

        return $cache;
    }
668670
public AuthenticationBuilder setCredentials(final @NonNull List<CredentialMetaData> credentials) {
        this.credentials.clear();
        this.credentials.addAll(credentials);
        return this;
    }
824692
private static CredentialsProvider buildCredentialProvider(
      CredentialOptions credentialOptions) throws IOException {
    try {
      final Credentials credentials = CredentialFactory.getCredentials(credentialOptions);
      if (credentials == null) {
        LOG.info("Enabling the use of null credentials. This should not be used in production.");
        return NoCredentialsProvider.create();
      }

      return FixedCredentialsProvider.create(credentials);
    } catch (GeneralSecurityException exception) {
      throw new IOException("Could not initialize credentials.", exception);
    }
  }
174736
public static void bindCurrent(final Credential... credentials) {
        CURRENT_CREDENTIAL_IDS.set(Arrays.stream(credentials).map(Credential::getId).toArray(String[]::new));
    }
550783
public function setAuthentication(array $credentials): AbstractClientBuilder
    {
        if (array_key_exists('session_id', $credentials)) {
            $this->authentication = new HeaderAuthenticate($credentials['session_id']);
        } elseif (array_key_exists('username', $credentials) && array_key_exists('password', $credentials)) {
            $this->authentication = new HeaderLogin($credentials['username'], $credentials['password']);
        } else {
            throw new \InvalidArgumentException('No credentials given.');
        }

        return $this;
    }
1324913
protected function createClientCredentials(array $clientCredentials)
    {
        $keys = array('identifier', 'secret');

        foreach ($keys as $key) {
            if (!isset($clientCredentials[$key])) {
                throw new \InvalidArgumentException("Missing client credentials key [$key] from options.");
            }
        }

        if (isset($clientCredentials['rsa_private_key']) && isset($clientCredentials['rsa_public_key'])) {
            $_clientCredentials = new RsaClientCredentials();
            $_clientCredentials->setRsaPrivateKey($clientCredentials['rsa_private_key']);
            $_clientCredentials->setRsaPublicKey($clientCredentials['rsa_public_key']);
        } else {
            $_clientCredentials = new ClientCredentials();
        }

        $_clientCredentials->setIdentifier($clientCredentials['identifier']);
        $_clientCredentials->setSecret($clientCredentials['secret']);

        if (isset($clientCredentials['callback_uri'])) {
            $_clientCredentials->setCallbackUri($clientCredentials['callback_uri']);
        }

        return $_clientCredentials;
    }
847439
private function setUpCredentials($credentials)
    {
        if (is_array($credentials)) {
            // using full credentials
            $this->clientId = $credentials['client-id'];
            $this->clientSecret = $credentials['client-secret'];
            $this->redirectUrl = $credentials['redirect-url'];
            $this->state = $credentials['state'];
            $this->scopes = $credentials['scopes'];
        } else {
            // using self issued access token
            $this->accessToken = $credentials;
        }
    }
1184042
@Override
    public void populateCredentials(Map<String, String> credentials, Map topologyConfiguration) {
        populateCredentials(credentials, topologyConfiguration, null);
    }
523961
function ClientSSLSecurity(key, cert, ca, defaults) {
  if (key) {
    if(Buffer.isBuffer(key)) {
      this.key = key;
    } else if (typeof key === 'string') {
      this.key = fs.readFileSync(key);
    } else {
      throw new Error('key should be a buffer or a string!');
    }
  }

  if (cert) {
    if(Buffer.isBuffer(cert)) {
      this.cert = cert;
    } else if (typeof cert === 'string') {
      this.cert = fs.readFileSync(cert);
    } else {
      throw new Error('cert should be a buffer or a string!');
    }
  }

  if (ca) {
    if(Buffer.isBuffer(ca) || Array.isArray(ca)) {
      this.ca = ca;
    } else if (typeof ca === 'string') {
      this.ca = fs.readFileSync(ca);
    } else {
      defaults = ca;
      this.ca = null;
    }
  }

  this.defaults = {};
  _.merge(this.defaults, defaults);

  this.agent = null;
}
963175
public function tokenize(array $credentials)
    {
        if (empty($credentials)) {
            throw new AuthenticationException('Unable to create token, no or empty credentials');
        }

        foreach ($this->providers as $provider) {
            if (!$provider->supportsCredentials($credentials)) {
                continue;
            }

            if (!$token = $provider->tokenize($credentials)) {
                $this->stash()
                     ->destroy();

                throw new AuthenticationException(sprintf('Unable to create token, credentials could not be authenticated in provider "%s"', get_class($provider)));
            }

            $this->stash()
                 ->put($token);

            return $this;
        }

        $this->stash()
             ->destroy();

        throw new AuthenticationException(sprintf('Unable to create token, missing provider supporting credentials "%s"', implode(', ', array_keys($credentials))));
    }
384582
public function syncConnectionCredentials(ConnectionKey $connection = null, array $credentials = [])
    {
        // Store credentials if any
        if (!$credentials) {
            return;
        }

        $key = 'connections.'.$connection->name.'.servers.'.$connection->server;

        $filtered = $this->filterUnsavableCredentials($connection, $credentials);
        $this->localStorage->set($key, $filtered);

        // Merge and save
        $current = (array) $this->config->get($key);
        $credentials = array_replace_recursive($current, $credentials);
        $this->config->set($key, $credentials);

        // Reset connections
        $this->connections->disconnect();

        return $credentials;
    }
158602
@Override
    public synchronized void authenticate() throws PortalSecurityException {
        int i;
        Enumeration e = mySubContexts.elements();

        while (e.hasMoreElements()) {
            ISecurityContext sctx = ((Entry) e.nextElement()).getCtx();
            // The principal and credential are now set for all subcontexts in Authentication
            try {
                if (sctx instanceof IParentAwareSecurityContext) {
                    ((IParentAwareSecurityContext) sctx).authenticate(this);
                } else {
                    sctx.authenticate();
                }
            } catch (Exception ex) {
                log.error("Exception authenticating subcontext " + sctx, ex);
            }
            // Stop attempting to authenticate if authenticated and if the property flag is set
            if (stopWhenAuthenticated && sctx.isAuthenticated()) {
                break;
            }
        }

        // Zero out the actual credentials if it isn't already null
        if (this.myOpaqueCredentials.credentialstring != null) {
            for (i = 0; i < this.myOpaqueCredentials.credentialstring.length; i++)
                this.myOpaqueCredentials.credentialstring[i] = 0;
            myOpaqueCredentials.credentialstring = null;
        }

        return;
    }
31513
protected function createTemporaryCredentials($body)
    {
        parse_str($body, $data);

        if (!$data || !is_array($data)) {
            throw new CredentialsException('Unable to parse temporary credentials response.');
        }

        if (!isset($data['oauth_callback_confirmed']) || $data['oauth_callback_confirmed'] != 'true') {
            throw new CredentialsException('Error in retrieving temporary credentials.');
        }

        $temporaryCredentials = new TemporaryCredentials();
        $temporaryCredentials->setIdentifier($data['oauth_token']);
        $temporaryCredentials->setSecret($data['oauth_token_secret']);

        return $temporaryCredentials;
    }
754678
public ContextualReference<T> destroy(CreationalContext<T> ctx) {
        if (this.instance == null) {
            throw new IllegalStateException("Trying to call destroy() before create() was called");
        }
        if (disposed) {
            throw new IllegalStateException("Trying to call destroy() on already disposed instance");
        }
        this.disposed = true;
        bean.destroy(instance, ctx);
        return this;
    }