code: public static AsymmetricKeyCredential create(final String clientId,
              final InputStream pkcs12Certificate, final String password)
              throws KeyStoreException, NoSuchProviderException,
              NoSuchAlgorithmException, CertificateException, IOException, UnrecoverableKeyException {
          final KeyStore keystore = KeyStore.getInstance("PKCS12", "SunJSSE");
          keystore.load(pkcs12Certificate, password.toCharArray());
          final Enumeration<String> aliases = keystore.aliases();
          final String alias = aliases.nextElement();
          final PrivateKey key = (PrivateKey) keystore.getKey(alias,
                  password.toCharArray());
          final X509Certificate publicCertificate = (X509Certificate) keystore
                  .getCertificate(alias);
          return create(clientId, key, publicCertificate);
      }
docs: Static method to create KeyCredential instance.
  
  @param clientId
  Identifier of the client requesting the token.
  @param pkcs12Certificate
  PKCS12 certificate stream containing public and private key.
  Caller is responsible for handling the input stream.
  @param password
  certificate password
  @return KeyCredential instance
  @throws KeyStoreException {@link KeyStoreException}
  @throws NoSuchProviderException {@link NoSuchProviderException}
  @throws NoSuchAlgorithmException {@link NoSuchAlgorithmException}
  @throws CertificateException {@link CertificateException}
  @throws IOException {@link IOException}
  @throws UnrecoverableKeyException {@link UnrecoverableKeyException}