java.security.acl.AclEntry Java Examples

The following examples show how to use java.security.acl.AclEntry. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AclImpl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #2
Source File: SnmpAcl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #3
Source File: SnmpAcl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #4
Source File: SnmpAcl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns ann enumeration of community strings. Community strings are returned as String.
 * @return The enumeration of community strings.
 */
public Enumeration<String> communities() {
    HashSet<String> set = new HashSet<String>();
    Vector<String> res = new Vector<String>();
    for (Enumeration<AclEntry> e = acl.entries() ; e.hasMoreElements() ;) {
        AclEntryImpl entry = (AclEntryImpl) e.nextElement();
        for (Enumeration<String> cs = entry.communities();
             cs.hasMoreElements() ;) {
            set.add(cs.nextElement());
        }
    }
    String[] objs = set.toArray(new String[0]);
    for(int i = 0; i < objs.length; i++)
        res.addElement(objs[i]);

    return res.elements();
}
 
Example #5
Source File: AclImpl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #6
Source File: AclImpl.java    From TencentKona-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #7
Source File: SnmpAcl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns ann enumeration of community strings. Community strings are returned as String.
 * @return The enumeration of community strings.
 */
public Enumeration<String> communities() {
    HashSet<String> set = new HashSet<String>();
    Vector<String> res = new Vector<String>();
    for (Enumeration<AclEntry> e = acl.entries() ; e.hasMoreElements() ;) {
        AclEntryImpl entry = (AclEntryImpl) e.nextElement();
        for (Enumeration<String> cs = entry.communities();
             cs.hasMoreElements() ;) {
            set.add(cs.nextElement());
        }
    }
    String[] objs = set.toArray(new String[0]);
    for(int i = 0; i < objs.length; i++)
        res.addElement(objs[i]);

    return res.elements();
}
 
Example #8
Source File: SnmpAcl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns ann enumeration of community strings. Community strings are returned as String.
 * @return The enumeration of community strings.
 */
public Enumeration<String> communities() {
    HashSet<String> set = new HashSet<String>();
    Vector<String> res = new Vector<String>();
    for (Enumeration<AclEntry> e = acl.entries() ; e.hasMoreElements() ;) {
        AclEntryImpl entry = (AclEntryImpl) e.nextElement();
        for (Enumeration<String> cs = entry.communities();
             cs.hasMoreElements() ;) {
            set.add(cs.nextElement());
        }
    }
    String[] objs = set.toArray(new String[0]);
    for(int i = 0; i < objs.length; i++)
        res.addElement(objs[i]);

    return res.elements();
}
 
Example #9
Source File: AclImpl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #10
Source File: SnmpAcl.java    From dragonwell8_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #11
Source File: SnmpAcl.java    From jdk8u60 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #12
Source File: AclImpl.java    From JDKSourceCode1.8 with MIT License 6 votes vote down vote up
/**
 * 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;
}
 
Example #13
Source File: SnmpAcl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns ann enumeration of community strings. Community strings are returned as String.
 * @return The enumeration of community strings.
 */
public Enumeration<String> communities() {
    HashSet<String> set = new HashSet<String>();
    Vector<String> res = new Vector<String>();
    for (Enumeration<AclEntry> e = acl.entries() ; e.hasMoreElements() ;) {
        AclEntryImpl entry = (AclEntryImpl) e.nextElement();
        for (Enumeration<String> cs = entry.communities();
             cs.hasMoreElements() ;) {
            set.add(cs.nextElement());
        }
    }
    String[] objs = set.toArray(new String[0]);
    for(int i = 0; i < objs.length; i++)
        res.addElement(objs[i]);

    return res.elements();
}
 
Example #14
Source File: SnmpAcl.java    From hottub with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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();
}
 
Example #15
Source File: SnmpAcl.java    From jdk8u-jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns ann enumeration of community strings. Community strings are returned as String.
 * @return The enumeration of community strings.
 */
public Enumeration<String> communities() {
    HashSet<String> set = new HashSet<String>();
    Vector<String> res = new Vector<String>();
    for (Enumeration<AclEntry> e = acl.entries() ; e.hasMoreElements() ;) {
        AclEntryImpl entry = (AclEntryImpl) e.nextElement();
        for (Enumeration<String> cs = entry.communities();
             cs.hasMoreElements() ;) {
            set.add(cs.nextElement());
        }
    }
    String[] objs = set.toArray(new String[0]);
    for(int i = 0; i < objs.length; i++)
        res.addElement(objs[i]);

    return res.elements();
}
 
Example #16
Source File: SnmpAcl.java    From openjdk-8 with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns ann enumeration of community strings. Community strings are returned as String.
 * @return The enumeration of community strings.
 */
public Enumeration<String> communities() {
    HashSet<String> set = new HashSet<String>();
    Vector<String> res = new Vector<String>();
    for (Enumeration<AclEntry> e = acl.entries() ; e.hasMoreElements() ;) {
        AclEntryImpl entry = (AclEntryImpl) e.nextElement();
        for (Enumeration<String> cs = entry.communities();
             cs.hasMoreElements() ;) {
            set.add(cs.nextElement());
        }
    }
    String[] objs = set.toArray(new String[0]);
    for(int i = 0; i < objs.length; i++)
        res.addElement(objs[i]);

    return res.elements();
}
 
Example #17
Source File: SnmpAcl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns ann enumeration of community strings. Community strings are returned as String.
 * @return The enumeration of community strings.
 */
public Enumeration<String> communities() {
    HashSet<String> set = new HashSet<String>();
    Vector<String> res = new Vector<String>();
    for (Enumeration<AclEntry> e = acl.entries() ; e.hasMoreElements() ;) {
        AclEntryImpl entry = (AclEntryImpl) e.nextElement();
        for (Enumeration<String> cs = entry.communities();
             cs.hasMoreElements() ;) {
            set.add(cs.nextElement());
        }
    }
    String[] objs = set.toArray(new String[0]);
    for(int i = 0; i < objs.length; i++)
        res.addElement(objs[i]);

    return res.elements();
}
 
Example #18
Source File: AclImpl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #19
Source File: AclImpl.java    From openjdk-8-source with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #20
Source File: SnmpAcl.java    From jdk1.8-source-analysis with Apache License 2.0 6 votes vote down vote up
/**
 * Returns ann enumeration of community strings. Community strings are returned as String.
 * @return The enumeration of community strings.
 */
public Enumeration<String> communities() {
    HashSet<String> set = new HashSet<String>();
    Vector<String> res = new Vector<String>();
    for (Enumeration<AclEntry> e = acl.entries() ; e.hasMoreElements() ;) {
        AclEntryImpl entry = (AclEntryImpl) e.nextElement();
        for (Enumeration<String> cs = entry.communities();
             cs.hasMoreElements() ;) {
            set.add(cs.nextElement());
        }
    }
    String[] objs = set.toArray(new String[0]);
    for(int i = 0; i < objs.length; i++)
        res.addElement(objs[i]);

    return res.elements();
}
 
Example #21
Source File: AclImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 6 votes vote down vote up
/**
 * 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;
}
 
Example #22
Source File: SnmpAcl.java    From jdk8u_jdk with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns ann enumeration of community strings. Community strings are returned as String.
 * @return The enumeration of community strings.
 */
public Enumeration<String> communities() {
    HashSet<String> set = new HashSet<String>();
    Vector<String> res = new Vector<String>();
    for (Enumeration<AclEntry> e = acl.entries() ; e.hasMoreElements() ;) {
        AclEntryImpl entry = (AclEntryImpl) e.nextElement();
        for (Enumeration<String> cs = entry.communities();
             cs.hasMoreElements() ;) {
            set.add(cs.nextElement());
        }
    }
    String[] objs = set.toArray(new String[0]);
    for(int i = 0; i < objs.length; i++)
        res.addElement(objs[i]);

    return res.elements();
}
 
Example #23
Source File: SnmpAcl.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #24
Source File: SnmpAcl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #25
Source File: SnmpAcl.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #26
Source File: SnmpAcl.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #27
Source File: SnmpAcl.java    From jdk8u-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * 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();
}
 
Example #28
Source File: AclImpl.java    From openjdk-8-source with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Checks whether or not the specified community string is defined.
 *
 * @param community the community name associated with the principal.
 *
 * @return true if the specified community string is defined, false
 *      otherwise.
 * @see java.security.Principal
 * @see java.security.Permission
 */
public boolean checkCommunity(String community) {
      for (Enumeration<AclEntry> e = entryList.elements();e.hasMoreElements();){
        AclEntryImpl ent = (AclEntryImpl) e.nextElement();
        if (ent.checkCommunity(community)) return true;
      }
      return false;
}
 
Example #29
Source File: AclImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Checks whether or not the specified principal has the specified
 * permission.
 * If it does, true is returned, otherwise false is returned.
 * More specifically, this method checks whether the passed permission
 * is a member of the allowed permission set of the specified principal.
 * The allowed permission set is determined by the same algorithm as is
 * used by the getPermissions method.
 *
 * @param user the principal, assumed to be a valid authenticated Principal.
 * @param community the community name associated with the principal.
 * @param perm the permission to be checked for.
 * @return true if the principal has the specified permission, false
 *        otherwise.
 * @see java.security.Principal
 * @see java.security.Permission
 */
public boolean checkPermission(Principal user, String community,
                               java.security.acl.Permission perm) {
      for (Enumeration<AclEntry> e = entryList.elements();e.hasMoreElements();){
        AclEntryImpl ent = (AclEntryImpl) e.nextElement();
        if (ent.getPrincipal().equals(user))
              if (ent.checkPermission(perm) && ent.checkCommunity(community)) return true;
      }
      return false;
}
 
Example #30
Source File: AclImpl.java    From openjdk-jdk8u with GNU General Public License v2.0 3 votes vote down vote up
/**
 * Checks whether or not the specified community string is defined.
 *
 * @param community the community name associated with the principal.
 *
 * @return true if the specified community string is defined, false
 *      otherwise.
 * @see java.security.Principal
 * @see java.security.Permission
 */
public boolean checkCommunity(String community) {
      for (Enumeration<AclEntry> e = entryList.elements();e.hasMoreElements();){
        AclEntryImpl ent = (AclEntryImpl) e.nextElement();
        if (ent.checkCommunity(community)) return true;
      }
      return false;
}