• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

NX: securityException

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Ranch Hand
Posts: 194
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 !
 
There's a way to do it better - find it. -Edison. A better tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic