1 11 12 13 package com.sun.jmx.snmp.IPAcl; 14 15 16 17 import java.util.Vector ; 18 import java.io.Serializable ; 19 20 import java.security.Principal ; 21 import java.security.acl.Owner ; 22 import java.security.acl.LastOwnerException ; 23 import java.security.acl.NotOwnerException ; 24 25 26 35 36 class OwnerImpl implements Owner , Serializable { 37 private Vector ownerList = null; 38 39 42 public OwnerImpl (){ 43 ownerList = new Vector (); 44 } 45 46 51 public OwnerImpl (PrincipalImpl owner){ 52 ownerList = new Vector (); 53 ownerList.addElement(owner); 54 } 55 56 69 public boolean addOwner(Principal caller, Principal owner) 70 throws NotOwnerException { 71 if (!ownerList.contains(caller)) 72 throw new NotOwnerException (); 73 74 if (ownerList.contains(owner)) { 75 return false; 76 } else { 77 ownerList.addElement(owner); 78 return true; 79 } 80 } 81 82 96 public boolean deleteOwner(Principal caller, Principal owner) 97 throws NotOwnerException ,LastOwnerException { 98 99 if (!ownerList.contains(caller)) 100 throw new NotOwnerException (); 101 102 if (!ownerList.contains(owner)){ 103 return false; 104 } else { 105 if (ownerList.size() == 1) 106 throw new LastOwnerException (); 107 108 ownerList.removeElement(owner); 109 return true; 110 } 111 } 112 113 120 public boolean isOwner(Principal owner){ 121 return ownerList.contains(owner); 122 } 123 } 124 | Popular Tags |