feat(jdk8): move files to new folder to avoid resources compiled.

This commit is contained in:
2025-09-07 15:25:52 +08:00
parent 3f0047bf6f
commit 8c35cfb1c0
17415 changed files with 217 additions and 213 deletions

View File

@@ -0,0 +1,402 @@
/*
* Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JavaCC: Do not edit this line. ASCII_CharStream.java Version 0.7pre6 */
package com.sun.jmx.snmp.IPAcl;
/**
* An implementation of interface CharStream, where the stream is assumed to
* contain only ASCII characters (without unicode processing).
*/
final class ASCII_CharStream
{
public static final boolean staticFlag = false;
int bufsize;
int available;
int tokenBegin;
public int bufpos = -1;
private int bufline[];
private int bufcolumn[];
private int column = 0;
private int line = 1;
private boolean prevCharIsCR = false;
private boolean prevCharIsLF = false;
private java.io.Reader inputStream;
private char[] buffer;
private int maxNextCharInd = 0;
private int inBuf = 0;
private final void ExpandBuff(boolean wrapAround)
{
char[] newbuffer = new char[bufsize + 2048];
int newbufline[] = new int[bufsize + 2048];
int newbufcolumn[] = new int[bufsize + 2048];
try
{
if (wrapAround)
{
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
System.arraycopy(buffer, 0, newbuffer,
bufsize - tokenBegin, bufpos);
buffer = newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
System.arraycopy(bufline, 0, newbufline, bufsize - tokenBegin, bufpos);
bufline = newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
System.arraycopy(bufcolumn, 0, newbufcolumn, bufsize - tokenBegin, bufpos);
bufcolumn = newbufcolumn;
maxNextCharInd = (bufpos += (bufsize - tokenBegin));
}
else
{
System.arraycopy(buffer, tokenBegin, newbuffer, 0, bufsize - tokenBegin);
buffer = newbuffer;
System.arraycopy(bufline, tokenBegin, newbufline, 0, bufsize - tokenBegin);
bufline = newbufline;
System.arraycopy(bufcolumn, tokenBegin, newbufcolumn, 0, bufsize - tokenBegin);
bufcolumn = newbufcolumn;
maxNextCharInd = (bufpos -= tokenBegin);
}
}
catch (Throwable t)
{
throw new Error(t.getMessage());
}
bufsize += 2048;
available = bufsize;
tokenBegin = 0;
}
private final void FillBuff() throws java.io.IOException
{
if (maxNextCharInd == available)
{
if (available == bufsize)
{
if (tokenBegin > 2048)
{
bufpos = maxNextCharInd = 0;
available = tokenBegin;
}
else if (tokenBegin < 0)
bufpos = maxNextCharInd = 0;
else
ExpandBuff(false);
}
else if (available > tokenBegin)
available = bufsize;
else if ((tokenBegin - available) < 2048)
ExpandBuff(true);
else
available = tokenBegin;
}
int i;
try {
if ((i = inputStream.read(buffer, maxNextCharInd,
available - maxNextCharInd)) == -1)
{
inputStream.close();
throw new java.io.IOException();
}
else
maxNextCharInd += i;
return;
}
catch(java.io.IOException e) {
--bufpos;
backup(0);
if (tokenBegin == -1)
tokenBegin = bufpos;
throw e;
}
}
public final char BeginToken() throws java.io.IOException
{
tokenBegin = -1;
char c = readChar();
tokenBegin = bufpos;
return c;
}
private final void UpdateLineColumn(char c)
{
column++;
if (prevCharIsLF)
{
prevCharIsLF = false;
line += (column = 1);
}
else if (prevCharIsCR)
{
prevCharIsCR = false;
if (c == '\n')
{
prevCharIsLF = true;
}
else
line += (column = 1);
}
switch (c)
{
case '\r' :
prevCharIsCR = true;
break;
case '\n' :
prevCharIsLF = true;
break;
case '\t' :
column--;
column += (8 - (column & 07));
break;
default :
break;
}
bufline[bufpos] = line;
bufcolumn[bufpos] = column;
}
public final char readChar() throws java.io.IOException
{
if (inBuf > 0)
{
--inBuf;
return (char)((char)0xff & buffer[(bufpos == bufsize - 1) ? (bufpos = 0) : ++bufpos]);
}
if (++bufpos >= maxNextCharInd)
FillBuff();
char c = (char)((char)0xff & buffer[bufpos]);
UpdateLineColumn(c);
return (c);
}
/**
* @deprecated
* @see #getEndColumn
*/
@Deprecated
public final int getColumn() {
return bufcolumn[bufpos];
}
/**
* @deprecated
* @see #getEndLine
*/
@Deprecated
public final int getLine() {
return bufline[bufpos];
}
public final int getEndColumn() {
return bufcolumn[bufpos];
}
public final int getEndLine() {
return bufline[bufpos];
}
public final int getBeginColumn() {
return bufcolumn[tokenBegin];
}
public final int getBeginLine() {
return bufline[tokenBegin];
}
public final void backup(int amount) {
inBuf += amount;
if ((bufpos -= amount) < 0)
bufpos += bufsize;
}
public ASCII_CharStream(java.io.Reader dstream, int startline,
int startcolumn, int buffersize)
{
inputStream = dstream;
line = startline;
column = startcolumn - 1;
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
}
public ASCII_CharStream(java.io.Reader dstream, int startline,
int startcolumn)
{
this(dstream, startline, startcolumn, 4096);
}
public void ReInit(java.io.Reader dstream, int startline,
int startcolumn, int buffersize)
{
inputStream = dstream;
line = startline;
column = startcolumn - 1;
if (buffer == null || buffersize != buffer.length)
{
available = bufsize = buffersize;
buffer = new char[buffersize];
bufline = new int[buffersize];
bufcolumn = new int[buffersize];
}
prevCharIsLF = prevCharIsCR = false;
tokenBegin = inBuf = maxNextCharInd = 0;
bufpos = -1;
}
public void ReInit(java.io.Reader dstream, int startline,
int startcolumn)
{
ReInit(dstream, startline, startcolumn, 4096);
}
public ASCII_CharStream(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
this(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
public ASCII_CharStream(java.io.InputStream dstream, int startline,
int startcolumn)
{
this(dstream, startline, startcolumn, 4096);
}
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn, int buffersize)
{
ReInit(new java.io.InputStreamReader(dstream), startline, startcolumn, 4096);
}
public void ReInit(java.io.InputStream dstream, int startline,
int startcolumn)
{
ReInit(dstream, startline, startcolumn, 4096);
}
public final String GetImage()
{
if (bufpos >= tokenBegin)
return new String(buffer, tokenBegin, bufpos - tokenBegin + 1);
else
return new String(buffer, tokenBegin, bufsize - tokenBegin) +
new String(buffer, 0, bufpos + 1);
}
public final char[] GetSuffix(int len)
{
char[] ret = new char[len];
if ((bufpos + 1) >= len)
System.arraycopy(buffer, bufpos - len + 1, ret, 0, len);
else
{
System.arraycopy(buffer, bufsize - (len - bufpos - 1), ret, 0,
len - bufpos - 1);
System.arraycopy(buffer, 0, ret, len - bufpos - 1, bufpos + 1);
}
return ret;
}
public void Done()
{
buffer = null;
bufline = null;
bufcolumn = null;
}
/**
* Method to adjust line and column numbers for the start of a token.
*/
public void adjustBeginLineColumn(int newLine, int newCol)
{
int start = tokenBegin;
int len;
if (bufpos >= tokenBegin)
{
len = bufpos - tokenBegin + inBuf + 1;
}
else
{
len = bufsize - tokenBegin + bufpos + 1 + inBuf;
}
int i = 0, j = 0, k = 0;
int nextColDiff = 0, columnDiff = 0;
while (i < len &&
bufline[j = start % bufsize] == bufline[k = ++start % bufsize])
{
bufline[j] = newLine;
nextColDiff = columnDiff + bufcolumn[k] - bufcolumn[j];
bufcolumn[j] = newCol + columnDiff;
columnDiff = nextColDiff;
i++;
}
if (i < len)
{
bufline[j] = newLine++;
bufcolumn[j] = newCol + columnDiff;
while (i++ < len)
{
if (bufline[j = start % bufsize] != bufline[++start % bufsize])
bufline[j] = newLine++;
else
bufline[j] = newLine;
}
}
line = bufline[j];
column = bufcolumn[j];
}
}

View File

@@ -0,0 +1,263 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.jmx.snmp.IPAcl;
import java.security.acl.Permission;
import java.util.Vector;
import java.util.Enumeration;
import java.io.Serializable;
import java.net.UnknownHostException;
import java.security.Principal;
import java.security.acl.AclEntry;
/**
* Represent one entry in the Access Control List (ACL).
* This ACL entry object contains a permission associated with a particular principal.
* (A principal represents an entity such as an individual machine or a group).
*
* @see java.security.acl.AclEntry
*/
class AclEntryImpl implements AclEntry, Serializable {
private static final long serialVersionUID = -5047185131260073216L;
private AclEntryImpl (AclEntryImpl i) throws UnknownHostException {
setPrincipal(i.getPrincipal());
permList = new Vector<Permission>();
commList = new Vector<String>();
for (Enumeration<String> en = i.communities(); en.hasMoreElements();){
addCommunity(en.nextElement());
}
for (Enumeration<Permission> en = i.permissions(); en.hasMoreElements();){
addPermission(en.nextElement());
}
if (i.isNegative()) setNegativePermissions();
}
/**
* Contructs an empty ACL entry.
*/
public AclEntryImpl (){
princ = null;
permList = new Vector<Permission>();
commList = new Vector<String>();
}
/**
* Constructs an ACL entry with a specified principal.
*
* @param p the principal to be set for this entry.
*/
public AclEntryImpl (Principal p) throws UnknownHostException {
princ = p;
permList = new Vector<Permission>();
commList = new Vector<String>();
}
/**
* Clones this ACL entry.
*
* @return a clone of this ACL entry.
*/
public Object clone() {
AclEntryImpl i;
try {
i = new AclEntryImpl(this);
}catch (UnknownHostException e) {
i = null;
}
return (Object) i;
}
/**
* Returns true if this is a negative ACL entry (one denying the associated principal
* the set of permissions in the entry), false otherwise.
*
* @return true if this is a negative ACL entry, false if it's not.
*/
public boolean isNegative(){
return neg;
}
/**
* Adds the specified permission to this ACL entry. Note: An entry can
* have multiple permissions.
*
* @param perm the permission to be associated with the principal in this
* entry
* @return true if the permission is removed, false if the permission was
* not part of this entry's permission set.
*
*/
public boolean addPermission(java.security.acl.Permission perm){
if (permList.contains(perm)) return false;
permList.addElement(perm);
return true;
}
/**
* Removes the specified permission from this ACL entry.
*
* @param perm the permission to be removed from this entry.
* @return true if the permission is removed, false if the permission
* was not part of this entry's permission set.
*/
public boolean removePermission(java.security.acl.Permission perm){
if (!permList.contains(perm)) return false;
permList.removeElement(perm);
return true;
}
/**
* Checks if the specified permission is part of the permission set in
* this entry.
*
* @param perm the permission to be checked for.
* @return true if the permission is part of the permission set in this
* entry, false otherwise.
*/
public boolean checkPermission(java.security.acl.Permission perm){
return (permList.contains(perm));
}
/**
* Returns an enumeration of the permissions in this ACL entry.
*
* @return an enumeration of the permissions in this ACL entry.
*/
public Enumeration<Permission> permissions(){
return permList.elements();
}
/**
* Sets this ACL entry to be a negative one. That is, the associated principal
* (e.g., a user or a group) will be denied the permission set specified in the
* entry. Note: ACL entries are by default positive. An entry becomes a negative
* entry only if this setNegativePermissions method is called on it.
*
* Not Implemented.
*/
public void setNegativePermissions(){
neg = true;
}
/**
* Returns the principal for which permissions are granted or denied by this ACL
* entry. Returns null if there is no principal set for this entry yet.
*
* @return the principal associated with this entry.
*/
public Principal getPrincipal(){
return princ;
}
/**
* Specifies the principal for which permissions are granted or denied by
* this ACL entry. If a principal was already set for this ACL entry,
* false is returned, otherwise true is returned.
*
* @param p the principal to be set for this entry.
* @return true if the principal is set, false if there was already a
* principal set for this entry.
*/
public boolean setPrincipal(Principal p) {
if (princ != null )
return false;
princ = p;
return true;
}
/**
* Returns a string representation of the contents of this ACL entry.
*
* @return a string representation of the contents.
*/
public String toString(){
return "AclEntry:"+princ.toString();
}
/**
* Returns an enumeration of the communities in this ACL entry.
*
* @return an enumeration of the communities in this ACL entry.
*/
public Enumeration<String> communities(){
return commList.elements();
}
/**
* Adds the specified community to this ACL entry. Note: An entry can
* have multiple communities.
*
* @param comm the community to be associated with the principal
* in this entry.
* @return true if the community was added, false if the community was
* already part of this entry's community set.
*/
public boolean addCommunity(String comm){
if (commList.contains(comm)) return false;
commList.addElement(comm);
return true;
}
/**
* Removes the specified community from this ACL entry.
*
* @param comm the community to be removed from this entry.
* @return true if the community is removed, false if the community was
* not part of this entry's community set.
*/
public boolean removeCommunity(String comm){
if (!commList.contains(comm)) return false;
commList.removeElement(comm);
return true;
}
/**
* Checks if the specified community is part of the community set in this
* entry.
*
* @param comm the community to be checked for.
* @return true if the community is part of the community set in this
* entry, false otherwise.
*/
public boolean checkCommunity(String comm){
return (commList.contains(comm));
}
private Principal princ = null;
private boolean neg = false;
private Vector<Permission> permList = null;
private Vector<String> commList = null;
}

View File

@@ -0,0 +1,295 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.jmx.snmp.IPAcl;
import java.security.Principal;
import java.security.acl.Acl;
import java.security.acl.AclEntry;
import java.security.acl.NotOwnerException;
import java.io.Serializable;
import java.security.acl.Permission;
import java.util.Vector;
import java.util.Enumeration;
/**
* Represent an Access Control List (ACL) which is used to guard access to http adaptor.
* <P>
* It is a data structure with multiple ACL entries. Each ACL entry, of interface type
* AclEntry, contains a set of permissions and a set of communities associated with a
* particular principal. (A principal represents an entity such as a host or a group of host).
* Additionally, each ACL entry is specified as being either positive or negative.
* If positive, the permissions are to be granted to the associated principal.
* If negative, the permissions are to be denied.
*
* @see java.security.acl.Acl
*/
class AclImpl extends OwnerImpl implements Acl, Serializable {
private static final long serialVersionUID = -2250957591085270029L;
private Vector<AclEntry> entryList = null;
private String aclName = null;
/**
* Constructs the ACL with a specified owner
*
* @param owner owner of the ACL.
* @param name name of this ACL.
*/
public AclImpl (PrincipalImpl owner, String name) {
super(owner);
entryList = new Vector<>();
aclName = name;
}
/**
* Sets the name of this ACL.
*
* @param caller the principal invoking this method. It must be an owner
* of this ACL.
* @param name the name to be given to this ACL.
*
* @exception NotOwnerException if the caller principal is not an owner
* of this ACL.
* @see java.security.Principal
*/
@Override
public void setName(Principal caller, String name)
throws NotOwnerException {
if (!isOwner(caller))
throw new NotOwnerException();
aclName = name;
}
/**
* Returns the name of this ACL.
*
* @return the name of this ACL.
*/
@Override
public String getName(){
return aclName;
}
/**
* 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;
}
/**
* Removes an ACL entry from this ACL.
*
* @param caller the principal invoking this method. It must be an owner
* of this ACL.
* @param entry the ACL entry to be removed from this ACL.
* @return true on success, false if the entry is not part of this ACL.
* @exception NotOwnerException if the caller principal is not an owner
* of this Acl.
* @see java.security.Principal
* @see java.security.acl.AclEntry
*/
@Override
public boolean removeEntry(Principal caller, AclEntry entry)
throws NotOwnerException {
if (!isOwner(caller))
throw new NotOwnerException();
return (entryList.removeElement(entry));
}
/**
* Removes all ACL entries from this ACL.
*
* @param caller the principal invoking this method. It must be an owner
* of this ACL.
* @exception NotOwnerException if the caller principal is not an owner of
* this Acl.
* @see java.security.Principal
*/
public void removeAll(Principal caller)
throws NotOwnerException {
if (!isOwner(caller))
throw new NotOwnerException();
entryList.removeAllElements();
}
/**
* Returns an enumeration for the set of allowed permissions for
* the specified principal
* (representing an entity such as an individual or a group).
* This set of allowed permissions is calculated as follows:
* <UL>
* <LI>If there is no entry in this Access Control List for the specified
* principal, an empty permission set is returned.</LI>
* <LI>Otherwise, the principal's group permission sets are determined.
* (A principal can belong to one or more groups, where a group is a group
* of principals, represented by the Group interface.)</LI>
* </UL>
* @param user the principal whose permission set is to be returned.
* @return the permission set specifying the permissions the principal
* is allowed.
* @see java.security.Principal
*/
@Override
public Enumeration<Permission> getPermissions(Principal user){
Vector<Permission> empty = new Vector<>();
for (Enumeration<AclEntry> e = entryList.elements();e.hasMoreElements();){
AclEntry ent = e.nextElement();
if (ent.getPrincipal().equals(user))
return ent.permissions();
}
return empty.elements();
}
/**
* Returns an enumeration of the entries in this ACL. Each element in the
* enumeration is of type AclEntry.
*
* @return an enumeration of the entries in this ACL.
*/
@Override
public Enumeration<AclEntry> entries(){
return entryList.elements();
}
/**
* 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 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
*/
@Override
public boolean checkPermission(Principal user,
java.security.acl.Permission perm) {
for (Enumeration<AclEntry> e = entryList.elements();e.hasMoreElements();){
AclEntry ent = e.nextElement();
if (ent.getPrincipal().equals(user))
if (ent.checkPermission(perm)) return true;
}
return false;
}
/**
* 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;
}
/**
* 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;
}
/**
* Returns a string representation of the ACL contents.
*
* @return a string representation of the ACL contents.
*/
@Override
public String toString(){
return ("AclImpl: "+ getName());
}
}

View File

@@ -0,0 +1,142 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.jmx.snmp.IPAcl;
import java.util.Vector;
import java.util.Enumeration;
import java.io.Serializable;
import java.net.UnknownHostException;
import java.security.Principal;
import java.security.acl.Group;
/**
* This class is used to represent a subnet mask (a group of hosts
* matching the same
* IP mask).
*
*/
class GroupImpl extends PrincipalImpl implements Group, Serializable {
private static final long serialVersionUID = -7777387035032541168L;
/**
* Constructs an empty group.
* @exception UnknownHostException Not implemented
*/
public GroupImpl () throws UnknownHostException {
}
/**
* Constructs a group using the specified subnet mask.
*
* @param mask The subnet mask to use to build the group.
* @exception UnknownHostException if the subnet mask cann't be built.
*/
public GroupImpl (String mask) throws UnknownHostException {
super(mask);
}
/**
* Adds the specified member to the group.
*
* @param p the principal to add to this group.
* @return true if the member was successfully added, false if the
* principal was already a member.
*/
public boolean addMember(Principal p) {
// we don't need to add members because the ip address is a
// subnet mask
return true;
}
public int hashCode() {
return super.hashCode();
}
/**
* Compares this group to the specified object. Returns true if the object
* passed in matches the group represented.
*
* @param p the object to compare with.
* @return true if the object passed in matches the subnet mask,
* false otherwise.
*/
public boolean equals (Object p) {
if (p instanceof PrincipalImpl || p instanceof GroupImpl){
if ((super.hashCode() & p.hashCode()) == p.hashCode()) return true;
else return false;
} else {
return false;
}
}
/**
* Returns true if the passed principal is a member of the group.
*
* @param p the principal whose membership is to be checked.
* @return true if the principal is a member of this group, false otherwise.
*/
public boolean isMember(Principal p) {
if ((p.hashCode() & super.hashCode()) == p.hashCode()) return true;
else return false;
}
/**
* Returns an enumeration which contains the subnet mask.
*
* @return an enumeration which contains the subnet mask.
*/
public Enumeration<? extends Principal> members(){
Vector<Principal> v = new Vector<Principal>(1);
v.addElement(this);
return v.elements();
}
/**
* Removes the specified member from the group. (Not implemented)
*
* @param p the principal to remove from this group.
* @return allways return true.
*/
public boolean removeMember(Principal p) {
return true;
}
/**
* Prints a string representation of this group.
*
* @return a string representation of this group.
*/
public String toString() {
return ("GroupImpl :"+super.getAddress().toString());
}
}

View File

@@ -0,0 +1,181 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.jmx.snmp.IPAcl;
// java import
//
import java.io.Serializable;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Hashtable;
import java.util.logging.Level;
import java.util.Vector;
import java.security.acl.NotOwnerException;
import static com.sun.jmx.defaults.JmxProperties.SNMP_LOGGER;
/**
* The class defines an abstract representation of a host.
*
*/
abstract class Host extends SimpleNode implements Serializable {
public Host(int id) {
super(id);
}
public Host(Parser p, int id) {
super(p, id);
}
protected abstract PrincipalImpl createAssociatedPrincipal()
throws UnknownHostException;
protected abstract String getHname();
public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {
// Create a principal
//
PrincipalImpl p=null;
try {
p = createAssociatedPrincipal();
} catch(UnknownHostException e) {
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
"buildAclEntries",
"Cannot create ACL entry; got exception", e);
}
throw new IllegalArgumentException("Cannot create ACL entry for " + e.getMessage());
}
// Create an AclEntry
//
AclEntryImpl entry= null;
try {
entry = new AclEntryImpl(p);
// Add permission
//
registerPermission(entry);
acl.addEntry(owner, entry);
} catch(UnknownHostException e) {
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
"buildAclEntries",
"Cannot create ACL entry; got exception", e);
}
return;
} catch(NotOwnerException a) {
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
"buildAclEntries",
"Cannot create ACL entry; got exception", a);
}
return;
}
}
private void registerPermission(AclEntryImpl entry) {
JDMHost host= (JDMHost) jjtGetParent();
JDMManagers manager= (JDMManagers) host.jjtGetParent();
JDMAclItem acl= (JDMAclItem) manager.jjtGetParent();
JDMAccess access= acl.getAccess();
access.putPermission(entry);
JDMCommunities comm= acl.getCommunities();
comm.buildCommunities(entry);
}
public void buildTrapEntries(Hashtable<InetAddress, Vector<String>> dest) {
JDMHostTrap host= (JDMHostTrap) jjtGetParent();
JDMTrapInterestedHost hosts= (JDMTrapInterestedHost) host.jjtGetParent();
JDMTrapItem trap = (JDMTrapItem) hosts.jjtGetParent();
JDMTrapCommunity community = trap.getCommunity();
String comm = community.getCommunity();
InetAddress add = null;
try {
add = java.net.InetAddress.getByName(getHname());
} catch(UnknownHostException e) {
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
"buildTrapEntries",
"Cannot create TRAP entry; got exception", e);
}
return;
}
Vector<String> list = null;
if (dest.containsKey(add)){
list = dest.get(add);
if (!list.contains(comm)){
list.addElement(comm);
}
} else {
list = new Vector<String>();
list.addElement(comm);
dest.put(add,list);
}
}
public void buildInformEntries(Hashtable<InetAddress, Vector<String>> dest) {
JDMHostInform host= (JDMHostInform) jjtGetParent();
JDMInformInterestedHost hosts= (JDMInformInterestedHost) host.jjtGetParent();
JDMInformItem inform = (JDMInformItem) hosts.jjtGetParent();
JDMInformCommunity community = inform.getCommunity();
String comm = community.getCommunity();
InetAddress add = null;
try {
add = java.net.InetAddress.getByName(getHname());
} catch(UnknownHostException e) {
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, Host.class.getName(),
"buildTrapEntries",
"Cannot create INFORM entry; got exception", e);
}
return;
}
Vector<String> list = null;
if (dest.containsKey(add)){
list = dest.get(add);
if (!list.contains(comm)){
list.addElement(comm);
}
} else {
list = new Vector<String>();
list.addElement(comm);
dest.put(add,list);
}
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMAccess.java */
package com.sun.jmx.snmp.IPAcl;
class JDMAccess extends SimpleNode {
protected int access= -1;
JDMAccess(int id) {
super(id);
}
JDMAccess(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMAccess(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMAccess(p, id);
}
protected void putPermission(AclEntryImpl entry) {
if (access == ParserConstants.RO) {
// We have a read-only access.
//
entry.addPermission(com.sun.jmx.snmp.IPAcl.SnmpAcl.getREAD());
}
if (access == ParserConstants.RW) {
// We have a read-write access.
//
entry.addPermission(com.sun.jmx.snmp.IPAcl.SnmpAcl.getREAD());
entry.addPermission(com.sun.jmx.snmp.IPAcl.SnmpAcl.getWRITE());
}
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMAclBlock.java */
package com.sun.jmx.snmp.IPAcl;
import java.net.InetAddress;
import java.util.Hashtable;
import java.util.Vector;
class JDMAclBlock extends SimpleNode {
JDMAclBlock(int id) {
super(id);
}
JDMAclBlock(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMAclBlock(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMAclBlock(p, id);
}
/**
* Do no need to go through this part of the tree for
* building TrapEntry.
*/
@Override
public void buildTrapEntries(Hashtable<InetAddress, Vector<String>> dest) {}
/**
* Do no need to go through this part of the tree for
* building InformEntry.
*/
@Override
public void buildInformEntries(Hashtable<InetAddress, Vector<String>> dest) {}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMAclItem.java */
package com.sun.jmx.snmp.IPAcl;
class JDMAclItem extends SimpleNode {
protected JDMAccess access= null;
protected JDMCommunities com= null;
JDMAclItem(int id) {
super(id);
}
JDMAclItem(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMAclItem(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMAclItem(p, id);
}
public JDMAccess getAccess() {
return access;
}
public JDMCommunities getCommunities() {
return com;
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMCommunities.java */
package com.sun.jmx.snmp.IPAcl;
class JDMCommunities extends SimpleNode {
JDMCommunities(int id) {
super(id);
}
JDMCommunities(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMCommunities(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMCommunities(p, id);
}
public void buildCommunities(AclEntryImpl entry){
for (int i =0 ; i < children.length ; i++)
entry.addCommunity(((JDMCommunity)children[i]).getCommunity());
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMCommunity.java */
package com.sun.jmx.snmp.IPAcl;
class JDMCommunity extends SimpleNode {
protected String communityString= "";
JDMCommunity(int id) {
super(id);
}
JDMCommunity(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMCommunity(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMCommunity(p, id);
}
public String getCommunity(){
return communityString;
}
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMEnterprise.java */
package com.sun.jmx.snmp.IPAcl;
class JDMEnterprise extends SimpleNode {
protected String enterprise= "";
JDMEnterprise(int id) {
super(id);
}
JDMEnterprise(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMEnterprise(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMEnterprise(p, id);
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMHost.java */
package com.sun.jmx.snmp.IPAcl;
class JDMHost extends SimpleNode {
JDMHost(int id) {
super(id);
}
JDMHost(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMHost(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMHost(p, id);
}
}

View File

@@ -0,0 +1,48 @@
/*
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMHostInform.java */
package com.sun.jmx.snmp.IPAcl;
class JDMHostInform extends SimpleNode {
protected String name= "";
JDMHostInform(int id) {
super(id);
}
JDMHostInform(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMHostInform(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMHostInform(p, id);
}
}

View File

@@ -0,0 +1,62 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMHostName.java */
package com.sun.jmx.snmp.IPAcl;
import java.net.UnknownHostException;
class JDMHostName extends Host {
private static final long serialVersionUID = -9120082068923591122L;
protected StringBuffer name = new StringBuffer();
JDMHostName(int id) {
super(id);
}
JDMHostName(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMHostName(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMHostName(p, id);
}
protected String getHname() {
return name.toString();
}
protected PrincipalImpl createAssociatedPrincipal()
throws UnknownHostException {
return new PrincipalImpl(name.toString());
}
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMHostTrap.java */
package com.sun.jmx.snmp.IPAcl;
class JDMHostTrap extends SimpleNode {
protected String name= "";
JDMHostTrap(int id) {
super(id);
}
JDMHostTrap(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMHostTrap(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMHostTrap(p, id);
}
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMInformBlock.java */
package com.sun.jmx.snmp.IPAcl;
import java.net.InetAddress;
import java.util.Hashtable;
import java.util.Vector;
class JDMInformBlock extends SimpleNode {
JDMInformBlock(int id) {
super(id);
}
JDMInformBlock(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMInformBlock(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMInformBlock(p, id);
}
/**
* Do no need to go through this part of the tree for
* building AclEntry.
*/
@Override
public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {}
/**
* Do no need to go through this part of the tree for
* building TrapEntry.
*/
@Override
public void buildTrapEntries(Hashtable<InetAddress, Vector<String>> dest) {}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMInformCommunity.java */
package com.sun.jmx.snmp.IPAcl;
class JDMInformCommunity extends SimpleNode {
protected String community= "";
JDMInformCommunity(int id) {
super(id);
}
JDMInformCommunity(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMInformCommunity(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMInformCommunity(p, id);
}
public String getCommunity() {
return community;
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMInformInterestedHost.java */
package com.sun.jmx.snmp.IPAcl;
class JDMInformInterestedHost extends SimpleNode {
JDMInformInterestedHost(int id) {
super(id);
}
JDMInformInterestedHost(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMInformInterestedHost(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMInformInterestedHost(p, id);
}
}

View File

@@ -0,0 +1,51 @@
/*
* Copyright (c) 2000, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMInformItem.java */
package com.sun.jmx.snmp.IPAcl;
class JDMInformItem extends SimpleNode {
protected JDMInformCommunity comm = null;
JDMInformItem(int id) {
super(id);
}
JDMInformItem(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMInformItem(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMInformItem(p, id);
}
public JDMInformCommunity getCommunity(){
return comm;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMIpAddress.java */
package com.sun.jmx.snmp.IPAcl;
import java.lang.StringBuffer;
import java.net.UnknownHostException;
class JDMIpAddress extends Host {
private static final long serialVersionUID = 849729919486384484L;
protected StringBuffer address= new StringBuffer();
JDMIpAddress(int id) {
super(id);
}
JDMIpAddress(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMIpAddress(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMIpAddress(p, id);
}
protected String getHname() {
return address.toString();
}
protected PrincipalImpl createAssociatedPrincipal()
throws UnknownHostException {
return new PrincipalImpl(address.toString());
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMIpMask.java */
package com.sun.jmx.snmp.IPAcl;
import java.lang.StringBuffer;
import java.net.UnknownHostException;
class JDMIpMask extends Host {
private static final long serialVersionUID = -8211312690652331386L;
protected StringBuffer address= new StringBuffer();
JDMIpMask(int id) {
super(id);
}
JDMIpMask(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMIpMask(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMIpMask(p, id);
}
protected String getHname() {
return address.toString();
}
protected PrincipalImpl createAssociatedPrincipal()
throws UnknownHostException {
return new GroupImpl(address.toString());
}
}

View File

@@ -0,0 +1,41 @@
/*
* Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMIpV6Address.java */
package com.sun.jmx.snmp.IPAcl;
class JDMIpV6Address extends JDMIpAddress {
private static final long serialVersionUID = -5929917334606674243L;
public JDMIpV6Address(int id) {
super(id);
}
public JDMIpV6Address(Parser p, int id) {
super(p, id);
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMManagers.java */
package com.sun.jmx.snmp.IPAcl;
class JDMManagers extends SimpleNode {
JDMManagers(int id) {
super(id);
}
JDMManagers(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMManagers(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMManagers(p, id);
}
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMNetMask.java */
package com.sun.jmx.snmp.IPAcl;
import java.net.UnknownHostException;
class JDMNetMask extends Host {
private static final long serialVersionUID = -1979318280250821787L;
protected StringBuffer address= new StringBuffer();
protected String mask = null;
public JDMNetMask(int id) {
super(id);
}
public JDMNetMask(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMNetMask(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMNetMask(p, id);
}
protected String getHname() {
return address.toString();
}
protected PrincipalImpl createAssociatedPrincipal()
throws UnknownHostException {
return new NetMaskImpl(address.toString(), Integer.parseInt(mask));
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (c) 2002, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMNetMaskV6.java */
package com.sun.jmx.snmp.IPAcl;
import java.net.UnknownHostException;
class JDMNetMaskV6 extends JDMNetMask {
private static final long serialVersionUID = 4505256777680576645L;
public JDMNetMaskV6(int id) {
super(id);
}
public JDMNetMaskV6(Parser p, int id) {
super(p, id);
}
protected PrincipalImpl createAssociatedPrincipal()
throws UnknownHostException {
return new NetMaskImpl(address.toString(), Integer.parseInt(mask));
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMSecurityDefs.java */
package com.sun.jmx.snmp.IPAcl;
class JDMSecurityDefs extends SimpleNode {
JDMSecurityDefs(int id) {
super(id);
}
JDMSecurityDefs(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMSecurityDefs(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMSecurityDefs(p, id);
}
}

View File

@@ -0,0 +1,65 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMTrapBlock.java */
package com.sun.jmx.snmp.IPAcl;
import java.net.InetAddress;
import java.util.Hashtable;
import java.util.Vector;
class JDMTrapBlock extends SimpleNode {
JDMTrapBlock(int id) {
super(id);
}
JDMTrapBlock(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMTrapBlock(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMTrapBlock(p, id);
}
/**
* Do no need to go through this part of the tree for
* building AclEntry.
*/
@Override
public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {}
/**
* Do no need to go through this part of the tree for
* building InformEntry.
*/
@Override
public void buildInformEntries(Hashtable<InetAddress, Vector<String>> dest) {}
}

View File

@@ -0,0 +1,52 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMTrapCommunity.java */
package com.sun.jmx.snmp.IPAcl;
class JDMTrapCommunity extends SimpleNode {
protected String community= "";
JDMTrapCommunity(int id) {
super(id);
}
JDMTrapCommunity(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMTrapCommunity(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMTrapCommunity(p, id);
}
public String getCommunity() {
return community;
}
}

View File

@@ -0,0 +1,47 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMTrapInterestedHost.java */
package com.sun.jmx.snmp.IPAcl;
class JDMTrapInterestedHost extends SimpleNode {
JDMTrapInterestedHost(int id) {
super(id);
}
JDMTrapInterestedHost(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMTrapInterestedHost(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMTrapInterestedHost(p, id);
}
}

View File

@@ -0,0 +1,53 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMTrapItem.java */
package com.sun.jmx.snmp.IPAcl;
class JDMTrapItem extends SimpleNode {
protected JDMTrapCommunity comm = null;
JDMTrapItem(int id) {
super(id);
}
JDMTrapItem(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMTrapItem(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMTrapItem(p, id);
}
public JDMTrapCommunity getCommunity(){
return comm;
}
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JDMTrapNum.java */
package com.sun.jmx.snmp.IPAcl;
class JDMTrapNum extends SimpleNode {
protected int low=0;
protected int high=0;
JDMTrapNum(int id) {
super(id);
}
JDMTrapNum(Parser p, int id) {
super(p, id);
}
public static Node jjtCreate(int id) {
return new JDMTrapNum(id);
}
public static Node jjtCreate(Parser p, int id) {
return new JDMTrapNum(p, id);
}
}

View File

@@ -0,0 +1,148 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. JJTParserState.java */
package com.sun.jmx.snmp.IPAcl;
class JJTParserState {
private java.util.Stack<Node> nodes;
private java.util.Stack<Integer> marks;
private int sp; // number of nodes on stack
private int mk; // current mark
private boolean node_created;
JJTParserState() {
nodes = new java.util.Stack<>();
marks = new java.util.Stack<>();
sp = 0;
mk = 0;
}
/* Determines whether the current node was actually closed and
pushed. This should only be called in the final user action of a
node scope. */
boolean nodeCreated() {
return node_created;
}
/* Call this to reinitialize the node stack. It is called
automatically by the parser's ReInit() method. */
void reset() {
nodes.removeAllElements();
marks.removeAllElements();
sp = 0;
mk = 0;
}
/* Returns the root node of the AST. It only makes sense to call
this after a successful parse. */
Node rootNode() {
return nodes.elementAt(0);
}
/* Pushes a node on to the stack. */
void pushNode(Node n) {
nodes.push(n);
++sp;
}
/* Returns the node on the top of the stack, and remove it from the
stack. */
Node popNode() {
if (--sp < mk) {
mk = marks.pop().intValue();
}
return nodes.pop();
}
/* Returns the node currently on the top of the stack. */
Node peekNode() {
return nodes.peek();
}
/* Returns the number of children on the stack in the current node
scope. */
int nodeArity() {
return sp - mk;
}
void clearNodeScope(Node n) {
while (sp > mk) {
popNode();
}
mk = marks.pop().intValue();
}
void openNodeScope(Node n) {
marks.push(new Integer(mk));
mk = sp;
n.jjtOpen();
}
/* A definite node is constructed from a specified number of
children. That number of nodes are popped from the stack and
made the children of the definite node. Then the definite node
is pushed on to the stack. */
void closeNodeScope(Node n, int num) {
mk = marks.pop().intValue();
while (num-- > 0) {
Node c = popNode();
c.jjtSetParent(n);
n.jjtAddChild(c, num);
}
n.jjtClose();
pushNode(n);
node_created = true;
}
/* A conditional node is constructed if its condition is true. All
the nodes that have been pushed since the node was opened are
made children of the the conditional node, which is then pushed
on to the stack. If the condition is false the node is not
constructed and they are left on the stack. */
void closeNodeScope(Node n, boolean condition) {
if (condition) {
int a = nodeArity();
mk = marks.pop().intValue();
while (a-- > 0) {
Node c = popNode();
c.jjtSetParent(n);
n.jjtAddChild(c, a);
}
n.jjtClose();
pushNode(n);
node_created = true;
} else {
mk = marks.pop().intValue();
node_created = false;
}
}
}

View File

@@ -0,0 +1,266 @@
/*
* Copyright (c) 2002, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.jmx.snmp.IPAcl;
import static com.sun.jmx.defaults.JmxProperties.SNMP_LOGGER;
import java.util.logging.Level;
import java.util.Vector;
import java.util.Enumeration;
import java.io.Serializable;
import java.net.UnknownHostException;
import java.net.InetAddress;
import java.security.Principal;
import java.security.acl.Group;
/**
* This class is used to represent a subnet mask (a group of hosts matching the same
* IP mask).
*
* @see java.security.acl.Group
*/
class NetMaskImpl extends PrincipalImpl implements Group, Serializable {
private static final long serialVersionUID = -7332541893877932896L;
protected byte[] subnet = null;
protected int prefix = -1;
/**
* Constructs an empty group.
* @exception UnknownHostException Not implemented
*/
public NetMaskImpl () throws UnknownHostException {
}
private byte[] extractSubNet(byte[] b) {
int addrLength = b.length;
byte[] subnet = null;
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(),
"extractSubNet", "BINARY ARRAY :");
StringBuffer buff = new StringBuffer();
for(int i =0; i < addrLength; i++) {
buff.append((b[i] &0xFF) +":");
}
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(),
"extractSubNet", buff.toString());
}
// 8 is a byte size. Common to any InetAddress (V4 or V6).
int fullyCoveredByte = prefix / 8;
if(fullyCoveredByte == addrLength) {
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
"The mask is the complete address, strange..." + addrLength);
}
subnet = b;
return subnet;
}
if(fullyCoveredByte > addrLength) {
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
"The number of covered byte is longer than the address. BUG");
}
throw new IllegalArgumentException("The number of covered byte is longer than the address.");
}
int partialyCoveredIndex = fullyCoveredByte;
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
"Partially covered index : " + partialyCoveredIndex);
}
byte toDeal = b[partialyCoveredIndex];
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
"Partially covered byte : " + toDeal);
}
// 8 is a byte size. Common to any InetAddress (V4 or V6).
int nbbits = prefix % 8;
int subnetSize = 0;
if(nbbits == 0)
subnetSize = partialyCoveredIndex;
else
subnetSize = partialyCoveredIndex + 1;
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
"Remains : " + nbbits);
}
byte mask = 0;
for(int i = 0; i < nbbits; i++) {
mask |= (1 << (7 - i));
}
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
"Mask value : " + (mask & 0xFF));
}
byte maskedValue = (byte) ((int)toDeal & (int)mask);
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
"Masked byte : " + (maskedValue &0xFF));
}
subnet = new byte[subnetSize];
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
"Resulting subnet : ");
}
for(int i = 0; i < partialyCoveredIndex; i++) {
subnet[i] = b[i];
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
(subnet[i] & 0xFF) +":");
}
}
if(nbbits != 0) {
subnet[partialyCoveredIndex] = maskedValue;
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "extractSubNet",
"Last subnet byte : " + (subnet[partialyCoveredIndex] &0xFF));
}
}
return subnet;
}
/**
* Constructs a group using the specified subnet mask.
* THIS ALGORITHM IS V4 and V6 compatible.
*
* @exception UnknownHostException if the subnet mask cann't be built.
*/
public NetMaskImpl (String a, int prefix) throws UnknownHostException {
super(a);
this.prefix = prefix;
subnet = extractSubNet(getAddress().getAddress());
}
/**
* Adds the specified member to the group.
*
* @param p the principal to add to this group.
* @return true if the member was successfully added, false if the
* principal was already a member.
*/
public boolean addMember(Principal p) {
// we don't need to add members because the ip address is a subnet mask
return true;
}
public int hashCode() {
return super.hashCode();
}
/**
* Compares this group to the specified object. Returns true if the object
* passed in matches the group represented.
*
* @param p the object to compare with.
* @return true if the object passed in matches the subnet mask,
* false otherwise.
*/
public boolean equals (Object p) {
if (p instanceof PrincipalImpl || p instanceof NetMaskImpl){
PrincipalImpl received = (PrincipalImpl) p;
InetAddress addr = received.getAddress();
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "equals",
"Received Address : " + addr);
}
byte[] recAddr = addr.getAddress();
for(int i = 0; i < subnet.length; i++) {
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "equals",
"(recAddr[i]) : " + (recAddr[i] & 0xFF));
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "equals",
"(recAddr[i] & subnet[i]) : " +
((recAddr[i] & (int)subnet[i]) &0xFF) +
" subnet[i] : " + (subnet[i] &0xFF));
}
if((recAddr[i] & subnet[i]) != subnet[i]) {
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "equals",
"FALSE");
}
return false;
}
}
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, NetMaskImpl.class.getName(), "equals",
"TRUE");
}
return true;
} else
return false;
}
/**
* Returns true if the passed principal is a member of the group.
*
* @param p the principal whose membership is to be checked.
* @return true if the principal is a member of this group, false otherwise.
*/
public boolean isMember(Principal p) {
if ((p.hashCode() & super.hashCode()) == p.hashCode()) return true;
else return false;
}
/**
* Returns an enumeration which contains the subnet mask.
*
* @return an enumeration which contains the subnet mask.
*/
public Enumeration<? extends Principal> members(){
Vector<Principal> v = new Vector<Principal>(1);
v.addElement(this);
return v.elements();
}
/**
* Removes the specified member from the group. (Not implemented)
*
* @param p the principal to remove from this group.
* @return allways return true.
*/
public boolean removeMember(Principal p) {
return true;
}
/**
* Prints a string representation of this group.
*
* @return a string representation of this group.
*/
public String toString() {
return ("NetMaskImpl :"+ super.getAddress().toString() + "/" + prefix);
}
}

View File

@@ -0,0 +1,60 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. Node.java */
package com.sun.jmx.snmp.IPAcl;
/* All AST nodes must implement this interface. It provides basic
machinery for constructing the parent and child relationships
between nodes. */
interface Node {
/** This method is called after the node has been made the current
node. It indicates that child nodes can now be added to it. */
public void jjtOpen();
/** This method is called after all the child nodes have been
added. */
public void jjtClose();
/** This pair of methods are used to inform the node of its
parent. */
public void jjtSetParent(Node n);
public Node jjtGetParent();
/** This method tells the node to add its argument to the node's
list of children. */
public void jjtAddChild(Node n, int i);
/** This method returns a child node. The children are numbered
from zero, left to right. */
public Node jjtGetChild(int i);
/** Return the number of children the node has. */
public int jjtGetNumChildren();
}

View File

@@ -0,0 +1,137 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.jmx.snmp.IPAcl;
import java.util.Vector;
import java.io.Serializable;
import java.security.Principal;
import java.security.acl.Owner;
import java.security.acl.LastOwnerException;
import java.security.acl.NotOwnerException;
/**
* Owner of Access Control Lists (ACLs).
* The initial owner Principal should be specified as an
* argument to the constructor of the class AclImpl.
*
* @see java.security.acl.Owner
*/
class OwnerImpl implements Owner, Serializable {
private static final long serialVersionUID = -576066072046319874L;
private Vector<Principal> ownerList = null;
/**
* Constructs an empty list of owner.
*/
public OwnerImpl (){
ownerList = new Vector<Principal>();
}
/**
* Constructs a list of owner with the specified principal as first element.
*
* @param owner the principal added to the owner list.
*/
public OwnerImpl (PrincipalImpl owner){
ownerList = new Vector<Principal>();
ownerList.addElement(owner);
}
/**
* Adds an owner. Only owners can modify ACL contents. The caller principal
* must be an owner of the ACL in order to invoke this method. That is, only
* an owner can add another owner. The initial owner is configured at
* ACL construction time.
*
* @param caller the principal invoking this method.
* It must be an owner of the ACL.
* @param owner the owner that should be added to 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.
*/
public boolean addOwner(Principal caller, Principal owner)
throws NotOwnerException {
if (!ownerList.contains(caller))
throw new NotOwnerException();
if (ownerList.contains(owner)) {
return false;
} else {
ownerList.addElement(owner);
return true;
}
}
/**
* 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;
}
}
/**
* Returns true if the given principal is an owner of the ACL.
*
* @param owner the principal to be checked to determine whether or
* not it is an owner.
* @return true if the given principal is an owner of the ACL.
*/
public boolean isOwner(Principal owner){
return ownerList.contains(owner);
}
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JavaCC: Do not edit this line. ParseError.java Version 0.7pre1 */
package com.sun.jmx.snmp.IPAcl;
class ParseError extends Exception {
private static final long serialVersionUID = 4907307342076722310L;
public ParseError() {
}
public ParseError(String message) {
super(message);
}
}

View File

@@ -0,0 +1,217 @@
/*
* Copyright (c) 1997, 2006, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JavaCC: Do not edit this line. ParseException.java Version 0.7pre6 */
package com.sun.jmx.snmp.IPAcl;
/**
* This exception is thrown when parse errors are encountered.
* You can explicitly create objects of this exception type by
* calling the method generateParseException in the generated
* parser.
*
* You can modify this class to customize your error reporting
* mechanisms so long as you retain the public fields.
*/
class ParseException extends Exception {
private static final long serialVersionUID = -3695190720704845876L;
/**
* This constructor is used by the method "generateParseException"
* in the generated parser. Calling this constructor generates
* a new object of this type with the fields "currentToken",
* "expectedTokenSequences", and "tokenImage" set. The boolean
* flag "specialConstructor" is also set to true to indicate that
* this constructor was used to create this object.
* This constructor calls its super class with the empty string
* to force the "toString" method of parent class "Throwable" to
* print the error message in the form:
* ParseException: <result of getMessage>
*/
public ParseException(Token currentTokenVal,
int[][] expectedTokenSequencesVal,
String[] tokenImageVal
)
{
super("");
specialConstructor = true;
currentToken = currentTokenVal;
expectedTokenSequences = expectedTokenSequencesVal;
tokenImage = tokenImageVal;
}
/**
* The following constructors are for use by you for whatever
* purpose you can think of. Constructing the exception in this
* manner makes the exception behave in the normal way - i.e., as
* documented in the class "Throwable". The fields "errorToken",
* "expectedTokenSequences", and "tokenImage" do not contain
* relevant information. The JavaCC generated code does not use
* these constructors.
*/
public ParseException() {
super();
specialConstructor = false;
}
public ParseException(String message) {
super(message);
specialConstructor = false;
}
/**
* This variable determines which constructor was used to create
* this object and thereby affects the semantics of the
* "getMessage" method (see below).
*/
protected boolean specialConstructor;
/**
* This is the last token that has been consumed successfully. If
* this object has been created due to a parse error, the token
* followng this token will (therefore) be the first error token.
*/
public Token currentToken;
/**
* Each entry in this array is an array of integers. Each array
* of integers represents a sequence of tokens (by their ordinal
* values) that is expected at this point of the parse.
*/
public int[][] expectedTokenSequences;
/**
* This is a reference to the "tokenImage" array of the generated
* parser within which the parse error occurred. This array is
* defined in the generated ...Constants interface.
*/
public String[] tokenImage;
/**
* This method has the standard behavior when this object has been
* created using the standard constructors. Otherwise, it uses
* "currentToken" and "expectedTokenSequences" to generate a parse
* error message and returns it. If this object has been created
* due to a parse error, and you do not catch it (it gets thrown
* from the parser), then this method is called during the printing
* of the final stack trace, and hence the correct error message
* gets displayed.
*/
public String getMessage() {
if (!specialConstructor) {
return super.getMessage();
}
String expected = "";
int maxSize = 0;
for (int i = 0; i < expectedTokenSequences.length; i++) {
if (maxSize < expectedTokenSequences[i].length) {
maxSize = expectedTokenSequences[i].length;
}
for (int j = 0; j < expectedTokenSequences[i].length; j++) {
expected += tokenImage[expectedTokenSequences[i][j]] + " ";
}
if (expectedTokenSequences[i][expectedTokenSequences[i].length - 1] != 0) {
expected += "...";
}
expected += eol + " ";
}
String retval = "Encountered \"";
Token tok = currentToken.next;
for (int i = 0; i < maxSize; i++) {
if (i != 0) retval += " ";
if (tok.kind == 0) {
retval += tokenImage[0];
break;
}
retval += add_escapes(tok.image);
tok = tok.next;
}
retval += "\" at line " + currentToken.next.beginLine + ", column " + currentToken.next.beginColumn + "." + eol;
if (expectedTokenSequences.length == 1) {
retval += "Was expecting:" + eol + " ";
} else {
retval += "Was expecting one of:" + eol + " ";
}
retval += expected;
return retval;
}
/**
* The end of line string for this machine.
*/
protected String eol = System.getProperty("line.separator", "\n");
/**
* Used to convert raw characters to their escaped version
* when these raw version cannot be used as part of an ASCII
* string literal.
*/
protected String add_escapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
case '\t':
retval.append("\\t");
continue;
case '\n':
retval.append("\\n");
continue;
case '\f':
retval.append("\\f");
continue;
case '\r':
retval.append("\\r");
continue;
case '\"':
retval.append("\\\"");
continue;
case '\'':
retval.append("\\\'");
continue;
case '\\':
retval.append("\\\\");
continue;
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
continue;
}
}
return retval.toString();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,111 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree&JavaCC: Do not edit this line. ParserConstants.java */
package com.sun.jmx.snmp.IPAcl;
interface ParserConstants {
int EOF = 0;
int ACCESS = 7;
int ACL = 8;
int ASSIGN = 9;
int COMMUNITIES = 10;
int ENTERPRISE = 11;
int HOSTS = 12;
int LBRACE = 13;
int MANAGERS = 14;
int RANGE = 15;
int RBRACE = 16;
int RO = 17;
int RW = 18;
int TRAP = 19;
int INFORM = 20;
int TRAPCOMMUNITY = 21;
int INFORMCOMMUNITY = 22;
int TRAPNUM = 23;
int INTEGER_LITERAL = 24;
int DECIMAL_LITERAL = 25;
int HEX_LITERAL = 26;
int OCTAL_LITERAL = 27;
int V6_ADDRESS = 28;
int H = 29;
int D = 30;
int IDENTIFIER = 31;
int LETTER = 32;
int SEPARATOR = 33;
int DIGIT = 34;
int CSTRING = 35;
int COMMA = 36;
int DOT = 37;
int MARK = 38;
int MASK = 39;
int DEFAULT = 0;
String[] tokenImage = {
"<EOF>",
"\" \"",
"\"\\t\"",
"\"\\n\"",
"\"\\r\"",
"<token of kind 5>",
"<token of kind 6>",
"\"access\"",
"\"acl\"",
"\"=\"",
"\"communities\"",
"\"enterprise\"",
"\"hosts\"",
"\"{\"",
"\"managers\"",
"\"-\"",
"\"}\"",
"\"read-only\"",
"\"read-write\"",
"\"trap\"",
"\"inform\"",
"\"trap-community\"",
"\"inform-community\"",
"\"trap-num\"",
"<INTEGER_LITERAL>",
"<DECIMAL_LITERAL>",
"<HEX_LITERAL>",
"<OCTAL_LITERAL>",
"<V6_ADDRESS>",
"<H>",
"<D>",
"<IDENTIFIER>",
"<LETTER>",
"<SEPARATOR>",
"<DIGIT>",
"<CSTRING>",
"\",\"",
"\".\"",
"\"!\"",
"\"/\"",
};
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,88 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. ParserTreeConstants.java */
package com.sun.jmx.snmp.IPAcl;
interface ParserTreeConstants
{
public int JJTSECURITYDEFS = 0;
public int JJTACLBLOCK = 1;
public int JJTACLITEM = 2;
public int JJTCOMMUNITIES = 3;
public int JJTCOMMUNITY = 4;
public int JJTACCESS = 5;
public int JJTMANAGERS = 6;
public int JJTHOST = 7;
public int JJTHOSTNAME = 8;
public int JJTIPADDRESS = 9;
public int JJTIPV6ADDRESS = 10;
public int JJTIPMASK = 11;
public int JJTNETMASK = 12;
public int JJTNETMASKV6 = 13;
public int JJTTRAPBLOCK = 14;
public int JJTTRAPITEM = 15;
public int JJTTRAPCOMMUNITY = 16;
public int JJTTRAPINTERESTEDHOST = 17;
public int JJTHOSTTRAP = 18;
public int JJTENTERPRISE = 19;
public int JJTTRAPNUM = 20;
public int JJTINFORMBLOCK = 21;
public int JJTINFORMITEM = 22;
public int JJTINFORMCOMMUNITY = 23;
public int JJTINFORMINTERESTEDHOST = 24;
public int JJTHOSTINFORM = 25;
public String[] jjtNodeName = {
"SecurityDefs",
"AclBlock",
"AclItem",
"Communities",
"Community",
"Access",
"Managers",
"Host",
"HostName",
"IpAddress",
"IpV6Address",
"IpMask",
"NetMask",
"NetMaskV6",
"TrapBlock",
"TrapItem",
"TrapCommunity",
"TrapInterestedHost",
"HostTrap",
"Enterprise",
"TrapNum",
"InformBlock",
"InformItem",
"InformCommunity",
"InformInterestedHost",
"HostInform",
};
}

View File

@@ -0,0 +1,89 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.jmx.snmp.IPAcl;
import java.io.Serializable;
/**
* Permission is represented as a String.
*
* @see java.security.acl.Permission
*/
class PermissionImpl implements java.security.acl.Permission, Serializable {
private static final long serialVersionUID = 4478110422746916589L;
private String perm = null;
/**
* Constructs a permission.
*
* @param s the string representing the permission.
*/
public PermissionImpl(String s) {
perm = s;
}
public int hashCode() {
return super.hashCode();
}
/**
* Returns true if the object passed matches the permission represented in.
*
* @param p the Permission object to compare with.
* @return true if the Permission objects are equal, false otherwise.
*/
public boolean equals(Object p){
if (p instanceof PermissionImpl){
return perm.equals(((PermissionImpl)p).getString());
} else {
return false;
}
}
/**
* Prints a string representation of this permission.
*
* @return a string representation of this permission.
*/
public String toString(){
return perm;
}
/**
* Prints the permission.
*
* @return a string representation of this permission.
*/
public String getString(){
return perm;
}
}

View File

@@ -0,0 +1,148 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.jmx.snmp.IPAcl;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.io.Serializable;
/**
* Principal represents a host.
*
*/
class PrincipalImpl implements java.security.Principal, Serializable {
private static final long serialVersionUID = -7910027842878976761L;
private InetAddress[] add = null;
/**
* Constructs a principal with the local host.
*/
public PrincipalImpl () throws UnknownHostException {
add = new InetAddress[1];
add[0] = java.net.InetAddress.getLocalHost();
}
/**
* Construct a principal using the specified host.
* <P>
* The host can be either:
* <UL>
* <LI> a host name
* <LI> an IP address
* </UL>
*
* @param hostName the host used to make the principal.
*/
public PrincipalImpl(String hostName) throws UnknownHostException {
if ((hostName.equals("localhost")) || (hostName.equals("127.0.0.1"))) {
add = new InetAddress[1];
add[0] = java.net.InetAddress.getByName(hostName);
}
else
add = java.net.InetAddress.getAllByName( hostName );
}
/**
* Constructs a principal using an Internet Protocol (IP) address.
*
* @param address the Internet Protocol (IP) address.
*/
public PrincipalImpl(InetAddress address) {
add = new InetAddress[1];
add[0] = address;
}
/**
* Returns the name of this principal.
*
* @return the name of this principal.
*/
public String getName() {
return add[0].toString();
}
/**
* Compares this principal to the specified object. Returns true if the
* object passed in matches the principal
* represented by the implementation of this interface.
*
* @param a the principal to compare with.
* @return true if the principal passed in is the same as that encapsulated by this principal, false otherwise.
*/
public boolean equals(Object a) {
if (a instanceof PrincipalImpl){
for(int i = 0; i < add.length; i++) {
if(add[i].equals (((PrincipalImpl) a).getAddress()))
return true;
}
return false;
} else {
return false;
}
}
/**
* Returns a hashcode for this principal.
*
* @return a hashcode for this principal.
*/
public int hashCode(){
return add[0].hashCode();
}
/**
* Returns a string representation of this principal. In case of multiple address, the first one is returned.
*
* @return a string representation of this principal.
*/
public String toString() {
return ("PrincipalImpl :"+add[0].toString());
}
/**
* Returns the Internet Protocol (IP) address for this principal. In case of multiple address, the first one is returned.
*
* @return the Internet Protocol (IP) address for this principal.
*/
public InetAddress getAddress(){
return add[0];
}
/**
* Returns the Internet Protocol (IP) address for this principal. In case of multiple address, the first one is returned.
*
* @return the array of Internet Protocol (IP) addresses for this principal.
*/
public InetAddress[] getAddresses(){
return add;
}
}

View File

@@ -0,0 +1,155 @@
/*
* Copyright (c) 1997, 2007, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JJTree: Do not edit this line. SimpleNode.java */
package com.sun.jmx.snmp.IPAcl;
import java.net.InetAddress;
import java.util.Hashtable;
import java.util.Vector;
class SimpleNode implements Node {
protected Node parent;
protected Node[] children;
protected int id;
protected Parser parser;
public SimpleNode(int i) {
id = i;
}
public SimpleNode(Parser p, int i) {
this(i);
parser = p;
}
public static Node jjtCreate(int id) {
return new SimpleNode(id);
}
public static Node jjtCreate(Parser p, int id) {
return new SimpleNode(p, id);
}
public void jjtOpen() {
}
public void jjtClose() {
}
public void jjtSetParent(Node n) { parent = n; }
public Node jjtGetParent() { return parent; }
public void jjtAddChild(Node n, int i) {
if (children == null) {
children = new Node[i + 1];
} else if (i >= children.length) {
Node c[] = new Node[i + 1];
System.arraycopy(children, 0, c, 0, children.length);
children = c;
}
children[i] = n;
}
public Node jjtGetChild(int i) {
return children[i];
}
public int jjtGetNumChildren() {
return (children == null) ? 0 : children.length;
}
/*
SR. Extend the SimpleNode definition
*/
/**
* Build the Trap entries from the syntactic tree.
*/
public void buildTrapEntries(Hashtable<InetAddress, Vector<String>> dest) {
if (children != null) {
for (int i = 0; i < children.length; ++i) {
SimpleNode n = (SimpleNode)children[i];
if (n != null) {
n.buildTrapEntries(dest);
}
} /* end of loop */
}
}
/**
* Build the Inform entries from the syntactic tree.
*/
public void buildInformEntries(Hashtable<InetAddress, Vector<String>> dest) {
if (children != null) {
for (int i = 0; i < children.length; ++i) {
SimpleNode n = (SimpleNode)children[i];
if (n != null) {
n.buildInformEntries(dest);
}
} /* end of loop */
}
}
/**
* Build the Acl entries from the syntactic tree.
*/
public void buildAclEntries(PrincipalImpl owner, AclImpl acl) {
if (children != null) {
for (int i = 0; i < children.length; ++i) {
SimpleNode n = (SimpleNode)children[i];
if (n != null) {
n.buildAclEntries(owner, acl);
}
} /* end of loop */
}
}
/* END SR */
/* You can override these two methods in subclasses of SimpleNode to
customize the way the node appears when the tree is dumped. If
your output uses more than one line you should override
toString(String), otherwise overriding toString() is probably all
you need to do. */
public String toString() { return ParserTreeConstants.jjtNodeName[id]; }
public String toString(String prefix) { return prefix + toString(); }
/* Override this method if you want to customize how the node dumps
out its children. */
public void dump(String prefix) {
if (children != null) {
for (int i = 0; i < children.length; ++i) {
SimpleNode n = (SimpleNode)children[i];
if (n != null) {
n.dump(prefix + " ");
}
}
}
}
}

View File

@@ -0,0 +1,486 @@
/*
* Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
package com.sun.jmx.snmp.IPAcl;
// java import
//
import java.io.Serializable;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Hashtable;
import java.util.logging.Level;
import java.util.Vector;
import java.util.Enumeration;
import java.util.HashSet;
import java.security.acl.AclEntry;
import java.security.acl.NotOwnerException;
// SNMP Runtime import
//
import static com.sun.jmx.defaults.JmxProperties.SNMP_LOGGER;
import com.sun.jmx.snmp.InetAddressAcl;
/**
* 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
* its default location is "$JRE/lib/snmp.acl" - See
* {@link #getDefaultAclFileName()}
* <p>
* <OL>
*
* <p><b>This API is a Sun Microsystems internal API and is subject
* to change without notice.</b></p>
*/
public class SnmpAcl implements InetAddressAcl, Serializable {
private static final long serialVersionUID = -6702287103824397063L;
static final PermissionImpl READ = new PermissionImpl("READ");
static final PermissionImpl WRITE = new PermissionImpl("WRITE");
/**
* 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.
*/
public SnmpAcl(String Owner)
throws UnknownHostException, IllegalArgumentException {
this(Owner,null);
}
/**
* 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();
}
/**
* 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.
*/
public Enumeration<AclEntry> entries() {
return acl.entries();
}
/**
* 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();
}
/**
* Returns the name of the ACL.
*
* @return The name of the ACL.
*/
public String getName() {
return acl.getName();
}
/**
* Returns the read permission instance used.
*
* @return The read permission instance.
*/
static public PermissionImpl getREAD() {
return READ;
}
/**
* Returns the write permission instance used.
*
* @return The write permission instance.
*/
static public PermissionImpl getWRITE() {
return WRITE;
}
/**
* Get the default name for the ACL file.
* In this implementation this is "$JRE/lib/snmp.acl"
* @return The default name for the ACL file.
**/
public static String getDefaultAclFileName() {
final String fileSeparator =
System.getProperty("file.separator");
final StringBuffer defaultAclName =
new StringBuffer(System.getProperty("java.home")).
append(fileSeparator).append("lib").append(fileSeparator).
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.
*/
public void setAuthorizedListFile(String filename)
throws IllegalArgumentException {
File file = new File(filename);
if (!file.isFile() ) {
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
SNMP_LOGGER.logp(Level.FINEST, SnmpAcl.class.getName(),
"setAuthorizedListFile", "ACL file not found: " + filename);
}
throw new
IllegalArgumentException("The specified file ["+file+"] "+
"doesn't exist or is not a file, "+
"no configuration loaded");
}
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"setAuthorizedListFile", "Default file set to " + filename);
}
authorizedListFile = filename;
}
/**
* 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();
}
/**
* Returns the full path of the file used to get ACL information.
*
* @return The full path of the file used to get ACL information.
*/
public String getAuthorizedListFile() {
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.
*/
public boolean checkReadPermission(InetAddress address) {
if (alwaysAuthorized) return ( true );
PrincipalImpl p = new PrincipalImpl(address);
return acl.checkPermission(p, READ);
}
/**
* 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.
*/
public boolean checkReadPermission(InetAddress address, String community) {
if (alwaysAuthorized) return ( true );
PrincipalImpl p = new PrincipalImpl(address);
return acl.checkPermission(p, community, READ);
}
/**
* 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.
*/
public boolean checkCommunity(String community) {
return acl.checkCommunity(community);
}
/**
* 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.
*/
public boolean checkWritePermission(InetAddress address) {
if (alwaysAuthorized) return ( true );
PrincipalImpl p = new PrincipalImpl(address);
return acl.checkPermission(p, WRITE);
}
/**
* 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.
*/
public boolean checkWritePermission(InetAddress address, String community) {
if (alwaysAuthorized) return ( true );
PrincipalImpl p = new PrincipalImpl(address);
return acl.checkPermission(p, community, WRITE);
}
/**
* Returns an enumeration of trap destinations.
*
* @return An enumeration of the trap destinations (enumeration of <CODE>InetAddress</CODE>).
*/
public Enumeration<InetAddress> getTrapDestinations() {
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>).
*/
public Enumeration<String> getTrapCommunities(InetAddress i) {
Vector<String> list = null;
if ((list = trapDestList.get(i)) != null ) {
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getTrapCommunities", "["+i.toString()+"] is in list");
}
return list.elements();
} else {
list = new Vector<>();
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getTrapCommunities", "["+i.toString()+"] is not in list");
}
return list.elements();
}
}
/**
* Returns an enumeration of inform destinations.
*
* @return An enumeration of the inform destinations (enumeration of <CODE>InetAddress</CODE>).
*/
public Enumeration<InetAddress> getInformDestinations() {
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>).
*/
public Enumeration<String> getInformCommunities(InetAddress i) {
Vector<String> list = null;
if ((list = informDestList.get(i)) != null ) {
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getInformCommunities", "["+i.toString()+"] is in list");
}
return list.elements();
} else {
list = new Vector<>();
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
SNMP_LOGGER.logp(Level.FINER, SnmpAcl.class.getName(),
"getInformCommunities", "["+i.toString()+"] is not in list");
}
return list.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);
}
}
}
}
}
/**
* Set the default full path for "snmp.acl" input file.
* Do not complain if the file does not exists.
*/
private void setDefaultFileName() {
try {
setAuthorizedListFile(getDefaultAclFileName());
} catch (IllegalArgumentException x) {
// OK...
}
}
// PRIVATE VARIABLES
//------------------
/**
* Represents the Access Control List.
*/
private AclImpl acl = null;
/**
* 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.
*/
private String authorizedListFile = null;
/**
* Contains the hosts list for trap destination.
*/
private Hashtable<InetAddress, Vector<String>> trapDestList = null;
/**
* Contains the hosts list for inform destination.
*/
private Hashtable<InetAddress, Vector<String>> informDestList = null;
private PrincipalImpl owner = null;
}

View File

@@ -0,0 +1,107 @@
/*
* Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JavaCC: Do not edit this line. Token.java Version 0.7pre3 */
package com.sun.jmx.snmp.IPAcl;
/**
* Describes the input token stream.
*/
class Token {
/**
* An integer that describes the kind of this token. This numbering
* system is determined by JavaCCParser, and a table of these numbers is
* stored in the file ...Constants.java.
*/
public int kind;
/**
* beginLine and beginColumn describe the position of the first character
* of this token; endLine and endColumn describe the position of the
* last character of this token.
*/
public int beginLine, beginColumn, endLine, endColumn;
/**
* The string image of the token.
*/
public String image;
/**
* A reference to the next regular (non-special) token from the input
* stream. If this is the last token from the input stream, or if the
* token manager has not read tokens beyond this one, this field is
* set to null. This is true only if this token is also a regular
* token. Otherwise, see below for a description of the contents of
* this field.
*/
public Token next;
/**
* This field is used to access special tokens that occur prior to this
* token, but after the immediately preceding regular (non-special) token.
* If there are no such special tokens, this field is set to null.
* When there are more than one such special token, this field refers
* to the last of these special tokens, which in turn refers to the next
* previous special token through its specialToken field, and so on
* until the first special token (whose specialToken field is null).
* The next fields of special tokens refer to other special tokens that
* immediately follow it (without an intervening regular token). If there
* is no such token, this field is null.
*/
public Token specialToken;
/**
* Returns the image.
*/
public final String toString()
{
return image;
}
/**
* Returns a new Token object, by default. However, if you want, you
* can create and return subclass objects based on the value of ofKind.
* Simply add the cases to the switch for all those special cases.
* For example, if you have a subclass of Token called IDToken that
* you want to create if ofKind is ID, simlpy add something like :
*
* case MyParserConstants.ID : return new IDToken();
*
* to the following switch statement. Then you can cast matchedToken
* variable to the appropriate type and use it in your lexical actions.
*/
public static final Token newToken(int ofKind)
{
switch(ofKind)
{
default : return new Token();
}
}
}

View File

@@ -0,0 +1,160 @@
/*
* Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* 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.
*/
/* Generated By:JavaCC: Do not edit this line. TokenMgrError.java Version 0.7pre2 */
package com.sun.jmx.snmp.IPAcl;
class TokenMgrError extends Error
{
private static final long serialVersionUID = -6373071623408870347L;
/*
* Ordinals for various reasons why an Error of this type can be thrown.
*/
/**
* Lexical error occurred.
*/
static final int LEXICAL_ERROR = 0;
/**
* An attempt wass made to create a second instance of a static token manager.
*/
static final int STATIC_LEXER_ERROR = 1;
/**
* Tried to change to an invalid lexical state.
*/
static final int INVALID_LEXICAL_STATE = 2;
/**
* Detected (and bailed out of) an infinite loop in the token manager.
*/
static final int LOOP_DETECTED = 3;
/**
* Indicates the reason why the exception is thrown. It will have
* one of the above 4 values.
*/
int errorCode;
/**
* Replaces unprintable characters by their espaced (or unicode escaped)
* equivalents in the given string
*/
protected static final String addEscapes(String str) {
StringBuffer retval = new StringBuffer();
char ch;
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i))
{
case 0 :
continue;
case '\b':
retval.append("\\b");
continue;
case '\t':
retval.append("\\t");
continue;
case '\n':
retval.append("\\n");
continue;
case '\f':
retval.append("\\f");
continue;
case '\r':
retval.append("\\r");
continue;
case '\"':
retval.append("\\\"");
continue;
case '\'':
retval.append("\\\'");
continue;
case '\\':
retval.append("\\\\");
continue;
default:
if ((ch = str.charAt(i)) < 0x20 || ch > 0x7e) {
String s = "0000" + Integer.toString(ch, 16);
retval.append("\\u" + s.substring(s.length() - 4, s.length()));
} else {
retval.append(ch);
}
continue;
}
}
return retval.toString();
}
/**
* Returns a detailed message for the Error when it is thrown by the
* token manager to indicate a lexical error.
* Parameters :
* EOFSeen : indicates if EOF caused the lexicl error
* curLexState : lexical state in which this error occurred
* errorLine : line number when the error occurred
* errorColumn : column number when the error occurred
* errorAfter : prefix that was seen before this error occurred
* curchar : the offending character
* Note: You can customize the lexical error message by modifying this method.
*/
private static final String LexicalError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar) {
return("Lexical error at line " +
errorLine + ", column " +
errorColumn + ". Encountered: " +
(EOFSeen ? "<EOF> " : ("\"" + addEscapes(String.valueOf(curChar)) + "\"") + " (" + (int)curChar + "), ") +
"after : \"" + addEscapes(errorAfter) + "\"");
}
/**
* You can also modify the body of this method to customize your error messages.
* For example, cases like LOOP_DETECTED and INVALID_LEXICAL_STATE are not
* of end-users concern, so you can return something like :
*
* "Internal Error : Please file a bug report .... "
*
* from this method for such cases in the release version of your parser.
*/
public String getMessage() {
return super.getMessage();
}
/*
* Constructors of various flavors follow.
*/
public TokenMgrError() {
}
public TokenMgrError(String message, int reason) {
super(message);
errorCode = reason;
}
public TokenMgrError(boolean EOFSeen, int lexState, int errorLine, int errorColumn, String errorAfter, char curChar, int reason) {
this(LexicalError(EOFSeen, lexState, errorLine, errorColumn, errorAfter, curChar), reason);
}
}