try to get the keystore
@param context a context
@param config the configuration
@return the keystore, or null if none provided / failure
551579
@Nullable
    public static KeyStore getKeyStore(@NonNull Context context, @NonNull CoreConfiguration config) {
        final HttpSenderConfiguration senderConfiguration = ConfigUtils.getPluginConfiguration(config, HttpSenderConfiguration.class);
        final InstanceCreator instanceCreator = new InstanceCreator();
        KeyStore keyStore = instanceCreator.create(senderConfiguration.keyStoreFactoryClass(), NoKeyStoreFactory::new).create(context);
        if(keyStore == null) {
            //either users factory did not create a keystore, or the configuration is default {@link NoKeyStoreFactory}
            final int certificateRes = senderConfiguration.resCertificate();
            final String certificatePath = senderConfiguration.certificatePath();
            final String certificateType = senderConfiguration.certificateType();
            if(certificateRes != ACRAConstants.DEFAULT_RES_VALUE){
                keyStore = new ResourceKeyStoreFactory(certificateType, certificateRes).create(context);
            }else if(!certificatePath.equals(ACRAConstants.DEFAULT_STRING_VALUE)){
                if(certificatePath.startsWith(ASSET_PREFIX)) {
                    keyStore = new AssetKeyStoreFactory(certificateType, certificatePath.substring(ASSET_PREFIX.length())).create(context);
                } else {
                    keyStore = new FileKeyStoreFactory(certificateType, certificatePath).create(context);
                }
            }
        }
        return keyStore;
    }
1027817
public static int getConf(ClientContext ctx, String... args) {
    return getConfImpl(
        () -> new RetryHandlingMetaMasterConfigClient(MasterClientContext.newBuilder(ctx).build()),
        ctx.getConf(), args);
  }
1308542
public static KeyStore getKeyStore(File keyStoreFile, String keyStorePassword, String tlsStoreType)
            throws IOException {
        KeyStore keyStore = null;
        if (keyStoreFile != null && keyStorePassword != null) {
            try (InputStream inputStream = new FileInputStream(keyStoreFile)) {
                keyStore = KeyStore.getInstance(tlsStoreType);
                keyStore.load(inputStream, keyStorePassword.toCharArray());
            } catch (CertificateException | NoSuchAlgorithmException | KeyStoreException e) {
                throw new IOException(e);
            }
        }
        return keyStore;
    }
936808
def configurationStore(self):
        """"""
        url = self._url + "/configstore"

        return ConfigurationStore(url=url,
                                  securityHandler=self._securityHandler,
                                  proxy_url=self._proxy_url,
                                  proxy_port=self._proxy_port)
457781
private String keyStorePassword()
  {
    String password = _config.get(_prefix + ".ssl.key-store-password");
    
    if (password != null) {
      return password;
    }
    else {
      return _config.get(_prefix + ".ssl.password");
    }
  }
442572
public static SSLContext buildSSLContext(HttpClientConfig config) throws IOException, GeneralSecurityException {

    KeyManagerFactory kmf = null;
    if (isSslKeyManagerEnabled(config)) {
      kmf = getKeyManagerFactory(config.getKeyStorePath(),
          new StoreProperties(config.getKeyStorePassword(), config.getKeyManagerType(),
              config.getKeyStoreType(), config.getKeyStoreProvider()));
    }
    TrustManagerFactory tmf = null;
    if (isSslTrustStoreEnbaled(config)) {
      tmf = getTrustManagerFactory(config.getTrustStorePath(), new StoreProperties(config.getTrustStorePassword(),
          config.getTrustManagerType(), config.getTrustStoreType(), config.getTrustStoreProvider()));
    }

    SSLContext sslContext = SSLContext.getInstance(config.getSslContextType());
    sslContext.init(kmf != null ? kmf.getKeyManagers() : null,
        tmf != null ? tmf.getTrustManagers() : null,
        null);

    return sslContext;
  }
1189627
public PrivateKey get(KeyStoreChooser keyStoreChooser, PrivateKeyChooserByAlias privateKeyChooserByAlias) {
        CacheKey cacheKey = new CacheKey(keyStoreChooser.getKeyStoreName(), privateKeyChooserByAlias.getAlias());
        PrivateKey retrievedPrivateKey = cache.get(cacheKey);

        if (retrievedPrivateKey != null) {
            return retrievedPrivateKey;
        }

        KeyStore keyStore = keyStoreRegistry.get(keyStoreChooser);

        if (keyStore != null) {
            PrivateKeyFactoryBean factory = new PrivateKeyFactoryBean();
            factory.setKeystore(keyStore);
            factory.setAlias(privateKeyChooserByAlias.getAlias());
            factory.setPassword(privateKeyChooserByAlias.getPassword());
            try {
                factory.afterPropertiesSet();
                PrivateKey privateKey = (PrivateKey) factory.getObject();

                if (privateKey != null) {
                    cache.put(cacheKey, privateKey);
                }
                return privateKey;
            } catch (Exception e) {
                throw new PrivateKeyException("error initializing private key factory bean", e);
            }
        }

        return null;
    }
283677
public static synchronized AbstractApplicationContext getContext(Class<?> springConfigurationClass) {
        if (!CONTEXTS.containsKey(springConfigurationClass)) {
            AbstractApplicationContext context = new AnnotationConfigApplicationContext(springConfigurationClass);
            context.registerShutdownHook();
            CONTEXTS.put(springConfigurationClass, context);
        }

        return CONTEXTS.get(springConfigurationClass);
    }
62785
protected LoginContext getLoginContext(final UsernamePasswordCredential credential) throws GeneralSecurityException {
        val callbackHandler = new UsernamePasswordCallbackHandler(credential.getUsername(), credential.getPassword());
        if (this.loginConfigurationFile != null && StringUtils.isNotBlank(this.loginConfigType)
            && this.loginConfigurationFile.exists() && this.loginConfigurationFile.canRead()) {
            final Configuration.Parameters parameters = new URIParameter(loginConfigurationFile.toURI());
            val loginConfig = Configuration.getInstance(this.loginConfigType, parameters);
            return new LoginContext(this.realm, null, callbackHandler, loginConfig);
        }
        return new LoginContext(this.realm, callbackHandler);
    }
1181556
public String getKeyStore()
			throws IOException
	{
		if (!isSecured())
		{
			return null;
		}
		
		if (keyStore == null)
		{
			throw new IllegalArgumentException("You must specify keystore file location");
		}

		final File keyStoreFile = new File(keyStore);

		if (!keyStoreFile.exists())
		{
			throw new FileNotFoundException(String.format("KeyStore file '%s' does not exists",
														  keyStoreFile.getAbsolutePath()));
		}

		return keyStore;
	}
301799
@SuppressWarnings("unchecked")
    private static ISecurityContext getCasContext(ISecurityContext context) {
        if (context instanceof ICasSecurityContext) {
            return context;
        }
        Enumeration contextEnum = context.getSubContexts();
        while (contextEnum.hasMoreElements()) {
            ISecurityContext subContext = (ISecurityContext) contextEnum.nextElement();
            if (subContext instanceof ICasSecurityContext) {
                return subContext;
            }
        }
        return null;
    }
1352735
public synchronized KeyStore do_getKeyStore(boolean reinitialize, boolean createIfNotPresent) throws Exception {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "do_getKeyStore", new Object[] { Boolean.valueOf(reinitialize), Boolean.valueOf(createIfNotPresent) });

        final String storeFile = this.location;
        final boolean create = createIfNotPresent;

        try {
            myKeyStore = obtainKeyStore(storeFile, create);
        } catch (PrivilegedActionException e) {
            Exception ex = e.getException();

            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "Cannot open keystore URL: " + storeFile + "; " + ex);

            //Return a more HW friendly message if this is PKCS11
            if (getType().equals(Constants.KEYSTORE_TYPE_JAVACRYPTO)) {
                String msg = ex.getMessage();
                if (msg == null) {
                    msg = ex.getCause().getMessage();
                }
                Tr.error(tc, "ssl.hwkeystore.load.error.CWPKI0814E", new Object[] { getName(), storeFile, msg });
            } else {
                Tr.error(tc, "ssl.keystore.load.error.CWPKI0033E", new Object[] { storeFile, ex.getMessage() });
            }

            // Caller creates FFDC
            Tr.warning(tc, "ssl.config.not.used.CWPKI0809W", new Object[] { this.name, this.name });
            throw ex;
        }

        if (isDefault)
            Tr.info(tc, "Successfully loaded default keystore: " + this.location + " of type: " + this.type);

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "do_getKeyStore", myKeyStore);
        return myKeyStore;
    }
613764
private SecretKey retrieveKey() {
        SecretKey key = null;
        try {
            String workingDir = getMain().getFileSystemManager().getSystemLocation().getAbsolutePath();
            final String keyStoreFile = workingDir + File.separator + "izou.keystore";
            KeyStore keyStore = createKeyStore(keyStoreFile, "4b[X:+H4CS&avY<)");

            KeyStore.PasswordProtection keyPassword = new KeyStore.PasswordProtection("Ev45j>eP}QTR?K9_".toCharArray());
            KeyStore.Entry entry = keyStore.getEntry("izou_key", keyPassword);
            key = ((KeyStore.SecretKeyEntry) entry).getSecretKey();
        } catch(NullPointerException e) {
            return null;
        } catch (UnrecoverableEntryException | NoSuchAlgorithmException | KeyStoreException e) {
            logger.error("Unable to retrieve key", e);
        }

        return key;
    }
103556
private static InstanceContext parseContext(JsonObject config) {
    JsonObject context = config.getObject("__context__");
    if (context == null) {
      throw new IllegalArgumentException("No component context found.");
    }
    config.removeField("__context__");
    return Contexts.deserialize(context);
  }
1347725
public SSLEngine get() {
    try {
      String pass = env.sslKeystorePassword();
      char[] password = pass == null || pass.isEmpty() ? null : pass.toCharArray();

      KeyStore ks = env.sslKeystore();
      if (ks == null) {
        ks = KeyStore.getInstance(KeyStore.getDefaultType());
        String ksFile = env.sslKeystoreFile();
        if (ksFile == null || ksFile.isEmpty()) {
          throw new IllegalArgumentException("Path to Keystore File must not be null or empty.");
        }
        ks.load(new FileInputStream(ksFile), password);
      }
      String defaultAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
      KeyManagerFactory kmf = KeyManagerFactory.getInstance(defaultAlgorithm);
      TrustManagerFactory tmf = TrustManagerFactory.getInstance(defaultAlgorithm);
      kmf.init(ks, password);
      tmf.init(ks);

      SSLContext ctx = SSLContext.getInstance("TLS");
      ctx.init(kmf.getKeyManagers(), tmf.getTrustManagers(), null);

      SSLEngine engine = ctx.createSSLEngine();
      engine.setUseClientMode(true);
      return engine;
    } catch (Exception ex) {
      throw new SSLException("Could not create SSLEngine.", ex);
    }
  }
606788
static public Object get(String key) {
        if (setContext()) {
            return m_context.get(key);
        } else {
            return m_defaultContext.get(key);
        }
    }
1348567
@Nullable
	public static SSLContext createRestServerSSLContext(Configuration config) throws Exception {
		final RestSSLContextConfigMode configMode;
		if (isRestSSLAuthenticationEnabled(config)) {
			configMode = RestSSLContextConfigMode.MUTUAL;
		} else {
			configMode = RestSSLContextConfigMode.SERVER;
		}

		return createRestSSLContext(config, configMode);
	}