Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Java > Problems with applet for displaying desktop app's output

Reply
Thread Tools

Problems with applet for displaying desktop app's output

 
 
Paul
Guest
Posts: n/a
 
      08-15-2009
All,

I inherited a desktop C++ (VC6) application that uses the user's web
browser for output. When the system first wants to display output it
writes a temporary html file, fires up the web browser with an html
page with an applet that opens a socket that listens for messages on a
particular port. The C++ app then sends the temp file name through the
socket for the applet to display. When new output comes along the new
file name gets sent through the socket and the applet updates the web
page (so all of this work is just so that you don't get a new web page
for each output). It uses a similar mechanism to display help (sending
the relevant section number through the socket). The relevant Java
looks something like this:
m_serverSocket = new ServerSocket(m_theApp.m_port);
and then later
clientSocket = m_serverSocket.accept();
Recently the java people decided that connecting to localhost is a
security risk (see http://sunsolve.sun.com/search/docum...1-66-246387-1),
so that this accept() now throws a security exception. I'm trying to
fix this but I'm not getting anywhere. Here are the things I've tried
and decided doesn't work (feel free to point out mistakes or
misunderstandings on my side, I'm a noob at java):
1) I changed the C:\Program Files\Java\jre6\lib\security\java.policy
file to add "accpet" for localhost:
permission java.net.SocketPermission "localhost:1024-",
"listen,accept";
this works, but I can't use this because a) it isn't safe, b) we
don't want users to have to change their java.policy files and
obviously the installer can't do it
for them.
2) I don't want to sign the applet because this will be really
confusing to users (why should they be asked to trust anything from a
desktop app that doesn't even do
anything over the net?)
3) I've tried passing a command line parameter to the applet in order
for it to use an "application" specific policy file, but it seems that
an applet can't take
the -Djava.security.policy command line parameter.
4) I've read that unsigned applets can (only) open sockets back to the
server from which it was loaded, but I'm not using a web server so
there is no server URL (and
localhost doesn't work).

I'm out of ideas but would love to hear some!

Paul
 
Reply With Quote
 
 
 
 
John B. Matthews
Guest
Posts: n/a
 
      08-15-2009
In article
<(E-Mail Removed)>,
Paul <(E-Mail Removed)> wrote:
[...]
> http://sunsolve.sun.com/search/docum...=1-66-246387-1

[...]
> 1) I changed the C:\Program Files\Java\jre6\lib\security\java.policy
> file to add "accpet" for localhost: permission
> java.net.SocketPermission "localhost:1024-", "listen,accept"; this
> works, but I can't use this because a) it isn't safe, b) we don't
> want users to have to change their java.policy files and obviously
> the installer can't do it for them.
> 2) I don't want to sign the applet because this will be really
> confusing to users (why should they be asked to trust anything from a
> desktop app that doesn't even do anything over the net?)


I think you should consider signing the applet. Even though it's from
localhost, the applet is accepting an incoming network connection. The
user is being offered a chance to verify that the applet is the one
expected. They only have to accept it once, and you can invite them to
verify your certificate's fingerprint in whatever way makes sense for
your users. Seeing the warning a second time means the applet may have
been tampered with locally, which is exactly what the security patch is
trying to prevent.

> 3) I've tried passing a command line parameter to the applet in order
> for it to use an "application" specific policy file, but it seems
> that an applet can't take the -Djava.security.policy command line
> parameter.
> 4) I've read that unsigned applets can (only) open sockets back to
> the server from which it was loaded, but I'm not using a web server
> so there is no server URL (and localhost doesn't work).


--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>
 
Reply With Quote
 
 
 
 
Roedy Green
Guest
Posts: n/a
 
      08-15-2009
On Sat, 15 Aug 2009 04:30:30 -0700 (PDT), Paul <(E-Mail Removed)>
wrote, quoted or indirectly quoted someone who said :

>4) I've read that unsigned applets can (only) open sockets back to the
>server from which it was loaded, but I'm not using a web server so
>there is no server URL (and
> localhost doesn't work).


to get around that, you must sign your Applet. See
http://mindprod.com/jgloss/signedapplets.html

The whole process sounds somewhat convoluted and difficult to
maintain. A simplifying revamp of the whole approach might be better
in the long run e.g.

1. display raw data using an Applet or Java Web Start application.
2. set up a little local webserver that builds the pages.
3. port the C++ code to Java

--
Roedy Green Canadian Mind Products
http://mindprod.com

"If you think it’s expensive to hire a professional to do the job, wait until you hire an amateur."
~ Red Adair (born: 1915-06-18 died: 2004-08-07 at age: 89)
 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      08-15-2009
Roedy Green wrote:

> 3. port the C++ code to Java
>


I was going to suggest the opposite. There must be a C++/VC object that
displays HTML. I think getting rid of the clunky browser-applet thing
and just displaying a window directly would simplify things greatly for
the programmer and the user.

 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      08-15-2009
markspace wrote:
> Roedy Green wrote:
>> 3. port the C++ code to Java

>
> I was going to suggest the opposite. There must be a C++/VC object that
> displays HTML.


There is.

But COM programming in C++ is about 100 times more difficult than
doing stuff in Java.

Arne

 
Reply With Quote
 
markspace
Guest
Posts: n/a
 
      08-15-2009
Arne Vajhøj wrote:
> markspace wrote:
>> Roedy Green wrote:
>>> 3. port the C++ code to Java

>>
>> I was going to suggest the opposite. There must be a C++/VC object
>> that displays HTML.

>
> There is.
>
> But COM programming in C++ is about 100 times more difficult than
> doing stuff in Java.



I was thinking something that works like a JEditorPane. Not a COM
object, just an ordinary object that will take a string or buffer full
of HTML, and does basic rendering on it. I think Windows has a help
system with such an object, not 100% sure however.
 
Reply With Quote
 
Richard Maher
Guest
Posts: n/a
 
      08-15-2009
Hi Paul,

"Paul" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
8<
> 4) I've read that unsigned applets can (only) open sockets back to the
> server from which it was loaded, but I'm not using a web server so
> there is no server URL (and
> localhost doesn't work).


Not knowing what your application is doing, or why, I would suggest the
server (C++ or whatever) do the listening on whatever port number you like
and have the Applet connect back to it and request(read) the updates as they
arrive. If you only have a small number of users and don't want to write a
multi-threaded server then you might want to investigate using INETd.

Regards Richard Maher


 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      08-16-2009
On Aug 15, 6:55*pm, "Richard Maher" <(E-Mail Removed)>
wrote:
> Hi Paul,
>
> "Paul" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
> 8<
>
> > 4) I've read that unsigned applets can (only) open sockets back to the
> > server from which it was loaded, but I'm not using a web server so
> > there is no server URL (and
> > * *localhost doesn't work).

>
> Not knowing what your application is doing, or why, I would suggest the
> server (C++ or whatever) do the listening on whatever port number you like
> and have the Applet connect back to it and request(read) the updates as they
> arrive. If you only have a small number of users and don't want to write a
> multi-threaded server then you might want to investigate using INETd.
>
> Regards Richard Maher



But isn't this still the applet opening a socket to localhost? Or does
it matter whether it is the Applet or the C++ app that is accepting
the connection?

Thanks for the help!

Paul
 
Reply With Quote
 
Arne Vajhøj
Guest
Posts: n/a
 
      08-16-2009
markspace wrote:
> Arne Vajhøj wrote:
>> markspace wrote:
>>> Roedy Green wrote:
>>>> 3. port the C++ code to Java
>>>
>>> I was going to suggest the opposite. There must be a C++/VC object
>>> that displays HTML.

>>
>> There is.
>>
>> But COM programming in C++ is about 100 times more difficult than
>> doing stuff in Java.

>
>
> I was thinking something that works like a JEditorPane. Not a COM
> object, just an ordinary object that will take a string or buffer full
> of HTML, and does basic rendering on it. I think Windows has a help
> system with such an object, not 100% sure however.


The low level Windows API is C and does not have an object.

The high level API's in Windows are usually COM based.

This includes the MSHTML stuff:
http://msdn.microsoft.com/en-us/library/bb508516.aspx

Arne
 
Reply With Quote
 
Paul
Guest
Posts: n/a
 
      08-16-2009
On Aug 16, 11:12*am, Paul <(E-Mail Removed)> wrote:
> On Aug 15, 6:55*pm, "Richard Maher" <(E-Mail Removed)>
> wrote:
>
>
>
> > Hi Paul,

>
> > "Paul" <(E-Mail Removed)> wrote in message

>
> >news:(E-Mail Removed)....
> > 8<

>
> > > 4) I've read that unsigned applets can (only) open sockets back to the
> > > server from which it was loaded, but I'm not using a web server so
> > > there is no server URL (and
> > > * *localhost doesn't work).

>
> > Not knowing what your application is doing, or why, I would suggest the
> > server (C++ or whatever) do the listening on whatever port number you like
> > and have the Applet connect back to it and request(read) the updates as they
> > arrive. If you only have a small number of users and don't want to write a
> > multi-threaded server then you might want to investigate using INETd.

>
> > Regards Richard Maher

>
> But isn't this still the applet opening a socket to localhost? Or does
> it matter whether it is the Applet or the C++ app that is accepting
> the connection?
>
> Thanks for the help!
>
> Paul


Tried it, but you just can't connect to localhost from an unsigned
applet. Both "connect" and "accept" throw a security exception.

Paul
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Java on historic (i.e., older than 10 years) Windows versions (was: Displaying a Text upside Down using an applet) Stefan Ram Java 1 02-14-2009 01:37 AM
displaying URL contents via an applet yawnmoth Java 7 08-16-2006 02:48 PM
FreeRIDE is not displaying the output in the output window juhunu@gmail.com Ruby 1 05-23-2006 01:08 PM
Java Applet that is capable of displaying a PDF document within a web-browser sushil Java 3 09-27-2005 02:15 AM
Displaying Retrieved Data on Applet using HttpConnetion farazkazmi@gmail.com Java 3 09-12-2005 12:16 PM



Advertisments