Bind credentials to ThreadLocal.

@param credentials the credentials
174736
public static void bindCurrent(final Credential... credentials) {
        CURRENT_CREDENTIAL_IDS.set(Arrays.stream(credentials).map(Credential::getId).toArray(String[]::new));
    }
491700
protected void commitLocalConnection(Connection connection) {
    try {
      if (connection != null ) {
        connection.commit();
      }
    } catch (SQLException e) {
      if (logger.isTraceEnabled()) {
        logger.trace(e.getMessage());
      }
    }
  }
1335979
def create_queue(self, credentials):
        
        if credentials:
            session = self.session or aiohttp.ClientSession(loop=self.event_loop)
            return Queue(
                options={
                    'credentials': credentials,
                    'rootUrl': self.config['taskcluster_root_url'],
                },
                session=session
            )
1006803
private void getCredentials() {
        jcrService.getUserName(new BaseCallback<String>() {
            @Override
            public void onSuccess(String name) {
                showMainForm(name);
            }
        });
    }
85170
private void addLocalRuntimeDefinition(
          final AvroLocalAppSubmissionParameters localAppSubmissionParams,
          final AvroJobSubmissionParameters jobSubmissionParameters,
          final MultiRuntimeDefinitionBuilder builder) {
    // create and serialize local configuration if defined
    final Configuration localModule = LocalDriverConfiguration.CONF
            .set(LocalDriverConfiguration.MAX_NUMBER_OF_EVALUATORS,
                    localAppSubmissionParams.getMaxNumberOfConcurrentEvaluators())
            // ROOT FOLDER will point to the current runtime directory
            .set(LocalDriverConfiguration.ROOT_FOLDER, ".")
            .set(LocalDriverConfiguration.JVM_HEAP_SLACK, 0.0)
            .set(LocalDriverConfiguration.CLIENT_REMOTE_IDENTIFIER, ClientRemoteIdentifier.NONE)
            .set(LocalDriverConfiguration.JOB_IDENTIFIER,
                    jobSubmissionParameters.getJobId().toString())
            .set(LocalDriverConfiguration.RUNTIME_NAMES,
                    org.apache.reef.runtime.local.driver.RuntimeIdentifier.RUNTIME_NAME)
            .build();

    // add local runtime to the builder
    builder.addRuntime(localModule, org.apache.reef.runtime.local.driver.RuntimeIdentifier.RUNTIME_NAME);
  }
863850
public void setContextParameters(
            Map<String, String> principals,
            Map<String, String> credentials,
            String ctxName,
            ISecurityContext securityContext) {

        if (log.isDebugEnabled()) {
            final StringBuilder msg = new StringBuilder();
            msg.append("Preparing to authenticate;  setting parameters for context name '")
                    .append(ctxName)
                    .append("', context class '")
                    .append(securityContext.getClass().getName())
                    .append("'");
            // Display principalTokens...
            msg.append("\n\t Available Principal Tokens");
            for (final Object o : principals.entrySet()) {
                final Map.Entry<?, ?> y = (Map.Entry<?, ?>) o;
                msg.append("\n\t\t").append(y.getKey()).append("=").append(y.getValue());
            }
            // Keep credentialTokens secret, but indicate whether they were provided...
            msg.append("\n\t Available Credential Tokens");
            for (final Object o : credentials.entrySet()) {
                final Map.Entry<?, ?> y = (Map.Entry<?, ?>) o;
                final String val = (String) y.getValue();
                String valWasSpecified = null;
                if (val != null) {
                    valWasSpecified = val.trim().length() == 0 ? "empty" : "provided";
                }
                msg.append("\n\t\t").append(y.getKey()).append(" was ").append(valWasSpecified);
            }
            log.debug(msg.toString());
        }

        String username = principals.get(ctxName);
        String credential = credentials.get(ctxName);
        // If username or credential are null, this indicates that the token was not
        // set in security.properties. We will then use the value for root.
        username = username != null ? username : (String) principals.get(BASE_CONTEXT_NAME);
        credential = credential != null ? credential : (String) credentials.get(BASE_CONTEXT_NAME);
        if (log.isDebugEnabled()) {
            log.debug("Authentication::setContextParameters() username: " + username);
        }
        // Retrieve and populate an instance of the principal object
        final IPrincipal principalInstance = securityContext.getPrincipalInstance();
        if (username != null && !username.equals("")) {
            principalInstance.setUID(username);
        }
        // Retrieve and populate an instance of the credentials object
        final IOpaqueCredentials credentialsInstance =
                securityContext.getOpaqueCredentialsInstance();
        if (credentialsInstance != null) {
            credentialsInstance.setCredentials(credential);
        }
    }
1087220
def read_credentials(self, credentials):
        
        self._items.clear()
        for key in credentials.get_key_names():
            value = credentials.get_as_nullable_string(key)
            self._items.append(CredentialParams.from_tuples([key, value]))
1145901
@Override
    public synchronized void refreshCredentials() {
        GetSessionTokenResult sessionTokenResult = securityTokenService
                .getSessionToken(new GetSessionTokenRequest().withDurationSeconds(sessionDurationSeconds));
        sessionCredentials = sessionTokenResult.getCredentials();
    }
941887
def from_credentials(credentials, loop: asyncio.AbstractEventLoop=asyncio.get_event_loop()):
        
        return API(username=credentials.username, password=credentials.password,
                   database=credentials.database, session_id=credentials.session_id,
                   server=credentials.server, loop=loop)
743696
public void cleanThreadLocals(Thread thread) {
        try {
            svThreadLocalsField.set(thread, null);
        } catch (IllegalAccessException e) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Unable to clear java.lang.ThreadLocals: ", e);
        }
    }
34058
def RegisterCredentials(cls, credentials):
    
    if credentials.type_indicator in cls._credentials:
      raise KeyError(
          'Credentials object already set for type indicator: {0:s}.'.format(
              credentials.type_indicator))

    cls._credentials[credentials.type_indicator] = credentials
1357950
public synchronized final void putThreadLocal(Object key, Object value)
    {
        if (sealed) onSealedMutation();
        if (threadLocalMap == null)
            threadLocalMap = new HashMap<Object,Object>();
        threadLocalMap.put(key, value);
    }
1034999
def set_credentials(self, username, password=None, region=None,
            tenant_id=None, authenticate=False):
        """"""
        self.username = username
        self.password = password
        self.tenant_id = tenant_id
        if region:
            self.region = region
        if authenticate:
            self.authenticate()
842430
public void readCredentials(ConfigParams credentials) {
		synchronized (_lock) {
			_items.clear();
			for (Map.Entry<String, String> entry : credentials.entrySet())
				_items.put(entry.getKey(), CredentialParams.fromString(entry.getValue()));
		}
	}
904309
def _thread_init(cls):
    """"""
    if not hasattr(cls._local, '_in_order_futures'):
      cls._local._in_order_futures = set()
      cls._local._activated = False
33517
public synchronized Object put(Object name, Object credentials)
    {
        if (credentials instanceof Principal)
            return super.put(name.toString(),
                             credentials);
        
        if (credentials instanceof Password)
            return super.put(name,
                             new KnownUser(name.toString(),
                                          (Password)credentials));
        if (credentials != null)
            return super
                .put(name,
                     new KnownUser(name.toString(),
                                   Credential.getCredential(credentials.toString())));
        return null;
    }
551293
public static void bind(ApplicationContext context) {
        Object old = contextMap.putIfAbsent(getContextClassLoader(), context);
        if (old != null) {
            throw new IllegalStateException(
                "There is already a ApplicationContext associated with the context ClassLoader of the current thread!");
        }
    }