0N/A/*
2362N/A * Copyright (c) 2000, 2007, Oracle and/or its affiliates. All rights reserved.
0N/A * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
0N/A *
0N/A * This code is free software; you can redistribute it and/or modify it
0N/A * under the terms of the GNU General Public License version 2 only, as
2362N/A * published by the Free Software Foundation. Oracle designates this
0N/A * particular file as subject to the "Classpath" exception as provided
2362N/A * by Oracle in the LICENSE file that accompanied this code.
0N/A *
0N/A * This code is distributed in the hope that it will be useful, but WITHOUT
0N/A * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
0N/A * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
0N/A * version 2 for more details (a copy is included in the LICENSE file that
0N/A * accompanied this code).
0N/A *
0N/A * You should have received a copy of the GNU General Public License version
0N/A * 2 along with this work; if not, write to the Free Software Foundation,
0N/A * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
0N/A *
2362N/A * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
2362N/A * or visit www.oracle.com if you need additional information or have any
2362N/A * questions.
0N/A */
0N/A
0N/A/*
0N/A * NOTE: this file was copied from javax.net.ssl.SSLContext
0N/A */
0N/A
0N/Apackage com.sun.net.ssl;
0N/A
0N/Aimport java.security.*;
0N/Aimport java.util.*;
0N/Aimport javax.net.ssl.*;
0N/A
0N/Aimport sun.security.ssl.SSLSocketFactoryImpl;
0N/Aimport sun.security.ssl.SSLServerSocketFactoryImpl;
0N/A
0N/A/**
0N/A * Instances of this class represent a secure socket protocol
0N/A * implementation which acts as a factory for secure socket
0N/A * factories. This class is initialized with an optional set of
0N/A * key and trust managers and source of secure random bytes.
0N/A *
0N/A * @deprecated As of JDK 1.4, this implementation-specific class was
0N/A * replaced by {@link javax.net.ssl.SSLContext}.
0N/A */
0N/A@Deprecated
0N/Apublic class SSLContext {
0N/A private Provider provider;
0N/A
0N/A private SSLContextSpi contextSpi;
0N/A
0N/A private String protocol;
0N/A
0N/A /**
0N/A * Creates an SSLContext object.
0N/A *
0N/A * @param contextSpi the delegate
0N/A * @param provider the provider
0N/A * @param algorithm the algorithm
0N/A */
0N/A protected SSLContext(SSLContextSpi contextSpi, Provider provider,
0N/A String protocol) {
0N/A this.contextSpi = contextSpi;
0N/A this.provider = provider;
0N/A this.protocol = protocol;
0N/A }
0N/A
0N/A /**
0N/A * Generates a <code>SSLContext</code> object that implements the
0N/A * specified secure socket protocol.
0N/A *
0N/A * @param protocol the standard name of the requested protocol.
0N/A *
0N/A * @return the new <code>SSLContext</code> object
0N/A *
0N/A * @exception NoSuchAlgorithmException if the specified protocol is not
0N/A * available in the default provider package or any of the other provider
0N/A * packages that were searched.
0N/A */
0N/A public static SSLContext getInstance(String protocol)
0N/A throws NoSuchAlgorithmException
0N/A {
0N/A try {
0N/A Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext",
0N/A (String) null);
0N/A return new SSLContext((SSLContextSpi)objs[0], (Provider)objs[1],
0N/A protocol);
0N/A } catch (NoSuchProviderException e) {
0N/A throw new NoSuchAlgorithmException(protocol + " not found");
0N/A }
0N/A }
0N/A
0N/A /**
0N/A * Generates a <code>SSLContext</code> object that implements the
0N/A * specified secure socket protocol.
0N/A *
0N/A * @param protocol the standard name of the requested protocol.
0N/A * @param provider the name of the provider
0N/A *
0N/A * @return the new <code>SSLContext</code> object
0N/A *
0N/A * @exception NoSuchAlgorithmException if the specified protocol is not
0N/A * available from the specified provider.
0N/A * @exception NoSuchProviderException if the specified provider has not
0N/A * been configured.
0N/A */
0N/A public static SSLContext getInstance(String protocol, String provider)
0N/A throws NoSuchAlgorithmException, NoSuchProviderException
0N/A {
0N/A if (provider == null || provider.length() == 0)
0N/A throw new IllegalArgumentException("missing provider");
0N/A Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext",
0N/A provider);
0N/A return new SSLContext((SSLContextSpi)objs[0], (Provider)objs[1],
0N/A protocol);
0N/A }
0N/A
0N/A /**
0N/A * Generates a <code>SSLContext</code> object that implements the
0N/A * specified secure socket protocol.
0N/A *
0N/A * @param protocol the standard name of the requested protocol.
0N/A * @param provider an instance of the provider
0N/A *
0N/A * @return the new <code>SSLContext</code> object
0N/A *
0N/A * @exception NoSuchAlgorithmException if the specified protocol is not
0N/A * available from the specified provider.
0N/A */
0N/A public static SSLContext getInstance(String protocol, Provider provider)
0N/A throws NoSuchAlgorithmException
0N/A {
0N/A if (provider == null)
0N/A throw new IllegalArgumentException("missing provider");
0N/A Object[] objs = SSLSecurity.getImpl(protocol, "SSLContext",
0N/A provider);
0N/A return new SSLContext((SSLContextSpi)objs[0], (Provider)objs[1],
0N/A protocol);
0N/A }
0N/A
0N/A /**
0N/A * Returns the protocol name of this <code>SSLContext</code> object.
0N/A *
0N/A * <p>This is the same name that was specified in one of the
0N/A * <code>getInstance</code> calls that created this
0N/A * <code>SSLContext</code> object.
0N/A *
0N/A * @return the protocol name of this <code>SSLContext</code> object.
0N/A */
0N/A public final String getProtocol() {
0N/A return this.protocol;
0N/A }
0N/A
0N/A /**
0N/A * Returns the provider of this <code>SSLContext</code> object.
0N/A *
0N/A * @return the provider of this <code>SSLContext</code> object
0N/A */
0N/A public final Provider getProvider() {
0N/A return this.provider;
0N/A }
0N/A
0N/A /**
0N/A * Initializes this context. Either of the first two parameters
0N/A * may be null in which case the installed security providers will
0N/A * be searched for the highest priority implementation of the
0N/A * appropriate factory. Likewise, the secure random parameter may
0N/A * be null in which case the default implementation will be used.
0N/A *
0N/A * @param km the sources of authentication keys or null
0N/A * @param tm the sources of peer authentication trust decisions or null
0N/A * @param random the source of randomness for this generator or null
0N/A */
0N/A public final void init(KeyManager[] km, TrustManager[] tm,
0N/A SecureRandom random)
0N/A throws KeyManagementException {
0N/A contextSpi.engineInit(km, tm, random);
0N/A }
0N/A
0N/A /**
0N/A * Returns a <code>SocketFactory</code> object for this
0N/A * context.
0N/A *
0N/A * @return the factory
0N/A */
0N/A public final SSLSocketFactory getSocketFactory() {
0N/A return contextSpi.engineGetSocketFactory();
0N/A }
0N/A
0N/A /**
0N/A * Returns a <code>ServerSocketFactory</code> object for
0N/A * this context.
0N/A *
0N/A * @return the factory
0N/A */
0N/A public final SSLServerSocketFactory getServerSocketFactory() {
0N/A return contextSpi.engineGetServerSocketFactory();
0N/A }
0N/A}