/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
// java import
//
// SNMP Runtime import
//
/**
* Defines an implementation of the {@link com.sun.jmx.snmp.InetAddressAcl InetAddressAcl} interface.
* <p>
* In this implementation the ACL information is stored on a flat file and
* {@link #getDefaultAclFileName()}
* <p>
* <OL>
*
* <p><b>This API is a Sun Microsystems internal API and is subject
* to change without notice.</b></p>
*/
/**
* 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.
*
* @exception UnknownHostException If the local host is unknown.
* @exception IllegalArgumentException If the ACL file doesn't exist.
*/
throws UnknownHostException, IllegalArgumentException {
}
/**
* 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.
*/
throws UnknownHostException, IllegalArgumentException {
// PrincipalImpl() take the current host as entry
owner = new PrincipalImpl();
try {
} catch (NotOwnerException ex) {
"SnmpAcl(String,String)",
"Should never get NotOwnerException as the owner " +
"is built in this constructor");
}
}
else setAuthorizedListFile(aclFileName);
}
/**
* Returns an enumeration of the entries in this ACL. Each element in the
* enumeration is of type <CODE>java.security.acl.AclEntry</CODE>.
*
* @return An enumeration of the entries in this ACL.
*/
}
/**
* Returns ann enumeration of community strings. Community strings are returned as String.
* @return The enumeration of community strings.
*/
cs.hasMoreElements() ;) {
}
}
}
/**
* Returns the name of the ACL.
*
* @return The name of the ACL.
*/
}
/**
* Returns the read permission instance used.
*
* @return The read permission instance.
*/
return READ;
}
/**
* Returns the write permission instance used.
*
* @return The write permission instance.
*/
return WRITE;
}
/**
* Get the default name for the ACL file.
* @return The default name for the ACL file.
**/
final String fileSeparator =
final StringBuffer defaultAclName =
append("snmp.acl");
return defaultAclName.toString();
}
/**
* Sets the full path of the file containing the ACL information.
*
* @param filename The full path of the file containing the ACL information.
* @throws IllegalArgumentException If the passed ACL file doesn't exist.
*/
throws IllegalArgumentException {
}
throw new
"doesn't exist or is not a file, "+
"no configuration loaded");
}
}
}
/**
* 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.
*/
alwaysAuthorized = false;
}
/**
* Returns the full path of the file used to get ACL information.
*
* @return The full path of the file used to get ACL information.
*/
return authorizedListFile;
}
/**
* Checks whether or not the specified host has <CODE>READ</CODE> access.
*
* @param address The host address to check.
*
* @return <CODE>true</CODE> if the host has read permission, <CODE>false</CODE> otherwise.
*/
if (alwaysAuthorized) return ( true );
}
/**
* Checks whether or not the specified host and community have <CODE>READ</CODE> access.
*
* @param address The host address to check.
* @param community The community associated with the host.
*
* @return <CODE>true</CODE> if the pair (host, community) has read permission, <CODE>false</CODE> otherwise.
*/
if (alwaysAuthorized) return ( true );
}
/**
* Checks whether or not a community string is defined.
*
* @param community The community to check.
*
* @return <CODE>true</CODE> if the community is known, <CODE>false</CODE> otherwise.
*/
}
/**
* Checks whether or not the specified host has <CODE>WRITE</CODE> access.
*
* @param address The host address to check.
*
* @return <CODE>true</CODE> if the host has write permission, <CODE>false</CODE> otherwise.
*/
if (alwaysAuthorized) return ( true );
}
/**
* Checks whether or not the specified host and community have <CODE>WRITE</CODE> access.
*
* @param address The host address to check.
* @param community The community associated with the host.
*
* @return <CODE>true</CODE> if the pair (host, community) has write permission, <CODE>false</CODE> otherwise.
*/
if (alwaysAuthorized) return ( true );
}
/**
* Returns an enumeration of trap destinations.
*
* @return An enumeration of the trap destinations (enumeration of <CODE>InetAddress</CODE>).
*/
return trapDestList.keys();
}
/**
* Returns an enumeration of trap communities for a given host.
*
* @param i The address of the host.
*
* @return An enumeration of trap communities for a given host (enumeration of <CODE>String</CODE>).
*/
}
} else {
}
}
}
/**
* Returns an enumeration of inform destinations.
*
* @return An enumeration of the inform destinations (enumeration of <CODE>InetAddress</CODE>).
*/
return informDestList.keys();
}
/**
* Returns an enumeration of inform communities for a given host.
*
* @param i The address of the host.
*
* @return An enumeration of inform communities for a given host (enumeration of <CODE>String</CODE>).
*/
}
} else {
}
}
}
/**
* Converts the input configuration file into ACL.
*/
private void readAuthorizedListFile() {
alwaysAuthorized = false;
if (authorizedListFile == null) {
"readAuthorizedListFile", "alwaysAuthorized set to true");
}
alwaysAuthorized = true ;
} else {
// Read the file content
try {
} catch (FileNotFoundException e) {
"readAuthorizedListFile",
"The specified file was not found, authorize everybody");
}
alwaysAuthorized = true ;
return;
}
try {
} catch (ParseException e) {
"readAuthorizedListFile", "Got parsing exception", e);
}
throw new IllegalArgumentException(e.getMessage());
}
}
"readAuthorizedListFile",
}
}
}
}
}
}
/**
* Set the default full path for "snmp.acl" input file.
* Do not complain if the file does not exists.
*/
private void setDefaultFileName() {
try {
} catch (IllegalArgumentException x) {
// OK...
}
}
// PRIVATE VARIABLES
//------------------
/**
* Represents the Access Control List.
*/
/**
* Flag indicating whether the access is always authorized.
* <BR>This is the case if there is no flat file defined.
*/
private boolean alwaysAuthorized = false;
/**
* Represents the Access Control List flat file.
*/
/**
* Contains the hosts list for trap destination.
*/
/**
* Contains the hosts list for inform destination.
*/
}