FileDocCategorySizeDatePackage
OwnerImpl.javaAPI DocJava SE 6 API3486Tue Jun 10 00:22:04 BST 2008com.sun.jmx.snmp.IPAcl

OwnerImpl

public class OwnerImpl extends Object implements java.security.acl.Owner, Serializable
Owner of Access Control Lists (ACLs). The initial owner Principal should be specified as an argument to the constructor of the class AclImpl.
see
java.security.acl.Owner
version
4.10 11/17/05
author
Sun Microsystems, Inc

Fields Summary
private Vector
ownerList
Constructors Summary
public OwnerImpl()
Constructs an empty list of owner.

  
           
    
	ownerList = new Vector();
  
public OwnerImpl(PrincipalImpl owner)
Constructs a list of owner with the specified principal as first element.

param
owner the principal added to the owner list.

	ownerList = new Vector();
	ownerList.addElement(owner);
  
Methods Summary
public booleanaddOwner(java.security.Principal caller, java.security.Principal owner)
Adds an owner. Only owners can modify ACL contents. The caller principal must be an owner of the ACL in order to invoke this method. That is, only an owner can add another owner. The initial owner is configured at ACL construction time.

param
caller the principal invoking this method. It must be an owner of the ACL.
param
owner the owner that should be added to the list of owners.
return
true if successful, false if owner is already an owner.
exception
NotOwnerException if the caller principal is not an owner of the ACL.

	if (!ownerList.contains(caller)) 
	  throw new NotOwnerException();

	if (ownerList.contains(owner)) {
	  return false;
	} else {
	  ownerList.addElement(owner);
	  return true;
	}
  
public booleandeleteOwner(java.security.Principal caller, java.security.Principal owner)
Deletes an owner. If this is the last owner in the ACL, an exception is raised.

The caller principal must be an owner of the ACL in order to invoke this method.

param
caller the principal invoking this method. It must be an owner of the ACL.
param
owner the owner to be removed from the list of owners.
return
true if successful, false if owner is already an owner.
exception
NotOwnerException if the caller principal is not an owner of the ACL.
exception
LastOwnerException if there is only one owner left, so that deleteOwner would leave the ACL owner-less.


	if (!ownerList.contains(caller))
	  throw new NotOwnerException();
	
	if (!ownerList.contains(owner)){
	  return false;
	} else {
	  if (ownerList.size() == 1)
		throw new LastOwnerException();
	  
	  ownerList.removeElement(owner);
	  return true;
	}
  
public booleanisOwner(java.security.Principal owner)
Returns true if the given principal is an owner of the ACL.

param
owner the principal to be checked to determine whether or not it is an owner.
return
true if the given principal is an owner of the ACL.

	return ownerList.contains(owner);