I converted a local application to a Java applet for data security1 but I cannot figure out how to output information to a file. I am inputting files by a URL object but do not know how to output data to a file on the server.
secure in that the person running the program in supervised conditions cannot keep it and run it for someone else (it is a survey I am piloting).
Is there an easy way to do this?
Applets run on the client, not on the server, so an applet can't do this, period. What it can do is send data to a service of some kind on your server, which can then turn around and write the data to a file.
Related
I have have a BIG problem in the past few days. I'm developing an application for a customer and I have an external database in the web. In the program there are a login and some modules. At the time I store the data for access to the DB hardcoded in the Java code. Of course this is not a way to store those data.
Then I was searching so much to find out a way to connect to the database.
Store the password in a properties (.xml) file on the PC
Encrypt the password
etc.
But all of this is not really secure. Then I found something good. "Three-Tier Application Server" sounds really good and a possible way that I don't have to save the data on the PC. But I read everytime how a Three-Tier server works, but nowhere how to develop something like this in java. And is there a possibility that a hacker write an application that connects to this server too and get all of the data, because he decompile the application and get the access data?
Thanks for help
There are indeed many ways you can go about this.
The best way is to have the authentication checks spread throughout your code to where it would be very hard to remove them.
Have the authentication with SHA256/512 and or MD5 and have the user send a login request to the server.
Only authenticate the user if the server responds that it is registered.
Do not store any information other than the users info on the client end.
All the checks should be made and validated on the server side.
You also most definitely want to obfuscate your client sided code as well.
I have a program that I've created that is meant to poll an html internal page with different IPs that update and then will run a telnet session to those IPs to see if the device still has a connection... I'm attempting to challenge myself in creating something further with a dynamic webpage instead of my program spitting out console output...
My Issue:
I dont know what technologies / libraries Java has to execute such things
I want:
A Local Server, to upload a page LOCALLY only (no security is needed as this will be strictly intranet)
My program to implement: A database of sorts to save "logs" essentially that a certain IP / device has had successful connections
in the past....maybe stored to an external file is fine i presume (my
program currently has to re-poll everytime i run it.. i want some kind
of "remembering"..
Is it possible this can all be done in one file? so if i want my computer to run this as soon as it starts up... it will run... grab
its current state of the database of IPs... poll them (periodically)
and then persist and save and update the HTML page dynamically....
I hope i'm being as descriptive as possible... Its a bit of an abstract.. I really just want some introduction to different libraries ... a friend recommended stuff like MongoDB or something but I want to stay strictly to Java programming
I explain, I tried to open my database .sqlite contained in my server in Java with jdbc:sqlite:mydb, but it doesn't work because my database ".sqlite" is distant so i creat a script php based on my server which gets back me all of my databases.
So my question How can i Get back source data of data contained in a script PHP with Java?
Thanks a lot!
PS : Sorry for my english (I'm french)
One way would be to create a service in PHP which offers the data, so that your Java application can consume it.
E.g. PHP can expose the data in an XML or JSON format, for instance over HTTP. Your Java application would then call the HTTP URL and receive the data in JSON/XML/whatever, and then parse it to extract the data from that format.
There are other ways as well, e.g. a service bus could broker the data between the different systems, but that requires much more setup (though in the long run, it does have value, if you keep adding data that you want to expose to more and more systems).
You can create PHP WebService server and write some functions to operate that databases data for fixing your problems. Then just use Java to connect with soap to your created WebService functions.
How to start webservice, try to read this one:
http://greatgandhi.wordpress.com/2009/11/25/create-a-php-webservice-in-5min-using-php-soap-and-wsdl-technology-nusoap/
Its the best way i know, if you need to send some data back to your remote db. Its a little more complicated, but much more correct way to operate remote data.
I have a java application that will take the image as an input and output another image. I have a website with a popular host (PHP+MYSQL Hosting). I want to create a page on the website with PHP with a form where a user can upload an image which will then pass the image onto the Java application.
What I am planning on doing is when then user uploads the image, it gets stored in a folder on the web server. I will then call the java app on the server passing the url of the image as an argument and then the java app will output another image, let’s say, to a result folder. The PHP page after the execution will then display the result image on the browser.
Now my questions are:
Is it possible to execute java apps on popular webhosts (for example mine is WebHostingBuzz.com)?
The java app is fairly heavy as it does a lot of image processing. Should I offload the java app to another web server? If yes, are there any services that will run my java app?
(Optional) It’s a demo of my java app and I don’t want to store the images people upload. Is there a way where I can directly pass the uploaded image to the java app and output the image generated directly instead of storing it on the web server? I would prefer this because, if the image is big, I can make PHP stop the execution after a timeout.
How do I communicate with the java app from PHP for info on its execution, for example When PHP calls the java app, the page has to wait till the app finishes processing? I want the java app to send a response to the PHP page saying that the processing is completed and the page is redirected or refreshed accordingly.
I hope you get the idea, please suggest the technologies that I can use to implement this and also if you have a better idea, post it!
Thanks!
Now my questions are: Is it possible to execute java apps on popular webhosts (for example mine is WebHostingBuzz.com)?
It's technically possible. But the hosting has to install JRE at the host and give the PHP user sufficient OS-level and filesystem-level permissions. So you're really dependent on the hosting whether they provide this opportunity. Best is to just contact their support team and ask it.
If it is supported, you could just use shell_exec().
$result = shell_exec("java -jar /path/to/imageprocessor.jar " + $imagepath);
if ($result) {
// Shell execution succeed.
} else {
// Shell execution failed.
}
For asynchronous communication / background processing, the client has to fire an ajaxical request.
If it is not supported, consider porting Java to PHP. The GD image library has pretty a lot of functions which may be of use.
Google App Engine allows to host Java (and Python) web applications. The SDK and the basic account is free of charges. With the SDK, you could develop and test the application locally and then simply deploy to App Engine (NetBeans and Eclipse plugins are available).
Then the PHP app could send the data in a HTTP POST to the Google App Engine application and get the result in the response data.
Or the data is stored first in a database blob and a processing job is put in a task queue (a 'message queue'). This has the advantage that the PHP client request will return immediately after the data has been POSTed. Then, the PHP application could poll for the result data while Google App Engine processes the image. The PHP side would be more responsive this way.
Wouldn't it be easier to make your java app a web app, that PHP could call via an url in wich he would put the url of the image so java can download it?
like http://yourjavaserver/imageprocessing?imgurl=IMAGE_URL
and the java servlet would reply with the image file itlsef.
You can look for "java hosting" on google, to find a host for this, but it's more expensive than PHP hosting. Maybe the best choice would be to get a dedicated server which could host both PHP and java applications...
I think your best bet here is with your java app running as cron(or a deamon) that can load the file details from the database. This will require a (one or more) page-refresh on the users part after the generation is complete, at which point your script can recall the image from the database/filesystem.
I do not think you will be able to do this in real-time due to timeout restrictions on the PHP webpage. However, you could write a java applet that can take the file and process it before sending it to the server (or depending on how you intend to use it, perhaps you do not need to upload it after the transformation?).
I have a small linux vps. I have written a Java client application, which needs to connect and submit large string data and images. The string data will be stored as regular text files on the server, and will be parsed by another Java application that will run on the server and use this uploaded files and images.
The next part of the problem is, because this Java client will be run by several users, I need some way to uniquely identify each uploaded file to the currently logged in user session on the website (the user needs to login on the website, to be able to run the tasks). Any suggestions or more efficient patterns ?
Don't write the stuff to files. Punch the uploaded data into 'raw' database tables by user ID. The batch job job can pull the data out, parse/format/fold/spindle/mutilate, and stuff the results into the real tables, then delete the raw data.