Documentation

The Java™ Tutorials
Hide TOC
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 ExampleGame.一个名为ExampleGame的示例游戏。
  2. A class called HighScore, which is used by ExampleGame to store a user's latest high score.一个名为HighScore的类,ExampleName使用它来存储用户的最新高分。
  3. A class called HighScorePermission, which is used to protect access to the user's stored high score value.一个名为HighScorePermission的类,用于保护对用户存储的高分值的访问。
  4. A user's security policy file, which grants permission to ExampleGame to update his/her high score.用户的安全策略文件,它授予ExampleName更新他/她的高分的权限。

The basic scenario is as follows:基本场景如下:

  1. A user plays ExampleGame.用户播放ExampleName
  2. If the user reaches a new high score, ExampleGame uses the HighScore class to save this new value.如果用户达到新的高分,ExampleName将使用HighScore类保存此新值。
  3. The HighScore class looks into the user's security policy to check if ExampleGame has permission to update the user's high score value.HighScore类查看用户的安全策略,以检查ExampleName是否有权更新用户的高分值。
  4. If ExampleGame has permission to update the high score, then the HighScore class updates that value.如果ExampleName有权更新高分,则HighScore类会更新该值。

We describe the key points of each of the basic components and then show a sample run:我们描述了每个基本组件的关键点,然后展示了一个示例运行:


Previous page: Previous Lesson
Next page: ExampleGame