Archived

This forum has been archived. Please start a new discussion on GitHub.

How to set the path of client.jks,certs.jks and server.jks in applet

I am sorry to not show my question clearly in title beacause of limited words. I use glacier and storm to implement moitor system. Client uses applet to subscribe the topics. All the raleted resources are put into a jar inclues classes, client.jks, certs.jks and server.jks. This jar and the Ice.jar are downloaded to client to run the subscriber . But the next Exception has confused me several days.

subscriber: Ice.PluginInitializationException
reason = "IceSSL: unable to load keystore from `/client.jks'"
Ice.PluginInitializationException
reason = "IceSSL: unable to load keystore from `/client.jks'"
at IceSSL.Context.<init>(Context.java:116)
at IceSSL.Instance.createContext(Instance.java:131)
at IceSSL.Instance.<init>(Instance.java:46)
at IceSSL.PluginI.<init>(PluginI.java:17)
at IceSSL.PluginFactory.create(PluginFactory.java:23)
at Ice.PluginManagerI.loadPlugin(PluginManagerI.java:187)
at Ice.PluginManagerI.loadPlugins(PluginManagerI.java:130)
at IceInternal.Instance.finishSetup(Instance.java:497)
at Ice.CommunicatorI.finishSetup(CommunicatorI.java:183)
at Ice.Util.initializeWithPropertiesAndLogger(Util.java:113)
at com.thtf.ezone.ezibs.jpc.iceapp.Subscriber.run(Subscriber.java:224)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.FileNotFoundException: \client.jks
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at IceSSL.Context.<init>(Context.java:110)
... 11 more



Firstly
The main code in AlarmApplet.java
package com.thtf.ezone.ezibs.jpc.rmiaccess;

public class AlarmApplet extends Applet {

private Subscriber subs;

public void init() {
try {
System.out.println("init the alarm applet");
}
public void start() {
try {
subs = new Subscriber();
Thread sub = new Thread(subs);
sub.start();
} catch (Exception e) {
System.out.println(e.getMessage());
}

}

Secondly
The main code in Subscriber.java


public class Subscriber implements Runnable{
public int run(String[] args) {
Ice.RouterPrx defaultRouter = communicator().getDefaultRouter();

Glacier2.RouterPrx router = Glacier2.RouterPrxHelper
.checkedCast(defaultRouter);

while (true) {

try {
router.createSession(id, pw);
break;
} catch (Glacier2.PermissionDeniedException ex) {...}
catch (Glacier2.CannotCreateSessionException ex) {...}
} catch (Exception ex) {...}
}
...
...
}
private static Communicator communicator(){
return _communicator;
}
private static Communicator _communicator;
public void run() {

try {
StringSeqHolder argHolder = new StringSeqHolder(new String[0]);

Properties properties = Util.createProperties();
properties.setProperty("Clock.Subscriber.Endpoints","tcp");
properties.setProperty("Ice.Default.Router","DemoGlacier2/router:ssl -p 80 -h 192.168.0.6");
properties.setProperty("IceStorm.TopicManager.Proxy","DemoIceStorm/TopicManager:default -p 10000 -h 192.168.0.6");
properties.setProperty("IceStorm.TopicManager.Endpoints","default -p 10000");
...
properties.setProperty("IceSSL.Client.Keystore","/client.jks");
properties.setProperty("IceSSL.Client.Certs","/certs.jks");
properties.setProperty("IceSSL.Server.Keystore","/server.jks");
properties.setProperty("IceSSL.Server.Certs","/certs.jks");
_communicator = Util.initializeWithPropertiesAndLogger(
argHolder, properties, null);

this.run(new String[0]);
} catch (LocalException ex) {...}
catch (java.lang.Exception ex) {...}

}
}

Thirdly
In jsp file
<applet
codebase = "<%=Root%>"
code = "com.jpc.rmiaccess.AlarmApplet.class"
archive = "app.jar,Ice.jar"
name = "alarmApplet"
width = "0"
height = "0"
>
</applet>

Finally
I put client.jks, certs.jks and server.jks into app.jar and at the root directory. Three files is side by side the "com" directory.


Thank you to read my question.

Comments

  • benoit
    benoit Rennes, France
    Hi,

    These errors indicate that IceSSL can't open the keystore files because they are not found on the filesystem where your applet is running. IceSSL only supports reading the keystore files from the filesystem, it can't look for them in Jar files. If you have a commercial interest for this feature, we could look into adding support for it. If that's the case please contact us at info@zeroc.com.

    Cheers,
    Benoit.
  • Thank you very much for your rapid reply! But I regret to recieve the message to block the way to use applet to accross firewall with glacier. I have done a lof of work with application programe not applet and been succeed. :mad:
  • I have succeeded.

    I hava change the FileInputStream to the URL InputStream in Ice.Context.java. Then I set those paths like "http://localhost:8080/test/app/(client.jks,certs.jks , server.jks )". Finally I put client.jks,certs.jks , server.jks in correct paths whick are same to setted properties.