类java.security.acl.NotOwnerException源码实例Demo

下面列出了怎么用java.security.acl.NotOwnerException的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: jdk8u_jdk   文件: OwnerImpl.java
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * 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.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      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;
      }
}
 
源代码2 项目: jdk1.8-source-analysis   文件: SnmpAcl.java
/**
 * Constructs the Java Dynamic Management(TM) Access Control List
 * based on IP addresses. The ACL will take the given owner name.
 * The current IP address will be the owner of the ACL.
 *
 * @param Owner The name of the ACL Owner.
 * @param aclFileName The name of the ACL File.
 *
 * @exception UnknownHostException If the local host is unknown.
 * @exception IllegalArgumentException If the ACL file doesn't exist.
 */
public SnmpAcl(String Owner, String aclFileName)
    throws UnknownHostException, IllegalArgumentException {
    trapDestList= new Hashtable<InetAddress, Vector<String>>();
    informDestList= new Hashtable<InetAddress, Vector<String>>();

    // PrincipalImpl() take the current host as entry
    owner = new PrincipalImpl();
    try {
        acl = new AclImpl(owner,Owner);
        AclEntry ownEntry = new AclEntryImpl(owner);
        ownEntry.addPermission(READ);
        ownEntry.addPermission(WRITE);
        acl.addEntry(owner,ownEntry);
    } catch (NotOwnerException ex) {
        if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_LOGGER.logp(Level.FINEST, SnmpAcl.class.getName(),
                "SnmpAcl(String,String)",
                "Should never get NotOwnerException as the owner " +
                "is built in this constructor");
        }
    }
    if (aclFileName == null) setDefaultFileName();
    else setAuthorizedListFile(aclFileName);
    readAuthorizedListFile();
}
 
源代码3 项目: jdk1.8-source-analysis   文件: OwnerImpl.java
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * 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.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      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;
      }
}
 
源代码4 项目: dragonwell8_jdk   文件: AclImpl.java
/**
 * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group)
 * with a set of permissions. Each principal can have at most one positive ACL entry
 * (specifying permissions to be granted to the principal) and one negative ACL entry
 * (specifying permissions to be denied). If there is already an ACL entry
 * of the same type (negative or positive) already in the ACL, false is returned.
 *
 * @param caller the principal invoking this method. It must be an owner
 *        of this ACL.
 * @param entry the ACL entry to be added to this ACL.
 * @return true on success, false if an entry of the same type (positive
 *       or negative) for the same principal is already present in this ACL.
 * @exception NotOwnerException if the caller principal is not an owner of
 *       this ACL.
 * @see java.security.Principal
 */
@Override
public boolean addEntry(Principal caller, AclEntry entry)
      throws NotOwnerException {
        if (!isOwner(caller))
              throw new NotOwnerException();

        if (entryList.contains(entry))
              return false;
        /*
               for (Enumeration e = entryList.elements();e.hasMoreElements();){
               AclEntry ent = (AclEntry) e.nextElement();
               if (ent.getPrincipal().equals(entry.getPrincipal()))
               return false;
               }
               */

        entryList.addElement(entry);
        return true;
}
 
源代码5 项目: dragonwell8_jdk   文件: SnmpAcl.java
/**
 * Constructs the Java Dynamic Management(TM) Access Control List
 * based on IP addresses. The ACL will take the given owner name.
 * The current IP address will be the owner of the ACL.
 *
 * @param Owner The name of the ACL Owner.
 * @param aclFileName The name of the ACL File.
 *
 * @exception UnknownHostException If the local host is unknown.
 * @exception IllegalArgumentException If the ACL file doesn't exist.
 */
public SnmpAcl(String Owner, String aclFileName)
    throws UnknownHostException, IllegalArgumentException {
    trapDestList= new Hashtable<InetAddress, Vector<String>>();
    informDestList= new Hashtable<InetAddress, Vector<String>>();

    // PrincipalImpl() take the current host as entry
    owner = new PrincipalImpl();
    try {
        acl = new AclImpl(owner,Owner);
        AclEntry ownEntry = new AclEntryImpl(owner);
        ownEntry.addPermission(READ);
        ownEntry.addPermission(WRITE);
        acl.addEntry(owner,ownEntry);
    } catch (NotOwnerException ex) {
        if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_LOGGER.logp(Level.FINEST, SnmpAcl.class.getName(),
                "SnmpAcl(String,String)",
                "Should never get NotOwnerException as the owner " +
                "is built in this constructor");
        }
    }
    if (aclFileName == null) setDefaultFileName();
    else setAuthorizedListFile(aclFileName);
    readAuthorizedListFile();
}
 
源代码6 项目: dragonwell8_jdk   文件: OwnerImpl.java
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * 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.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      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;
      }
}
 
源代码7 项目: TencentKona-8   文件: AclImpl.java
/**
 * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group)
 * with a set of permissions. Each principal can have at most one positive ACL entry
 * (specifying permissions to be granted to the principal) and one negative ACL entry
 * (specifying permissions to be denied). If there is already an ACL entry
 * of the same type (negative or positive) already in the ACL, false is returned.
 *
 * @param caller the principal invoking this method. It must be an owner
 *        of this ACL.
 * @param entry the ACL entry to be added to this ACL.
 * @return true on success, false if an entry of the same type (positive
 *       or negative) for the same principal is already present in this ACL.
 * @exception NotOwnerException if the caller principal is not an owner of
 *       this ACL.
 * @see java.security.Principal
 */
@Override
public boolean addEntry(Principal caller, AclEntry entry)
      throws NotOwnerException {
        if (!isOwner(caller))
              throw new NotOwnerException();

        if (entryList.contains(entry))
              return false;
        /*
               for (Enumeration e = entryList.elements();e.hasMoreElements();){
               AclEntry ent = (AclEntry) e.nextElement();
               if (ent.getPrincipal().equals(entry.getPrincipal()))
               return false;
               }
               */

        entryList.addElement(entry);
        return true;
}
 
源代码8 项目: TencentKona-8   文件: SnmpAcl.java
/**
 * Constructs the Java Dynamic Management(TM) Access Control List
 * based on IP addresses. The ACL will take the given owner name.
 * The current IP address will be the owner of the ACL.
 *
 * @param Owner The name of the ACL Owner.
 * @param aclFileName The name of the ACL File.
 *
 * @exception UnknownHostException If the local host is unknown.
 * @exception IllegalArgumentException If the ACL file doesn't exist.
 */
public SnmpAcl(String Owner, String aclFileName)
    throws UnknownHostException, IllegalArgumentException {
    trapDestList= new Hashtable<InetAddress, Vector<String>>();
    informDestList= new Hashtable<InetAddress, Vector<String>>();

    // PrincipalImpl() take the current host as entry
    owner = new PrincipalImpl();
    try {
        acl = new AclImpl(owner,Owner);
        AclEntry ownEntry = new AclEntryImpl(owner);
        ownEntry.addPermission(READ);
        ownEntry.addPermission(WRITE);
        acl.addEntry(owner,ownEntry);
    } catch (NotOwnerException ex) {
        if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_LOGGER.logp(Level.FINEST, SnmpAcl.class.getName(),
                "SnmpAcl(String,String)",
                "Should never get NotOwnerException as the owner " +
                "is built in this constructor");
        }
    }
    if (aclFileName == null) setDefaultFileName();
    else setAuthorizedListFile(aclFileName);
    readAuthorizedListFile();
}
 
源代码9 项目: jdk8u60   文件: AclImpl.java
/**
 * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group)
 * with a set of permissions. Each principal can have at most one positive ACL entry
 * (specifying permissions to be granted to the principal) and one negative ACL entry
 * (specifying permissions to be denied). If there is already an ACL entry
 * of the same type (negative or positive) already in the ACL, false is returned.
 *
 * @param caller the principal invoking this method. It must be an owner
 *        of this ACL.
 * @param entry the ACL entry to be added to this ACL.
 * @return true on success, false if an entry of the same type (positive
 *       or negative) for the same principal is already present in this ACL.
 * @exception NotOwnerException if the caller principal is not an owner of
 *       this ACL.
 * @see java.security.Principal
 */
@Override
public boolean addEntry(Principal caller, AclEntry entry)
      throws NotOwnerException {
        if (!isOwner(caller))
              throw new NotOwnerException();

        if (entryList.contains(entry))
              return false;
        /*
               for (Enumeration e = entryList.elements();e.hasMoreElements();){
               AclEntry ent = (AclEntry) e.nextElement();
               if (ent.getPrincipal().equals(entry.getPrincipal()))
               return false;
               }
               */

        entryList.addElement(entry);
        return true;
}
 
源代码10 项目: jdk8u60   文件: SnmpAcl.java
/**
 * Constructs the Java Dynamic Management(TM) Access Control List
 * based on IP addresses. The ACL will take the given owner name.
 * The current IP address will be the owner of the ACL.
 *
 * @param Owner The name of the ACL Owner.
 * @param aclFileName The name of the ACL File.
 *
 * @exception UnknownHostException If the local host is unknown.
 * @exception IllegalArgumentException If the ACL file doesn't exist.
 */
public SnmpAcl(String Owner, String aclFileName)
    throws UnknownHostException, IllegalArgumentException {
    trapDestList= new Hashtable<InetAddress, Vector<String>>();
    informDestList= new Hashtable<InetAddress, Vector<String>>();

    // PrincipalImpl() take the current host as entry
    owner = new PrincipalImpl();
    try {
        acl = new AclImpl(owner,Owner);
        AclEntry ownEntry = new AclEntryImpl(owner);
        ownEntry.addPermission(READ);
        ownEntry.addPermission(WRITE);
        acl.addEntry(owner,ownEntry);
    } catch (NotOwnerException ex) {
        if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_LOGGER.logp(Level.FINEST, SnmpAcl.class.getName(),
                "SnmpAcl(String,String)",
                "Should never get NotOwnerException as the owner " +
                "is built in this constructor");
        }
    }
    if (aclFileName == null) setDefaultFileName();
    else setAuthorizedListFile(aclFileName);
    readAuthorizedListFile();
}
 
源代码11 项目: jdk8u60   文件: OwnerImpl.java
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * 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.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      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;
      }
}
 
源代码12 项目: JDKSourceCode1.8   文件: AclImpl.java
/**
 * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group)
 * with a set of permissions. Each principal can have at most one positive ACL entry
 * (specifying permissions to be granted to the principal) and one negative ACL entry
 * (specifying permissions to be denied). If there is already an ACL entry
 * of the same type (negative or positive) already in the ACL, false is returned.
 *
 * @param caller the principal invoking this method. It must be an owner
 *        of this ACL.
 * @param entry the ACL entry to be added to this ACL.
 * @return true on success, false if an entry of the same type (positive
 *       or negative) for the same principal is already present in this ACL.
 * @exception NotOwnerException if the caller principal is not an owner of
 *       this ACL.
 * @see java.security.Principal
 */
@Override
public boolean addEntry(Principal caller, AclEntry entry)
      throws NotOwnerException {
        if (!isOwner(caller))
              throw new NotOwnerException();

        if (entryList.contains(entry))
              return false;
        /*
               for (Enumeration e = entryList.elements();e.hasMoreElements();){
               AclEntry ent = (AclEntry) e.nextElement();
               if (ent.getPrincipal().equals(entry.getPrincipal()))
               return false;
               }
               */

        entryList.addElement(entry);
        return true;
}
 
源代码13 项目: JDKSourceCode1.8   文件: SnmpAcl.java
/**
 * Constructs the Java Dynamic Management(TM) Access Control List
 * based on IP addresses. The ACL will take the given owner name.
 * The current IP address will be the owner of the ACL.
 *
 * @param Owner The name of the ACL Owner.
 * @param aclFileName The name of the ACL File.
 *
 * @exception UnknownHostException If the local host is unknown.
 * @exception IllegalArgumentException If the ACL file doesn't exist.
 */
public SnmpAcl(String Owner, String aclFileName)
    throws UnknownHostException, IllegalArgumentException {
    trapDestList= new Hashtable<InetAddress, Vector<String>>();
    informDestList= new Hashtable<InetAddress, Vector<String>>();

    // PrincipalImpl() take the current host as entry
    owner = new PrincipalImpl();
    try {
        acl = new AclImpl(owner,Owner);
        AclEntry ownEntry = new AclEntryImpl(owner);
        ownEntry.addPermission(READ);
        ownEntry.addPermission(WRITE);
        acl.addEntry(owner,ownEntry);
    } catch (NotOwnerException ex) {
        if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_LOGGER.logp(Level.FINEST, SnmpAcl.class.getName(),
                "SnmpAcl(String,String)",
                "Should never get NotOwnerException as the owner " +
                "is built in this constructor");
        }
    }
    if (aclFileName == null) setDefaultFileName();
    else setAuthorizedListFile(aclFileName);
    readAuthorizedListFile();
}
 
源代码14 项目: JDKSourceCode1.8   文件: OwnerImpl.java
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * 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.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      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;
      }
}
 
源代码15 项目: openjdk-jdk8u   文件: AclImpl.java
/**
 * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group)
 * with a set of permissions. Each principal can have at most one positive ACL entry
 * (specifying permissions to be granted to the principal) and one negative ACL entry
 * (specifying permissions to be denied). If there is already an ACL entry
 * of the same type (negative or positive) already in the ACL, false is returned.
 *
 * @param caller the principal invoking this method. It must be an owner
 *        of this ACL.
 * @param entry the ACL entry to be added to this ACL.
 * @return true on success, false if an entry of the same type (positive
 *       or negative) for the same principal is already present in this ACL.
 * @exception NotOwnerException if the caller principal is not an owner of
 *       this ACL.
 * @see java.security.Principal
 */
@Override
public boolean addEntry(Principal caller, AclEntry entry)
      throws NotOwnerException {
        if (!isOwner(caller))
              throw new NotOwnerException();

        if (entryList.contains(entry))
              return false;
        /*
               for (Enumeration e = entryList.elements();e.hasMoreElements();){
               AclEntry ent = (AclEntry) e.nextElement();
               if (ent.getPrincipal().equals(entry.getPrincipal()))
               return false;
               }
               */

        entryList.addElement(entry);
        return true;
}
 
源代码16 项目: openjdk-jdk8u   文件: SnmpAcl.java
/**
 * Constructs the Java Dynamic Management(TM) Access Control List
 * based on IP addresses. The ACL will take the given owner name.
 * The current IP address will be the owner of the ACL.
 *
 * @param Owner The name of the ACL Owner.
 * @param aclFileName The name of the ACL File.
 *
 * @exception UnknownHostException If the local host is unknown.
 * @exception IllegalArgumentException If the ACL file doesn't exist.
 */
public SnmpAcl(String Owner, String aclFileName)
    throws UnknownHostException, IllegalArgumentException {
    trapDestList= new Hashtable<InetAddress, Vector<String>>();
    informDestList= new Hashtable<InetAddress, Vector<String>>();

    // PrincipalImpl() take the current host as entry
    owner = new PrincipalImpl();
    try {
        acl = new AclImpl(owner,Owner);
        AclEntry ownEntry = new AclEntryImpl(owner);
        ownEntry.addPermission(READ);
        ownEntry.addPermission(WRITE);
        acl.addEntry(owner,ownEntry);
    } catch (NotOwnerException ex) {
        if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_LOGGER.logp(Level.FINEST, SnmpAcl.class.getName(),
                "SnmpAcl(String,String)",
                "Should never get NotOwnerException as the owner " +
                "is built in this constructor");
        }
    }
    if (aclFileName == null) setDefaultFileName();
    else setAuthorizedListFile(aclFileName);
    readAuthorizedListFile();
}
 
源代码17 项目: openjdk-jdk8u   文件: OwnerImpl.java
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * 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.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      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;
      }
}
 
源代码18 项目: openjdk-8   文件: AclImpl.java
/**
 * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group)
 * with a set of permissions. Each principal can have at most one positive ACL entry
 * (specifying permissions to be granted to the principal) and one negative ACL entry
 * (specifying permissions to be denied). If there is already an ACL entry
 * of the same type (negative or positive) already in the ACL, false is returned.
 *
 * @param caller the principal invoking this method. It must be an owner
 *        of this ACL.
 * @param entry the ACL entry to be added to this ACL.
 * @return true on success, false if an entry of the same type (positive
 *       or negative) for the same principal is already present in this ACL.
 * @exception NotOwnerException if the caller principal is not an owner of
 *       this ACL.
 * @see java.security.Principal
 */
@Override
public boolean addEntry(Principal caller, AclEntry entry)
      throws NotOwnerException {
        if (!isOwner(caller))
              throw new NotOwnerException();

        if (entryList.contains(entry))
              return false;
        /*
               for (Enumeration e = entryList.elements();e.hasMoreElements();){
               AclEntry ent = (AclEntry) e.nextElement();
               if (ent.getPrincipal().equals(entry.getPrincipal()))
               return false;
               }
               */

        entryList.addElement(entry);
        return true;
}
 
源代码19 项目: openjdk-jdk8u-backup   文件: AclImpl.java
/**
 * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group)
 * with a set of permissions. Each principal can have at most one positive ACL entry
 * (specifying permissions to be granted to the principal) and one negative ACL entry
 * (specifying permissions to be denied). If there is already an ACL entry
 * of the same type (negative or positive) already in the ACL, false is returned.
 *
 * @param caller the principal invoking this method. It must be an owner
 *        of this ACL.
 * @param entry the ACL entry to be added to this ACL.
 * @return true on success, false if an entry of the same type (positive
 *       or negative) for the same principal is already present in this ACL.
 * @exception NotOwnerException if the caller principal is not an owner of
 *       this ACL.
 * @see java.security.Principal
 */
@Override
public boolean addEntry(Principal caller, AclEntry entry)
      throws NotOwnerException {
        if (!isOwner(caller))
              throw new NotOwnerException();

        if (entryList.contains(entry))
              return false;
        /*
               for (Enumeration e = entryList.elements();e.hasMoreElements();){
               AclEntry ent = (AclEntry) e.nextElement();
               if (ent.getPrincipal().equals(entry.getPrincipal()))
               return false;
               }
               */

        entryList.addElement(entry);
        return true;
}
 
源代码20 项目: openjdk-jdk8u-backup   文件: SnmpAcl.java
/**
 * Constructs the Java Dynamic Management(TM) Access Control List
 * based on IP addresses. The ACL will take the given owner name.
 * The current IP address will be the owner of the ACL.
 *
 * @param Owner The name of the ACL Owner.
 * @param aclFileName The name of the ACL File.
 *
 * @exception UnknownHostException If the local host is unknown.
 * @exception IllegalArgumentException If the ACL file doesn't exist.
 */
public SnmpAcl(String Owner, String aclFileName)
    throws UnknownHostException, IllegalArgumentException {
    trapDestList= new Hashtable<InetAddress, Vector<String>>();
    informDestList= new Hashtable<InetAddress, Vector<String>>();

    // PrincipalImpl() take the current host as entry
    owner = new PrincipalImpl();
    try {
        acl = new AclImpl(owner,Owner);
        AclEntry ownEntry = new AclEntryImpl(owner);
        ownEntry.addPermission(READ);
        ownEntry.addPermission(WRITE);
        acl.addEntry(owner,ownEntry);
    } catch (NotOwnerException ex) {
        if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_LOGGER.logp(Level.FINEST, SnmpAcl.class.getName(),
                "SnmpAcl(String,String)",
                "Should never get NotOwnerException as the owner " +
                "is built in this constructor");
        }
    }
    if (aclFileName == null) setDefaultFileName();
    else setAuthorizedListFile(aclFileName);
    readAuthorizedListFile();
}
 
源代码21 项目: openjdk-jdk8u-backup   文件: OwnerImpl.java
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * 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.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      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;
      }
}
 
源代码22 项目: openjdk-8-source   文件: SnmpAcl.java
/**
 * Constructs the Java Dynamic Management(TM) Access Control List
 * based on IP addresses. The ACL will take the given owner name.
 * The current IP address will be the owner of the ACL.
 *
 * @param Owner The name of the ACL Owner.
 * @param aclFileName The name of the ACL File.
 *
 * @exception UnknownHostException If the local host is unknown.
 * @exception IllegalArgumentException If the ACL file doesn't exist.
 */
public SnmpAcl(String Owner, String aclFileName)
    throws UnknownHostException, IllegalArgumentException {
    trapDestList= new Hashtable<InetAddress, Vector<String>>();
    informDestList= new Hashtable<InetAddress, Vector<String>>();

    // PrincipalImpl() take the current host as entry
    owner = new PrincipalImpl();
    try {
        acl = new AclImpl(owner,Owner);
        AclEntry ownEntry = new AclEntryImpl(owner);
        ownEntry.addPermission(READ);
        ownEntry.addPermission(WRITE);
        acl.addEntry(owner,ownEntry);
    } catch (NotOwnerException ex) {
        if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_LOGGER.logp(Level.FINEST, SnmpAcl.class.getName(),
                "SnmpAcl(String,String)",
                "Should never get NotOwnerException as the owner " +
                "is built in this constructor");
        }
    }
    if (aclFileName == null) setDefaultFileName();
    else setAuthorizedListFile(aclFileName);
    readAuthorizedListFile();
}
 
源代码23 项目: jdk8u-jdk   文件: AclImpl.java
/**
 * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group)
 * with a set of permissions. Each principal can have at most one positive ACL entry
 * (specifying permissions to be granted to the principal) and one negative ACL entry
 * (specifying permissions to be denied). If there is already an ACL entry
 * of the same type (negative or positive) already in the ACL, false is returned.
 *
 * @param caller the principal invoking this method. It must be an owner
 *        of this ACL.
 * @param entry the ACL entry to be added to this ACL.
 * @return true on success, false if an entry of the same type (positive
 *       or negative) for the same principal is already present in this ACL.
 * @exception NotOwnerException if the caller principal is not an owner of
 *       this ACL.
 * @see java.security.Principal
 */
@Override
public boolean addEntry(Principal caller, AclEntry entry)
      throws NotOwnerException {
        if (!isOwner(caller))
              throw new NotOwnerException();

        if (entryList.contains(entry))
              return false;
        /*
               for (Enumeration e = entryList.elements();e.hasMoreElements();){
               AclEntry ent = (AclEntry) e.nextElement();
               if (ent.getPrincipal().equals(entry.getPrincipal()))
               return false;
               }
               */

        entryList.addElement(entry);
        return true;
}
 
源代码24 项目: jdk8u-jdk   文件: SnmpAcl.java
/**
 * Constructs the Java Dynamic Management(TM) Access Control List
 * based on IP addresses. The ACL will take the given owner name.
 * The current IP address will be the owner of the ACL.
 *
 * @param Owner The name of the ACL Owner.
 * @param aclFileName The name of the ACL File.
 *
 * @exception UnknownHostException If the local host is unknown.
 * @exception IllegalArgumentException If the ACL file doesn't exist.
 */
public SnmpAcl(String Owner, String aclFileName)
    throws UnknownHostException, IllegalArgumentException {
    trapDestList= new Hashtable<InetAddress, Vector<String>>();
    informDestList= new Hashtable<InetAddress, Vector<String>>();

    // PrincipalImpl() take the current host as entry
    owner = new PrincipalImpl();
    try {
        acl = new AclImpl(owner,Owner);
        AclEntry ownEntry = new AclEntryImpl(owner);
        ownEntry.addPermission(READ);
        ownEntry.addPermission(WRITE);
        acl.addEntry(owner,ownEntry);
    } catch (NotOwnerException ex) {
        if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_LOGGER.logp(Level.FINEST, SnmpAcl.class.getName(),
                "SnmpAcl(String,String)",
                "Should never get NotOwnerException as the owner " +
                "is built in this constructor");
        }
    }
    if (aclFileName == null) setDefaultFileName();
    else setAuthorizedListFile(aclFileName);
    readAuthorizedListFile();
}
 
源代码25 项目: jdk8u-jdk   文件: OwnerImpl.java
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * 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.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      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;
      }
}
 
源代码26 项目: hottub   文件: AclImpl.java
/**
 * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group)
 * with a set of permissions. Each principal can have at most one positive ACL entry
 * (specifying permissions to be granted to the principal) and one negative ACL entry
 * (specifying permissions to be denied). If there is already an ACL entry
 * of the same type (negative or positive) already in the ACL, false is returned.
 *
 * @param caller the principal invoking this method. It must be an owner
 *        of this ACL.
 * @param entry the ACL entry to be added to this ACL.
 * @return true on success, false if an entry of the same type (positive
 *       or negative) for the same principal is already present in this ACL.
 * @exception NotOwnerException if the caller principal is not an owner of
 *       this ACL.
 * @see java.security.Principal
 */
@Override
public boolean addEntry(Principal caller, AclEntry entry)
      throws NotOwnerException {
        if (!isOwner(caller))
              throw new NotOwnerException();

        if (entryList.contains(entry))
              return false;
        /*
               for (Enumeration e = entryList.elements();e.hasMoreElements();){
               AclEntry ent = (AclEntry) e.nextElement();
               if (ent.getPrincipal().equals(entry.getPrincipal()))
               return false;
               }
               */

        entryList.addElement(entry);
        return true;
}
 
源代码27 项目: hottub   文件: SnmpAcl.java
/**
 * Constructs the Java Dynamic Management(TM) Access Control List
 * based on IP addresses. The ACL will take the given owner name.
 * The current IP address will be the owner of the ACL.
 *
 * @param Owner The name of the ACL Owner.
 * @param aclFileName The name of the ACL File.
 *
 * @exception UnknownHostException If the local host is unknown.
 * @exception IllegalArgumentException If the ACL file doesn't exist.
 */
public SnmpAcl(String Owner, String aclFileName)
    throws UnknownHostException, IllegalArgumentException {
    trapDestList= new Hashtable<InetAddress, Vector<String>>();
    informDestList= new Hashtable<InetAddress, Vector<String>>();

    // PrincipalImpl() take the current host as entry
    owner = new PrincipalImpl();
    try {
        acl = new AclImpl(owner,Owner);
        AclEntry ownEntry = new AclEntryImpl(owner);
        ownEntry.addPermission(READ);
        ownEntry.addPermission(WRITE);
        acl.addEntry(owner,ownEntry);
    } catch (NotOwnerException ex) {
        if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
            SNMP_LOGGER.logp(Level.FINEST, SnmpAcl.class.getName(),
                "SnmpAcl(String,String)",
                "Should never get NotOwnerException as the owner " +
                "is built in this constructor");
        }
    }
    if (aclFileName == null) setDefaultFileName();
    else setAuthorizedListFile(aclFileName);
    readAuthorizedListFile();
}
 
源代码28 项目: hottub   文件: OwnerImpl.java
/**
 * Deletes an owner. If this is the last owner in the ACL, an exception is raised.
 *<P>
 * 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.
 */
public boolean deleteOwner(Principal caller, Principal owner)
              throws NotOwnerException,LastOwnerException {

      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;
      }
}
 
源代码29 项目: openjdk-8-source   文件: AclImpl.java
/**
 * Adds an ACL entry to this ACL. An entry associates a principal (e.g., an individual or a group)
 * with a set of permissions. Each principal can have at most one positive ACL entry
 * (specifying permissions to be granted to the principal) and one negative ACL entry
 * (specifying permissions to be denied). If there is already an ACL entry
 * of the same type (negative or positive) already in the ACL, false is returned.
 *
 * @param caller the principal invoking this method. It must be an owner
 *        of this ACL.
 * @param entry the ACL entry to be added to this ACL.
 * @return true on success, false if an entry of the same type (positive
 *       or negative) for the same principal is already present in this ACL.
 * @exception NotOwnerException if the caller principal is not an owner of
 *       this ACL.
 * @see java.security.Principal
 */
@Override
public boolean addEntry(Principal caller, AclEntry entry)
      throws NotOwnerException {
        if (!isOwner(caller))
              throw new NotOwnerException();

        if (entryList.contains(entry))
              return false;
        /*
               for (Enumeration e = entryList.elements();e.hasMoreElements();){
               AclEntry ent = (AclEntry) e.nextElement();
               if (ent.getPrincipal().equals(entry.getPrincipal()))
               return false;
               }
               */

        entryList.addElement(entry);
        return true;
}
 
源代码30 项目: jdk1.8-source-analysis   文件: SnmpAcl.java
/**
 * Resets this ACL to the values contained in the configuration file.
 *
 * @exception NotOwnerException If the principal attempting the reset is not an owner of this ACL.
 * @exception UnknownHostException If IP addresses for hosts contained in the ACL file couldn't be found.
 */
public void rereadTheFile() throws NotOwnerException, UnknownHostException {
    alwaysAuthorized = false;
    acl.removeAll(owner);
    trapDestList.clear();
    informDestList.clear();
    AclEntry ownEntry = new AclEntryImpl(owner);
    ownEntry.addPermission(READ);
    ownEntry.addPermission(WRITE);
    acl.addEntry(owner,ownEntry);
    readAuthorizedListFile();
}
 
 类所在包
 同包方法