home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 November / Chip_1998-11_cd.bin / tema / Cafe / main.bin / AclEntry.java < prev    next >
Text File  |  1997-05-20  |  5KB  |  150 lines

  1. /*
  2.  * @(#)AclEntry.java    1.8 97/01/30
  3.  * 
  4.  * Copyright (c) 1995, 1996 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  * CopyrightVersion 1.1_beta
  20.  * 
  21.  */
  22.  
  23. package java.security.acl;
  24.  
  25. import java.util.Enumeration;
  26. import java.security.Principal;
  27.  
  28. /**
  29.  * This is the interface used for representing one entry in an Access 
  30.  * Control List (ACL).<p>
  31.  * 
  32.  * An ACL can be thought of as a data structure with multiple ACL entry
  33.  * objects. Each ACL entry object contains a set of permissions associated 
  34.  * with a particular principal. (A principal represents an entity such as 
  35.  * an individual user or a group). Additionally, each ACL entry is specified
  36.  * as being either positive or negative. If positive, the permissions are 
  37.  * to be granted to the associated principal. If negative, the permissions 
  38.  * are to be denied. Each principal can have at most one positive ACL entry 
  39.  * and one negative entry; that is, multiple positive or negative ACL 
  40.  * entries are not allowed for any principal.
  41.  *
  42.  * Note: ACL entries are by default positive. An entry becomes a 
  43.  * negative entry only if the <a href = 
  44.  * "#setNegativePermissions">setNegativePermissions</a>
  45.  * method is called on it.
  46.  * 
  47.  * @see java.security.acl.Acl
  48.  *
  49.  * @author     Satish Dharmaraj
  50.  */
  51. public interface AclEntry extends Cloneable {
  52.  
  53.     /**
  54.      * Specifies the principal for which permissions are granted or denied 
  55.      * by this ACL entry. If a principal was already set for this ACL entry,
  56.      * false is returned, otherwise true is returned.
  57.      * 
  58.      * @param user the principal to be set for this entry.
  59.      * 
  60.      * @return true if the principal is set, false if there was 
  61.      * already a principal set for this entry.
  62.      */
  63.     public boolean setPrincipal(Principal user);
  64.  
  65.     /**
  66.      * Returns the principal for which permissions are granted or denied by 
  67.      * this ACL entry. Returns null if there is no principal set for this 
  68.      * entry yet. 
  69.      * 
  70.      * @return the principal associated with this entry.
  71.      */
  72.     public Principal getPrincipal();
  73.  
  74.     /**
  75.      * Sets this ACL entry to be a negative one. That is, the associated 
  76.      * principal (e.g., a user or a group) will be denied the permission set 
  77.      * specified in the entry.
  78.      * 
  79.      * Note: ACL entries are by default positive. An entry becomes a 
  80.      * negative entry only if this <code>setNegativePermissions</code> 
  81.      * method is called on it.
  82.      */
  83.     public void setNegativePermissions();
  84.  
  85.     /**
  86.      * Returns true if this is a negative ACL entry (one denying the 
  87.      * associated principal the set of permissions in the entry), false 
  88.      * otherwise.
  89.      * 
  90.      * @return true if this is a negative ACL entry, false if it's not.
  91.      */
  92.     public boolean isNegative();
  93.  
  94.     /**
  95.      * Adds the specified permission to this ACL entry. Note: An entry can 
  96.      * have multiple permissions. 
  97.      * 
  98.      * @param permission the permission to be associated with 
  99.      * the principal in this entry.
  100.      * 
  101.      * @return true if the permission was added, false if the 
  102.      * permission was already part of this entry's permission set.
  103.      */
  104.     public boolean addPermission(Permission permission);
  105.  
  106.     /**
  107.      * Removes the specified permission from this ACL entry.
  108.      *  
  109.      * @param permission the permission to be removed from this entry.
  110.      * 
  111.      * @return true if the permission is removed, false if the 
  112.      * permission was not part of this entry's permission set.
  113.      */
  114.     public boolean removePermission(Permission permission);
  115.  
  116.     /**
  117.      * Checks if the specified permission is part of the 
  118.      * permission set in this entry.
  119.      * 
  120.      * @param permission the permission to be checked for.
  121.      * 
  122.      * @return true if the permission is part of the        
  123.      * permission set in this entry, false otherwise. 
  124.      */
  125.     public boolean checkPermission(Permission permission);
  126.  
  127.     /**
  128.      * Returns an enumeration of the permissions in this ACL entry.
  129.      * 
  130.      * @return an enumeration of the permissions in this ACL entry.
  131.      */
  132.     public Enumeration permissions();
  133.  
  134.     /**
  135.      * Returns a string representation of the contents of this ACL entry.
  136.      * 
  137.      * @return a string representation of the contents.
  138.      */
  139.     public String toString();
  140.  
  141.     /**
  142.      * Clones this ACL entry.
  143.      * 
  144.      * @return a clone of this ACL entry.
  145.      */
  146.     public Object clone();
  147. }
  148.  
  149.  
  150.