< prev index next >

src/java.base/share/classes/javax/net/ssl/TrustManagerFactory.java

Print this page
rev 15967 : [mq]: GetInstance


  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.net.ssl;
  27 
  28 import java.security.Security;
  29 import java.security.*;

  30 
  31 import sun.security.jca.GetInstance;
  32 
  33 /**
  34  * This class acts as a factory for trust managers based on a
  35  * source of trust material. Each trust manager manages a specific
  36  * type of trust material for use by secure sockets. The trust
  37  * material is based on a KeyStore and/or provider-specific sources.
  38  *
  39  * <p> Every implementation of the Java platform is required to support the
  40  * following standard {@code TrustManagerFactory} algorithm:
  41  * <ul>
  42  * <li><tt>PKIX</tt></li>
  43  * </ul>
  44  * This algorithm is described in the <a href=
  45  * "{@docRoot}/../technotes/guides/security/StandardNames.html#TrustManagerFactory">
  46  * TrustManagerFactory section</a> of the
  47  * Java Cryptography Architecture Standard Algorithm Name Documentation.
  48  * Consult the release documentation for your implementation to see if any
  49  * other algorithms are supported.


 127      * TrustManagerFactorySpi implementation from the first
 128      * Provider that supports the specified algorithm is returned.
 129      *
 130      * <p> Note that the list of registered providers may be retrieved via
 131      * the {@link Security#getProviders() Security.getProviders()} method.
 132      *
 133      * @implNote
 134      * The JDK Reference Implementation additionally uses the
 135      * {@code jdk.security.provider.preferred}
 136      * {@link Security#getProperty(String) Security} property to determine
 137      * the preferred provider order for the specified algorithm. This
 138      * may be different than the order of providers returned by
 139      * {@link Security#getProviders() Security.getProviders()}.
 140      *
 141      * @param algorithm the standard name of the requested trust management
 142      *          algorithm.  See the <a href=
 143      *  "{@docRoot}/../technotes/guides/security/jsse/JSSERefGuide.html">
 144      *          Java Secure Socket Extension Reference Guide </a>
 145      *          for information about standard algorithm names.
 146      *
 147      * @return the new <code>TrustManagerFactory</code> object.
 148      *
 149      * @exception NoSuchAlgorithmException if no Provider supports a
 150      *          TrustManagerFactorySpi implementation for the
 151      *          specified algorithm.
 152      * @exception NullPointerException if algorithm is null.

 153      *
 154      * @see java.security.Provider
 155      */
 156     public static final TrustManagerFactory getInstance(String algorithm)
 157             throws NoSuchAlgorithmException {

 158         GetInstance.Instance instance = GetInstance.getInstance
 159                 ("TrustManagerFactory", TrustManagerFactorySpi.class,
 160                 algorithm);
 161         return new TrustManagerFactory((TrustManagerFactorySpi)instance.impl,
 162                 instance.provider, algorithm);
 163     }
 164 
 165     /**
 166      * Returns a <code>TrustManagerFactory</code> object that acts as a
 167      * factory for trust managers.
 168      *
 169      * <p> A new KeyManagerFactory object encapsulating the
 170      * KeyManagerFactorySpi implementation from the specified provider
 171      * is returned.  The specified provider must be registered
 172      * in the security provider list.
 173      *
 174      * <p> Note that the list of registered providers may be retrieved via
 175      * the {@link Security#getProviders() Security.getProviders()} method.
 176      *
 177      * @param algorithm the standard name of the requested trust management
 178      *          algorithm.  See the <a href=
 179      *  "{@docRoot}/../technotes/guides/security/jsse/JSSERefGuide.html">
 180      *          Java Secure Socket Extension Reference Guide </a>
 181      *          for information about standard algorithm names.
 182      *
 183      * @param provider the name of the provider.
 184      *
 185      * @return the new <code>TrustManagerFactory</code> object



 186      *
 187      * @throws NoSuchAlgorithmException if a TrustManagerFactorySpi
 188      *          implementation for the specified algorithm is not
 189      *          available from the specified provider.
 190      *
 191      * @throws NoSuchProviderException if the specified provider is not
 192      *          registered in the security provider list.
 193      *
 194      * @throws IllegalArgumentException if the provider name is null or empty.
 195      * @throws NullPointerException if algorithm is null.
 196      *
 197      * @see java.security.Provider
 198      */
 199     public static final TrustManagerFactory getInstance(String algorithm,
 200             String provider) throws NoSuchAlgorithmException,
 201             NoSuchProviderException {

 202         GetInstance.Instance instance = GetInstance.getInstance
 203                 ("TrustManagerFactory", TrustManagerFactorySpi.class,
 204                 algorithm, provider);
 205         return new TrustManagerFactory((TrustManagerFactorySpi)instance.impl,
 206                 instance.provider, algorithm);
 207     }
 208 
 209     /**
 210      * Returns a <code>TrustManagerFactory</code> object that acts as a
 211      * factory for trust managers.
 212      *
 213      * <p> A new TrustManagerFactory object encapsulating the
 214      * TrustManagerFactorySpi implementation from the specified Provider
 215      * object is returned.  Note that the specified Provider object
 216      * does not have to be registered in the provider list.
 217      *
 218      * @param algorithm the standard name of the requested trust management
 219      *          algorithm.  See the <a href=
 220      *  "{@docRoot}/../technotes/guides/security/jsse/JSSERefGuide.html">
 221      *          Java Secure Socket Extension Reference Guide </a>
 222      *          for information about standard algorithm names.
 223      *
 224      * @param provider an instance of the provider.
 225      *
 226      * @return the new <code>TrustManagerFactory</code> object.


 227      *
 228      * @throws NoSuchAlgorithmException if a TrustManagerFactorySpi
 229      *          implementation for the specified algorithm is not available
 230      *          from the specified Provider object.
 231      *
 232      * @throws IllegalArgumentException if the provider is null.
 233      * @throws NullPointerException if algorithm is null.
 234      *
 235      * @see java.security.Provider
 236      */
 237     public static final TrustManagerFactory getInstance(String algorithm,
 238             Provider provider) throws NoSuchAlgorithmException {

 239         GetInstance.Instance instance = GetInstance.getInstance
 240                 ("TrustManagerFactory", TrustManagerFactorySpi.class,
 241                 algorithm, provider);
 242         return new TrustManagerFactory((TrustManagerFactorySpi)instance.impl,
 243                 instance.provider, algorithm);
 244     }
 245 
 246     /**
 247      * Returns the provider of this <code>TrustManagerFactory</code> object.
 248      *
 249      * @return the provider of this <code>TrustManagerFactory</code> object
 250      */
 251     public final Provider getProvider() {
 252         return this.provider;
 253     }
 254 
 255 
 256     /**
 257      * Initializes this factory with a source of certificate
 258      * authorities and related trust material.




  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package javax.net.ssl;
  27 
  28 import java.security.Security;
  29 import java.security.*;
  30 import java.util.Objects;
  31 
  32 import sun.security.jca.GetInstance;
  33 
  34 /**
  35  * This class acts as a factory for trust managers based on a
  36  * source of trust material. Each trust manager manages a specific
  37  * type of trust material for use by secure sockets. The trust
  38  * material is based on a KeyStore and/or provider-specific sources.
  39  *
  40  * <p> Every implementation of the Java platform is required to support the
  41  * following standard {@code TrustManagerFactory} algorithm:
  42  * <ul>
  43  * <li><tt>PKIX</tt></li>
  44  * </ul>
  45  * This algorithm is described in the <a href=
  46  * "{@docRoot}/../technotes/guides/security/StandardNames.html#TrustManagerFactory">
  47  * TrustManagerFactory section</a> of the
  48  * Java Cryptography Architecture Standard Algorithm Name Documentation.
  49  * Consult the release documentation for your implementation to see if any
  50  * other algorithms are supported.


 128      * TrustManagerFactorySpi implementation from the first
 129      * Provider that supports the specified algorithm is returned.
 130      *
 131      * <p> Note that the list of registered providers may be retrieved via
 132      * the {@link Security#getProviders() Security.getProviders()} method.
 133      *
 134      * @implNote
 135      * The JDK Reference Implementation additionally uses the
 136      * {@code jdk.security.provider.preferred}
 137      * {@link Security#getProperty(String) Security} property to determine
 138      * the preferred provider order for the specified algorithm. This
 139      * may be different than the order of providers returned by
 140      * {@link Security#getProviders() Security.getProviders()}.
 141      *
 142      * @param algorithm the standard name of the requested trust management
 143      *          algorithm.  See the <a href=
 144      *  "{@docRoot}/../technotes/guides/security/jsse/JSSERefGuide.html">
 145      *          Java Secure Socket Extension Reference Guide </a>
 146      *          for information about standard algorithm names.
 147      *
 148      * @return the new {@code TrustManagerFactory} object
 149      *
 150      * @throws NoSuchAlgorithmException if no {@code Provider} supports a
 151      *         {@code TrustManagerFactorySpi} implementation for the
 152      *         specified algorithm
 153      *
 154      * @throws NullPointerException if {@code algorithm} is {@code null}
 155      *
 156      * @see java.security.Provider
 157      */
 158     public static final TrustManagerFactory getInstance(String algorithm)
 159             throws NoSuchAlgorithmException {
 160         Objects.requireNonNull(algorithm, "null algorithm name");
 161         GetInstance.Instance instance = GetInstance.getInstance
 162                 ("TrustManagerFactory", TrustManagerFactorySpi.class,
 163                 algorithm);
 164         return new TrustManagerFactory((TrustManagerFactorySpi)instance.impl,
 165                 instance.provider, algorithm);
 166     }
 167 
 168     /**
 169      * Returns a <code>TrustManagerFactory</code> object that acts as a
 170      * factory for trust managers.
 171      *
 172      * <p> A new KeyManagerFactory object encapsulating the
 173      * KeyManagerFactorySpi implementation from the specified provider
 174      * is returned.  The specified provider must be registered
 175      * in the security provider list.
 176      *
 177      * <p> Note that the list of registered providers may be retrieved via
 178      * the {@link Security#getProviders() Security.getProviders()} method.
 179      *
 180      * @param algorithm the standard name of the requested trust management
 181      *          algorithm.  See the <a href=
 182      *  "{@docRoot}/../technotes/guides/security/jsse/JSSERefGuide.html">
 183      *          Java Secure Socket Extension Reference Guide </a>
 184      *          for information about standard algorithm names.
 185      *
 186      * @param provider the name of the provider.
 187      *
 188      * @return the new {@code TrustManagerFactory} object
 189      *
 190      * @throws IllegalArgumentException if the provider name is
 191      *         {@code null} or empty
 192      *
 193      * @throws NoSuchAlgorithmException if a {@code TrustManagerFactorySpi}
 194      *         implementation for the specified algorithm is not
 195      *         available from the specified provider
 196      *
 197      * @throws NoSuchProviderException if the specified provider is not
 198      *         registered in the security provider list
 199      *
 200      * @throws NullPointerException if {@code algorithm} is {@code null}

 201      *
 202      * @see java.security.Provider
 203      */
 204     public static final TrustManagerFactory getInstance(String algorithm,
 205             String provider) throws NoSuchAlgorithmException,
 206             NoSuchProviderException {
 207         Objects.requireNonNull(algorithm, "null algorithm name");
 208         GetInstance.Instance instance = GetInstance.getInstance
 209                 ("TrustManagerFactory", TrustManagerFactorySpi.class,
 210                 algorithm, provider);
 211         return new TrustManagerFactory((TrustManagerFactorySpi)instance.impl,
 212                 instance.provider, algorithm);
 213     }
 214 
 215     /**
 216      * Returns a <code>TrustManagerFactory</code> object that acts as a
 217      * factory for trust managers.
 218      *
 219      * <p> A new TrustManagerFactory object encapsulating the
 220      * TrustManagerFactorySpi implementation from the specified Provider
 221      * object is returned.  Note that the specified Provider object
 222      * does not have to be registered in the provider list.
 223      *
 224      * @param algorithm the standard name of the requested trust management
 225      *          algorithm.  See the <a href=
 226      *  "{@docRoot}/../technotes/guides/security/jsse/JSSERefGuide.html">
 227      *          Java Secure Socket Extension Reference Guide </a>
 228      *          for information about standard algorithm names.
 229      *
 230      * @param provider an instance of the provider.
 231      *
 232      * @return the new {@code TrustManagerFactory} object
 233      *
 234      * @throws IllegalArgumentException if the provider is {@code null}
 235      *
 236      * @throws NoSuchAlgorithmException if a {@code TrustManagerFactorySpi}
 237      *         implementation for the specified algorithm is not available
 238      *         from the specified {@code Provider} object
 239      *
 240      * @throws NullPointerException if {@code algorithm} is {@code null}

 241      *
 242      * @see java.security.Provider
 243      */
 244     public static final TrustManagerFactory getInstance(String algorithm,
 245             Provider provider) throws NoSuchAlgorithmException {
 246         Objects.requireNonNull(algorithm, "null algorithm name");
 247         GetInstance.Instance instance = GetInstance.getInstance
 248                 ("TrustManagerFactory", TrustManagerFactorySpi.class,
 249                 algorithm, provider);
 250         return new TrustManagerFactory((TrustManagerFactorySpi)instance.impl,
 251                 instance.provider, algorithm);
 252     }
 253 
 254     /**
 255      * Returns the provider of this <code>TrustManagerFactory</code> object.
 256      *
 257      * @return the provider of this <code>TrustManagerFactory</code> object
 258      */
 259     public final Provider getProvider() {
 260         return this.provider;
 261     }
 262 
 263 
 264     /**
 265      * Initializes this factory with a source of certificate
 266      * authorities and related trust material.


< prev index next >