NOTA: La traducción de esta documentación es un esfuerzo personal y voluntario, no es un documento oficial de Sun Microsystems ni Oracle ni está patrocinado por ninguna de estas empresas. Los documentos originales (en inglés) están disponibles en: http://java.sun.com/docs/books/tutorial/.
Dirija cualquier comentario, petición, felicitación, etc. a tutorialesjava_@RROBA_codexion.com.
Si desea ayudar a mantener en funcionamiento esta web, colaborar con la traducción de estos documentos o necesita que se traduzca algĂșn capĂ­tulo en concreto puede realizar una donación directa mediante Paypal:
Lesson: Implementing Your Own Permission (The Java™ Tutorials > Security Features in Java SE)
Implementing Your Own Permission
Trail: Security Features in Java SE
Lesson: Implementing Your Own Permission
This lesson demonstrates how to write a class that defines its own special permission. The basic components in this lesson include:
  1. A sample game called TerrysGame.

  2. A class called HighScore, which is used by TerrysGame to store a user's latest high score.

  3. A class called HighScorePermission, which is used to protect access to the user's stored high score value.

  4. A user's security policy file, which grants permission to TerrysGame to update his/her high score.
The basic scenario is as follows:
  1. A user plays TerrysGame.

  2. If the user reaches a new high score, TerrysGame uses the HighScore class to save this new value.

  3. The HighScore class looks into the user's security policy to check if TerrysGame has permission to update the user's high score value.

  4. If TerrysGame has permission to update the high score, then the HighScore class updates that value.

We describe the key points of each of the basic components and then show a sample run:

Previous page: Previous Lesson
Next page: TerrysGame