Topshiriq:
Talaba laboratoriya ishi uchun shaxsiy topshiriq oladi. Bu topshiriq bo‘yicha
talaba tarmoqda xavfsiz soketlarlarni yaratadi.
Ishni bajarish tartibi:
1-qadam.
Ish NetBeans IDE integrallashgan
ishlab chiqarish muhitini
yuklash bilan boshlanadi. Quyidagi rasmda NetBeans
IDE muhitining asosiy
darchasi yuklangan.
5
10.1-rasm. NetBeans IDE muhiti asosiy darchasi
2-qadam.
“Файл”
menyusining
“Открыть
проект”
bo‘limidan
“Talabaning_Ismi” loyihasi ochiladi.
10.2-rasm. NetBeans IDE muhiti yangi klass
yaratish
3-qadam.
“New Класс Java” darchasining “Имя класса”
maydoniga
“Client”, “Пакет” maydoniga “ssl” kiritilib “Готово” tugmasi bosiladi.
6
10.3-rasm. NetBeans IDE muhiti “New Класс Java” darchasi
4-qadam.
Yaratilgan Client.java fayliga quyidagi Java kodi kiritiladi.
package ssl;
import java.io.*;
import javax.net.ssl.*;
import com.sun.net.ssl.*;
import com.sun.net.ssl.internal.ssl.Provider;
import java.security.Security;
public class Client {
public static void main(String[] args) throws Exception{
String strServerName = "localhost"; // SSL Server nomi
int intSSLport = 4443; // SSL eshitadigan port raqami
PrintWriter out = null;
BufferedReader in = null;
{
// JSSE provayderni ro’yxatdan o’tkazish
Security.addProvider(new Provider());
}
try {
// Kliyent soketini yaratish
9
// Oqimlar va soketni yopish
out.close();
in.close();
sslSocket.close();
sslServerSocket.close();
}
}
catch(Exception exp)
{
PrivilegedActionException
priexp
=
new
PrivilegedActionException(exp);
System.out.println(" Priv exp --- " + priexp.getMessage());
System.out.println(" Xatolik ro'y berdi .... " +exp);
exp.printStackTrace();
}
}
}
10.4-rasm. NetBeans IDE muhiti
Nazorat savollari
1.
Java
Security kutubxonasi
2.
Java Secure Socket Extension (JSSE)
3.
JSSE standart API
10
4.
SSLSocket & SSLEngine yaratish
5.
Java Security kutubxonasi
6.
Datagram Transport Layer
Security
7.
Transport Layer Security
8.
Secure
Socket Layer
9.
javax.net paketi
10.
javax.net.ssl paketi