File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: securityException 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 "NX: securityException " Watch "NX: securityException " New topic

NX: securityException

Annekee Bos

Joined: Apr 29, 2003
Posts: 2
Hi everybody, great place! I downloaded my developer assignment a couple of days ago: It had a DBAccess interface with deleteRecord, updateRecord methods that throw SecurityExceptions if the record is locked with a cookie other than 'lockCookie'. LockCookie is a long that is passed as an argument to these methods (also it is the return value of the lockRecord method).
Now the API documentation says that a java.lang.SecurityException is thrown by the security manager. Would this indicate that I must use a subclass of SecurityManager? Or should I create a mypackage.SecurityException that can be thrown by anyone?
S. Ganapathy
Ranch Hand

Joined: Mar 26, 2003
Posts: 194
Hi Annekee Bos,
1. lock the record to perform update/delete operation, which returns lockCookie once the record is locked.
2. update/delete the locked record. while doing so, you will ensure that this record is locked with the lockCookie. If the record is not locked, you do throw SecurityException with appropriate message. NO SECURITYMANAGER IS INVOLVED.
3. unlock the already locked, if no lock found on this record, throw SecurityException again.
Annekee Bos

Joined: Apr 29, 2003
Posts: 2
I'm still not 100% sure yet: the API documentation is very explicit about securityException:
'Thrown by the security manager to indicate a security violation.'.
Would you say that my Data class is a kind of security manager even though it is not an instance of SecurityManager? I could argue this, since the class does 'manage the security' of my database. Also I do think that if SUN really intended securityExceptions to be thrown by instances of SecurityManager only, the exception would not have a public constructor, but still I have doubts: please manage the security of my consciense here !
I agree. Here's the link:
subject: NX: securityException
It's not a secret anymore!