105
4. 1. 3. Implementasi kelas
4.1.3.1. Kelas Form
Nama method : Form Input : -
Output : -
initComponents;
switchPanelUtamapanelHome;
key=Key.loadFromFilekey.conf; messageHandler=new MessageHandlerthis;
messageHandler.start; loadData;
refreshInbox; refreshSent;
refreshContact;
Nama method : loadData Input : -
Output : -
inboxList.clear; sentList.clear;
contactList.clear;
106
BufferedReader in=null; String line;
try {
in= new BufferedReadernew FileReaderinbox.txt; whileline=in.readLine=null
{ String data[]=line.split;
inboxList.addnewMessagedata[0], data[1],data[2],Boolean.parseBooleandata[3],Long.parseLongdata[4];
} }catchException e{}
try {
in= new BufferedReadernew FileReadersent.txt;
whileline=in.readLine=null {
String data[]=line.split; sentList.addnewMessagedata[0],
data[1],data[2],Boolean.parseBooleandata[3],Long.parseLongdata[4]; }
}catchException e{}
try
107
{ in= new BufferedReadernew FileReadercontact.txt;
whileline=in.readLine=null {
String data[]=line.split; contactList.addnew Contactdata[0], data[1];
} }
catchException e{}
Nama method : saveInbox Input : -
Output : -
try {
FileWriter fw=new FileWriterinbox.txt;
forint i=0;iinboxList.size;i++ {
Message msg=inboxList.geti;
fw.writemsg.ip++msg.fileName++msg.signature++msg.read+ +msg.time+\n;
}
108
fw.flush; }
catchException e{}
Nama method : saveSent Input : -
Output : -
try {
FileWriter fw=new FileWritersent.txt;
forint i=0;isentList.size;i++ {
Message msg=sentList.geti;
fw.writemsg.ip++msg.fileName++msg.signature++msg.read+ +msg.time+\n;
}
fw.flush; }
catchException e{}
Nama method : saveContact Input : -
109
Output : -
try {
FileWriter fw=new FileWritercontact.txt;
forint i=0;icontactList.size;i++ {
Contact c=contactList.geti; fw.writec.name++c.ip+\n;
}
fw.flush; }
catchException e{}
Nama method : refreshInbox Input : -
Output : -
DefaultTableModel tableModel=
DefaultTableModel tabelInbox.getModel;
hapus semua table int size=tableModel.getRowCount;
forint i=0;isize;i++
110
{ tableModel.removeRow0;
}
bikin data Object[][] data=new Object[inboxList.size][4];
forint i=0;idata.length;i++ {
Message msg=inboxList.geti; try{
data[i][0]=msg.read?null: new
ImageIconimgseruMerah.png; }catchException e{e.printStackTrace;}
data[i][1]=getNameContactmsg.ip; data[i][2]=msg.fileName;
data[i][3]=String.format1td-1tm-1tY 1tH:1tM,msg.time;
}
masukkan data forint i=0;idata.length;i++
{ tableModel.addRowdata[i];
} tabelInbox.setModeltableModel;
111
Nama method : refreshSent Input : -
Output : -
DefaultTableModel tableModel=
DefaultTableModel tabelSent.getModel;
hapus semua table int size=tableModel.getRowCount;
forint i=0;isize;i++ {
tableModel.removeRow0; }
bikin data String[][] data=new String[sentList.size][3];
forint i=0;idata.length;i++ {
Message msg=sentList.geti; data[i][0]=getNameContactmsg.ip;
data[i][1]=msg.fileName; data[i][2]=String.format1td-1tm-1tY
1tH:1tM,msg.time; }
masukkan data forint i=0;idata.length;i++
{
112
tableModel.addRowdata[i]; }
tabelSent.setModeltableModel;
Nama method : refreshContact Input : -
Output : -
DefaultTableModel tableModel=
DefaultTableModel tabelContact.getModel;
hapus semua table int size=tableModel.getRowCount;
forint i=0;isize;i++ {
tableModel.removeRow0; }
bikin data String[][] data=new String[contactList.size][2];
forint i=0;idata.length;i++ {
Contact c=contactList.geti; data[i][0]=c.name;
data[i][1]=c.ip; }
113
masukkan data forint i=0;idata.length;i++
{ tableModel.addRowdata[i];
} tabelContact.setModeltableModel;
Nama method : getNameContact Input : -
Output : -
forint i=0;icontactList.size;i++ {
ifcontactList.geti.ip.equalsIgnoreCaseip return contactList.geti.name;
} return ip;
Nama method : getIPContact Input : -
Output : -
forint i=0;icontactList.size;i++ {
ifcontactList.geti.name.equalsIgnoreCasename
114
return contactList.geti.ip; }
return name;
Nama method : contactComposeCBActionPerformed Input : -
Output : -
int index=contactComposeCB.getSelectedIndex; ifindex-1
{ ifindexcontactList.size
{
ipComposeTF.setTextcontactList.getindex.ip; ipComposeTF.setEnabledfalse;
} else {
ipComposeTF.setText; ipComposeTF.setEnabledtrue;
} }
Nama method : browseComposeBActionPerformed Input : -
Output : -
115
JFileChooser jfc=new JFileChooser; int result=jfc.showOpenDialogthis;
ifresult==JFileChooser.APPROVE_OPTION {
File fileTemp=jfc.getSelectedFile; String
fileName=fileTemp.getName.toLowerCase; iffileName.endsWith.doc
|| fileName.endsWith.txt
{ long size=fileTemp.length;
ifsize26214400lebih kecil dari 25 MB
fileComposeTF.setTextjfc.getSelectedFile.toString; else
JOptionPane.showMessageDialogthis,File tidak boleh melebihi 25MB;
} else
JOptionPane.showMessageDialogthis,Aplikasi hanya
mendukung .txt dan .doc;
}
Nama method : generateComposeBActionPerformed Input : -
Output : -
116
iffileComposeTF.getText.equals {
JOptionPane.showMessageDialogthis,Pilih file pesan;
return; }
Key keyTemp=null;
ifkeyTemp=Key.parsePrivateKeyprivateKeyComposeTF.getText= =null
{ JOptionPane.showMessageDialogthis,Private
key tidak valid; return;
}
try {
read file File file=new FilefileComposeTF.getText;
byte fileArr[]=new byte[intfile.length]; new FileInputStreamfile.readfileArr;
String signature=Signature.createSignaturefileArr, keyTemp;
117
signatureComposeTF.setTextsignature; }
catchException e {
JOptionPane.showMessageDialogthis,Gagal membuat signature, +e;
e.printStackTrace; return;
}
Nama method : resetComposeBActionPerformed Input : -
Output : -
ipComposeTF.setText; fileComposeTF.setText;
contactComposeCB.removeAllItems; forint i=0;icontactList.size;i++
{
contactComposeCB.addItemcontactList.geti.name; }
contactComposeCB.addItem-Masukkan IP-;
signatureComposeTF.setText;
118
privateKeyComposeTF.setTextkey.getPrivateKey;
Nama method : sendComposeBActionPerformed Input : -
Output : -
ifcontactList.size==0 ipComposeTF.getText.equals ||
contactComposeCB.getSelectedIndex==contactList.size ipComposeTF.getText.equals
{ JOptionPane.showMessageDialogthis,Masukkan
ip tujuan atau pilih contact; return;
}
ifsignatureComposeTF.getText.equals {
JOptionPane.showMessageDialogthis,Generate dahulu signature file;
return; }
iffileComposeTF.getText.equals {
119
JOptionPane.showMessageDialogthis,Pilih file pesan;
return; }
try {
read file File file=new FilefileComposeTF.getText;
byte fileArr[]=new byte[intfile.length]; new FileInputStreamfile.readfileArr;
String destination=ipComposeTF.getText;
ifcontactComposeCB.getSelectedIndexcontactList.sizedestin ation=getIPContact+contactComposeCB.getSelectedItem;
messageHandler.sendMessagedestination,file.getName,fileArr,si gnatureComposeTF.getText;
JOptionPane.showMessageDialogthis,Sukses kirim pesan;
sentList.addnew Messagedestination,fileComposeTF.getText,signatureComposeTF.g
etText,true,System.currentTimeMillis; saveSent;
120
refreshSent; }
catchException e {
JOptionPane.showMessageDialogthis,Gagal mengirim pesan, +e;
e.printStackTrace; return;
}
Nama method : deleteInboxBActionPerformed Input : -
Output : - iftabelInbox.getSelectedRowCount==0 {
JOptionPane.showMessageDialogthis,Pilih dahulu message yang akan dihapus;
return; }
iftabelInbox.getSelectedRowCount1 { JOptionPane.showMessageDialogthis,Pilih
hanya satu message; return;
}
int index=tabelInbox.getSelectedRow; ifJOptionPane.showConfirmDialogthis,Apakah anda
yakin?,,JOptionPane.YES_NO_OPTION==JOptionPane.OK_OPTION
121
{ inboxList.removeindex;
saveInbox; refreshInbox;
}
Nama method : tabelInboxMouseClicked Input : -
Output : - ifevt.getClickCount==2 {
int index=tabelInbox.getSelectedRow; ifindex=-1 {
Message msg=inboxList.getindex; tempMessage=msg;
msg.read=true; replyViewB.setEnabledtrue;
showViewMessagemsg.ip, msg.fileName,msg.signature;
refreshInbox; saveInbox;
} }
Nama method : deleteSentBActionPerformed Input : -
122
Output : - iftabelSent.getSelectedRowCount==0 {
JOptionPane.showMessageDialogthis,Pilih dahulu message yang akan dihapus;
return; }
iftabelSent.getSelectedRowCount1 { JOptionPane.showMessageDialogthis,Pilih
hanya satu message; return;
}
int index=tabelSent.getSelectedRow; ifJOptionPane.showConfirmDialogthis,Apakah anda
yakin?,,JOptionPane.YES_NO_OPTION==JOptionPane.OK_OPTION {
sentList.removeindex; saveSent;
refreshSent; }
Nama method : tabelSentMouseClicked Input : -
Output : - ifevt.getClickCount==2 {
int index=tabelSent.getSelectedRow;
123
ifindex=-1 { tempMessage=null;
Message msg=sentList.getindex; replyViewB.setEnabledfalse;
showViewMessagemsg.ip, msg.fileName,msg.signature;
} }
Nama method : saveContactViewBActionPerformed Input : -
Output : - String
nama=JOptionPane.showInputDialogviewMessageDialog,Masukkan nama contact;
ifnama=null nama.equals {
Contact c=new Contact; c.ip=fromViewTF.getText;
c.name=nama; contactList.addc;
saveContactViewB.setEnabledfalse; saveContact;
refreshContact;
JOptionPane.showMessageDialogviewMessageDialog,Sukses tambah
contact;
124
}
Nama method : openViewBActionPerformed Input : -
Output : - iftempMessage==nullbuka file sent
{ try{
openFilenew FilefileViewTF.getText; }
catchException e{
JOptionPane.showMessageDialogviewMessageDialog,Gagal membuka
file +e; }
return; }
byte[] fileArr=null; File file=null;
String fileName=+tempMessage.time;
try {
read file file=new FilefileName;
fileArr=new byte[intfile.length];
125
new FileInputStreamfile.readfileArr; }
catchException e {
JOptionPane.showMessageDialogviewMessageDialog,Gagal membaca
file, +e; e.printStackTrace;
return; }
Key keyTemp=Key.parsePublicKeypublicKeyViewTF.getText;
ifkeyTemp==null {
JOptionPane.showMessageDialogviewMessageDialog,Public key
tidak valid; return;
}
try {
boolean sukses=Signature.checkSignaturefileArr,
keyTemp, signatureViewTF.getText;
ifsukses {
126
File to=new FiletempMessage.fileName;
ifto.existscopy file {
copyFilefile.toString,to.toString; }
openFileto; }
else JOptionPane.showMessageDialogviewMessageDialog,Signature tidak
valid; }
catchException e {
JOptionPane.showMessageDialogviewMessageDialog,Gagal mengecek signature +e;
return; }
Nama method : replyViewBActionPerformed Input : -
Output : - viewMessageDialog.setVisiblefalse;
switchPanelUtamapanelCompose;
127
String to=fromViewTF.getText;
ifto.containsto=to.substring0,to.indexOf; ipComposeTF.setTextto;
contactComposeCB.setSelectedIndexcontactList.size;
Nama method : addContactBActionPerformed Input : -
Output : - namaContactTF.setText;
ipContactTF.setText; addContactDialogB.setTextAdd;
addContactDialog.pack; addContactDialog.setVisibletrue;
Nama method : deleteContactBActionPerformed Input : -
Output : - iftabelContact.getSelectedRowCount==0 {
JOptionPane.showMessageDialogthis,Pilih dahulu contact yang akan dihapus;
return; }
iftabelContact.getSelectedRowCount1 { JOptionPane.showMessageDialogthis,Pilih
128
hanya satu contact; return;
}
int index=tabelContact.getSelectedRow; ifJOptionPane.showConfirmDialogthis,Apakah anda
yakin?,,JOptionPane.YES_NO_OPTION==JOptionPane.OK_OPTION {
contactList.removeindex; saveContact;
refreshContact; }
Nama method : editContactBActionPerformed Input : -
Output : - iftabelContact.getSelectedRowCount==0 {
JOptionPane.showMessageDialogthis,Pilih dahulu contact yang akan diedit;
return; }
iftabelContact.getSelectedRowCount1 { JOptionPane.showMessageDialogthis,Pilih
hanya satu contact; return;
}
129
int index=tabelContact.getSelectedRow; contactTemp=contactList.getindex;
namaContactTF.setTextcontactTemp.name; ipContactTF.setTextcontactTemp.ip;
addContactDialogB.setTextEdit; addContactDialog.pack;
addContactDialog.setVisibletrue;
Nama method : addContactDialogBActionPerformed Input : -
Output : - String ip=ipContactTF.getText;
ifip==null || ip.equals {
JOptionPane.showMessageDialogaddContactDialog,addContactDialogB .getText+ contact gagal\nIP harus dimasukkan;
return; }
String name=namaContactTF.getText; ifname.equals
|| getIPContactname.equalsIgnoreCaseip {
JOptionPane.showMessageDialogaddContactDialog,addContactDialogB .getText+ contact gagal\nNama harus dimasukkanNama Telah
ada; return;
}
130
Contact c=new Contact;
c.ip=ip; c.name=name;
ifaddContactDialogB.getText.equalsAddcontactList.add0,c ;
else edit {
int index=contactList.indexOfcontactTemp; contactList.setindex, c;
} saveContact;
refreshContact;
addContactDialog.setVisiblefalse;
Nama method : addContactDialogBActionPerformed Input : -
Output : - String ip=ipContactTF.getText;
ifip==null || ip.equals {
JOptionPane.showMessageDialogaddContactDialog,addContactDialogB .getText+ contact gagal\nIP harus dimasukkan;
return; }
131
String name=namaContactTF.getText; ifname.equals
|| getIPContactname.equalsIgnoreCaseip {
JOptionPane.showMessageDialogaddContactDialog,addContactDialogB .getText+ contact gagal\nNama harus dimasukkanNama Telah
ada; return;
} Contact c=new Contact;
c.ip=ip; c.name=name;
ifaddContactDialogB.getText.equalsAddcontactList.add0,c ;
else edit {
int index=contactList.indexOfcontactTemp; contactList.setindex, c;
} saveContact;
refreshContact;
addContactDialog.setVisiblefalse;
132
Nama method : generateSettingBActionPerformed Input : -
Output : - Key k=Signature.generateKey;
privateSettingTF.setTextk.s+-+k.p+-+k.q+- +k.a;
publicSettingTF.setTextk.lamdha+-+k.p+- +k.q+-+k.a;
Nama method : saveSettingBActionPerformed Input : -
Output : - Key
privateK=Key.parsePrivateKeyprivateSettingTF.getText; ifprivateK==null {
JOptionPane.showMessageDialogsettingDialog,Private key tidak valid;
return; }
Key publicK=Key.parsePublicKeypublicSettingTF.getText;
ifpublicK==null {
JOptionPane.showMessageDialogsettingDialog,Public key
tidak valid;
133
return; }
privateK.lamdha=publicK.lamdha; key=privateK;
try { Key.saveToFileKEY_FILE, key;
} catchException e{}
settingDialog.setVisiblefalse;
Nama method : broadcastSettingBActionPerformed Input : -
Output : - try {
messageHandler.sendKey key;
JOptionPane.showMessageDialogsettingDialog,Sukses broadcast
key; } catch Exception ex {
JOptionPane.showMessageDialogsettingDialog,Gagal broadcast key : +ex.getMessage;
ex.printStackTrace; }
134
Nama method : settingButtonActionPerformed Input : -
Output : - try
{ privateSettingTF.setTextkey.getPrivateKey;
publicSettingTF.setTextkey.getPublicKey; }
catchException e{}
settingDialog.pack; settingDialog.setVisibletrue;
Nama method : showViewMessage Input : -
Output : - publicKeyViewTF.setTextkey.getPublicKey;
String from=getNameContactip; String alamat=ip;
iffrom.equalsIgnoreCaseip{ saveContactViewB.setEnabledfalse;
alamat+=+from+; }
else saveContactViewB.setEnabledtrue; fromViewTF.setTextalamat;
signatureViewTF.setTextsignature;
135
fileViewTF.setTextfile.toString;
viewMessageDialog.pack; viewMessageDialog.setVisibletrue;
Nama method : receiveMessage Input : -
Output : - try
{ long now=System.currentTimeMillis;
tulis file new FileOutputStream+now.writefilearr;
inboxList.add0,new Messageip,namaFile,signature,false,now;
saveInbox; refreshInbox;
}catchException e {}
Nama method : openFile Input : -
Output : - try {
Runtime.getRuntime.execrundll32
136
SHELL32.DLL,ShellExec_RunDLL + file.getAbsolutePath; } catch Exception ex {
JOptionPane.showMessageDialogviewMessageDialog,Gagal buka
file, +ex; ex.printStackTrace;
}
Nama method : copyFile Input : -
Output : - FileWriter writer=new FileWriterto;
FileReader reader=new FileReaderfile;
int kar;
whilekar=reader.read=-1 {
writer.writekar; }
writer.flush; writer.close;
reader.close;
137
4.1.3.2. Kelas key
Nama method : key Input : -
Output : -
this.p=p; this.q=q;
this.a=a; this.s=s;
this.lamdha=lamdha;
Nama method : loadFromFile Input : String file
Output : -
try {
Properties props=new Properties; props.loadnew FileReaderfile;
Key privateK=parsePrivateKeyprops.getPropertyprivate_key;
Key publicK=parsePublicKeyprops.getPropertypublic_key;
privateK.lamdha=publicK.lamdha;
138
return privateK; }
catchException e{} return null;
Nama method : saveToFile Input : String file,Key key
Output : -
try {
FileWriter fw=new FileWriterfile; fw.writeprivate_key = +key.s+-+key.p+-
+key.q+-+key.a+\n; fw.writepublic_key
= +key.lamdha+-
+key.p+-+key.q+-+key.a;
fw.flush; return true;
} catchException e{}
return false;
Nama method : getPrivateKey Input : -
Output : -
139
return s+-+p+-+q+-+a;
Nama method : getPublicKey Input : -
Output : -
return lamdha+-+p+-+q+-+a;
Nama method : parsePrivateKey Input : -
Output : -
try {
String[] strTemp=str.split-; ifstrTemp.length=4return null;
Key key=new Key;
cari s key.s=new BigIntegerstrTemp[0];
cari p key.p=new BigIntegerstrTemp[1];
140
cari q key.q=new BigIntegerstrTemp[2];
cari a key.a=new BigIntegerstrTemp[3];
return key; }
catchException e{} return null;
Nama method : parsePublicKey Input : -
Output : -
try {
String[] strTemp=str.split-; ifstrTemp.length=4return null;
Key key=new Key;
cari lamdha key.lamdha=new BigIntegerstrTemp[0];
cari p key.p=new BigIntegerstrTemp[1];
141
cari q key.q=new BigIntegerstrTemp[2];
cari a key.a=new BigIntegerstrTemp[3];
return key; }
catchException e{} return null;
4.1.3.3. Kelas Signature
Nama method : generateKey Input : -
Output : -
Random rand=new Random;
BigInteger p=new BigIntegerBITNUM,0, rand; int i=0;
whiletrue {
ifp.isProbablePrimeBITNUMbreak; else p=p.nextProbablePrime;
i++;
142
ifi1000return generateKey; }
find the prime factor of p-1 BigInteger pTemp=p.subtractnew BigInteger1;
BigInteger q=new BigInteger9; i=0;
whiletrue {
ifpTemp.modq.intValue==0break; else q=q.nextProbablePrime;
i++; ifi1000return generateKey;
}
BigInteger a=new BigIntegerBITNUM, rand; cari aq mod p == 1
i=0; whiletrue
{
ifa.powq.intValue.modp.intValue==1break; else
{ a=a.subtractnew BigInteger1;
ifa.intValue=1 ||
a.intValue=p.intValuea=new BigIntegerBITNUM, rand; }
143
i++; ifi10000return generateKey;
}
BigInteger s=new BigIntegerBITNUM, rand; cari sq
i=0; whiletrue
{ ifs.intValue=0 s.compareToq0break;
else s=new BigIntegerBITNUM, rand; i++;
ifi10000return generateKey; }
BigInteger lamdha=a.modInversep.pows.intValue.modp;
return new Keyp,q,a,s,lamdha;
Nama method : createSignature Input : -
Output : -
Random rand=new Random;
buat rq
144
BigInteger r=new BigIntegerBITNUM, rand;
int i=0; whiletrue
{ ifi100000throw new ExceptionPrivate key
tidak valid; ifr.intValue=0
r.compareTokey.q0break; else r=new BigIntegerBITNUM, rand;
i++; }
buat x BigInteger x=key.a.powr.intValue.modkey.p;
byte[] bytex=x.toByteArray;
bacaFile byte[] fileArr=new byte[file.length+bytex.length];
M||X System.arraycopyfile,0,fileArr,0,file.length;
System.arraycopybytex,0,fileArr,file.length,bytex.length;
hitung digest dari M||X MessageDigest
md=MessageDigest.getInstanceSHA-
145
256; byte[] resultdigest=md.digestfileArr;
BigInteger h=new BigIntegerresultdigest; String kembali=h.toString;
h=h.modkey.q;
cari y BigInteger sh=key.s.multiplyh;
BigInteger y=r.addsh.modkey.q; kembali+=;+y;
return kembali;
Nama method : checkSignature Input : -
Output : -
String tempstr[]=signature.split;; BigInteger
h=new BigIntegertempstr[0].modkey.q;
BigInteger y=new BigIntegertempstr[1]; BigInteger z=key.a.powy.intValue;
BigInteger ztemp=key.lamdha.powh.intValue; z=z.multiplyztemp.modkey.p;
146
byte bytez[]=z.toByteArray;
bacaFile System.out.printlnfile.length;
byte[] fileArr=new byte[file.length+bytez.length];
System.arraycopyfile,0,fileArr,0,file.length;
System.arraycopybytez,0,fileArr,file.length,bytez.length;
hitung digest MessageDigest
md=MessageDigest.getInstanceSHA- 256;
byte[] resultdigest=md.digestfileArr;
BigInteger h1=new BigIntegerresultdigest; h1=h1.modkey.q;
System.out.printlnh1+ +h;
return h.intValue==h1.intValue;
4.1.3.4. Kelas Contact
Nama method : Contact Input : -
Output : -
147
name=n; ip=i;
4.1.3.5. Kelas Message
Nama method : Message Input : -
Output : -
this.ip=ip; this.fileName=file;
this.signature=signature; this.read=read;
this.time=time;
4.1.3.6. Kelas MessageHandler
Nama method : MessageHandler Input : -
Output : -
handler=form;
148
serverSocket=new ServerSocketPORT;
Nama method : Run Input : -
Output : -
whiletrue {
try {
Socket s=serverSocket.accept; DataInputStream in=new DataInputStreams.getInputStream;
byte kode=in.readByte; ifkode==0
{ String namaFile=in.readLine;
int length=Integer.parseIntin.readLine; byte file[]=new byte[length];
149
int readedTotal=0; int read=0;
whiletrue {
read=in.readfile,readedTotal,length-readedTotal; readedTotal+=read;
ifreadedTotal=lengthbreak; }
String signature=in.readLine;
panggil handler
handler.receiveMessages.getInetAddress.getHostAddress.toString, namaFile,file,signature;
} else ifkode==1update key
{
150
String temp=in.readLine; Key privateKey=Key.parsePrivateKeytemp;
temp=in.readLine; Key publicKey=Key.parsePublicKeytemp;
privateKey.lamdha=publicKey.lamdha;
handler.setKeyprivateKey; }
s.close; }
catchException e {
e.printStackTrace; }
}
Nama method : sendMessage
151
Input : - Output : -
Socket s=new Socketip, PORT; OutputStream out=s.getOutputStream;
out.write0; out.writefileName+\n+file.length+\n.getBytes;
out.writefile; out.writesignature+\n.getBytes;
out.flush; s.close;
Nama method : sendKey Input : -
Output : - EnumerationNetworkInterface
interfaces =NetworkInterface.getNetworkInterfaces;
while interfaces.hasMoreElements { NetworkInterface
networkInterface =
interfaces.nextElement; if
networkInterface.isLoopbackcontinue;
152
Dont want to broadcast to the loopback interface
for InterfaceAddress
interfaceAddress :
networkInterface.getInterfaceAddresses {
System.out.printlninterfaceAddress.getAddress; InetAddress
broadcast =
interfaceAddress.getBroadcast; if broadcast == nullcontinue;
Use the address try
{ System.out.printlnbroadcast;
Socket s=new Socketbroadcast, PORT; OutputStream out=s.getOutputStream;
out.write1;
out.writekey.getPrivateKey+\n.getBytes;
out.writekey.getPublicKey+\n.getBytes; out.flush;
s.close; }
catchException e{} }
}
153
4. 2. Pengujian Alpha
Pengujian perangkat lunak dilakukan untuk memeriksa kekompakam antar komponen sistem dan sub sistemnya dengan tujuan utamanya adalah untuk
memastikan elemen-elemen sistem berfungsi sesuai dengan yang diharapkan. Pengujian sistem juga termasuk pengujian program secara menyeluruh. Kumpulan
program yang telah terintegerasikan perlu diuji coba atau tes untuk melihat apakah sebuah program dapat menerima dengan baik, memproses dan memberikan
keluaran program yang baik pula.
4. 2. 1. Rencana Pengujian
Rencana pengujian akan dilakukan dengan menguji sistem secara alpha dan beta. Pengujian perangkat lunak aplikasi pembuatan digital signature ini
menggunakan uji berdasarkan data yang terdapat di PT. Citra Bumi Madani.
4. 2. 2. Pengujian Sistem
Pengujian sistem konfigurasi kunci ini dilakukan dengan pengujian objektif. Tabel hasil pengujian sistem dari berabgai kemungkinan proses input
yang dilakukan oleh pengguna selangkapnya dapat dilihat sebagai berikut :
Tabel 4. 3. Skenario Pengujian Sistem
Skenario Uji Metode
Pengujian Jaringan Lan Black Box
Pengujian Konfigurasi Kunci Black Box
Pengujian Form Utama Black Box
154
Pengujian Form Pesan Baru Black Box
Pengujian Buka Pesan Black Box
Pengujian add contact Black Box
4. 2. 2. 1. Pengujian Jaringan LAN
Pada subbab ini dijelaskan mengenai pengujian jaringan di PT. Citra Bumi Madani.
4. 2. 2. 2. Skema jaringan
Topologi jaringan yang digunakan pada perusahaan adalah topologi star. Berikut skema jaringan yang digunakan pada perusahaan tersebut
IP : 192.168.1.2
IP : 192.168.1.5 Direktur
Bagian Keuangan Bagian Peralatan
Admin IP : 192.168.1.3
IP : 192.168.1.4
Gambar 4. 1. Skema Jaringan