Creates a new {@link KeyStoreCredentialResolver}.
340637
public CredentialResolver build() throws IOException, GeneralSecurityException {
        final KeyStore ks = KeyStore.getInstance(type);
        try (InputStream is = open()) {
            ks.load(is, password != null ? password.toCharArray() : null);
        }
        return new KeyStoreCredentialResolver(ks, keyPasswords);
    }
537435
public ClientBuilderForConnector withCredentialsId(String credentialsId)
            throws UnrecoverableKeyException, NoSuchAlgorithmException, KeyStoreException, KeyManagementException {
        if (isNotBlank(credentialsId)) {
            withCredentials(lookupSystemCredentials(credentialsId));
        } else {
            withSslConfig(null);
        }

        return this;
    }
416797
function createResolver () {
    var
      resolver = {
        settled: false,
        fulfilledValues: [],
        rejectedValues: []
      },
      promise = new Promise(function promiseResolver (fulfill, reject) {
        resolver.fulfill = fulfill;
        resolver.reject = reject;
      });

    promise.fulfilled = 0;
    promise.rejected = 0;
    promise.pending = 0;
    resolver.promise = promise;

    return resolver;
  }
721509
public static void updateWithSelfSignedServerCertificate(KeyStore pKeyStore)
            throws NoSuchProviderException, NoSuchAlgorithmException, IOException,
                   InvalidKeyException, CertificateException, SignatureException, KeyStoreException {

        final Object x500Name;
        final Object[] certAttributes = { "Jolokia Agent " + Version.getAgentVersion(), // CN
                                          "JVM",                                        // OU
                                          "jolokia.org",                                // O
                                          "Pegnitz",                                    // L
                                          "Franconia",                                  // ST
                                          "DE" };
        if (ClassUtil.checkForClass(X500_NAME_SUN)) {
            x500Name = ClassUtil.newInstance(X500_NAME_SUN, certAttributes);
        } else if (ClassUtil.checkForClass(X500_NAME_IBM)) {
            x500Name = ClassUtil.newInstance(X500_NAME_IBM, certAttributes);
        } else {
            throw new IllegalStateException("Neither Sun- nor IBM-style JVM found.");
        }

        // Need to do it via reflection because Java8 moved class to a different package
        Object keypair = createKeyPair();
        PrivateKey privKey = getPrivateKey(keypair);

        X509Certificate[] chain = new X509Certificate[1];
        chain[0] = getSelfCertificate(keypair, x500Name, new Date(), (long) 3650 * 24 * 60 * 60);
        pKeyStore.setKeyEntry("jolokia-agent", privKey, new char[0], chain);
    }
272252
public static KeyStore createTrustStore(final Reader certReader) throws IOException, CertificateException,
            KeyStoreException, NoSuchAlgorithmException {
        try (PEMParser pemParser = new PEMParser(certReader)) {

            KeyStore trustStore = KeyStore.getInstance("JKS");
            trustStore.load(null);

            int index = 1;
            Object pemCert;

            while ((pemCert = pemParser.readObject()) != null) {
                Certificate caCertificate = new JcaX509CertificateConverter()
                        .setProvider(BouncyCastleProvider.PROVIDER_NAME)
                        .getCertificate((X509CertificateHolder) pemCert);
                trustStore.setCertificateEntry("ca-" + index, caCertificate);
                index++;
            }

            return trustStore;
        }
    }
279311
public GlobusCredential createCredential(X509Certificate[] certs, PrivateKey privateKey, int bits, int lifetime,
        int delegationMode) throws GeneralSecurityException {
        return createCredential(certs, privateKey, bits, lifetime, delegationMode, (X509ExtensionSet) null, null);
    }
918737
public static Keyspace createKeyspace(String keyspace, Cluster cluster,
      ConsistencyLevelPolicy consistencyLevelPolicy,
      FailoverPolicy failoverPolicy) {
    return new ExecutingKeyspace(keyspace, cluster.getConnectionManager(),
        consistencyLevelPolicy, failoverPolicy, cluster.getCredentials());
  }
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;
    }
941391
private static KeyManagerFactory getKeyManagerFactory(InputStream keyStoreStream, StoreProperties storeProperties)
      throws IOException, GeneralSecurityException {
    // use provider if given, otherwise use the first matching security provider
    final KeyStore ks;
    if (StringUtils.isNotBlank(storeProperties.getProvider())) {
      ks = KeyStore.getInstance(storeProperties.getType(), storeProperties.getProvider());
    }
    else {
      ks = KeyStore.getInstance(storeProperties.getType());
    }
    ks.load(keyStoreStream, storeProperties.getPassword().toCharArray());
    KeyManagerFactory kmf = KeyManagerFactory.getInstance(storeProperties.getManagerType());
    kmf.init(ks, storeProperties.getPassword().toCharArray());
    return kmf;
  }
552421
private StandardCredentials createCredentials(@Nonnull String serverAPIUrl,
                                                  final StandardCredentials credentials) {
        URI serverUri = URI.create(defaultIfBlank(serverAPIUrl, GITHUB_URL));

        List<DomainSpecification> specifications = asList(
                new SchemeSpecification(serverUri.getScheme()),
                new HostnameSpecification(serverUri.getHost(), null)
        );

        final Domain domain = new Domain(serverUri.getHost(), "GitHub domain (autogenerated)", specifications);
        ACL.impersonate(ACL.SYSTEM, new Runnable() { // do it with system rights
            @Override
            public void run() {
                try {
                    new SystemCredentialsProvider.StoreImpl().addDomain(domain, credentials);
                } catch (IOException e) {
                    LOGGER.error("Can't add creds for domain", e);
                }
            }
        });

        return credentials;
    }
504869
private static TrustManagerFactory getTrustManagerFactory(InputStream trustStoreStream, StoreProperties storeProperties)
      throws IOException, GeneralSecurityException {

    // use provider if given, otherwise use the first matching security provider
    final KeyStore ks;
    if (StringUtils.isNotBlank(storeProperties.getProvider())) {
      ks = KeyStore.getInstance(storeProperties.getType(), storeProperties.getProvider());
    }
    else {
      ks = KeyStore.getInstance(storeProperties.getType());
    }

    ks.load(trustStoreStream, storeProperties.getPassword().toCharArray());
    TrustManagerFactory tmf = TrustManagerFactory.getInstance(storeProperties.getManagerType());
    tmf.init(ks);
    return tmf;
  }
1336286
public GSSCredential createCredential (byte[] buff,
					   int option,
					   int lifetime,
					   Oid mech,
					   int usage)
	throws GSSException {
	checkMechanism(mech);

	if (buff == null || buff.length < 1) {
	    throw new GlobusGSSException(GSSException.FAILURE,
					 GlobusGSSException.BAD_ARGUMENT,
					 "invalidBuf");
	}

	if (lifetime == GSSCredential.INDEFINITE_LIFETIME ||
            lifetime > 0) {
            // lifetime not supported
            throw new GlobusGSSException(GSSException.FAILURE,
                                         GlobusGSSException.BAD_ARGUMENT,
                                         "badLifetime01");
	}

	InputStream input = null;

	switch (option) {
	case ExtendedGSSCredential.IMPEXP_OPAQUE:
	    input = new ByteArrayInputStream(buff);
	    break;
	case ExtendedGSSCredential.IMPEXP_MECH_SPECIFIC:
	    String s = new String(buff);
	    int pos = s.indexOf('=');
	    if (pos == -1) {
		throw new GSSException(GSSException.FAILURE);
	    }
	    String filename = s.substring(pos+1).trim();
	    try {
		input = new FileInputStream(filename);
	    } catch (IOException e) {
		throw new GlobusGSSException(GSSException.FAILURE, e);
	    }
	    break;
	default:
	    throw new GlobusGSSException(GSSException.FAILURE,
					 GlobusGSSException.BAD_ARGUMENT,
					 "unknownOption",
					 new Object[] {new Integer(option)});
	}

	X509Credential cred = null;
	try {
	    cred = new X509Credential(input);
	} catch(CredentialException e) {
	    throw new GlobusGSSException(GSSException.DEFECTIVE_CREDENTIAL, e);
	} catch (Exception e) {
	    throw new GlobusGSSException(GSSException.DEFECTIVE_CREDENTIAL, e);
	}

	return new GlobusGSSCredentialImpl(cred, usage);
    }
320439
public static KeyStore createTrustStore(String capem) throws IOException, CertificateException,
            KeyStoreException, NoSuchAlgorithmException {
        try (Reader certReader = new StringReader(capem)) {
            return createTrustStore(certReader);
        }
    }
36698
public static CloseableHttpClient createKeyMaterialHttpClient(KeyStore keystore,String keyPassword,int timeout,int retryExecutionCount) {
		return createKeyMaterialHttpClient(keystore, keyPassword, supportedProtocols,timeout,retryExecutionCount);
	}
401162
private String createSignature(Credentials credentials, String secretKey) {
        return new SignatureGenerator().generate(
                secretKey,
                credentials.getMethod(),
                credentials.getTimestamp(),
                credentials.getPath(),
                credentials.getContent());
    }
561251
public static PropertyResolver createResolver(PropertyRetriever instanceRetriever,
            PropertyRetriever projectRetriever, PropertyRetriever frameworkRetriever) {
        return new RuntimePropertyResolver(instanceRetriever, projectRetriever, frameworkRetriever);
    }
187585
protected I_CmsCredentialsResolver getCredentialsResolver() {

        if (m_credentialsResolver == null) {
            CmsSystemConfiguration systemConfig = (CmsSystemConfiguration)m_configurationManager.getConfiguration(
                CmsSystemConfiguration.class);
            return systemConfig.getCredentialsResolver();
        }

        return m_credentialsResolver;
    }