hc-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ggreg...@apache.org
Subject httpcomponents-core git commit: Redo where null checks are performed. Add Javadocs.
Date Sat, 13 May 2017 21:56:09 GMT
Repository: httpcomponents-core
Updated Branches:
  refs/heads/dev/4.4.x/HTTPCORE-466 2aea74193 -> 0945489ce


Redo where null checks are performed. Add Javadocs.

Project: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/repo
Commit: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/commit/0945489c
Tree: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/tree/0945489c
Diff: http://git-wip-us.apache.org/repos/asf/httpcomponents-core/diff/0945489c

Branch: refs/heads/dev/4.4.x/HTTPCORE-466
Commit: 0945489ceba403853496dc19c92de6a2b43dd570
Parents: 2aea741
Author: Gary Gregory <garydgregory@gmail.com>
Authored: Sat May 13 14:56:07 2017 -0700
Committer: Gary Gregory <garydgregory@gmail.com>
Committed: Sat May 13 14:56:07 2017 -0700

----------------------------------------------------------------------
 .../org/apache/http/ssl/SSLContextBuilder.java  | 59 ++++++++++++++++----
 1 file changed, 49 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/httpcomponents-core/blob/0945489c/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
----------------------------------------------------------------------
diff --git a/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java b/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
index 01d6fd3..f3c4add 100644
--- a/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
+++ b/httpcore/src/main/java/org/apache/http/ssl/SSLContextBuilder.java
@@ -71,7 +71,9 @@ import org.apache.http.util.Args;
  * <a href="http://docs.oracle.com/javase/7/docs/api/javax/net/ssl/SSLContext.html#init%28javax.net.ssl.KeyManager[],%20javax.net.ssl.TrustManager[],%20java.security.SecureRandom%29">
  * SSLContext.html#init
  * </a>
- *
+ * <p>
+ * TODO Specify which Oracle JSSE versions the above has been verified.
+ *  </p>
  * @since 4.4
  */
 public class SSLContextBuilder {
@@ -154,6 +156,18 @@ public class SSLContextBuilder {
     }
 
     /**
+     * Sets the key store type.
+     *
+     * @param keyStoreType
+     *            the SSLkey store type. See
+     *            the KeyStore section in the <a href=
+     *            "https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#KeyStore">Java
+     *            Cryptography Architecture Standard Algorithm Name
+     *            Documentation</a> for more information.
+     * @return this builder
+     * @see <a href=
+     *      "https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#KeyStore">Java
+     *      Cryptography Architecture Standard Algorithm Name Documentation</a>
      * @since 4.4.7
      */
     public SSLContextBuilder setKeyStoreType(final String keyStoreType) {
@@ -162,27 +176,51 @@ public class SSLContextBuilder {
     }
 
     /**
+     * Sets the key manager factory algorithm name.
+     *
+     * @param keyManagerFactoryAlgorithm
+     *            the key manager factory algorithm name of the requested protocol. See
+     *            the KeyManagerFactory section in the <a href=
+     *            "https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#KeyManagerFactory">Java
+     *            Cryptography Architecture Standard Algorithm Name
+     *            Documentation</a> for more information.
+     * @return this builder
+     * @see <a href=
+     *      "https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#KeyManagerFactory">Java
+     *      Cryptography Architecture Standard Algorithm Name Documentation</a>
      * @since 4.4.7
      */
     public SSLContextBuilder setKeyManagerFactoryAlgorithm(final String keyManagerFactoryAlgorithm)
{
-        this.keyManagerFactoryAlgorithm = keyManagerFactoryAlgorithm == null ? KeyManagerFactory.getDefaultAlgorithm()
-                : keyManagerFactoryAlgorithm;
+        this.keyManagerFactoryAlgorithm = keyManagerFactoryAlgorithm;
         return this;
     }
 
     /**
+     * Sets the trust manager factory algorithm name.
+     *
+     * @param trustManagerFactoryAlgorithm
+     *            the trust manager algorithm name of the requested protocol. See
+     *            the TrustManagerFactory section in the <a href=
+     *            "https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#TrustManagerFactory">Java
+     *            Cryptography Architecture Standard Algorithm Name
+     *            Documentation</a> for more information.
+     * @return this builder
+     * @see <a href=
+     *      "https://docs.oracle.com/javase/8/docs/technotes/guides/security/StandardNames.html#TrustManagerFactory">Java
+     *      Cryptography Architecture Standard Algorithm Name Documentation</a>
      * @since 4.4.7
      */
     public SSLContextBuilder setTrustManagerFactoryAlgorithm(final String trustManagerFactoryAlgorithm)
{
-        this.trustManagerFactoryAlgorithm = trustManagerFactoryAlgorithm == null ? TrustManagerFactory.getDefaultAlgorithm()
-                : trustManagerFactoryAlgorithm;
+        this.trustManagerFactoryAlgorithm = trustManagerFactoryAlgorithm;
         return this;
     }
 
     public SSLContextBuilder loadTrustMaterial(
             final KeyStore truststore,
             final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException
{
-        final TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(trustManagerFactoryAlgorithm);
+        final TrustManagerFactory tmfactory = TrustManagerFactory
+                .getInstance(trustManagerFactoryAlgorithm == null ? TrustManagerFactory.getDefaultAlgorithm()
+                        : trustManagerFactoryAlgorithm);
         tmfactory.init(truststore);
         final TrustManager[] tms = tmfactory.getTrustManagers();
         if (tms != null) {
@@ -190,8 +228,7 @@ public class SSLContextBuilder {
                 for (int i = 0; i < tms.length; i++) {
                     final TrustManager tm = tms[i];
                     if (tm instanceof X509TrustManager) {
-                        tms[i] = new TrustManagerDelegate(
-                                (X509TrustManager) tm, trustStrategy);
+                        tms[i] = new TrustManagerDelegate((X509TrustManager) tm, trustStrategy);
                     }
                 }
             }
@@ -259,9 +296,11 @@ public class SSLContextBuilder {
             final char[] keyPassword,
             final PrivateKeyStrategy aliasStrategy)
             throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException
{
-        final KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(keyManagerFactoryAlgorithm);
+        final KeyManagerFactory kmfactory = KeyManagerFactory
+                .getInstance(keyManagerFactoryAlgorithm == null ? KeyManagerFactory.getDefaultAlgorithm()
+                        : keyManagerFactoryAlgorithm);
         kmfactory.init(keystore, keyPassword);
-        final KeyManager[] kms =  kmfactory.getKeyManagers();
+        final KeyManager[] kms = kmfactory.getKeyManagers();
         if (kms != null) {
             if (aliasStrategy != null) {
                 for (int i = 0; i < kms.length; i++) {


Mime
View raw message