Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: securityException

 
Annekee Bos
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 194
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
Ganapathy
 
Annekee Bos
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 !
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic