feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
48
jdkSrc/jdk8/javax/rmi/CORBA/ClassDesc.java
Normal file
48
jdkSrc/jdk8/javax/rmi/CORBA/ClassDesc.java
Normal file
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2000, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package javax.rmi.CORBA;
|
||||
|
||||
/**
|
||||
* This class is used to marshal java.lang.Class objects over IIOP.
|
||||
*/
|
||||
public class ClassDesc implements java.io.Serializable {
|
||||
|
||||
/**
|
||||
* @serial The class's RepositoryId.
|
||||
*/
|
||||
private String repid;
|
||||
|
||||
/**
|
||||
* @serial A space-separated list of codebase URLs.
|
||||
*/
|
||||
private String codebase;
|
||||
}
|
||||
108
jdkSrc/jdk8/javax/rmi/CORBA/GetORBPropertiesFileAction.java
Normal file
108
jdkSrc/jdk8/javax/rmi/CORBA/GetORBPropertiesFileAction.java
Normal file
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* (C) Copyright IBM Corp. 1993 - 1997 - All Rights Reserved
|
||||
*
|
||||
* The original version of this source code and documentation is
|
||||
* copyrighted and owned by IBM, Inc. These materials are provided under
|
||||
* terms of a License Agreement between IBM and Sun. This technology is
|
||||
* protected by multiple US and International patents. This notice and
|
||||
* attribution to IBM may not be removed.
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
package javax.rmi.CORBA;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import sun.security.action.GetPropertyAction;
|
||||
import java.util.Properties;
|
||||
|
||||
class GetORBPropertiesFileAction implements PrivilegedAction {
|
||||
private boolean debug = false ;
|
||||
|
||||
public GetORBPropertiesFileAction () {
|
||||
}
|
||||
|
||||
private String getSystemProperty(final String name) {
|
||||
// This will not throw a SecurityException because this
|
||||
// class was loaded from rt.jar using the bootstrap classloader.
|
||||
String propValue = (String) AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public java.lang.Object run() {
|
||||
return System.getProperty(name);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return propValue;
|
||||
}
|
||||
|
||||
private void getPropertiesFromFile( Properties props, String fileName )
|
||||
{
|
||||
try {
|
||||
File file = new File( fileName ) ;
|
||||
if (!file.exists())
|
||||
return ;
|
||||
|
||||
FileInputStream in = new FileInputStream( file ) ;
|
||||
|
||||
try {
|
||||
props.load( in ) ;
|
||||
} finally {
|
||||
in.close() ;
|
||||
}
|
||||
} catch (Exception exc) {
|
||||
if (debug)
|
||||
System.out.println( "ORB properties file " + fileName +
|
||||
" not found: " + exc) ;
|
||||
}
|
||||
}
|
||||
|
||||
public Object run()
|
||||
{
|
||||
Properties defaults = new Properties() ;
|
||||
|
||||
String javaHome = getSystemProperty( "java.home" ) ;
|
||||
String fileName = javaHome + File.separator + "lib" + File.separator +
|
||||
"orb.properties" ;
|
||||
|
||||
getPropertiesFromFile( defaults, fileName ) ;
|
||||
|
||||
Properties results = new Properties( defaults ) ;
|
||||
|
||||
String userHome = getSystemProperty( "user.home" ) ;
|
||||
fileName = userHome + File.separator + "orb.properties" ;
|
||||
|
||||
getPropertiesFromFile( results, fileName ) ;
|
||||
return results ;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
/*
|
||||
* Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package javax.rmi.CORBA;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.NoSuchObjectException;
|
||||
import java.rmi.Remote;
|
||||
|
||||
/**
|
||||
* Supports delegation for method implementations in {@link javax.rmi.PortableRemoteObject}.
|
||||
* The delegate is a singleton instance of a class that implements this
|
||||
* interface and provides a replacement implementation for all the
|
||||
* methods of <code>javax.rmi.PortableRemoteObject</code>.
|
||||
*
|
||||
* Delegates are enabled by providing the delegate's class name as the
|
||||
* value of the
|
||||
* <code>javax.rmi.CORBA.PortableRemoteObjectClass</code>
|
||||
* system property.
|
||||
*
|
||||
* @see javax.rmi.PortableRemoteObject
|
||||
*/
|
||||
public interface PortableRemoteObjectDelegate {
|
||||
|
||||
/**
|
||||
* Delegation call for {@link javax.rmi.PortableRemoteObject#exportObject}.
|
||||
*/
|
||||
void exportObject(Remote obj)
|
||||
throws RemoteException;
|
||||
|
||||
/**
|
||||
* Delegation call for {@link javax.rmi.PortableRemoteObject#toStub}.
|
||||
*/
|
||||
Remote toStub (Remote obj)
|
||||
throws NoSuchObjectException;
|
||||
|
||||
/**
|
||||
* Delegation call for {@link javax.rmi.PortableRemoteObject#unexportObject}.
|
||||
*/
|
||||
void unexportObject(Remote obj)
|
||||
throws NoSuchObjectException;
|
||||
|
||||
/**
|
||||
* Delegation call for {@link javax.rmi.PortableRemoteObject#narrow}.
|
||||
*/
|
||||
java.lang.Object narrow (java.lang.Object narrowFrom,
|
||||
java.lang.Class narrowTo)
|
||||
throws ClassCastException;
|
||||
|
||||
/**
|
||||
* Delegation call for {@link javax.rmi.PortableRemoteObject#connect}.
|
||||
*/
|
||||
void connect (Remote target, Remote source)
|
||||
throws RemoteException;
|
||||
|
||||
}
|
||||
261
jdkSrc/jdk8/javax/rmi/CORBA/Stub.java
Normal file
261
jdkSrc/jdk8/javax/rmi/CORBA/Stub.java
Normal file
@@ -0,0 +1,261 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package javax.rmi.CORBA;
|
||||
|
||||
import org.omg.CORBA.ORB;
|
||||
import org.omg.CORBA.INITIALIZE;
|
||||
import org.omg.CORBA_2_3.portable.ObjectImpl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.rmi.RemoteException;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.net.MalformedURLException ;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Properties;
|
||||
import java.rmi.server.RMIClassLoader;
|
||||
|
||||
import com.sun.corba.se.impl.orbutil.GetPropertyAction;
|
||||
|
||||
|
||||
/**
|
||||
* Base class from which all RMI-IIOP stubs must inherit.
|
||||
*/
|
||||
public abstract class Stub extends ObjectImpl
|
||||
implements java.io.Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1087775603798577179L;
|
||||
|
||||
// This can only be set at object construction time (no sync necessary).
|
||||
private transient StubDelegate stubDelegate = null;
|
||||
private static Class stubDelegateClass = null;
|
||||
private static final String StubClassKey = "javax.rmi.CORBA.StubClass";
|
||||
|
||||
static {
|
||||
Object stubDelegateInstance = createDelegate(StubClassKey);
|
||||
if (stubDelegateInstance != null)
|
||||
stubDelegateClass = stubDelegateInstance.getClass();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a hash code value for the object which is the same for all stubs
|
||||
* that represent the same remote object.
|
||||
* @return the hash code value.
|
||||
*/
|
||||
public int hashCode() {
|
||||
|
||||
if (stubDelegate == null) {
|
||||
setDefaultDelegate();
|
||||
}
|
||||
|
||||
if (stubDelegate != null) {
|
||||
return stubDelegate.hashCode(this);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Compares two stubs for equality. Returns <code>true</code> when used to compare stubs
|
||||
* that represent the same remote object, and <code>false</code> otherwise.
|
||||
* @param obj the reference object with which to compare.
|
||||
* @return <code>true</code> if this object is the same as the <code>obj</code>
|
||||
* argument; <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean equals(java.lang.Object obj) {
|
||||
|
||||
if (stubDelegate == null) {
|
||||
setDefaultDelegate();
|
||||
}
|
||||
|
||||
if (stubDelegate != null) {
|
||||
return stubDelegate.equals(this, obj);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representation of this stub. Returns the same string
|
||||
* for all stubs that represent the same remote object.
|
||||
* @return a string representation of this stub.
|
||||
*/
|
||||
public String toString() {
|
||||
|
||||
|
||||
if (stubDelegate == null) {
|
||||
setDefaultDelegate();
|
||||
}
|
||||
|
||||
String ior;
|
||||
if (stubDelegate != null) {
|
||||
ior = stubDelegate.toString(this);
|
||||
if (ior == null) {
|
||||
return super.toString();
|
||||
} else {
|
||||
return ior;
|
||||
}
|
||||
}
|
||||
return super.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Connects this stub to an ORB. Required after the stub is deserialized
|
||||
* but not after it is demarshalled by an ORB stream. If an unconnected
|
||||
* stub is passed to an ORB stream for marshalling, it is implicitly
|
||||
* connected to that ORB. Application code should not call this method
|
||||
* directly, but should call the portable wrapper method
|
||||
* {@link javax.rmi.PortableRemoteObject#connect}.
|
||||
* @param orb the ORB to connect to.
|
||||
* @exception RemoteException if the stub is already connected to a different
|
||||
* ORB, or if the stub does not represent an exported remote or local object.
|
||||
*/
|
||||
public void connect(ORB orb) throws RemoteException {
|
||||
|
||||
if (stubDelegate == null) {
|
||||
setDefaultDelegate();
|
||||
}
|
||||
|
||||
if (stubDelegate != null) {
|
||||
stubDelegate.connect(this, orb);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialization method to restore the IOR state.
|
||||
*/
|
||||
private void readObject(java.io.ObjectInputStream stream)
|
||||
throws IOException, ClassNotFoundException {
|
||||
|
||||
if (stubDelegate == null) {
|
||||
setDefaultDelegate();
|
||||
}
|
||||
|
||||
if (stubDelegate != null) {
|
||||
stubDelegate.readObject(this, stream);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Serialization method to save the IOR state.
|
||||
* @serialData The length of the IOR type ID (int), followed by the IOR type ID
|
||||
* (byte array encoded using ISO8859-1), followed by the number of IOR profiles
|
||||
* (int), followed by the IOR profiles. Each IOR profile is written as a
|
||||
* profile tag (int), followed by the length of the profile data (int), followed
|
||||
* by the profile data (byte array).
|
||||
*/
|
||||
private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
|
||||
|
||||
if (stubDelegate == null) {
|
||||
setDefaultDelegate();
|
||||
}
|
||||
|
||||
if (stubDelegate != null) {
|
||||
stubDelegate.writeObject(this, stream);
|
||||
}
|
||||
}
|
||||
|
||||
private void setDefaultDelegate() {
|
||||
if (stubDelegateClass != null) {
|
||||
try {
|
||||
stubDelegate = (javax.rmi.CORBA.StubDelegate) stubDelegateClass.newInstance();
|
||||
} catch (Exception ex) {
|
||||
// what kind of exception to throw
|
||||
// delegate not set therefore it is null and will return default
|
||||
// values
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Same code as in PortableRemoteObject. Can not be shared because they
|
||||
// are in different packages and the visibility needs to be package for
|
||||
// security reasons. If you know a better solution how to share this code
|
||||
// then remove it from PortableRemoteObject. Also in Util.java
|
||||
private static Object createDelegate(String classKey) {
|
||||
String className = (String)
|
||||
AccessController.doPrivileged(new GetPropertyAction(classKey));
|
||||
if (className == null) {
|
||||
Properties props = getORBPropertiesFile();
|
||||
if (props != null) {
|
||||
className = props.getProperty(classKey);
|
||||
}
|
||||
}
|
||||
|
||||
if (className == null) {
|
||||
return new com.sun.corba.se.impl.javax.rmi.CORBA.StubDelegateImpl();
|
||||
}
|
||||
|
||||
try {
|
||||
return loadDelegateClass(className).newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
INITIALIZE exc = new INITIALIZE( "Cannot instantiate " + className);
|
||||
exc.initCause( ex ) ;
|
||||
throw exc ;
|
||||
} catch (Exception ex) {
|
||||
INITIALIZE exc = new INITIALIZE( "Error while instantiating" + className);
|
||||
exc.initCause( ex ) ;
|
||||
throw exc ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Class loadDelegateClass( String className ) throws ClassNotFoundException
|
||||
{
|
||||
try {
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
return Class.forName(className, false, loader);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// ignore, then try RMIClassLoader
|
||||
}
|
||||
|
||||
try {
|
||||
return RMIClassLoader.loadClass(className);
|
||||
} catch (MalformedURLException e) {
|
||||
String msg = "Could not load " + className + ": " + e.toString();
|
||||
ClassNotFoundException exc = new ClassNotFoundException( msg ) ;
|
||||
throw exc ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the orb.properties file.
|
||||
*/
|
||||
private static Properties getORBPropertiesFile () {
|
||||
return (Properties) AccessController.doPrivileged(new GetORBPropertiesFileAction());
|
||||
}
|
||||
|
||||
}
|
||||
93
jdkSrc/jdk8/javax/rmi/CORBA/StubDelegate.java
Normal file
93
jdkSrc/jdk8/javax/rmi/CORBA/StubDelegate.java
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package javax.rmi.CORBA;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.ObjectInputStream;
|
||||
import java.io.ObjectOutputStream;
|
||||
import java.rmi.RemoteException;
|
||||
import org.omg.CORBA.ORB;
|
||||
|
||||
/**
|
||||
* Supports delegation for method implementations in {@link Stub}.
|
||||
* A delegate is an instance of a class that implements this
|
||||
* interface and provides a replacement implementation for all the
|
||||
* methods of <code>javax.rmi.CORBA.Stub</code>. If delegation is
|
||||
* enabled, each stub has an associated delegate.
|
||||
*
|
||||
* Delegates are enabled by providing the delegate's class name as the
|
||||
* value of the
|
||||
* <code>javax.rmi.CORBA.StubClass</code>
|
||||
* system property.
|
||||
*
|
||||
* @see Stub
|
||||
*/
|
||||
public interface StubDelegate {
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Stub#hashCode}.
|
||||
*/
|
||||
int hashCode(Stub self);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Stub#equals}.
|
||||
*/
|
||||
boolean equals(Stub self, java.lang.Object obj);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Stub#toString}.
|
||||
*/
|
||||
String toString(Stub self);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Stub#connect}.
|
||||
*/
|
||||
void connect(Stub self, ORB orb)
|
||||
throws RemoteException;
|
||||
|
||||
// _REVISIT_ cannot link to Stub.readObject directly... why not?
|
||||
/**
|
||||
* Delegation call for
|
||||
* <a href="{@docRoot}/serialized-form.html#javax.rmi.CORBA.Stub"><code>Stub.readObject(java.io.ObjectInputStream)</code></a>.
|
||||
*/
|
||||
void readObject(Stub self, ObjectInputStream s)
|
||||
throws IOException, ClassNotFoundException;
|
||||
|
||||
// _REVISIT_ cannot link to Stub.writeObject directly... why not?
|
||||
/**
|
||||
* Delegation call for
|
||||
* <a href="{@docRoot}/serialized-form.html#javax.rmi.CORBA.Stub"><code>Stub.writeObject(java.io.ObjectOutputStream)</code></a>.
|
||||
*/
|
||||
void writeObject(Stub self, ObjectOutputStream s)
|
||||
throws IOException;
|
||||
|
||||
}
|
||||
85
jdkSrc/jdk8/javax/rmi/CORBA/Tie.java
Normal file
85
jdkSrc/jdk8/javax/rmi/CORBA/Tie.java
Normal file
@@ -0,0 +1,85 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package javax.rmi.CORBA;
|
||||
|
||||
import java.rmi.Remote;
|
||||
import java.util.Hashtable;
|
||||
|
||||
import org.omg.CORBA.portable.ApplicationException;
|
||||
import org.omg.CORBA.portable.InputStream;
|
||||
import org.omg.CORBA.portable.OutputStream;
|
||||
import org.omg.CORBA.portable.ObjectImpl;
|
||||
import org.omg.CORBA.portable.ResponseHandler;
|
||||
import org.omg.CORBA.portable.Delegate;
|
||||
import org.omg.CORBA.ORB;
|
||||
|
||||
/**
|
||||
* Defines methods which all RMI-IIOP server side ties must implement.
|
||||
*/
|
||||
public interface Tie extends org.omg.CORBA.portable.InvokeHandler {
|
||||
/**
|
||||
* Returns an object reference for the target object represented by
|
||||
* this tie.
|
||||
* @return an object reference for the target object.
|
||||
*/
|
||||
org.omg.CORBA.Object thisObject();
|
||||
|
||||
/**
|
||||
* Deactivates the target object represented by this tie.
|
||||
*/
|
||||
void deactivate() throws java.rmi.NoSuchObjectException;
|
||||
|
||||
/**
|
||||
* Returns the ORB for this tie.
|
||||
* @return the ORB.
|
||||
*/
|
||||
ORB orb();
|
||||
|
||||
/**
|
||||
* Sets the ORB for this tie.
|
||||
* @param orb the ORB.
|
||||
*/
|
||||
void orb(ORB orb);
|
||||
|
||||
/**
|
||||
* Called by {@link Util#registerTarget} to set the target
|
||||
* for this tie.
|
||||
* @param target the object to use as the target for this tie.
|
||||
*/
|
||||
void setTarget(java.rmi.Remote target);
|
||||
|
||||
/**
|
||||
* Returns the target for this tie.
|
||||
* @return the target.
|
||||
*/
|
||||
java.rmi.Remote getTarget();
|
||||
}
|
||||
421
jdkSrc/jdk8/javax/rmi/CORBA/Util.java
Normal file
421
jdkSrc/jdk8/javax/rmi/CORBA/Util.java
Normal file
@@ -0,0 +1,421 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package javax.rmi.CORBA;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
|
||||
import org.omg.CORBA.ORB;
|
||||
import org.omg.CORBA.INITIALIZE;
|
||||
import org.omg.CORBA.SystemException;
|
||||
import org.omg.CORBA.Any;
|
||||
import org.omg.CORBA.portable.InputStream;
|
||||
import org.omg.CORBA.portable.OutputStream;
|
||||
import org.omg.CORBA.portable.ObjectImpl;
|
||||
|
||||
import javax.rmi.CORBA.Tie;
|
||||
import java.rmi.Remote;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.SerializablePermission;
|
||||
import java.net.MalformedURLException ;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.util.Properties;
|
||||
import java.rmi.server.RMIClassLoader;
|
||||
|
||||
import com.sun.corba.se.impl.orbutil.GetPropertyAction;
|
||||
|
||||
/**
|
||||
* Provides utility methods that can be used by stubs and ties to
|
||||
* perform common operations.
|
||||
*/
|
||||
public class Util {
|
||||
|
||||
// This can only be set at static initialization time (no sync necessary).
|
||||
private static final javax.rmi.CORBA.UtilDelegate utilDelegate;
|
||||
private static final String UtilClassKey = "javax.rmi.CORBA.UtilClass";
|
||||
|
||||
private static final String ALLOW_CREATEVALUEHANDLER_PROP = "jdk.rmi.CORBA.allowCustomValueHandler";
|
||||
private static boolean allowCustomValueHandler;
|
||||
|
||||
static {
|
||||
utilDelegate = (javax.rmi.CORBA.UtilDelegate)createDelegate(UtilClassKey);
|
||||
allowCustomValueHandler = readAllowCustomValueHandlerProperty();
|
||||
}
|
||||
|
||||
private static boolean readAllowCustomValueHandlerProperty () {
|
||||
return AccessController
|
||||
.doPrivileged(new PrivilegedAction<Boolean>() {
|
||||
@Override
|
||||
public Boolean run() {
|
||||
return Boolean.getBoolean(ALLOW_CREATEVALUEHANDLER_PROP);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private Util(){}
|
||||
|
||||
/**
|
||||
* Maps a SystemException to a RemoteException.
|
||||
* @param ex the SystemException to map.
|
||||
* @return the mapped exception.
|
||||
*/
|
||||
public static RemoteException mapSystemException(SystemException ex) {
|
||||
|
||||
if (utilDelegate != null) {
|
||||
return utilDelegate.mapSystemException(ex);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes any java.lang.Object as a CORBA any.
|
||||
* @param out the stream in which to write the any.
|
||||
* @param obj the object to write as an any.
|
||||
*/
|
||||
public static void writeAny(OutputStream out, Object obj) {
|
||||
|
||||
if (utilDelegate != null) {
|
||||
utilDelegate.writeAny(out, obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a java.lang.Object as a CORBA any.
|
||||
* @param in the stream from which to read the any.
|
||||
* @return the object read from the stream.
|
||||
*/
|
||||
public static Object readAny(InputStream in) {
|
||||
|
||||
if (utilDelegate != null) {
|
||||
return utilDelegate.readAny(in);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a java.lang.Object as a CORBA Object. If <code>obj</code> is
|
||||
* an exported RMI-IIOP server object, the tie is found
|
||||
* and wired to <code>obj</code>, then written to
|
||||
* <code>out.write_Object(org.omg.CORBA.Object)</code>.
|
||||
* If <code>obj</code> is a CORBA Object, it is written to
|
||||
* <code>out.write_Object(org.omg.CORBA.Object)</code>.
|
||||
* @param out the stream in which to write the object.
|
||||
* @param obj the object to write.
|
||||
*/
|
||||
public static void writeRemoteObject(OutputStream out,
|
||||
java.lang.Object obj) {
|
||||
|
||||
if (utilDelegate != null) {
|
||||
utilDelegate.writeRemoteObject(out, obj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a java.lang.Object as either a value or a CORBA Object.
|
||||
* If <code>obj</code> is a value object or a stub object, it is written to
|
||||
* <code>out.write_abstract_interface(java.lang.Object)</code>. If <code>obj</code>
|
||||
is
|
||||
an exported
|
||||
* RMI-IIOP server object, the tie is found and wired to <code>obj</code>,
|
||||
* then written to <code>out.write_abstract_interface(java.lang.Object)</code>.
|
||||
* @param out the stream in which to write the object.
|
||||
* @param obj the object to write.
|
||||
*/
|
||||
public static void writeAbstractObject(OutputStream out,
|
||||
java.lang.Object obj) {
|
||||
|
||||
if (utilDelegate != null) {
|
||||
utilDelegate.writeAbstractObject(out, obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a target for a tie. Adds the tie to an internal table and calls
|
||||
* {@link Tie#setTarget} on the tie object.
|
||||
* @param tie the tie to register.
|
||||
* @param target the target for the tie.
|
||||
*/
|
||||
public static void registerTarget(javax.rmi.CORBA.Tie tie,
|
||||
java.rmi.Remote target) {
|
||||
|
||||
if (utilDelegate != null) {
|
||||
utilDelegate.registerTarget(tie, target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Removes the associated tie from an internal table and calls {@link
|
||||
Tie#deactivate}
|
||||
* to deactivate the object.
|
||||
* @param target the object to unexport.
|
||||
*/
|
||||
public static void unexportObject(java.rmi.Remote target)
|
||||
throws java.rmi.NoSuchObjectException
|
||||
{
|
||||
|
||||
if (utilDelegate != null) {
|
||||
utilDelegate.unexportObject(target);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the tie (if any) for a given target object.
|
||||
* @return the tie or null if no tie is registered for the given target.
|
||||
*/
|
||||
public static Tie getTie (Remote target) {
|
||||
|
||||
if (utilDelegate != null) {
|
||||
return utilDelegate.getTie(target);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a singleton instance of a class that implements the
|
||||
* {@link ValueHandler} interface.
|
||||
* @return a class which implements the ValueHandler interface.
|
||||
*/
|
||||
public static ValueHandler createValueHandler() {
|
||||
|
||||
isCustomSerializationPermitted();
|
||||
|
||||
if (utilDelegate != null) {
|
||||
return utilDelegate.createValueHandler();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the codebase, if any, for the given class.
|
||||
* @param clz the class to get a codebase for.
|
||||
* @return a space-separated list of URLs, or null.
|
||||
*/
|
||||
public static String getCodebase(java.lang.Class clz) {
|
||||
if (utilDelegate != null) {
|
||||
return utilDelegate.getCodebase(clz);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a class instance for the specified class.
|
||||
* <P>The spec for this method is the "Java to IDL language
|
||||
* mapping", ptc/00-01-06.
|
||||
* <P>In Java SE Platform, this method works as follows:
|
||||
* <UL><LI>Find the first non-null <tt>ClassLoader</tt> on the
|
||||
* call stack and attempt to load the class using this
|
||||
* <tt>ClassLoader</tt>.
|
||||
* <LI>If the first step fails, and if <tt>remoteCodebase</tt>
|
||||
* is non-null and
|
||||
* <tt>useCodebaseOnly</tt> is false, then call
|
||||
* <tt>java.rmi.server.RMIClassLoader.loadClass(remoteCodebase, className)</tt>.
|
||||
* <LI>If <tt>remoteCodebase</tt> is null or <tt>useCodebaseOnly</tt>
|
||||
* is true, then call <tt>java.rmi.server.RMIClassLoader.loadClass(className)</tt>.
|
||||
* <LI>If a class was not successfully loaded by step 1, 2, or 3,
|
||||
* and <tt>loader</tt> is non-null, then call <tt>loader.loadClass(className)</tt>.
|
||||
* <LI>If a class was successfully loaded by step 1, 2, 3, or 4, then
|
||||
* return the loaded class, else throw <tt>ClassNotFoundException</tt>.
|
||||
* @param className the name of the class.
|
||||
* @param remoteCodebase a space-separated list of URLs at which
|
||||
* the class might be found. May be null.
|
||||
* @param loader a <tt>ClassLoader</tt> that may be used to
|
||||
* load the class if all other methods fail.
|
||||
* @return the <code>Class</code> object representing the loaded class.
|
||||
* @exception ClassNotFoundException if class cannot be loaded.
|
||||
*/
|
||||
public static Class loadClass(String className,
|
||||
String remoteCodebase,
|
||||
ClassLoader loader)
|
||||
throws ClassNotFoundException {
|
||||
if (utilDelegate != null) {
|
||||
return utilDelegate.loadClass(className,remoteCodebase,loader);
|
||||
}
|
||||
return null ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The <tt>isLocal</tt> method has the same semantics as the
|
||||
* <tt>ObjectImpl._is_local</tt>
|
||||
* method, except that it can throw a <tt>RemoteException</tt>.
|
||||
*
|
||||
* The <tt>_is_local()</tt> method is provided so that stubs may determine if a
|
||||
* particular object is implemented by a local servant and hence local
|
||||
* invocation APIs may be used.
|
||||
*
|
||||
* @param stub the stub to test.
|
||||
*
|
||||
* @return The <tt>_is_local()</tt> method returns true if
|
||||
* the servant incarnating the object is located in the same process as
|
||||
* the stub and they both share the same ORB instance. The <tt>_is_local()</tt>
|
||||
* method returns false otherwise. The default behavior of <tt>_is_local()</tt> is
|
||||
* to return false.
|
||||
*
|
||||
* @throws RemoteException The Java to IDL specification does not
|
||||
* specify the conditions that cause a <tt>RemoteException</tt> to be thrown.
|
||||
*/
|
||||
public static boolean isLocal(Stub stub) throws RemoteException {
|
||||
|
||||
if (utilDelegate != null) {
|
||||
return utilDelegate.isLocal(stub);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Wraps an exception thrown by an implementation
|
||||
* method. It returns the corresponding client-side exception.
|
||||
* @param orig the exception to wrap.
|
||||
* @return the wrapped exception.
|
||||
*/
|
||||
public static RemoteException wrapException(Throwable orig) {
|
||||
|
||||
if (utilDelegate != null) {
|
||||
return utilDelegate.wrapException(orig);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies or connects an array of objects. Used by local stubs
|
||||
* to copy any number of actual parameters, preserving sharing
|
||||
* across parameters as necessary to support RMI semantics.
|
||||
* @param obj the objects to copy or connect.
|
||||
* @param orb the ORB.
|
||||
* @return the copied or connected objects.
|
||||
* @exception RemoteException if any object could not be copied or connected.
|
||||
*/
|
||||
public static Object[] copyObjects (Object[] obj, ORB orb)
|
||||
throws RemoteException {
|
||||
|
||||
if (utilDelegate != null) {
|
||||
return utilDelegate.copyObjects(obj, orb);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies or connects an object. Used by local stubs to copy
|
||||
* an actual parameter, result object, or exception.
|
||||
* @param obj the object to copy.
|
||||
* @param orb the ORB.
|
||||
* @return the copy or connected object.
|
||||
* @exception RemoteException if the object could not be copied or connected.
|
||||
*/
|
||||
public static Object copyObject (Object obj, ORB orb)
|
||||
throws RemoteException {
|
||||
|
||||
if (utilDelegate != null) {
|
||||
return utilDelegate.copyObject(obj, orb);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// Same code as in PortableRemoteObject. Can not be shared because they
|
||||
// are in different packages and the visibility needs to be package for
|
||||
// security reasons. If you know a better solution how to share this code
|
||||
// then remove it from PortableRemoteObject. Also in Stub.java
|
||||
private static Object createDelegate(String classKey) {
|
||||
|
||||
String className = (String)
|
||||
AccessController.doPrivileged(new GetPropertyAction(classKey));
|
||||
if (className == null) {
|
||||
Properties props = getORBPropertiesFile();
|
||||
if (props != null) {
|
||||
className = props.getProperty(classKey);
|
||||
}
|
||||
}
|
||||
|
||||
if (className == null) {
|
||||
return new com.sun.corba.se.impl.javax.rmi.CORBA.Util();
|
||||
}
|
||||
|
||||
try {
|
||||
return loadDelegateClass(className).newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
INITIALIZE exc = new INITIALIZE( "Cannot instantiate " + className);
|
||||
exc.initCause( ex ) ;
|
||||
throw exc ;
|
||||
} catch (Exception ex) {
|
||||
INITIALIZE exc = new INITIALIZE( "Error while instantiating" + className);
|
||||
exc.initCause( ex ) ;
|
||||
throw exc ;
|
||||
}
|
||||
}
|
||||
|
||||
private static Class loadDelegateClass( String className ) throws ClassNotFoundException
|
||||
{
|
||||
try {
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
return Class.forName(className, false, loader);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// ignore, then try RMIClassLoader
|
||||
}
|
||||
|
||||
try {
|
||||
return RMIClassLoader.loadClass(className);
|
||||
} catch (MalformedURLException e) {
|
||||
String msg = "Could not load " + className + ": " + e.toString();
|
||||
ClassNotFoundException exc = new ClassNotFoundException( msg ) ;
|
||||
throw exc ;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Load the orb.properties file.
|
||||
*/
|
||||
private static Properties getORBPropertiesFile ()
|
||||
{
|
||||
return (Properties) AccessController.doPrivileged(
|
||||
new GetORBPropertiesFileAction());
|
||||
}
|
||||
|
||||
private static void isCustomSerializationPermitted() {
|
||||
SecurityManager sm = System.getSecurityManager();
|
||||
if (!allowCustomValueHandler) {
|
||||
if ( sm != null) {
|
||||
// check that a serialization permission has been
|
||||
// set to allow the loading of the Util delegate
|
||||
// which provides access to custom ValueHandler
|
||||
sm.checkPermission(new SerializablePermission(
|
||||
"enableCustomValueHandler"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
135
jdkSrc/jdk8/javax/rmi/CORBA/UtilDelegate.java
Normal file
135
jdkSrc/jdk8/javax/rmi/CORBA/UtilDelegate.java
Normal file
@@ -0,0 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package javax.rmi.CORBA;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.rmi.Remote;
|
||||
import java.rmi.RemoteException;
|
||||
import javax.rmi.CORBA.Tie;
|
||||
import javax.rmi.CORBA.ValueHandler;
|
||||
import org.omg.CORBA.ORB;
|
||||
import org.omg.CORBA.portable.InputStream;
|
||||
import org.omg.CORBA.portable.OutputStream;
|
||||
import org.omg.CORBA.SystemException;
|
||||
|
||||
/**
|
||||
* Supports delegation for method implementations in {@link Util}. The
|
||||
* delegate is a singleton instance of a class that implements this
|
||||
* interface and provides a replacement implementation for all the
|
||||
* methods of <code>javax.rmi.CORBA.Util</code>.
|
||||
*
|
||||
* Delegation is enabled by providing the delegate's class name as the
|
||||
* value of the
|
||||
* <code>javax.rmi.CORBA.UtilClass</code>
|
||||
* system property.
|
||||
*
|
||||
* @see Util
|
||||
*/
|
||||
public interface UtilDelegate {
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#mapSystemException}.
|
||||
*/
|
||||
RemoteException mapSystemException(SystemException ex);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#writeAny}.
|
||||
*/
|
||||
void writeAny(OutputStream out, Object obj);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#readAny}.
|
||||
*/
|
||||
java.lang.Object readAny(InputStream in);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#writeRemoteObject}.
|
||||
*/
|
||||
void writeRemoteObject(OutputStream out, Object obj);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#writeAbstractObject}.
|
||||
*/
|
||||
void writeAbstractObject(OutputStream out, Object obj);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#registerTarget}.
|
||||
*/
|
||||
void registerTarget(Tie tie, Remote target);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#unexportObject}.
|
||||
*/
|
||||
void unexportObject(Remote target) throws java.rmi.NoSuchObjectException;
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#getTie}.
|
||||
*/
|
||||
Tie getTie(Remote target);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#createValueHandler}.
|
||||
*/
|
||||
ValueHandler createValueHandler();
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#getCodebase}.
|
||||
*/
|
||||
String getCodebase(Class clz);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#loadClass}.
|
||||
*/
|
||||
Class loadClass(String className, String remoteCodebase, ClassLoader loader)
|
||||
throws ClassNotFoundException;
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#isLocal}.
|
||||
*/
|
||||
boolean isLocal(Stub stub) throws RemoteException;
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#wrapException}.
|
||||
*/
|
||||
RemoteException wrapException(Throwable obj);
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#copyObject}.
|
||||
*/
|
||||
Object copyObject(Object obj, ORB orb) throws RemoteException;
|
||||
|
||||
/**
|
||||
* Delegation call for {@link Util#copyObjects}.
|
||||
*/
|
||||
Object[] copyObjects(Object[] obj, ORB orb) throws RemoteException;
|
||||
|
||||
}
|
||||
96
jdkSrc/jdk8/javax/rmi/CORBA/ValueHandler.java
Normal file
96
jdkSrc/jdk8/javax/rmi/CORBA/ValueHandler.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package javax.rmi.CORBA;
|
||||
|
||||
/**
|
||||
* Defines methods which allow serialization of Java objects
|
||||
* to and from GIOP streams.
|
||||
**/
|
||||
public interface ValueHandler {
|
||||
|
||||
/**
|
||||
* Writes a value to the stream using Java semantics.
|
||||
* @param out the stream to write the value to.
|
||||
* @param value the value to be written to the stream.
|
||||
**/
|
||||
void writeValue(org.omg.CORBA.portable.OutputStream out,
|
||||
java.io.Serializable value);
|
||||
|
||||
/**
|
||||
* Reads a value from the stream using Java semantics.
|
||||
* @param in the stream to read the value from.
|
||||
* @param offset the current position in the input stream.
|
||||
* @param clz the type of the value to be read in.
|
||||
* @param repositoryID the RepositoryId of the value to be read in.
|
||||
* @param sender the sending context runtime codebase.
|
||||
* @return the value read from the stream.
|
||||
**/
|
||||
java.io.Serializable readValue(org.omg.CORBA.portable.InputStream in,
|
||||
int offset,
|
||||
java.lang.Class clz,
|
||||
String repositoryID,
|
||||
org.omg.SendingContext.RunTime sender);
|
||||
|
||||
/**
|
||||
* Returns the CORBA RepositoryId for the given Java class.
|
||||
* @param clz a Java class.
|
||||
* @return the CORBA RepositoryId for the class.
|
||||
**/
|
||||
java.lang.String getRMIRepositoryID(java.lang.Class clz);
|
||||
|
||||
/**
|
||||
* Indicates whether the given class performs custom or
|
||||
* default marshaling.
|
||||
* @param clz the class to test for custom marshaling.
|
||||
* @return <code>true</code> if the class performs custom marshaling, <code>false</code>
|
||||
* if it does not.
|
||||
**/
|
||||
boolean isCustomMarshaled(java.lang.Class clz);
|
||||
|
||||
/**
|
||||
* Returns the CodeBase for this ValueHandler. This is used by
|
||||
* the ORB runtime. The server sends the service context containing
|
||||
* the IOR for this CodeBase on the first GIOP reply. The client
|
||||
* does the same on the first GIOP request.
|
||||
* @return the SendingContext.CodeBase of this ValueHandler.
|
||||
**/
|
||||
org.omg.SendingContext.RunTime getRunTimeCodeBase();
|
||||
|
||||
/**
|
||||
* If the value contains a <code>writeReplace</code> method then the result
|
||||
* is returned. Otherwise, the value itself is returned.
|
||||
* @param value the value to be marshaled.
|
||||
* @return the true value to marshal on the wire.
|
||||
**/
|
||||
java.io.Serializable writeReplace(java.io.Serializable value);
|
||||
|
||||
}
|
||||
70
jdkSrc/jdk8/javax/rmi/CORBA/ValueHandlerMultiFormat.java
Normal file
70
jdkSrc/jdk8/javax/rmi/CORBA/ValueHandlerMultiFormat.java
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package javax.rmi.CORBA;
|
||||
|
||||
/**
|
||||
* Java to IDL ptc 02-01-12 1.5.1.5
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface ValueHandlerMultiFormat extends ValueHandler {
|
||||
|
||||
/**
|
||||
* Returns the maximum stream format version for
|
||||
* RMI/IDL custom value types that is supported
|
||||
* by this ValueHandler object. The ValueHandler
|
||||
* object must support the returned stream format version and
|
||||
* all lower versions.
|
||||
*
|
||||
* An ORB may use this value to include in a standard
|
||||
* IOR tagged component or service context to indicate to other
|
||||
* ORBs the maximum RMI-IIOP stream format that it
|
||||
* supports. If not included, the default for GIOP 1.2
|
||||
* is stream format version 1, and stream format version
|
||||
* 2 for GIOP 1.3 and higher.
|
||||
*/
|
||||
byte getMaximumStreamFormatVersion();
|
||||
|
||||
/**
|
||||
* Allows the ORB to pass the stream format
|
||||
* version for RMI/IDL custom value types. If the ORB
|
||||
* calls this method, it must pass a stream format version
|
||||
* between 1 and the value returned by the
|
||||
* getMaximumStreamFormatVersion method inclusive,
|
||||
* or else a BAD_PARAM exception with standard minor code
|
||||
* will be thrown.
|
||||
*
|
||||
* If the ORB calls the older ValueHandler.writeValue(OutputStream,
|
||||
* Serializable) method, stream format version 1 is implied.
|
||||
*
|
||||
* The ORB output stream passed to the ValueHandlerMultiFormat.writeValue
|
||||
* method must implement the ValueOutputStream interface, and the
|
||||
* ORB input stream passed to the ValueHandler.readValue method must
|
||||
* implement the ValueInputStream interface.
|
||||
*/
|
||||
void writeValue(org.omg.CORBA.portable.OutputStream out,
|
||||
java.io.Serializable value,
|
||||
byte streamFormatVersion);
|
||||
}
|
||||
293
jdkSrc/jdk8/javax/rmi/PortableRemoteObject.java
Normal file
293
jdkSrc/jdk8/javax/rmi/PortableRemoteObject.java
Normal file
@@ -0,0 +1,293 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
/*
|
||||
* Licensed Materials - Property of IBM
|
||||
* RMI-IIOP v1.0
|
||||
* Copyright IBM Corp. 1998 1999 All Rights Reserved
|
||||
*
|
||||
*/
|
||||
|
||||
package javax.rmi;
|
||||
|
||||
import java.lang.reflect.Method ;
|
||||
|
||||
import org.omg.CORBA.INITIALIZE;
|
||||
import javax.rmi.CORBA.Util;
|
||||
|
||||
import java.rmi.RemoteException;
|
||||
import java.rmi.NoSuchObjectException;
|
||||
import java.rmi.Remote;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.util.Properties;
|
||||
import java.net.MalformedURLException ;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
import java.rmi.server.RMIClassLoader;
|
||||
|
||||
import com.sun.corba.se.impl.orbutil.GetPropertyAction;
|
||||
|
||||
/**
|
||||
* Server implementation objects may either inherit from
|
||||
* javax.rmi.PortableRemoteObject or they may implement a remote interface
|
||||
* and then use the exportObject method to register themselves as a server object.
|
||||
* The toStub method takes a server implementation and returns a stub that
|
||||
* can be used to access that server object.
|
||||
* The connect method makes a Remote object ready for remote communication.
|
||||
* The unexportObject method is used to deregister a server object, allowing it to become
|
||||
* available for garbage collection.
|
||||
* The narrow method takes an object reference or abstract interface type and
|
||||
* attempts to narrow it to conform to
|
||||
* the given interface. If the operation is successful the result will be an
|
||||
* object of the specified type, otherwise an exception will be thrown.
|
||||
*/
|
||||
public class PortableRemoteObject {
|
||||
|
||||
private static final javax.rmi.CORBA.PortableRemoteObjectDelegate proDelegate;
|
||||
|
||||
private static final String PortableRemoteObjectClassKey =
|
||||
"javax.rmi.CORBA.PortableRemoteObjectClass";
|
||||
|
||||
static {
|
||||
proDelegate = (javax.rmi.CORBA.PortableRemoteObjectDelegate)
|
||||
createDelegate(PortableRemoteObjectClassKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes the object by calling <code>exportObject(this)</code>.
|
||||
* @exception RemoteException if export fails.
|
||||
*/
|
||||
protected PortableRemoteObject() throws RemoteException {
|
||||
if (proDelegate != null) {
|
||||
PortableRemoteObject.exportObject((Remote)this);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a server object ready to receive remote calls. Note
|
||||
* that subclasses of PortableRemoteObject do not need to call this
|
||||
* method, as it is called by the constructor.
|
||||
* @param obj the server object to export.
|
||||
* @exception RemoteException if export fails.
|
||||
*/
|
||||
public static void exportObject(Remote obj)
|
||||
throws RemoteException {
|
||||
|
||||
// Let the delegate do everything, including error handling.
|
||||
if (proDelegate != null) {
|
||||
proDelegate.exportObject(obj);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a stub for the given server object.
|
||||
* @param obj the server object for which a stub is required. Must either be a subclass
|
||||
* of PortableRemoteObject or have been previously the target of a call to
|
||||
* {@link #exportObject}.
|
||||
* @return the most derived stub for the object.
|
||||
* @exception NoSuchObjectException if a stub cannot be located for the given server object.
|
||||
*/
|
||||
public static Remote toStub (Remote obj)
|
||||
throws NoSuchObjectException {
|
||||
|
||||
if (proDelegate != null) {
|
||||
return proDelegate.toStub(obj);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deregisters a server object from the runtime, allowing the object to become
|
||||
* available for garbage collection.
|
||||
* @param obj the object to unexport.
|
||||
* @exception NoSuchObjectException if the remote object is not
|
||||
* currently exported.
|
||||
*/
|
||||
public static void unexportObject(Remote obj)
|
||||
throws NoSuchObjectException {
|
||||
|
||||
if (proDelegate != null) {
|
||||
proDelegate.unexportObject(obj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks to ensure that an object of a remote or abstract interface type
|
||||
* can be cast to a desired type.
|
||||
* @param narrowFrom the object to check.
|
||||
* @param narrowTo the desired type.
|
||||
* @return an object which can be cast to the desired type.
|
||||
* @throws ClassCastException if narrowFrom cannot be cast to narrowTo.
|
||||
*/
|
||||
public static java.lang.Object narrow ( java.lang.Object narrowFrom,
|
||||
java.lang.Class narrowTo)
|
||||
throws ClassCastException {
|
||||
|
||||
if (proDelegate != null) {
|
||||
return proDelegate.narrow(narrowFrom, narrowTo);
|
||||
}
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes a Remote object ready for remote communication. This normally
|
||||
* happens implicitly when the object is sent or received as an argument
|
||||
* on a remote method call, but in some circumstances it is useful to
|
||||
* perform this action by making an explicit call. See the
|
||||
* {@link javax.rmi.CORBA.Stub#connect} method for more information.
|
||||
* @param target the object to connect.
|
||||
* @param source a previously connected object.
|
||||
* @throws RemoteException if <code>source</code> is not connected
|
||||
* or if <code>target</code> is already connected to a different ORB than
|
||||
* <code>source</code>.
|
||||
*/
|
||||
public static void connect (Remote target, Remote source)
|
||||
throws RemoteException {
|
||||
|
||||
if (proDelegate != null) {
|
||||
proDelegate.connect(target, source);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Same code as in javax.rmi.CORBA.Util. Can not be shared because they
|
||||
// are in different packages and the visibility needs to be package for
|
||||
// security reasons. If you know a better solution how to share this code
|
||||
// then remove it from here.
|
||||
private static Object createDelegate(String classKey) {
|
||||
String className = (String)
|
||||
AccessController.doPrivileged(new GetPropertyAction(classKey));
|
||||
if (className == null) {
|
||||
Properties props = getORBPropertiesFile();
|
||||
if (props != null) {
|
||||
className = props.getProperty(classKey);
|
||||
}
|
||||
}
|
||||
if (className == null) {
|
||||
return new com.sun.corba.se.impl.javax.rmi.PortableRemoteObject();
|
||||
}
|
||||
|
||||
try {
|
||||
return (Object) loadDelegateClass(className).newInstance();
|
||||
} catch (ClassNotFoundException ex) {
|
||||
INITIALIZE exc = new INITIALIZE( "Cannot instantiate " + className);
|
||||
exc.initCause( ex ) ;
|
||||
throw exc ;
|
||||
} catch (Exception ex) {
|
||||
INITIALIZE exc = new INITIALIZE( "Error while instantiating" + className);
|
||||
exc.initCause( ex ) ;
|
||||
throw exc ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static Class loadDelegateClass( String className ) throws ClassNotFoundException
|
||||
{
|
||||
try {
|
||||
ClassLoader loader = Thread.currentThread().getContextClassLoader();
|
||||
return Class.forName(className, false, loader);
|
||||
} catch (ClassNotFoundException e) {
|
||||
// ignore, then try RMIClassLoader
|
||||
}
|
||||
|
||||
try {
|
||||
return RMIClassLoader.loadClass(className);
|
||||
} catch (MalformedURLException e) {
|
||||
String msg = "Could not load " + className + ": " + e.toString();
|
||||
ClassNotFoundException exc = new ClassNotFoundException( msg ) ;
|
||||
throw exc ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the orb.properties file.
|
||||
*/
|
||||
private static Properties getORBPropertiesFile () {
|
||||
return (Properties) AccessController.doPrivileged(new GetORBPropertiesFileAction());
|
||||
}
|
||||
}
|
||||
|
||||
class GetORBPropertiesFileAction implements PrivilegedAction {
|
||||
private boolean debug = false ;
|
||||
|
||||
public GetORBPropertiesFileAction () {
|
||||
}
|
||||
|
||||
private String getSystemProperty(final String name) {
|
||||
// This will not throw a SecurityException because this
|
||||
// class was loaded from rt.jar using the bootstrap classloader.
|
||||
String propValue = (String) AccessController.doPrivileged(
|
||||
new PrivilegedAction() {
|
||||
public java.lang.Object run() {
|
||||
return System.getProperty(name);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
return propValue;
|
||||
}
|
||||
|
||||
private void getPropertiesFromFile( Properties props, String fileName )
|
||||
{
|
||||
try {
|
||||
File file = new File( fileName ) ;
|
||||
if (!file.exists())
|
||||
return ;
|
||||
|
||||
FileInputStream in = new FileInputStream( file ) ;
|
||||
|
||||
try {
|
||||
props.load( in ) ;
|
||||
} finally {
|
||||
in.close() ;
|
||||
}
|
||||
} catch (Exception exc) {
|
||||
if (debug)
|
||||
System.out.println( "ORB properties file " + fileName +
|
||||
" not found: " + exc) ;
|
||||
}
|
||||
}
|
||||
|
||||
public Object run()
|
||||
{
|
||||
Properties defaults = new Properties() ;
|
||||
|
||||
String javaHome = getSystemProperty( "java.home" ) ;
|
||||
String fileName = javaHome + File.separator + "lib" + File.separator +
|
||||
"orb.properties" ;
|
||||
|
||||
getPropertiesFromFile( defaults, fileName ) ;
|
||||
|
||||
Properties results = new Properties( defaults ) ;
|
||||
|
||||
String userHome = getSystemProperty( "user.home" ) ;
|
||||
fileName = userHome + File.separator + "orb.properties" ;
|
||||
|
||||
getPropertiesFromFile( results, fileName ) ;
|
||||
return results ;
|
||||
}
|
||||
}
|
||||
212
jdkSrc/jdk8/javax/rmi/ssl/SslRMIClientSocketFactory.java
Normal file
212
jdkSrc/jdk8/javax/rmi/ssl/SslRMIClientSocketFactory.java
Normal file
@@ -0,0 +1,212 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package javax.rmi.ssl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.net.Socket;
|
||||
import java.rmi.server.RMIClientSocketFactory;
|
||||
import java.util.StringTokenizer;
|
||||
import javax.net.SocketFactory;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
/**
|
||||
* <p>An <code>SslRMIClientSocketFactory</code> instance is used by the RMI
|
||||
* runtime in order to obtain client sockets for RMI calls via SSL.</p>
|
||||
*
|
||||
* <p>This class implements <code>RMIClientSocketFactory</code> over
|
||||
* the Secure Sockets Layer (SSL) or Transport Layer Security (TLS)
|
||||
* protocols.</p>
|
||||
*
|
||||
* <p>This class creates SSL sockets using the default
|
||||
* <code>SSLSocketFactory</code> (see {@link
|
||||
* SSLSocketFactory#getDefault}). All instances of this class are
|
||||
* functionally equivalent. In particular, they all share the same
|
||||
* truststore, and the same keystore when client authentication is
|
||||
* required by the server. This behavior can be modified in
|
||||
* subclasses by overriding the {@link #createSocket(String,int)}
|
||||
* method; in that case, {@link #equals(Object) equals} and {@link
|
||||
* #hashCode() hashCode} may also need to be overridden.</p>
|
||||
*
|
||||
* <p>If the system property
|
||||
* <code>javax.rmi.ssl.client.enabledCipherSuites</code> is specified,
|
||||
* the {@link #createSocket(String,int)} method will call {@link
|
||||
* SSLSocket#setEnabledCipherSuites(String[])} before returning the
|
||||
* socket. The value of this system property is a string that is a
|
||||
* comma-separated list of SSL/TLS cipher suites to enable.</p>
|
||||
*
|
||||
* <p>If the system property
|
||||
* <code>javax.rmi.ssl.client.enabledProtocols</code> is specified,
|
||||
* the {@link #createSocket(String,int)} method will call {@link
|
||||
* SSLSocket#setEnabledProtocols(String[])} before returning the
|
||||
* socket. The value of this system property is a string that is a
|
||||
* comma-separated list of SSL/TLS protocol versions to enable.</p>
|
||||
*
|
||||
* @see javax.net.ssl.SSLSocketFactory
|
||||
* @see javax.rmi.ssl.SslRMIServerSocketFactory
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SslRMIClientSocketFactory
|
||||
implements RMIClientSocketFactory, Serializable {
|
||||
|
||||
/**
|
||||
* <p>Creates a new <code>SslRMIClientSocketFactory</code>.</p>
|
||||
*/
|
||||
public SslRMIClientSocketFactory() {
|
||||
// We don't force the initialization of the default SSLSocketFactory
|
||||
// at construction time - because the RMI client socket factory is
|
||||
// created on the server side, where that initialization is a priori
|
||||
// meaningless, unless both server and client run in the same JVM.
|
||||
// We could possibly override readObject() to force this initialization,
|
||||
// but it might not be a good idea to actually mix this with possible
|
||||
// deserialization problems.
|
||||
// So contrarily to what we do for the server side, the initialization
|
||||
// of the SSLSocketFactory will be delayed until the first time
|
||||
// createSocket() is called - note that the default SSLSocketFactory
|
||||
// might already have been initialized anyway if someone in the JVM
|
||||
// already called SSLSocketFactory.getDefault().
|
||||
//
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Creates an SSL socket.</p>
|
||||
*
|
||||
* <p>If the system property
|
||||
* <code>javax.rmi.ssl.client.enabledCipherSuites</code> is
|
||||
* specified, this method will call {@link
|
||||
* SSLSocket#setEnabledCipherSuites(String[])} before returning
|
||||
* the socket. The value of this system property is a string that
|
||||
* is a comma-separated list of SSL/TLS cipher suites to
|
||||
* enable.</p>
|
||||
*
|
||||
* <p>If the system property
|
||||
* <code>javax.rmi.ssl.client.enabledProtocols</code> is
|
||||
* specified, this method will call {@link
|
||||
* SSLSocket#setEnabledProtocols(String[])} before returning the
|
||||
* socket. The value of this system property is a string that is a
|
||||
* comma-separated list of SSL/TLS protocol versions to
|
||||
* enable.</p>
|
||||
*/
|
||||
public Socket createSocket(String host, int port) throws IOException {
|
||||
// Retrieve the SSLSocketFactory
|
||||
//
|
||||
final SocketFactory sslSocketFactory = getDefaultClientSocketFactory();
|
||||
// Create the SSLSocket
|
||||
//
|
||||
final SSLSocket sslSocket = (SSLSocket)
|
||||
sslSocketFactory.createSocket(host, port);
|
||||
// Set the SSLSocket Enabled Cipher Suites
|
||||
//
|
||||
final String enabledCipherSuites =
|
||||
System.getProperty("javax.rmi.ssl.client.enabledCipherSuites");
|
||||
if (enabledCipherSuites != null) {
|
||||
StringTokenizer st = new StringTokenizer(enabledCipherSuites, ",");
|
||||
int tokens = st.countTokens();
|
||||
String enabledCipherSuitesList[] = new String[tokens];
|
||||
for (int i = 0 ; i < tokens; i++) {
|
||||
enabledCipherSuitesList[i] = st.nextToken();
|
||||
}
|
||||
try {
|
||||
sslSocket.setEnabledCipherSuites(enabledCipherSuitesList);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw (IOException)
|
||||
new IOException(e.getMessage()).initCause(e);
|
||||
}
|
||||
}
|
||||
// Set the SSLSocket Enabled Protocols
|
||||
//
|
||||
final String enabledProtocols =
|
||||
System.getProperty("javax.rmi.ssl.client.enabledProtocols");
|
||||
if (enabledProtocols != null) {
|
||||
StringTokenizer st = new StringTokenizer(enabledProtocols, ",");
|
||||
int tokens = st.countTokens();
|
||||
String enabledProtocolsList[] = new String[tokens];
|
||||
for (int i = 0 ; i < tokens; i++) {
|
||||
enabledProtocolsList[i] = st.nextToken();
|
||||
}
|
||||
try {
|
||||
sslSocket.setEnabledProtocols(enabledProtocolsList);
|
||||
} catch (IllegalArgumentException e) {
|
||||
throw (IOException)
|
||||
new IOException(e.getMessage()).initCause(e);
|
||||
}
|
||||
}
|
||||
// Return the preconfigured SSLSocket
|
||||
//
|
||||
return sslSocket;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Indicates whether some other object is "equal to" this one.</p>
|
||||
*
|
||||
* <p>Because all instances of this class are functionally equivalent
|
||||
* (they all use the default
|
||||
* <code>SSLSocketFactory</code>), this method simply returns
|
||||
* <code>this.getClass().equals(obj.getClass())</code>.</p>
|
||||
*
|
||||
* <p>A subclass should override this method (as well
|
||||
* as {@link #hashCode()}) if its instances are not all
|
||||
* functionally equivalent.</p>
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) return false;
|
||||
if (obj == this) return true;
|
||||
return this.getClass().equals(obj.getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns a hash code value for this
|
||||
* <code>SslRMIClientSocketFactory</code>.</p>
|
||||
*
|
||||
* @return a hash code value for this
|
||||
* <code>SslRMIClientSocketFactory</code>.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return this.getClass().hashCode();
|
||||
}
|
||||
|
||||
// We use a static field because:
|
||||
//
|
||||
// SSLSocketFactory.getDefault() always returns the same object
|
||||
// (at least on Sun's implementation), and we want to make sure
|
||||
// that the Javadoc & the implementation stay in sync.
|
||||
//
|
||||
// If someone needs to have different SslRMIClientSocketFactory factories
|
||||
// with different underlying SSLSocketFactory objects using different key
|
||||
// and trust stores, he can always do so by subclassing this class and
|
||||
// overriding createSocket(String host, int port).
|
||||
//
|
||||
private static SocketFactory defaultSocketFactory = null;
|
||||
|
||||
private static synchronized SocketFactory getDefaultClientSocketFactory() {
|
||||
if (defaultSocketFactory == null)
|
||||
defaultSocketFactory = SSLSocketFactory.getDefault();
|
||||
return defaultSocketFactory;
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = -8310631444933958385L;
|
||||
}
|
||||
378
jdkSrc/jdk8/javax/rmi/ssl/SslRMIServerSocketFactory.java
Normal file
378
jdkSrc/jdk8/javax/rmi/ssl/SslRMIServerSocketFactory.java
Normal file
@@ -0,0 +1,378 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package javax.rmi.ssl;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.ServerSocket;
|
||||
import java.net.Socket;
|
||||
import java.rmi.server.RMIServerSocketFactory;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import javax.net.ssl.SSLContext;
|
||||
import javax.net.ssl.SSLServerSocketFactory;
|
||||
import javax.net.ssl.SSLSocket;
|
||||
import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
/**
|
||||
* <p>An <code>SslRMIServerSocketFactory</code> instance is used by the RMI
|
||||
* runtime in order to obtain server sockets for RMI calls via SSL.</p>
|
||||
*
|
||||
* <p>This class implements <code>RMIServerSocketFactory</code> over
|
||||
* the Secure Sockets Layer (SSL) or Transport Layer Security (TLS)
|
||||
* protocols.</p>
|
||||
*
|
||||
* <p>This class creates SSL sockets using the default
|
||||
* <code>SSLSocketFactory</code> (see {@link
|
||||
* SSLSocketFactory#getDefault}) or the default
|
||||
* <code>SSLServerSocketFactory</code> (see {@link
|
||||
* SSLServerSocketFactory#getDefault}) unless the
|
||||
* constructor taking an <code>SSLContext</code> is
|
||||
* used in which case the SSL sockets are created using
|
||||
* the <code>SSLSocketFactory</code> returned by
|
||||
* {@link SSLContext#getSocketFactory} or the
|
||||
* <code>SSLServerSocketFactory</code> returned by
|
||||
* {@link SSLContext#getServerSocketFactory}.
|
||||
*
|
||||
* When an <code>SSLContext</code> is not supplied all the instances of this
|
||||
* class share the same keystore, and the same truststore (when client
|
||||
* authentication is required by the server). This behavior can be modified
|
||||
* by supplying an already initialized <code>SSLContext</code> instance.
|
||||
*
|
||||
* @see javax.net.ssl.SSLSocketFactory
|
||||
* @see javax.net.ssl.SSLServerSocketFactory
|
||||
* @see javax.rmi.ssl.SslRMIClientSocketFactory
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SslRMIServerSocketFactory implements RMIServerSocketFactory {
|
||||
|
||||
/**
|
||||
* <p>Creates a new <code>SslRMIServerSocketFactory</code> with
|
||||
* the default SSL socket configuration.</p>
|
||||
*
|
||||
* <p>SSL connections accepted by server sockets created by this
|
||||
* factory have the default cipher suites and protocol versions
|
||||
* enabled and do not require client authentication.</p>
|
||||
*/
|
||||
public SslRMIServerSocketFactory() {
|
||||
this(null, null, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Creates a new <code>SslRMIServerSocketFactory</code> with
|
||||
* the specified SSL socket configuration.</p>
|
||||
*
|
||||
* @param enabledCipherSuites names of all the cipher suites to
|
||||
* enable on SSL connections accepted by server sockets created by
|
||||
* this factory, or <code>null</code> to use the cipher suites
|
||||
* that are enabled by default
|
||||
*
|
||||
* @param enabledProtocols names of all the protocol versions to
|
||||
* enable on SSL connections accepted by server sockets created by
|
||||
* this factory, or <code>null</code> to use the protocol versions
|
||||
* that are enabled by default
|
||||
*
|
||||
* @param needClientAuth <code>true</code> to require client
|
||||
* authentication on SSL connections accepted by server sockets
|
||||
* created by this factory; <code>false</code> to not require
|
||||
* client authentication
|
||||
*
|
||||
* @exception IllegalArgumentException when one or more of the cipher
|
||||
* suites named by the <code>enabledCipherSuites</code> parameter is
|
||||
* not supported, when one or more of the protocols named by the
|
||||
* <code>enabledProtocols</code> parameter is not supported or when
|
||||
* a problem is encountered while trying to check if the supplied
|
||||
* cipher suites and protocols to be enabled are supported.
|
||||
*
|
||||
* @see SSLSocket#setEnabledCipherSuites
|
||||
* @see SSLSocket#setEnabledProtocols
|
||||
* @see SSLSocket#setNeedClientAuth
|
||||
*/
|
||||
public SslRMIServerSocketFactory(
|
||||
String[] enabledCipherSuites,
|
||||
String[] enabledProtocols,
|
||||
boolean needClientAuth)
|
||||
throws IllegalArgumentException {
|
||||
this(null, enabledCipherSuites, enabledProtocols, needClientAuth);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Creates a new <code>SslRMIServerSocketFactory</code> with the
|
||||
* specified <code>SSLContext</code> and SSL socket configuration.</p>
|
||||
*
|
||||
* @param context the SSL context to be used for creating SSL sockets.
|
||||
* If <code>context</code> is null the default <code>SSLSocketFactory</code>
|
||||
* or the default <code>SSLServerSocketFactory</code> will be used to
|
||||
* create SSL sockets. Otherwise, the socket factory returned by
|
||||
* <code>SSLContext.getSocketFactory()</code> or
|
||||
* <code>SSLContext.getServerSocketFactory()</code> will be used instead.
|
||||
*
|
||||
* @param enabledCipherSuites names of all the cipher suites to
|
||||
* enable on SSL connections accepted by server sockets created by
|
||||
* this factory, or <code>null</code> to use the cipher suites
|
||||
* that are enabled by default
|
||||
*
|
||||
* @param enabledProtocols names of all the protocol versions to
|
||||
* enable on SSL connections accepted by server sockets created by
|
||||
* this factory, or <code>null</code> to use the protocol versions
|
||||
* that are enabled by default
|
||||
*
|
||||
* @param needClientAuth <code>true</code> to require client
|
||||
* authentication on SSL connections accepted by server sockets
|
||||
* created by this factory; <code>false</code> to not require
|
||||
* client authentication
|
||||
*
|
||||
* @exception IllegalArgumentException when one or more of the cipher
|
||||
* suites named by the <code>enabledCipherSuites</code> parameter is
|
||||
* not supported, when one or more of the protocols named by the
|
||||
* <code>enabledProtocols</code> parameter is not supported or when
|
||||
* a problem is encountered while trying to check if the supplied
|
||||
* cipher suites and protocols to be enabled are supported.
|
||||
*
|
||||
* @see SSLSocket#setEnabledCipherSuites
|
||||
* @see SSLSocket#setEnabledProtocols
|
||||
* @see SSLSocket#setNeedClientAuth
|
||||
* @since 1.7
|
||||
*/
|
||||
public SslRMIServerSocketFactory(
|
||||
SSLContext context,
|
||||
String[] enabledCipherSuites,
|
||||
String[] enabledProtocols,
|
||||
boolean needClientAuth)
|
||||
throws IllegalArgumentException {
|
||||
// Initialize the configuration parameters.
|
||||
//
|
||||
this.enabledCipherSuites = enabledCipherSuites == null ?
|
||||
null : enabledCipherSuites.clone();
|
||||
this.enabledProtocols = enabledProtocols == null ?
|
||||
null : enabledProtocols.clone();
|
||||
this.needClientAuth = needClientAuth;
|
||||
|
||||
// Force the initialization of the default at construction time,
|
||||
// rather than delaying it to the first time createServerSocket()
|
||||
// is called.
|
||||
//
|
||||
this.context = context;
|
||||
final SSLSocketFactory sslSocketFactory =
|
||||
context == null ?
|
||||
getDefaultSSLSocketFactory() : context.getSocketFactory();
|
||||
SSLSocket sslSocket = null;
|
||||
if (this.enabledCipherSuites != null || this.enabledProtocols != null) {
|
||||
try {
|
||||
sslSocket = (SSLSocket) sslSocketFactory.createSocket();
|
||||
} catch (Exception e) {
|
||||
final String msg = "Unable to check if the cipher suites " +
|
||||
"and protocols to enable are supported";
|
||||
throw (IllegalArgumentException)
|
||||
new IllegalArgumentException(msg).initCause(e);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if all the cipher suites and protocol versions to enable
|
||||
// are supported by the underlying SSL/TLS implementation and if
|
||||
// true create lists from arrays.
|
||||
//
|
||||
if (this.enabledCipherSuites != null) {
|
||||
sslSocket.setEnabledCipherSuites(this.enabledCipherSuites);
|
||||
enabledCipherSuitesList = Arrays.asList(this.enabledCipherSuites);
|
||||
}
|
||||
if (this.enabledProtocols != null) {
|
||||
sslSocket.setEnabledProtocols(this.enabledProtocols);
|
||||
enabledProtocolsList = Arrays.asList(this.enabledProtocols);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the names of the cipher suites enabled on SSL
|
||||
* connections accepted by server sockets created by this factory,
|
||||
* or <code>null</code> if this factory uses the cipher suites
|
||||
* that are enabled by default.</p>
|
||||
*
|
||||
* @return an array of cipher suites enabled, or <code>null</code>
|
||||
*
|
||||
* @see SSLSocket#setEnabledCipherSuites
|
||||
*/
|
||||
public final String[] getEnabledCipherSuites() {
|
||||
return enabledCipherSuites == null ?
|
||||
null : enabledCipherSuites.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns the names of the protocol versions enabled on SSL
|
||||
* connections accepted by server sockets created by this factory,
|
||||
* or <code>null</code> if this factory uses the protocol versions
|
||||
* that are enabled by default.</p>
|
||||
*
|
||||
* @return an array of protocol versions enabled, or
|
||||
* <code>null</code>
|
||||
*
|
||||
* @see SSLSocket#setEnabledProtocols
|
||||
*/
|
||||
public final String[] getEnabledProtocols() {
|
||||
return enabledProtocols == null ?
|
||||
null : enabledProtocols.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns <code>true</code> if client authentication is
|
||||
* required on SSL connections accepted by server sockets created
|
||||
* by this factory.</p>
|
||||
*
|
||||
* @return <code>true</code> if client authentication is required
|
||||
*
|
||||
* @see SSLSocket#setNeedClientAuth
|
||||
*/
|
||||
public final boolean getNeedClientAuth() {
|
||||
return needClientAuth;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Creates a server socket that accepts SSL connections
|
||||
* configured according to this factory's SSL socket configuration
|
||||
* parameters.</p>
|
||||
*/
|
||||
public ServerSocket createServerSocket(int port) throws IOException {
|
||||
final SSLSocketFactory sslSocketFactory =
|
||||
context == null ?
|
||||
getDefaultSSLSocketFactory() : context.getSocketFactory();
|
||||
return new ServerSocket(port) {
|
||||
public Socket accept() throws IOException {
|
||||
Socket socket = super.accept();
|
||||
SSLSocket sslSocket = (SSLSocket) sslSocketFactory.createSocket(
|
||||
socket, socket.getInetAddress().getHostName(),
|
||||
socket.getPort(), true);
|
||||
sslSocket.setUseClientMode(false);
|
||||
if (enabledCipherSuites != null) {
|
||||
sslSocket.setEnabledCipherSuites(enabledCipherSuites);
|
||||
}
|
||||
if (enabledProtocols != null) {
|
||||
sslSocket.setEnabledProtocols(enabledProtocols);
|
||||
}
|
||||
sslSocket.setNeedClientAuth(needClientAuth);
|
||||
return sslSocket;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Indicates whether some other object is "equal to" this one.</p>
|
||||
*
|
||||
* <p>Two <code>SslRMIServerSocketFactory</code> objects are equal
|
||||
* if they have been constructed with the same SSL context and
|
||||
* SSL socket configuration parameters.</p>
|
||||
*
|
||||
* <p>A subclass should override this method (as well as
|
||||
* {@link #hashCode()}) if it adds instance state that affects
|
||||
* equality.</p>
|
||||
*/
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) return false;
|
||||
if (obj == this) return true;
|
||||
if (!(obj instanceof SslRMIServerSocketFactory))
|
||||
return false;
|
||||
SslRMIServerSocketFactory that = (SslRMIServerSocketFactory) obj;
|
||||
return (getClass().equals(that.getClass()) && checkParameters(that));
|
||||
}
|
||||
|
||||
private boolean checkParameters(SslRMIServerSocketFactory that) {
|
||||
// SSL context
|
||||
//
|
||||
if (context == null ? that.context != null : !context.equals(that.context))
|
||||
return false;
|
||||
|
||||
// needClientAuth flag
|
||||
//
|
||||
if (needClientAuth != that.needClientAuth)
|
||||
return false;
|
||||
|
||||
// enabledCipherSuites
|
||||
//
|
||||
if ((enabledCipherSuites == null && that.enabledCipherSuites != null) ||
|
||||
(enabledCipherSuites != null && that.enabledCipherSuites == null))
|
||||
return false;
|
||||
if (enabledCipherSuites != null && that.enabledCipherSuites != null) {
|
||||
List<String> thatEnabledCipherSuitesList =
|
||||
Arrays.asList(that.enabledCipherSuites);
|
||||
if (!enabledCipherSuitesList.equals(thatEnabledCipherSuitesList))
|
||||
return false;
|
||||
}
|
||||
|
||||
// enabledProtocols
|
||||
//
|
||||
if ((enabledProtocols == null && that.enabledProtocols != null) ||
|
||||
(enabledProtocols != null && that.enabledProtocols == null))
|
||||
return false;
|
||||
if (enabledProtocols != null && that.enabledProtocols != null) {
|
||||
List<String> thatEnabledProtocolsList =
|
||||
Arrays.asList(that.enabledProtocols);
|
||||
if (!enabledProtocolsList.equals(thatEnabledProtocolsList))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns a hash code value for this
|
||||
* <code>SslRMIServerSocketFactory</code>.</p>
|
||||
*
|
||||
* @return a hash code value for this
|
||||
* <code>SslRMIServerSocketFactory</code>.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getClass().hashCode() +
|
||||
(context == null ? 0 : context.hashCode()) +
|
||||
(needClientAuth ? Boolean.TRUE.hashCode() : Boolean.FALSE.hashCode()) +
|
||||
(enabledCipherSuites == null ? 0 : enabledCipherSuitesList.hashCode()) +
|
||||
(enabledProtocols == null ? 0 : enabledProtocolsList.hashCode());
|
||||
}
|
||||
|
||||
// We use a static field because:
|
||||
//
|
||||
// SSLSocketFactory.getDefault() always returns the same object
|
||||
// (at least on Sun's implementation), and we want to make sure
|
||||
// that the Javadoc & the implementation stay in sync.
|
||||
//
|
||||
// If someone needs to have different SslRMIServerSocketFactory
|
||||
// factories with different underlying SSLSocketFactory objects
|
||||
// using different keystores and truststores, he/she can always
|
||||
// use the constructor that takes an SSLContext as input.
|
||||
//
|
||||
private static SSLSocketFactory defaultSSLSocketFactory = null;
|
||||
|
||||
private static synchronized SSLSocketFactory getDefaultSSLSocketFactory() {
|
||||
if (defaultSSLSocketFactory == null)
|
||||
defaultSSLSocketFactory =
|
||||
(SSLSocketFactory) SSLSocketFactory.getDefault();
|
||||
return defaultSSLSocketFactory;
|
||||
}
|
||||
|
||||
private final String[] enabledCipherSuites;
|
||||
private final String[] enabledProtocols;
|
||||
private final boolean needClientAuth;
|
||||
private List<String> enabledCipherSuitesList;
|
||||
private List<String> enabledProtocolsList;
|
||||
private SSLContext context;
|
||||
}
|
||||
Reference in New Issue
Block a user