Signeret applet
Hej folkens.Jeg er igang med at lave et applet som lister klients drev og finder en nøglefil som bruges i et loginsystem.
For at kunne gøre det skal jeg signere en jar fil; så det første jeg gør, er selvfølgelig at lave en jar fil;
>jar cvf key.jar Load.class
Og signerings proceduren;
>del "C:\Documents and Settings\Niklas Nielsen\.keystore"
>keytool -genkey -alias "key" -keyalg RSA -validity 3600 ->dname "CN=FPR, OU=FPR, O=FPR, L=Fpr, S=Fpr, C=SG"
>jarsigner key.jar key
>jarsigner -verify -verbose key.jar
Og resultatet af ovenstående;
---------------------------------------------------
110 Mon Aug 14 12:38:54 CEST 2006 META-INF/MANIFEST.MF
187 Mon Aug 14 12:38:54 CEST 2006 META-INF/KEY.SF
863 Mon Aug 14 12:38:54 CEST 2006 META-INF/KEY.RSA
0 Mon Aug 14 12:38:46 CEST 2006 META-INF/
smk 1050 Mon Aug 14 12:17:20 CEST 2006 Load.class
s = signature was verified
m = entry is listed in manifest
k = at least one certificate was found in keystore
i = at least one certificate was found in identity scope
jar verified.
---------------------------------------------------
Så det ser vel fint og fornuftigt ud.
Men når jeg skal have det vist i en browser (IE her) med følgende html;
---------------------------------------------------
<html>
<head></head>
<body>
<applet achive="key.jar" code="Load.class" width="200px" height="200px"/>
</body>
</html>
---------------------------------------------------
Får jeg denne besked;
---------------------------------------------------
load: class Load.class not found.
java.lang.ClassNotFoundException: Load.class
at sun.applet.AppletClassLoader.findClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadClass(Unknown Source)
at java.lang.ClassLoader.loadClass(Unknown Source)
at sun.applet.AppletClassLoader.loadCode(Unknown Source)
at sun.applet.AppletPanel.createApplet(Unknown Source)
at sun.plugin.AppletViewer.createApplet(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: C:\Programmer\xampplite\htdocs\fpr\www\Load\class.class (Den angivne sti blev ikke fundet)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(Unknown Source)
at sun.applet.AppletClassLoader.getBytes(Unknown Source)
at sun.applet.AppletClassLoader.access$100(Unknown Source)
at sun.applet.AppletClassLoader$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
... 10 more
Exception in thread "Thread-32" java.lang.NullPointerException
at sun.plugin.util.GrayBoxPainter.showLoadingError(Unknown Source)
at sun.plugin.AppletViewer.showAppletException(Unknown Source)
at sun.applet.AppletPanel.runLoader(Unknown Source)
at sun.applet.AppletPanel.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
---------------------------------------------------
Kildekoden til demo-programmet (Load.java);
--------------------------------------------
import java.awt.*;
import java.applet.*;
import javax.swing.*;
import java.io.*;
public class Load extends Applet{
private static final long serialVersionUID = -3992323008401405904L;
private JLabel info_string;
public void init()
{
setLayout(new FlowLayout());
File drives[] = File.listRoots();
info_string = new JLabel();
if(drives.length == 0)
info_string.setText("Drev kunne ikke findes!");
else
info_string.setText("Drev blev fundet!");
info_string.setBorder(BorderFactory.createEmptyBorder(10,10,10,10));
add(info_string);
}
}
--------------------------------------------
Jeg ved der er oprettet 100vis af postet ang. disse applets; som jeg også har læst, og prøvet foreslagene - dog uden held.
Jeg har bøvlet med det her i laaang tid - så jeg ville virkelig blive glad, hvis nogle kunne hjælpe :-)
mvh
Niklas