Get a context factory for the client from keys already stored at
    path.

    Raises IOError if the credentials didn't exist.
322170
def getContextFactory(path):
    
    with path.child("client.pem").open() as pemFile:
        cert = PrivateCertificate.loadPEM(pemFile.read())

    certOptions = cert.options() # TODO: verify server cert (see #1)
    certOptions.method = SSL.SSLv23_METHOD
    ctxFactory = SecureCiphersContextFactory(certOptions)
    return ctxFactory
1078465
def fetch(bank, key):
    '''
    
    '''
    _init_client()
    etcd_key = '{0}/{1}/{2}'.format(path_prefix, bank, key)
    try:
        value = client.read(etcd_key).value
        return __context__['serial'].loads(base64.b64decode(value))
    except etcd.EtcdKeyNotFound:
        return {}
    except Exception as exc:
        raise SaltCacheError(
            'There was an error reading the key, {0}: {1}'.format(
                etcd_key, exc
            )
        )
725694
def load_key_file(self):
        """"""
        self.client_key = None
        if self.key_file_path:
            key_file_path = self.key_file_path
        else:
            key_file_path = self._get_key_file_path()
        key_dict = {}

        logger.debug('load keyfile from %s', key_file_path);

        if os.path.isfile(key_file_path):
            with open(key_file_path, 'r') as f:
                raw_data = f.read()
                if raw_data:
                    key_dict = json.loads(raw_data)

        logger.debug('getting client_key for %s from %s', self.ip, key_file_path);
        if self.ip in key_dict:
            self.client_key = key_dict[self.ip]
740773
def fetch(self):
        
        params = values.of({})

        payload = self._version.fetch(
            'GET',
            self._uri,
            params=params,
        )

        return ExecutionContextInstance(
            self._version,
            payload,
            flow_sid=self._solution['flow_sid'],
            execution_sid=self._solution['execution_sid'],
        )
403177
def from_path(cls, path, origin=MISSING, **kwargs):
        
        origin, relpath = cls._key_from_path(path, origin)

        # Open in binary mode so we can reliably detect the encoding
        with path.open('rb') as f:
            return cls.from_file(f, origin, relpath, **kwargs)
541108
def get_ssl_context(private_key, certificate):
    
    if (
        certificate
        and os.path.isfile(certificate)
        and private_key
        and os.path.isfile(private_key)
    ):
        context = ssl.SSLContext(ssl.PROTOCOL_TLSv1_2)
        context.load_cert_chain(certificate, private_key)
        return context
    return None
770704
def connection_from_context(self, request_context):
        
        scheme = request_context['scheme'].lower()
        pool_key_constructor = self.key_fn_by_scheme[scheme]
        pool_key = pool_key_constructor(request_context)

        return self.connection_from_pool_key(pool_key, request_context=request_context)
466305
def load_from_path(path: str) -> Config:
    
    data = _ensure_load(path)
    if not data:
        data = {}
    values, should_write = _ensure_values(data)
    values.update({'path': path})
    config = Config(**values)
    if config.signature_required:
        if not os.path.exists(config.update_cert_path):
            LOG.warning(
                f"No signing cert is present in {config.update_cert_path}, "
                "code signature checking disabled")
            config = config._replace(signature_required=False)
            config = config._replace(update_cert_path=DEFAULT_CERT_PATH)
    if should_write:
        save_to_path(path, config)
    return config
440067
def _get_explicit_environ_credentials():
    """"""
    explicit_file = os.environ.get(environment_vars.CREDENTIALS)

    if explicit_file is not None:
        credentials, project_id = _load_credentials_from_file(
            os.environ[environment_vars.CREDENTIALS])

        return credentials, project_id

    else:
        return None, None
1294653
def _get_context(keyspaces, connections):
    """"""

    if keyspaces:
        if not isinstance(keyspaces, (list, tuple)):
            raise ValueError('keyspaces must be a list or a tuple.')

    if connections:
        if not isinstance(connections, (list, tuple)):
            raise ValueError('connections must be a list or a tuple.')

    keyspaces = keyspaces if keyspaces else [None]
    connections = connections if connections else [None]

    return product(connections, keyspaces)
104356
def ExtractCredentialsFromPathSpec(self, path_spec):
    
    credentials = manager.CredentialsManager.GetCredentials(path_spec)
    for identifier in credentials.CREDENTIALS:
      value = getattr(path_spec, identifier, None)
      if value is None:
        continue

      self.SetCredential(path_spec, identifier, value)
991499
def RegistryKeyFromClient(args):
  
  for path in _GetExpandedPaths(args):
    pathspec = rdf_paths.PathSpec(
        path=path, pathtype=rdf_paths.PathSpec.PathType.REGISTRY)
    with vfs.VFSOpen(pathspec) as file_obj:
      yield file_obj.Stat()
1219391
protected String getResourceCacheKey(String path, GeneratorContext context) {

		StringBuilder strbCacheKey = new StringBuilder(path);
		if (StringUtils.isNotEmpty(context.getBracketsParam())) {
			strbCacheKey.append("_").append(context.getBracketsParam());
		}
		if (StringUtils.isNotEmpty(context.getParenthesesParam())) {
			strbCacheKey.append("_").append(context.getParenthesesParam());
		}

		String cacheKey = strbCacheKey.toString();

		Locale locale = context.getLocale();
		if (locale != null) {
			cacheKey = LocaleUtils.toBundleName(strbCacheKey.toString(), locale);

		}

		cacheKey = cacheKey.replaceAll("[^\\w\\.\\-]", "_");

		return cacheKey;
	}
1090529
def _mk_client():
    '''
    
    '''
    if 'cp.fileclient_{0}'.format(id(__opts__)) not in __context__:
        __context__['cp.fileclient_{0}'.format(id(__opts__))] = \
                salt.fileclient.get_file_client(__opts__)
1052093
def _get_client(self):
        
        return (_oss.StsAuth if 'security_token' in self._storage_parameters
                else _oss.Auth if self._storage_parameters
                else _oss.AnonymousAuth)(**self._storage_parameters)
758595
private SslContext getSslContext() {
        final SslContext sslCtx;
        if (clientConfig.isEnableTls()) {
            try {
                SslContextBuilder clientSslCtxBuilder = SslContextBuilder.forClient();
                if (Strings.isNullOrEmpty(clientConfig.getTrustStore())) {
                    clientSslCtxBuilder = clientSslCtxBuilder.trustManager(FingerprintTrustManagerFactory
                                                                                   .getInstance(FingerprintTrustManagerFactory.getDefaultAlgorithm()));
                    log.debug("SslContextBuilder was set to an instance of {}", FingerprintTrustManagerFactory.class);
                } else {
                    clientSslCtxBuilder = SslContextBuilder.forClient()
                                                           .trustManager(new File(clientConfig.getTrustStore()));
                }
                sslCtx = clientSslCtxBuilder.build();
            } catch (SSLException | NoSuchAlgorithmException e) {
                throw new RuntimeException(e);
            }
        } else {
            sslCtx = null;
        }
        return sslCtx;
    }
1114912
def client(self):
        
        ctx = stack.top
        attr_name = self._config_key("client")
        if ctx is not None:
            if not hasattr(ctx, attr_name):
                setattr(
                    ctx,
                    attr_name,
                    BankIDClient(
                        (
                            current_app.config.get(self._config_key("CERT_PATH")),
                            current_app.config.get(self._config_key("KEY_PATH")),
                        ),
                        current_app.config.get(self._config_key("TEST_SERVER")),
                    ),
                )
            return getattr(ctx, attr_name)