/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* NOTE: this file was copied from javax.net.ssl.SSLSecurity,
* but was heavily modified to allow com.sun.* users to
* access providers written using the javax.sun.* APIs.
*/
/**
* This class instantiates implementations of JSSE engine classes from
* providers registered with the java.security.Security object.
*
* @author Jan Luehe
* @author Jeff Nisewanger
* @author Brad Wetmore
*/
final class SSLSecurity {
/*
* Don't let anyone instantiate this.
*/
private SSLSecurity() {
}
// ProviderList.getService() is not accessible now, implement our own loop
if (s != null) {
return s;
}
}
return null;
}
/**
* The body of the driver for the getImpl method.
*/
{
try {
// system class
} else {
}
} catch (ClassNotFoundException e) {
" configured for " +
" not found: " +
e.getMessage());
} catch (SecurityException e) {
" configured for " +
" cannot be accessed: " +
e.getMessage());
}
/*
* JSSE 1.0, 1.0.1, and 1.0.2 used the com.sun.net.ssl API as the
* API was being developed. As JSSE was folded into the main
* release, it was decided to promote the com.sun.net.ssl API to
* be javax.net.ssl. It is desired to keep binary compatibility
* with vendors of JSSE implementation written using the
* com.sun.net.sll API, so we do this magic to handle everything.
*
* API used Implementation used Supported?
* ======== =================== ==========
* com.sun javax Yes
* com.sun com.sun Yes
* javax javax Yes
* javax com.sun Not Currently
*
* Make sure the implementation class is a subclass of the
* corresponding engine class.
*
* In wrapping these classes, there's no way to know how to
* wrap all possible classes that extend the TrustManager/KeyManager.
* We only wrap the x509 variants.
*/
try { // catch instantiation errors
/*
* (The following Class.forName()s should alway work, because
* this class and all the SPI classes in javax.crypto are
* loaded by the same class loader.) That is, unless they
* give us a SPI class that doesn't exist, say SSLFoo,
* or someone has removed classes from the jsse.jar file.
*/
/*
* Odds are more likely that we have a javax variant, try this
* first.
*/
} else {
/*
* We should throw an error if we get
* something totally unexpected. Don't ever
* expect to see this one...
*/
throw new IllegalStateException(
" unknown engineType wrapper:" + engineType);
}
}
} else {
throw new NoSuchAlgorithmException(
"Couldn't locate correct object or wrapper: " +
}
} catch (ClassNotFoundException e) {
"Engine Class Not Found for " + engineType);
throw exc;
}
}
/**
* Returns an array of objects: the first object in the array is
* an instance of an implementation of the requested algorithm
* and type, and the second object in the array identifies the provider
* of that implementation.
* The <code>provName</code> argument can be null, in which case all
* configured providers will be searched in order of preference.
*/
{
throw new NoSuchProviderException("No such provider: " +
provName);
}
} else {
}
+ " not available");
}
}
/**
* Returns an array of objects: the first object in the array is
* an instance of an implementation of the requested algorithm
* and type, and the second object in the array identifies the provider
* of that implementation.
* The <code>prov</code> argument can be null, in which case all
* configured providers will be searched in order of preference.
*/
throws NoSuchAlgorithmException
{
throw new NoSuchAlgorithmException("No such algorithm: " +
algName);
}
}
/*
* Checks whether one class is the superclass of another
*/
return false;
return false;
}
}
return true;
}
/*
* Return at most the first "resize" elements of an array.
*
* Didn't want to use java.util.Arrays, as PJava may not have it.
*/
}
return newArray;
}
}
/*
* =================================================================
* The remainder of this file is for the wrapper and wrapper-support
* classes. When SSLSecurity finds something which extends the
* javax.net.ssl.*Spi, we need to go grab a real instance of the
* thing that the Spi supports, and wrap into a com.sun.net.ssl.*Spi
* object. This also mean that anything going down into the SPI
* needs to be wrapped, as well as anything coming back up.
*/
}
// Keep track of the actual number of array elements copied
int dst;
int src;
// Convert com.sun.net.ssl.kma to a javax.net.ssl.kma
// wrapper if need be.
/*
* These key managers may implement both javax
* and com.sun interfaces, so if they do
* javax, there's no need to wrap them.
*/
/*
* Do we know how to convert them? If not, oh well...
* We'll have to drop them on the floor in this
* case, cause we don't know how to handle them.
* This will be pretty rare, but put here for
* completeness.
*/
dst++;
}
} else {
// We can convert directly, since they implement.
dst++;
}
src++;
}
/*
* If dst != src, there were more items in the original array
* than in the new array. Compress the new elements to avoid
* any problems down the road.
*/
}
} else {
}
// Now do the same thing with the TrustManagers.
/*
* These key managers may implement both...see above...
*/
// Do we know how to convert them?
dst++;
}
} else {
dst++;
}
src++;
}
}
} else {
}
}
return theSSLContext.getSocketFactory();
}
return theSSLContext.getServerSocketFactory();
}
}
}
}
int dst;
int src;
// We only know how to wrap X509TrustManagers, as
// TrustManagers don't have any methods to wrap.
dst++;
}
} else {
dst++;
}
src++;
}
tmaw = (TrustManager [])
}
return tmaw;
}
}
}
}
int dst;
int src;
// We only know how to wrap X509KeyManagers, as
// KeyManagers don't have any methods to wrap.
dst++;
}
} else {
dst++;
}
src++;
}
kmaw = (KeyManager [])
}
return kmaw;
}
}
// =================================
final class X509KeyManagerJavaxWrapper implements
}
}
return null;
}
/*
* Scan the list, look for something we can pass back.
*/
return retval;
}
return null;
}
/*
* JSSE 1.0.x was only socket based, but it's possible someone might
* want to install a really old provider. We should at least
* try to be nice.
*/
return null;
}
/*
* Scan the list, look for something we can pass back.
*/
return retval;
}
return null;
}
}
return null;
}
}
/*
* JSSE 1.0.x was only socket based, but it's possible someone might
* want to install a really old provider. We should at least
* try to be nice.
*/
return null;
}
}
}
}
}
final class X509TrustManagerJavaxWrapper implements
}
public void checkClientTrusted(
"Untrusted Client Certificate Chain");
}
}
public void checkServerTrusted(
"Untrusted Server Certificate Chain");
}
}
return theX509TrustManager.getAcceptedIssuers();
}
}
}
}
}
}
}
}
}
}
}
public boolean isClientTrusted(
try {
return true;
return false;
}
}
public boolean isServerTrusted(
try {
return true;
return false;
}
}
return theX509TrustManager.getAcceptedIssuers();
}
}