ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzaha_5.4.0.1/sslsfact.htm

94 lines
7.3 KiB
HTML
Raw Permalink Normal View History

2024-04-02 14:02:31 +00:00
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-us" xml:lang="en-us">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="security" content="public" />
<meta name="Robots" content="index,follow" />
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
<meta name="DC.Type" content="task" />
<meta name="DC.Title" content="Change your Java code to use socket factories" />
<meta name="abstract" content="To use secure sockets layer (SSL) with your existing code, you must first change your code to use socket factories." />
<meta name="description" content="To use secure sockets layer (SSL) with your existing code, you must first change your code to use socket factories." />
<meta name="DC.Relation" scheme="URI" content="usessl.htm" />
<meta name="DC.Relation" scheme="URI" content="sslprepf.htm" />
<meta name="DC.Relation" scheme="URI" content="sslmcode.htm" />
<meta name="DC.Relation" scheme="URI" content="ssldecdc.htm" />
<meta name="DC.Relation" scheme="URI" content="sslusedc.htm" />
<meta name="DC.Relation" scheme="URI" content="sslcex03.htm" />
<meta name="DC.Relation" scheme="URI" content="sslcex01.htm" />
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
<meta name="DC.Format" content="XHTML" />
<meta name="DC.Identifier" content="sslsfact" />
<meta name="DC.Language" content="en-us" />
<!-- All rights reserved. Licensed Materials Property of IBM -->
<!-- US Government Users Restricted Rights -->
<!-- Use, duplication or disclosure restricted by -->
<!-- GSA ADP Schedule Contract with IBM Corp. -->
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
<link rel="stylesheet" type="text/css" href="./ic.css" />
<title>Change your Java code to use socket factories</title>
</head>
<body id="sslsfact"><a name="sslsfact"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">Change your Java code to use socket factories</h1>
<div><p>To use secure sockets layer (SSL) with your existing code, you
must first change your code to use socket factories.</p>
<div class="section"><p>To change your code to use socket factories, perform the following
steps:</p>
</div>
<ol><li class="stepexpand"><span>Add this line to your program to import the SocketFactory class: </span> <pre>import javax.net.*;</pre>
</li>
<li class="stepexpand"><span>Add a line that declares an instance of a SocketFactory object.
For example: </span> <pre>SocketFactory socketFactory</pre>
</li>
<li class="stepexpand"><span>Initialize the SocketFactory instance by setting it equal to the
method SocketFactory.getDefault(). For example:</span> <pre>socketFactory = SocketFactory.getDefault();</pre>
<div class="p">The whole declaration of the SocketFactory should look like
this: <pre>SocketFactory socketFactory = SocketFactory.getDefault();</pre>
</div>
</li>
<li class="stepexpand"><span>Initialize your existing sockets. Call the SocketFactory method
createSocket(host,port) on your socket factory for each socket you declare.</span> <div class="p">Your socket declarations should now look like this:<pre>Socket <em>s</em> = <em>socketFactory</em>.createSocket(<em>host</em>,<em>port</em>);</pre>
</div>
Where: <ul><li><em>s</em> is the socket that is being created.</li>
<li><em>socketFactory</em> is the SocketFactory that was created in step 2.</li>
<li><em>host</em> is a string variable that represents the name of a host server.</li>
<li><em>port</em> is an integer variable that represents the port number of
the socket connection.</li>
</ul>
</li>
</ol>
<div class="section"><p>When you have completed all of these steps, your code uses socket
factories. You do not need to make any other changes to your code. All of
the methods that you call and all the syntax with your sockets still work.</p>
<p>See <a href="sslcex03.htm">Examples: Change your Java™ code to use server socket factories</a> for
an example of a client program being converted to use socket factories.</p>
<p>See <a href="sslcex01.htm">Example: Change your Java code to use client socket factories</a> for
an example of a client program being converted to use socket factories.</p>
</div>
</div>
<div>
<ul class="ullinks">
<li class="ulchildlink"><strong><a href="sslcex03.htm">Examples: Change your Java code to use server socket factories</a></strong><br />
These examples show you how to change a simple socket class, named simpleSocketServer, so that it uses socket factories to create all of the sockets. The first example shows you the simpleSocketServer class without socket factories. The second example shows you the simpleSocketServer class with socket factories. In the second example, simpleSocketServer is renamed to factorySocketServer.</li>
<li class="ulchildlink"><strong><a href="sslcex01.htm">Examples: Change your Java code to use client socket factories</a></strong><br />
These examples show you how to change a simple socket class, named simpleSocketClient, so that it uses socket factories to create all of the sockets. The first example shows you the simpleSocketClient class without socket factories. The second example shows you the simpleSocketClient class with socket factories. In the second example, simpleSocketClient is renamed to factorySocketClient.</li>
</ul>
<div class="familylinks">
<div class="parentlink"><strong>Parent topic:</strong> <a href="usessl.htm" title="SSL provides a means of authenticating a server and a client to provide privacy and data integrity. All SSL communications begin with a &#34;handshake&#34; between the server and the client. During the handshake, SSL negotiates the cipher suite that the client and server use to communicate with each other. This cipher suite is a combination of the various security features available through SSL. You can only use SSL with J2SDK, version 1.3. You can use the Java Secure Socket Extension (JSSE, version 1.0.8), which is the Java implementation of secure sockets layer (SSL), to make your Java application more secure.">Using SSL (JSSE, version 1.0.8)</a></div>
</div>
<div class="relconcepts"><strong>Related concepts</strong><br />
<div><a href="ssldecdc.htm" title="You should consider several factors when deciding which digital certificate to use. You can use your system's default certificate or you can specify another certificate to use.">Select a digital certificate to use</a></div>
<div><a href="sslusedc.htm" title="To use secure sockets layer (SSL), you must run your Java application using a digital certificate.">Use the digital certificate when you run your Java application</a></div>
</div>
<div class="reltasks"><strong>Related tasks</strong><br />
<div><a href="sslprepf.htm" title="To prepare your system to use secure sockets layer (SSL), you need to install Licensed Programs. the Digital Certificate Manager LP:">Prepare iSeries server for secure sockets layer support</a></div>
<div><a href="sslmcode.htm">Change your Java code to use secure sockets layer</a></div>
</div>
</div>
</body>
</html>