aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Policy file question and readme question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Policy file question and readme question" Watch "Policy file question and readme question" New topic
Author

Policy file question and readme question

Greg Georges
Ranch Hand

Joined: May 10, 2001
Posts: 116
Hello all,
Well, I am close to uploading the jar, have some final questions.
For the server and client, I have a policy file with all permissions allowed. Now, I have a server with a GUI with a textfield which allows the user to type in the location of the db.db file (The user enters the IP address, port and location of the db.db file in the GUI). I am wondering if file permission exceptions (read,write) could be thrown even if I have all permissions in the policy file.
This is my policy file for the client and server
grant {
permission java.security.AllPermission;
};
As for my readme file, I have sections for
1)Overview of files in jar
2)Before you begin (make sure jdk is installed)
3)Unpacking the jar, extracting the db.db file
4)Starting the server (java -Djava.security.policy=server.policy -jar server.jar) and how to open command prompt in windows 95, 98, 2000, XP.
5)Starting the client (java -Djava.security.policy=client.policy -jar cleint.jar)
6)Complete listing of every file in jars (clent,
server, help files, designdocument, etc.)
Would appreciate your feedback. Thanks


<b>Greg Georges</b><br /><i>Sun Certified Java Programmer for the Java2 platform (SCJP)</i><br /><i>Sun Certified Java Developer for the Java2 platform (SCJD)</i>
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Ok, Greg, now I don't want you to second think your submission but I have one question
Now, I have a server with a GUI with a textfield which allows the user to type in the location of the db.db file (The user enters the IP address, port and location of the db.db file in the GUI).

Why would you need to give the IP address and port of the location to the db.db file? This is the server, it has the db.db file on the same amchine. You don't need IP address or Port, only the client needs it to connect to the server. In all other cases you will have the db.db file nearby.
As far as the policy file is concerned, you gave given all permissions, so you are fine.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Greg Georges
Ranch Hand

Joined: May 10, 2001
Posts: 116
Good point Mark, never thought of that. To tell you the truth the ip address and port are not needed at all. Think will get rid of it
Greg Georges
Ranch Hand

Joined: May 10, 2001
Posts: 116
Mark, I have been trying my server.jar and policy file on different machines, it works on mine but not on the comps here at work, I have read that you did not use the new RMISecurityManager(), is this the case, and could this be causing my problems?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Mayeb, the onyl place I create an RMISecurity Manager is for the client, not the server. The when a client requests a DataAccessRemote class it makes one for the client.
Hope that helps.
Mark
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
I think its ok to provide a port number and host name. Forexample, on the remote server, I might now wish to start the registry on port 1099 but on on 2010.


Never be satisfied with anything less than the best and you will surely pass the test...
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Ok, I am rethinking now... .
They say specifically that only the DNS name can be provided on the command line? Is rmi://localhost a valid DNS Name? Or is the DNS name only localhost? In otherwords does the protocol before the host still be part of the dns name? See I am not really sure, as my server starts with
java -DHOSTNAME=rmi://localhost -DPORTNUM=1099 blah blah...
Does it always have to be rmi???
I need sleep, confusing myself endlessly..Someone please give me a shot in the arm...
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Also when I start from the client, I specify
java -DHOST=rmi://localhost -DPORT=1099? How can ne access the java.rmi.server.hostname property from within the code after passing in -Djava.rmi.server.hostname?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

They say specifically that only the DNS name can be provided on the command line? Is rmi://localhost a valid DNS Name? Or is the DNS name only localhost? In otherwords does the protocol before the host still be part of the dns name? See I am not really sure, as my server starts with
java -DHOSTNAME=rmi://localhost -DPORTNUM=1099 blah blah...
Does it always have to be rmi???
I need sleep, confusing myself endlessly..Someone please give me a shot in the arm...

Sheesh, I have to quote the entire thing.
yes and no, meaning you don't have to put the rmi in the command line, because you can add it in code, but that, I think is if you are using it as an argument like the one that comes into main() as args[]
How can ne access the java.rmi.server.hostname property from within the code after passing in -Djava.rmi.server.hostname?

Is it a method of System. Like getProperty or something like that?
By the way, Who is ne?
Mark
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Sorry Mark,
I mean we. See the thing is if we hard code inside as rmi then what will happen if in the future we wish to use dynamic class? We need to supplu the code base and then that would be the remote url to contact the server wouldnt it?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

We need to supplu the code base and then that would be the remote url to contact the server wouldnt it?

Yes, in the real world, or maybe not. I mean how long would it take to change that. You only do the lookup in one place, so to change it would still be centralized in one place.
Mark
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Thanks, thats a good one. I see that in your implementation you have made the clients to contain the server stub files. I am doing the same as I do not want the hassle of webserver/codebase etc. You mentioned that you were using a RMISecurityManager on the client? Why do you need it please?
Kalichar Rangantittu
Ranch Hand

Joined: Jan 15, 2002
Posts: 240
Mark,
Also a simple question, when I specify the remote url, I specify it at
rmi:// + remoteHostDNS.
Do I need to specify the port number of 1099 too ?
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

you were using a RMISecurityManager on the client? Why do you need it please?

I don't know to use it, and to show that I know how to use it. not sure if I had to really.
Do I need to specify the port number of 1099 too ?

Since it is the default, you do not need to include it in the lookup. It is only when it is a different port number that you need to include it.
Mark
 
Don't get me started about those stupid light bulbs.
 
subject: Policy file question and readme question