/* */ public boolean checkCommunity(String paramString) /* */ { /* 272 */ for (Enumeration localEnumeration = this.entryList.elements(); localEnumeration.hasMoreElements(); ) { /* 273 */ AclEntryImpl localAclEntryImpl = (AclEntryImpl) localEnumeration.nextElement(); /* 274 */ if (localAclEntryImpl.checkCommunity(paramString)) return true; /* */ } /* 276 */ return false; /* */ }
/* */ public boolean checkPermission( Principal paramPrincipal, String paramString, Permission paramPermission) /* */ { /* 253 */ for (Enumeration localEnumeration = this.entryList.elements(); localEnumeration.hasMoreElements(); ) { /* 254 */ AclEntryImpl localAclEntryImpl = (AclEntryImpl) localEnumeration.nextElement(); /* 255 */ if ((localAclEntryImpl.getPrincipal().equals(paramPrincipal)) && /* 256 */ (localAclEntryImpl.checkPermission(paramPermission)) && (localAclEntryImpl.checkCommunity(paramString))) return true; /* */ } /* 258 */ return false; /* */ }
/** * 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(); }
/** Converts the input configuration file into ACL. */ private void readAuthorizedListFile() { alwaysAuthorized = false; if (authorizedListFile == null) { if (SNMP_LOGGER.isLoggable(Level.FINER)) { SNMP_LOGGER.logp( Level.FINER, SnmpAcl.class.getName(), "readAuthorizedListFile", "alwaysAuthorized set to true"); } alwaysAuthorized = true; } else { // Read the file content Parser parser = null; try { parser = new Parser(new FileInputStream(getAuthorizedListFile())); } catch (FileNotFoundException e) { if (SNMP_LOGGER.isLoggable(Level.FINEST)) { SNMP_LOGGER.logp( Level.FINEST, SnmpAcl.class.getName(), "readAuthorizedListFile", "The specified file was not found, authorize everybody"); } alwaysAuthorized = true; return; } try { JDMSecurityDefs n = parser.SecurityDefs(); n.buildAclEntries(owner, acl); n.buildTrapEntries(trapDestList); n.buildInformEntries(informDestList); } catch (ParseException e) { if (SNMP_LOGGER.isLoggable(Level.FINEST)) { SNMP_LOGGER.logp( Level.FINEST, SnmpAcl.class.getName(), "readAuthorizedListFile", "Got parsing exception", e); } throw new IllegalArgumentException(e.getMessage()); } catch (Error err) { if (SNMP_LOGGER.isLoggable(Level.FINEST)) { SNMP_LOGGER.logp( Level.FINEST, SnmpAcl.class.getName(), "readAuthorizedListFile", "Got unexpected error", err); } throw new IllegalArgumentException(err.getMessage()); } for (Enumeration<AclEntry> e = acl.entries(); e.hasMoreElements(); ) { AclEntryImpl aa = (AclEntryImpl) e.nextElement(); if (SNMP_LOGGER.isLoggable(Level.FINER)) { SNMP_LOGGER.logp( Level.FINER, SnmpAcl.class.getName(), "readAuthorizedListFile", "===> " + aa.getPrincipal().toString()); } for (Enumeration<java.security.acl.Permission> eee = aa.permissions(); eee.hasMoreElements(); ) { java.security.acl.Permission perm = eee.nextElement(); if (SNMP_LOGGER.isLoggable(Level.FINER)) { SNMP_LOGGER.logp( Level.FINER, SnmpAcl.class.getName(), "readAuthorizedListFile", "perm = " + perm); } } } } }