I want to permit the java application only to read any local file but i don't want any application to update a local file.
Is this related to java.policy?
Please suggest ....!
I want to permit the java application only to read any local file but i don't want any application to update a local file.
Is this related to java.policy?
Please suggest ....!
No.
You can only control only what your Java program can read using policy files.
No no don't misunderstand me .... I want to discuss this over here instead of looking for Google.
What I did with this file that is, i changed a line permission java.security.F ilePermission within grant block for applet to do have acces to it's local file system.
That's why i asking about, if i want to change permission settings in java application which runs from the local except Applet code what i need to do.
Please have a discussion over here ..this is my earnest request to all of you experts .... :-)
No no don't misunderstand me .... I want to discuss this over here instead of looking for Google.
What I did with this file that is, i changed a line permission java.security.F ilePermission within grant block for applet to do have acces to it's local file system.
That's why i asking about, if i want to change permission settings in java application which runs from the local except Applet code what i need to do.
Please have a discussion over here ..this is my earnest request to all of you experts .... :-)
Sorry r035198x ... I went for details and now the picture is cleared to me. :-)
What you told that's right.
The java.policy can't be changed just you can edit it through Program.
A code snippet is given below ..
[code=java]
System.setSecur ityManager(new SecurityManager (){
@Override
public void checkWrite(Stri ng file){
throw new SecurityExcepti on("File write not allowed..!!!");
}
});
FileWriter file = new FileWriter("d:/test.txt");
file.write("My name is Debasis Jana");
file.close();
[/code]
Here i am getting the security exception.
Now after main thread terminates the default permission set.
Now tell me r035198x, how java.policy works ..could you tell me in details? :-)
What you told that's right.
The java.policy can't be changed just you can edit it through Program.
A code snippet is given below ..
[code=java]
System.setSecur ityManager(new SecurityManager (){
@Override
public void checkWrite(Stri ng file){
throw new SecurityExcepti on("File write not allowed..!!!");
}
});
FileWriter file = new FileWriter("d:/test.txt");
file.write("My name is Debasis Jana");
file.close();
[/code]
Here i am getting the security exception.
Now after main thread terminates the default permission set.
Now tell me r035198x, how java.policy works ..could you tell me in details? :-)
I come back again here.
Actually still it's not clear how java.policy works?
When it's read up..Please tell me in brief. :-)
There is a long story ..lolz!
Ok let me read then I ll ask if something remains misunderstood.
Ok ..let's start with something.
When i am setting the SecurityManager like....
[code=java]
System.setSecur ityManager(new SecurityManager (){
//my code goes here
});
[/code]
It means i am simply overriding the default implementation of java policy.
Once I start this then how long it alives unless i set it to default SecurityManager .
Please explain!
Ok ..let's start with something.
When i am setting the SecurityManager like....
[code=java]
System.setSecur ityManager(new SecurityManager (){
//my code goes here
});
[/code]
It means i am simply overriding the default implementation of java policy.
Once I start this then how long it alives unless i set it to default SecurityManager .
Please explain!
Look what happens if you attempt to constuct a SecurityManager :
Originally posted by JavaDoc SecurityManager
If there is a security manager already installed, this method first calls the security manager's checkPermission method with the RuntimePermissi on("createSecur ityManager") permission to ensure the calling thread has permission to create a new security manager. This may result in throwing a SecurityExcepti on.
Comment