Diffie-Hellman key agreement. There's actually a better way of doing this if you are using long term public keys, see the light-weight version for details.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.