• 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

Generated Cookie

 
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Ranchers

I would like to know wich are the cookie strategies generation ? I've read here about "System.nanoTime()" but....there are another options ?
Regards.
 
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Fernando,

I used System.nanoTime(), but of course you can use the Random class and use the nextLong() method. Or you can use both and multiply both results with each other. But i think System.nanoTime() should do the job. You can always add something to your choices.txt that generation cookie logic can be refined (extended) in a future release...

Kind regards,
Roel
 
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Howdy, Fernando!

You may also want to take a look at the SecureRandom class.
 
Fernando Franzini
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks Roel and Roberto.

Another question about it: What should I do when someone try lock an ID that already looked ?? My inteface only throw RecordNotFoundException ? Should I throw one database runtime exception ? What did you do Roel ??
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, Fernando!

What should I do when someone try lock an ID that already looked ??



Ah... that's where the locking mechanism comes in! This is what I have in my instructions.html file:

Any attempt to lock a resource that is already locked should cause the current thread to give up the CPU, consuming no CPU cycles until the desired resource becomes available.



So... the client trying to lock a record that is already locked should wait until that particular record is available. After getting its lock, then the update/delete should proceed normaly.
 
Fernando Franzini
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OHH MY GODDD !!! This is exactly what my assignment said !!! Wowwwwwwwww......sorry
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Fernando,

I would certainly not throw any exception, otherwise you will fail automatically, like Laura Pecoraro. Here you can find some information about her mistake and how you can/should deal with it.

Kind regards,
Roel
 
Fernando Franzini
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks again Roel.... I'm sure that I wont comit the Laura mistake.
About SecurityException in unlock method. Can I throw it if passed a recordNumber that wasn't locked or if passed a wrong cookie value ?
 
Roel De Nijs
Sheriff
Posts: 11604
178
Hibernate jQuery Eclipse IDE Spring MySQL Database AngularJS Tomcat Server Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Fernando,

You can certainly throw it if a wrong cookie value is passed, because I believe that is exactly why the SecurityException exists. But a record that is not locked, is a subtle difference.
In my assignment I had no SecurityException, so I throw in both situations an IllegalStateException.

In this thread someone asked the same question like you.

Kind regards,
Roel
 
Fernando Franzini
Ranch Hand
Posts: 497
2
Spring Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi folks

I'm writting choice.txt and I need put 'why' I choose System.nanoTime() to generate locke cookie.
I'm actually did cause you guys suggest for me.... And it really work !
Could you help me please ?
Regards.
 
Roberto Perillo
Bartender
Posts: 2292
3
Eclipse IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can just say that this approach is secure enough to distinguish one client from the others.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic