Applets, Security, Sockets General Question

  • Thread starter Stefan Willmert
  • Start date
S

Stefan Willmert

Hey everyone,
I'm fairly new to Java, (although i have experience with just about every
other language), so i have a couple questions before i dig too deep into a
possible java solution.

Here's the skinny:
I have an embedded internet enabled device which runs a webserver and
various socket servers for communcations. From the embedded webserver, I
would like to serve a page containing a fairly sophisticated java applet.
The key to this applet being useful however, is the ability to exchange data
with the embedded device (either via http or socket connections) during the
use of the applet.

Now: a few key points that makes me question the possibility:
1. The user may be accessing the embedded webserver (and java applet)
either from a local network or over the internet. (i could possibly live
without access to the java applet from an internet address, but it must be
available from a local network)
2. The java applet will not know until run time, the IP address, socket
port, or hostname of the embedded device, therefore, all connection
parameters MUST be dynamic.
3. The applet will need to request data from the embedded device, which
the user can then modify, and upload back to the embedded device. Basically,
lets just assume the applet is requesting configuration data, modifying the
configuration in the applet, then uploaded the new settings back to the
embedded device. (a graphical UI is needed here to provide a reasonably
simple interface)

So...is this possible using java applets? Any suggestions on the
requirements for completing this? Do i need to sign the applet? But how do i
sign it without knowing the embedded device (server) connection parameters
until run time? I'm just looking for general ideas here on whether java is
the right choice for this project, and possibly some tips and what parts of
java i will need to research to accomplish this.

My other option that i've considered, is a small windows application that
can be included on the embedded device for download on the user's machine.
That would allow the user to then communicate in any capacity with the
device. But I thought it may be a bit nicer if everything is automatically
included and available from a web browser rather than forcing the user to
install an application.

Thanks in advance for all your help

-stefan
 
D

Danny Woods

Stefan Willmert said:
Hey everyone,
I'm fairly new to Java, (although i have experience with just about every
other language)

Cripes. That's a lot of languages...
Now: a few key points that makes me question the possibility:
1. The user may be accessing the embedded webserver (and java applet)
either from a local network or over the internet. (i could possibly live
without access to the java applet from an internet address, but it must be
available from a local network)

Java applets can communicate with the machine from which they were
served using simple sockets. Depending on your usage, the URLConnection
class in java.net may be able to offer a slightly higher-level interface.
The applet can connect to any port on the machine that's visible from
where it wakes up. The only issue I can think of with sockets is if the
applet finds itself behind an opaque proxy upon initialisation (one that
insists that all communication goes through it, such as many coporate
setups)
2. The java applet will not know until run time, the IP address, socket
port, or hostname of the embedded device, therefore, all connection
parameters MUST be dynamic.

Applets provide the getCodeBase method that provides it with a means to
locate its source: there's no need to set IP addresses or the like
beforehand.
3. The applet will need to request data from the embedded device, which
the user can then modify, and upload back to the embedded device. Basically,
lets just assume the applet is requesting configuration data, modifying the
configuration in the applet, then uploaded the new settings back to the
embedded device. (a graphical UI is needed here to provide a reasonably
simple interface)

I'm not 100% certain of what protocol support is built-in with Java,
but you're certainly free to roll your own over sockets.
So...is this possible using java applets?
Yes.

Any suggestions on the requirements for completing this?

Depending on your target audience, you may need to limit yourself
to Java 1.1 code. Microsoft's Java never got beyond 1.1.5, and is
still unfortunately the most common browser JVM out there. This
isn't a problem if you know that your users have the Java2 plugin.
Do i need to sign the applet?

Not unless it needs to access files on the local machine or
communicate with machines other than the device that served it.
But how do i sign it without knowing the embedded device (server)
connection parameters until run time?

As I mentioned above, the applet has means to query its environment
when it wakes up that save you from this. Check the API docs.

Have fun,

Danny.
 
R

Roedy Green

Hey everyone,
I'm fairly new to Java, (although i have experience with just about every
other language), so i have a couple questions before i dig too deep into a
possible java solution.

Here's the skinny:
I have an embedded internet enabled device which runs a webserver and
various socket servers for communcations. From the embedded webserver, I
would like to serve a page containing a fairly sophisticated java applet.
The key to this applet being useful however, is the ability to exchange data
with the embedded device (either via http or socket connections) during the
use of the applet.

Now: a few key points that makes me question the possibility:
1. The user may be accessing the embedded webserver (and java applet)
either from a local network or over the internet. (i could possibly live
without access to the java applet from an internet address, but it must be
available from a local network)

Applets live inside browsers. I presume you have a browser capable of
requesting a web page in which is embedded the Java Applet.

2. The java applet will not know until run time, the IP address, socket
port, or hostname of the embedded device, therefore, all connection
parameters MUST be dynamic.
This is normal. A garden variety Applet in unaware of this.
Additional info, you can embed as PARAM's in the serving page.

3. The applet will need to request data from the embedded device, which
the user can then modify, and upload back to the embedded device. Basically,
lets just assume the applet is requesting configuration data, modifying the
configuration in the applet, then uploaded the new settings back to the
embedded device. (a graphical UI is needed here to provide a reasonably
simple interface)

It could do get/puts, or set up a socket connection. See
http://mindprod.com/fileio.html for how. The only catch is an
UNsigned Applet can only talk to the server from which it was loaded.
So...is this possible using java applets? Any suggestions on the
requirements for completing this? Do i need to sign the applet? But how do i
sign it without knowing the embedded device (server) connection parameters
until run time?

To get a file from the server using an Applet you can use code like
this:

url = new URL( getDocumentBase(), urlString + ".ser" );

URLConnection urlc = (URLConnection)url.openConnection();
urlc.setAllowUserInteraction( false );
urlc.setDoInput( true );
urlc.setDoOutput( false );
urlc.setUseCaches( false );
urlc.connect();
InputStream is = urlc.getInputStream();

again http://mindprod.com/fileio.html will show you how.

I'm just looking for general ideas here on whether java is
the right choice for this project, and possibly some tips and what parts of
java i will need to research to accomplish this.

My other option that i've considered, is a small windows application that
can be included on the embedded device for download on the user's machine.
That would allow the user to then communicate in any capacity with the
device. But I thought it may be a bit nicer if everything is automatically
included and available from a web browser rather than forcing the user to
install an application.

The Java equivalent to that Is Java Web Start which has several
advantages:

1. download caching
2. no browser needed.
3. no browser hogging RAM.
4. autoupdates.

see http://mindprod.com/jgloss/javawebstart.html
 
S

Stefan Willmert

Thanks guys. Knowing that its possible to get the level of communication i
want, its time to start digging in and do some research. Thanks for all the
suggestions.

-stefan
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top