How to control network access of applications by java? - java

At the moment I am using LittleSnitch, but I was interested in how to create an app in java that controls internet access in runtime or restricts, allows to the specific application at all. And monitor all network connections like in WireShark.
When I googled I could found almost nothing suitable. I doubt that there is any ready project or open source one. So I am very curious about this.
What library should I use? Or do I need to use some JNI libraries to create this kind of application in java?

Related

External plugin framework to my JAVA application

I built a large JAVA web application using SPRING & MongoDB,
In some scenarios, I want to allow my users to upload their own code, and the application will run it later on when necessary.
I called this operation "Plugin framework", the plugin is the user's code of course which I prefer to be in NodeJS for now.
There is any recommended / known architecture for that purpose?
I've read about pf4j and senecajs, but they quite different from my needs.
Thanks!
You loose complete control over code running on node. The uploaded code can access network, files, database, you name it. That is not a good plan.
I suggest to work with the embedded JS module in Java, called rhino. Here, you define which environment the code can access.
You find samples of using the scripting in Java here http://docs.oracle.com/javase/7/docs/technotes/guides/scripting/programmer_guide/index.html for jdk7, the Javadocs https://docs.oracle.com/javase/8/docs/api/javax/script/ScriptEngine.html and here some info on Java8 changes http://www.oracle.com/technetwork/articles/java/jf14-nashorn-2126515.html
UPDATE:
On the comment below, you state that you think you are safe, if the code runs on the other server. Actually, the problem is still the same. Just it won't hit your application's server but the JS code server.
My advice stands. Implement a JS execution service using the built-in Javascript engine (Rhino or Nashorn) and restrict the running JS to a sandbox, you control the script's reach out of the box through carefully implemented env-access methods. It is actually pretty easy to get started, no more complicated than implementing a remote javascript implementation engine on top of node...

Sending data using system calls in Java (Flex project)

I am constructing an application using flex. I want to be able to send data from one device (a tablet) to another (mobile phone) and vice-versa.I haven't found a way to do this using flex and heard that maybe using system calls might allow me to do this. I don't think there is a way to make system calls in flex, but I know that I can in Java.
Does anyone know how I can accomplish this? Sending the data? Using system calls or any other method?
And will I be able to combine the Java code into my flex project?
To invoke Java from Flex, you will have to create an Adobe Native Extension.
A nice tuto is available here
Could you provide more details about what you want to achieve? Sharing data between devices is really vague and could be achieved with very different solutions depending on the context.

Debugging Java application in Eclipse using transport=dt_shmem

Is there a way to use Eclipse to connect to a Java application started in debug mode with transport=dt_shmem?
I'm on Windows, the application is local, and everything works perfectly when using transport=dt_socket. Just out of curiosity I was wondering if I could also use dt_shmem, but I can't find anything related to that when creating a new remote application in Eclipse.
I found examples for jdb, but nothing Eclipse related.
See eclipse bug on it:
Currently have no plans to implement shared memory transport.
And
Currently, we do not have the resources to implement shared memory
transport. Contributions welcome.
However, I guess the only difference would be speed. Like said in here, shared memory is faster, but socket protocol can be used across computers.
It does not look like it. If you look at the debug launch configurations for remote debugging it gives you only choices related to using a socket. And the help only refers to that as well.

Best way of making win OS calls from browser app

We have some code that must access low level windows XP os calls which do some simple manufacturing machine controls. These are not real time functions- just setup/config type operations.
All the rest of our system is cloud hosted, and is written in ruby on rails. I want to minimize the amount of windows code we have to write, and keep as much of the code running as a browser app. I also want to as much as possibly deploy the code from the rails server, with as little config or specialized setup of the PC's as possible.
I am looking for recommendations to somehow interface browser based html/javascript code to those low level calls, that minimizes the work we have to outside our normal rails framework, and is also fairly simple to set up / learn / etc.
What I would like is to keep everything as a normal web application, that some how can make a call out to some PC code.
These bits of PC code are intended to run on a very limited number of installations on PCs that we have full control of security etc in factory floors.
One way perhaps is to make a small java applet (which can be written in Ruby), but I don't know if you can then communicate between the java applet and javascript?
Another way is to do something with silverlight that just provides a basic interface, again I don't know if silver light allows any kind of communication from the HTML/javascript to the silverlight code.
Another way perhaps is to do something as a firefox plugin not sure at all if this would work...
Another way (I think) is create a .net app that contains a browser control. Then the .net app might be able to load the browser window from our rails server, etc.
What would be really nice, would be if there was some way to simply add a new javascript functions that would handle this low level stuff...
Look forward to your input!
As I interpret your requirements and please correct me if I am wrong, you're looking for a way to modify configuration on a number of factory floor PCs running Windows XP--that manage various manufacturing processes--from a web browser running on an administrator's computer.
If this is correct, you'd need to run a web server on each controller to process HTTP requests, and of course there are lots of options you can choose from, but I'm not sure this is the best path.
If I needed to solve this problem, I'd create a Windows "service" that would monitor a configuration file for changes and reconfigure the controller when they occurred.
Using this approach, you could use SCP or SFTP to copy the config file up to the controller(s) and let them reconfigure themselves. This would be more secure and far more lightweight than a web server.
For information on writing windows services in Ruby, see Running a Ruby Program as a Windows Service?

Options for Client Server Communication in Android

I'm currently in the research phase of my dissertation project.
My project is a ticket booking system for a mobile device and I have chosen to target Android.
I anticipate the need for a client/server architecture with a central server, and so am currently looking at how Android could communicate with such a server. The server would grant the client access to ticketing information, and the client would send information about ticket bookings to the server. I'm looking at Java EE for the server as Java is the language I'm most experienced with.
I'm aware that Android comes with java.nio and java.net, as well as some org.apache packages, but am also looking for libraries/technologies that would be possible to use with Android.
So far I've not found anything massively helpful on the internet, so I'm seeing what SO can suggest.
Specifically I am interested in knowing:
What support is there for various middleware technologies in Android? e.g.
RPC based middleware
CORBA
Message based middleware
Web services such as XML-RPC, SOAP, REST
How well (or not) do existing Java libraries work when used on the Android platform? (e.g. If I wanted to use a library/API designed for Java SE rather than Android what problems might I encounter?)
Ideally, as the focus of my project isn't meant to be the communication between the server and client, I could use an existing middleware to handle the communication, but I am prepared for the worst case, which is having to write my own.
What support is there for various
middleware technologies in Android?
My personal opinion -- though I do not feel I am alone in thinking this way -- is that only protocols specifically designed to run over the Internet are remotely suitable for use with a mobile client. So, of your list, the only one that I would even entertain would be:
Web services such as XML-RPC, SOAP, REST
Some people have been maintaining an Android port of kSOAP2. However, I get the distinct impression that most Android developers working in this area have tended towards REST and REST-ish protocols. If nothing else, that's what all the fun Web sites and services are using for an API, particularly compared with XML-RPC (old) and SOAP (old and icky).
I have successfully used both the java.net.URLConnection and Apache HTTPClient libraries in Android for communicating with REST-style endpoints -- both directly and through third-party JARs -- with no real Android-specific issues.
How well (or not) do existing Java
libraries work when used on the
Android platform?
It is difficult to answer that in the abstract. Android implements a substantial subset of JavaSE, but not all of JavaSE, so there's a chance that any given JAR will expect something Android does not offer. Similarly, Android does not use environment variables, command-line switches, or a variety of other things that developers focused on the desktop might have introduced as semi-requirements. So, some things have worked for me with nothing more than a recompile (Beanshell), and some things have worked for me after removing redundant classs (JTwitter), and some things looked like they were going to be ghastly to get working (JavaMail).

Categories