Java application security permissions - java

I have a compiled Java Application (.jar file extension, no source code) which will not function correctly without read/write permissions. How do it get it to run with these administrator permissions?
EDIT: This is being run in Windows 7.

This appears to be a question of Windows 7 security, rather than Java security. Java JAR by default have full access that the OS allows.
Can you not create a shortcut and run it as administrator or start a prompt as administrator and run the jar from this prompt. If you have a service, you can set it up to run as administrator.

Related

OSX Catalina broke osascript launch with administrator priviledges

All known prior macOS versions were working with this sort of script context:
osascript -e "/path/to/my/app.command" with administrator privileges
Now it just silently fails...after asking for admin password.
The command file is what was originally used to launch the app, and the app has a button to re-launch with privileges...and the prior non privileged app closes.
If I remove the "with administrator privileges", it re-launches. if that is there, it does not.
If I try using:
/usr/bin/security execute-with-privileges /path/to/my/app.command
It also fails...never even shows password prompt.
I tried also "sudo open /Applications/myApp.app" but that of course doesn't actually launch with privileges.
From a shell i can sudo launch my app, and that is fine, but I can't expect an average user to be able to do sudo in a shell.
As I said, this had been a nice method that has worked for probably the past 6 to 8 years...but now fails. Anyone have any tricks or ways to get around it?
At one time....and I have no idea why, I saw the OSX security popup indicating "java" is not a trusted app and my settings only allow app store apps. But that only happened once...and it was strange. I clicked OK, it disappeared. I thought maybe java had been quarantined, so I did the command to clear that flag:
xattr -rd com.apple.quarantine /path/to/the/binary/java
But that made no difference. I'm sure this is new security features in Catalina making things difficult...but I can't figure out why or how to work through them. Its a java app that is launched via the app.command file which finds java on the machine and then launches it...defaulting to finding a local copy in its own subfolder.
Checkout out the sandbox settings of your project. the App Sandbox should be set as false in the entitlements file.
The sandboxing feature prevents your app from elevating the privilege in your app.
reference: https://developer.apple.com/app-sandboxing/

Running exe files with Hudson on Windows 8

I am attempting to have a Hudson job run a windows executable on a Windows 8 VM. When I attempt to run the exe file I get the error:
java.io.IOException: Cannot run program "C:\hudson\workspace\workspaceName\installer\bin\fileToExecute.exe": CreateProcess error=740, The requested operation requires elevation
Has anyone run into this and had it run automatically? I can't just have the exe file on the VM and set its permissions because a new copy gets downloaded at the start of each build.
Thanks in advance.
Disclaimer: I have not tried this with Windows 8.
First things first, even if you succeed to launch an .exe application from Hudson/Jenkins, it will be running under a different session, probably invisible to you. I've managed to achieve the workarounds for this with PsExec as detailed here:
Open Excel on Jenkins CI
With the above method, you will be able to launch an application and actually see it in the logged in session.
If your application does require elevated permissions for whatever reason, you've got to add -h switch to PsExec

Run java application as administrator priviledge in XP

I have created a small program in java which reads the UninstallString of an application from registry and then using
Process p = Runtime.getRuntime.exec("command")
to uninstall this application. But this task require administrator priviledge.
On Windows Vista, 7 and 8 this work fine by creating a bat file with the following command "java -jar java_app.jar", right click on the bat file and run as administrator.
But on XP, my account is an administrator account but still it fails to run the java program as administrator.
Can anyone provide me with some solutions which can solve this problem?
You can use RunAs command:
RUNAS /TrustLevel:Unrestricted notepad.exe
You can find trust levels available on you system:
RUNAS /ShowTrustLevels
The following liks explains that in more details http://blog.johnmuellerbooks.com/2011/04/26/simulating-users-with-the-runas-command.aspx

Java start program on user login (platform-wide)

Across linux, MAC, and Windows, is there any way to make a Java program startup on login? I know on windows their would just need to be a shortcut to the jar file in the user's startup folder. But for linux and MAC what should i do?
There's no cross-platform method of starting a program at login or boot, but you can configure each individually.
Windows - Put the program in your user's startup folder in or use a scheduled task, both detailed here: [Instructions]
Mac - Configure through system preferences: [Instructions]
Linux - Configure ~/.bashrc to start on login or use /etc/rc.d/rc.sysinit to start on boot.

How to start a java jar with administrators privileges on windows 7

I am developing a grammar with ANTLRWorks on Windows 7. The ANTLRWorks debugger doesn't start unless ANTLRWorks has Administrator privileges. ANTLRWorks is delivered as one Java .jar which starts by a doubleclick on the file.
Question: How can I assure that the .jar file runs with Administrator Privileges ?
You can run cmd under Administrator and launch ANTRLWorks using java -jar command.
You may want to have a look at Johannes Passing's Opensource Tool Elevate.exe There are many possibilities of using it. You can make a wrapper jar or simply use a batch file with something like:
Elevate.exe javaw.exe -jar path-to-your-jar-file
and this will launch UAC prompt, when allowed will permit the jar to have elevated privileges.
if you do not like batch files, then you can write a simple wrapper class to do so. Normally i make another jar file as a launcher for the jar which requires admin access, and in the launcher file, simply execute external process with the above command, and this way my jar has admin privileges.
first, download this program from here
http://code.kliu.org/misc/elevate/
then copy the "elevate.exe" file to the folder where your .jar file is.
Make, a .bat file as "elevate java -jar YourJARFile.jar".
Run the .bat file.Simple as that.

Categories