Skip to main content
IBM  
Shop Support Downloads
IBM Home Products Consulting Industries News About IBM
IBM developerWorks : Java : Education - Tutorials
Java security, Part 2: Authentication and authorization
ZIPPDF (letter)PDF (A4)e-mail
Main menuSection menuFeedbackPreviousNext
4. Authorization in JAAS
  


Create your own permissions page 5 of 9


The Java platform lets you create your own permission objects. Like regular permissions, these can be placed in the policy file and configured at deployment time. To demonstrate, take a look at the following PersonnelPermission. We'll use this code later on to allow access to some sensitive personnel-action code.


import java.security.*;
//
// Implement a user defined permission for access to the personnel //
code for this example public class PersonnelPermission extends
BasicPermission {

     public PersonnelPermission(String name) {
       super(name);
     }

     public PersonnelPermission(String name, String action) {
       super(name);
     }
}

Here's what you should note about the above permission: first, a constructor takes the user-defined name of the permission (in this example there is only one type, called access). A second constructor then takes an additional refining parameter called an action, although we won't use it here. For this example we'll use a BasicPermission class. If we need more features, we can use a Permission class.


Main menuSection menuFeedbackPreviousNext
Privacy Legal Contact