Applets, Security, Sockets General Question

Discussion in 'Java' started by Stefan Willmert, Jun 5, 2004.

  1. 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
    Stefan Willmert, Jun 5, 2004
    #1
    1. Advertising

  2. Stefan Willmert

    Danny Woods Guest

    "Stefan Willmert" <> writes:

    > 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.
    Danny Woods, Jun 5, 2004
    #2
    1. Advertising

  3. Stefan Willmert

    Roedy Green Guest

    On Sat, 5 Jun 2004 12:51:56 -0500, "Stefan Willmert"
    <> wrote or quoted :

    >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


    --
    Canadian Mind Products, Roedy Green.
    Coaching, problem solving, economical contract programming.
    See http://mindprod.com/jgloss/jgloss.html for The Java Glossary.
    Roedy Green, Jun 5, 2004
    #3
  4. 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
    Stefan Willmert, Jun 5, 2004
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. roy anderson

    General Security Question

    roy anderson, Dec 20, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    350
    Daniel TIZON
    Dec 20, 2005
  2. Andre M. Maier
    Replies:
    0
    Views:
    475
    Andre M. Maier
    Dec 3, 2003
  3. Lasse Hassing

    Sockets with unsigned applets

    Lasse Hassing, Jan 26, 2004, in forum: Java
    Replies:
    2
    Views:
    327
    Andrew Thompson
    Jan 26, 2004
  4. Richard Maher
    Replies:
    10
    Views:
    525
    Richard Maher
    Dec 3, 2006
  5. Dave Dean
    Replies:
    2
    Views:
    265
    Steve Holden
    May 7, 2007
Loading...

Share This Page