|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.atlassian.bamboo.utils.FilePermissionUtil
public class FilePermissionUtil
Utility class for changing the file permissions using JDK1.6 File.setWritable and family if available, falling back to executing a chmod command.
The only supported method in this version is setting "600" mode for a file, as seen in preparing a keyfile for ssh command.
chmodUserPrivate(java.io.File)
Method Summary | |
---|---|
static void |
chmodUserPrivate(java.io.File file)
Changes the mode of the file to 600, as required for example by the ssh key files. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Method Detail |
---|
public static void chmodUserPrivate(java.io.File file) throws java.io.IOException, java.lang.InterruptedException
It tries to first invoke Java 1.6 {link}File#setWritable{link} and family using reflection. If it's unavailable, it tries to invoke chmod executable - be aware it will fail on windows unless you have cygwin or similar installed.
Please note that this method is not guaranteed to have done what it's asked - it may fail to change the permission and there is no way for you to know.
file
- the file to change permissions on
java.io.IOException
- when chmod process execution fails - not thrown when using reflection
java.lang.InterruptedException
- when process.waitFor(chmod) is interrupted - not thrown when using reflection
java.lang.RuntimeException
- when the reflection call on JDK1.6 fails (might be caused by SecurityException)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |