How to access an applet from the java code? - java

We are developing an application which accesses an API exposed over some embedded system. This API internally validates the user to provide the access to the embedded system. To validate the call, it opens a dialog box and asks for username and password. This dialog box is essentially a Java applet opened in applet viewer.
We want to automate this whole process by building small exe or by doing the same in tomcat server. To do the same, we need get the object of the dialog box and fill the credentials. How can we achieve this. There must be some way to automate the testing of applets which can be used to do the above task.
Thanks for helping. It will be great if someone can provide a code snippet or link for the same :)
Reason why I want to have this kind of system:
We need to build an application which gets the memory status of PLC device. This device is connected with heavy machines and has its own programming language via digital networks. To get the memory map, there are APIs exposed in java which communicates with assembly language. We use these APIs to get the memory status of various memory variables from PLC device. On the basis of the memory status we raise an alert by sending an email or SMS. When we try to access the memory area of this device for the very first time, it pops up an authorization dialog box which asks for username and password of PLC device.
Hence, to automate the memory monitoring system which can send the alerts, we have to fill the authorization dialog box through java program or some of the other way. When I access memory of PLC from java console program we need this authorization dialog to be filled by itself without any manual intervention.
So, How can we get an object of this dialog box?
I hope scenario is clear. We don't need any framework to build which can automate the applet UI. We just need for specific dialog box. Please help!!

You can do with with any number of Java GUI functional testing tools. Here's a good list, looks like FEST or Jemmy might be a good approach:
Automated tests for Java Swing GUIs
It looks like they all build on top of java.awt.Robot so you can look at that if you want to roll your own.
If this does not work you may have to go to a native GUI testing framework. Some good options are listed here for Windows:
https://stackoverflow.com/questions/120359/tools-for-automated-gui-testing-on-windows
http://sikuli.org/ pretty good.

Related

UI to control machine access

I've a generic design question. Hope you folks can help me. Our technology stack is Java, Angular, Spring and REST. We wish to implement a reservation system (to reserve machines/servers) so that if one user wishes to ssh to a machine then they first reserve it one our UI and then they only can use it and no-one else can.
Do you guys know a way/technology/design where we could control access to machines this way (possibly something like LDAP) ?. Even something where the user logs into our UI, reserves the box by clicking a Reserve button etc and then clicks a Launch button - which could then launch an actual ssh command window or a remote desktop access session etc. In this way we could set a certain predefined username+password for our boxes (which our application could control) and we can allow users to connect to boxes via our UI.
Wondering if any one you had to do anything similiar to this before or if there is anything obvious I'm missing. Is it easy to "launch" a remote desktop connection or indeed an ssh terminal from java.
I'm fine with the UI part, rest, java etc. It's more the connections / logic to the remote machines that I'd like to get peoples thoughts on.
Sorry if this is too generic. I'd like to get some directions on it.
Any thoughts/guidance would be great.
Thanks - Ro

Launch an application on button click from a web page

In my web application I need to launch a Windows application installed on client machine when a button in the page is clicked.
I know there are security policies in browsers that avoid this by default, but I also know application that do this. An example could be online meeting, web conferencing applications like WebEx or GoToMeeting.
How they do that?
I'm working with Java, so I'm wondering if Java Applets are an option to achieve this.
Is there some other well known way to solve this issue?
NOTE application execution MUST be allowed by user
The best way to deploy a Java desktop application is using Java Web Start.
And forget applets. Soon Chrome won't be able to load them (along with a number of other plug-ins) at all.
you can achieve it with applet. but user must allow to run it. it is hard to run some extern application from button or link because this is potentially danger behaviour. Remember the applet can not get access to the files on user computer and other servers (unless it is digitally signed)

Open blackberry device options programmatically

App details:
I am writing an app that requires the user to have a device password set. The company distributes blackberry devices to its associates who will then use them to report on sales etc. The company wants to make sure that the device password is set so that the confidential information can not be easily accessed by anyone if they steal the phone. The app must not work if the password is not set, which is easy enough.
The problem:
The company wants the a message to come up saying "Please set a device password" and then direct the user to the device to the options menu to show them where to set their device password. Doing this seems troublesome
What I have tried so far:
I have looked into the ApplicationManager object, which allows you to bring an application to the foreground. However when I use the following code to see what applications are available:
ApplicationManager manager = ApplicationManager.getApplicationManager();
ApplicationDescriptor descriptors[] = manager.getVisibleApplications();
for(int i=0;i<descriptors.length;i++)
{
String applicationName= descriptors[i].getName();
System.out.println("applicationName");
}
The only visible applications are stuff like Phone, Messages, Blackberry Messages, Home Screen etc, but the options application is not present, which leads me to believe its not accessable from here. (If I'm wrong please let me know)
I have also taken a look at the Invoke.invokeApplication(appType, args) method, however the API does not have an appType constant for the options, or settings etc. The API specifies only the following types and I cannot find the one I need:
APP_TYPE_ADDRESSBOOK
APP_TYPE_BLUETOOTH_CONFIG
APP_TYPE_CALCULATOR
APP_TYPE_CALENDAR
APP_TYPE_CAMERA
APP_TYPE_MAPS
APP_TYPE_MEMOPAD
APP_TYPE_MESSAGES
APP_TYPE_PHONE
APP_TYPE_SEARCH
APP_TYPE_TASKS
I have scanned the API docs and I cannot find anything that looks right. Ive searched for Device and Options and Settings but none of the hits are relevant.
If anyone knows what to do then let me know.
Unfortunately there's no standard API to invoke this screen programmatically. But there's a workaround. Use EventInjector to inject a sequence of keyboard events to open Options screen.
This way is not an elegant one, but I think it is the only workaround in this case.
UPDATE:
I would implement the following approach. Upon application startup I would check, whether device is password protected via DeviceInfo.isPasswordEnabled().
If device is not password protected I would display message: Device is not password protected. Please set password for your device in the device Options. And launch the application again.
I understand, this way is not elegant, but it is reliable and provides full information to the customers, how to use this application properly.
Ok so as it turns out you can run internal apps using the ApplicationManager, so I launched the Options app using the following code:
ApplicationManager.getApplicationManager().launch("net_rim_bb_options_app");
However this only launches the Options app, and does not navigate the user to the Security section.
The following blurb from this page helped me understand what this method really does:
Starting
A BlackBerry application can be started in a number of ways:
by the system automatically on device startup
by another application
by the system at a scheduled time
Regardless of how an application is started, the Application Manager is responsible for starting the process the application will run within.
The ApplicationManager class enables applications to interact with the Application Manager to perform tasks, including:
run an application immediately or at a scheduled time
interact with processes, including retrieving the IDs for foreground applications
post global events to the system
Entry points
The Application Manager starts an application by getting a new process and spawning a thread within that process to call one of the entry points of the application. For many applications, the main() method of its application class is the single entry point that is called. But you can configure more than one entry point for an application.
Using more than one entry point lets you create different ways for a user to start an application. For example, if your application allows users to create a new document, you might like to provide users with two icons that they can click to start the application. Users could click one icon to open the application to its home screen and the other icon to open the application to the screen required to create a new document.
Summary
So basically this method just runs the main method of the app, and supplies the arguments in the main method. It is my suspicion that the main method of the Options app does not allow for you to supply the page you want to open up on as an argument in the main method.
There is no documentation (as far as I can tell) on what arguments the options app takes, so short of guessing how it can be used, it seems that directing the user here and giving them some instructions on how to navigate further is my only option
u_u

Authenticating from PHP to Java and retrieve data via WSDL

Ok, so I inherited a project where our core program is built by another company (built in Java) and I have to build another program around it. Problem is that the Java program has to stay as is and I am only allowed to authenticate through to it and pull the findings once users go through there. I am not even sure what to ask for cause I've never cross authenticated before nor used a WSDL etc...
I am an intermediate/advanced PHP coder and would have rather built the entire thing from the ground up (it would be faster and customizable) but, i can't. this java application needs to stand on its own--maybe in an iFrame--and once our users sign into our site, they need to automatically signed in there so when they click on it from the panel, they perform their actions which mark them complete there. We read their completion and mark them complete on our side (via PHP). Their develops have a WSDL file that supposedly we pass the information and we can read their completion and status stuff. No idea how to use it.
The dev environment is IIS 7 (im more used to linux and unix environments)
Any idea where I should start? How to do this? What questions I should ask their developer for so I can develop the PHP side of things?

Java Applet Printing dialog won't go away

I have a simple java applet that retrieves an image from a server and prints it out. The only problem is that I get the following java security warning:
Researching on this site and all over the web, some people suggest that I sign the applet (I tried that to no avail) and others suggest that I Modify a local java security setting but that isn't feasible for my clients.
Not only do I get this warning at the start of my applet, but seemingly any time the code attempts to interact with the printer, the dialog re-appears. Also, note that there is no checkbox next to 'Always allow this applet to access the printer'. These symptoms show on any browser.
How do I get java to respect the users choice to allow it to send jobs to the printer?
You might use the JNLP API services in a sand-boxed applet in a plug-in 2 JRE. They will still prompt the user each first time they go to print, but should also put an 'always allow' check-box on the dialog (though it really only applies for that run). See a demo. of the PrintService.
See also the applet info. page that includes a link on the Next Generation in Applet Java Plug-in Technology which "..brings new abilities to applets: such as .. allowing embedded applets to gain full access to the services of Java Web Start."

Categories

Resources