feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
757
jdkSrc/jdk8/com/sun/jmx/snmp/BerDecoder.java
Normal file
757
jdkSrc/jdk8/com/sun/jmx/snmp/BerDecoder.java
Normal file
@@ -0,0 +1,757 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* The <CODE>BerDecoder</CODE> class is used for decoding
|
||||
* BER-encoded data.
|
||||
*
|
||||
* A <CODE>BerDecoder</CODE> needs to be set up with the byte string containing
|
||||
* the encoding. It maintains a current position in the byte string.
|
||||
*
|
||||
* Methods allows to fetch integer, string, OID, etc., from the current
|
||||
* position. After a fetch the current position is moved forward.
|
||||
*
|
||||
* A fetch throws a <CODE>BerException</CODE> if the encoding is not of the
|
||||
* expected type.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public class BerDecoder {
|
||||
|
||||
/**
|
||||
* Constructs a new decoder and attaches it to the specified byte string.
|
||||
*
|
||||
* @param b The byte string containing the encoded data.
|
||||
*/
|
||||
|
||||
public BerDecoder(byte b[]) {
|
||||
bytes = b ;
|
||||
reset() ;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
next = 0 ;
|
||||
stackTop = 0 ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetch an integer.
|
||||
*
|
||||
* @return The decoded integer.
|
||||
*
|
||||
* @exception BerException Current position does not point to an integer.
|
||||
*/
|
||||
|
||||
public int fetchInteger() throws BerException {
|
||||
return fetchInteger(IntegerTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an integer with the specified tag.
|
||||
*
|
||||
* @param tag The expected tag.
|
||||
*
|
||||
* @return The decoded integer.
|
||||
*
|
||||
* @exception BerException Current position does not point to an integer
|
||||
* or the tag is not the expected one.
|
||||
*/
|
||||
|
||||
public int fetchInteger(int tag) throws BerException {
|
||||
int result = 0 ;
|
||||
final int backup = next ;
|
||||
try {
|
||||
if (fetchTag() != tag) {
|
||||
throw new BerException() ;
|
||||
}
|
||||
result = fetchIntegerValue() ;
|
||||
}
|
||||
catch(BerException e) {
|
||||
next = backup ;
|
||||
throw e ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an integer and return a long value.
|
||||
*
|
||||
* @return The decoded integer.
|
||||
*
|
||||
* @exception BerException Current position does not point to an integer.
|
||||
*/
|
||||
|
||||
public long fetchIntegerAsLong() throws BerException {
|
||||
return fetchIntegerAsLong(IntegerTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an integer with the specified tag and return a long value.
|
||||
*
|
||||
* @param tag The expected tag.
|
||||
*
|
||||
* @return The decoded integer.
|
||||
*
|
||||
* @exception BerException Current position does not point to an integer
|
||||
* or the tag is not the expected one.
|
||||
*/
|
||||
|
||||
public long fetchIntegerAsLong(int tag) throws BerException {
|
||||
long result = 0 ;
|
||||
final int backup = next ;
|
||||
try {
|
||||
if (fetchTag() != tag) {
|
||||
throw new BerException() ;
|
||||
}
|
||||
result = fetchIntegerValueAsLong() ;
|
||||
}
|
||||
catch(BerException e) {
|
||||
next = backup ;
|
||||
throw e ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an octet string.
|
||||
*
|
||||
* @return The decoded string.
|
||||
*
|
||||
* @exception BerException Current position does not point to an octet string.
|
||||
*/
|
||||
|
||||
public byte[] fetchOctetString() throws BerException {
|
||||
return fetchOctetString(OctetStringTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an octet string with a specified tag.
|
||||
*
|
||||
* @param tag The expected tag.
|
||||
*
|
||||
* @return The decoded string.
|
||||
*
|
||||
* @exception BerException Current position does not point to an octet string
|
||||
* or the tag is not the expected one.
|
||||
*/
|
||||
|
||||
public byte[] fetchOctetString(int tag) throws BerException {
|
||||
byte[] result = null ;
|
||||
final int backup = next ;
|
||||
try {
|
||||
if (fetchTag() != tag) {
|
||||
throw new BerException() ;
|
||||
}
|
||||
result = fetchStringValue() ;
|
||||
}
|
||||
catch(BerException e) {
|
||||
next = backup ;
|
||||
throw e ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an object identifier.
|
||||
*
|
||||
* @return The decoded object identifier as an array of long.
|
||||
*/
|
||||
|
||||
public long[] fetchOid() throws BerException {
|
||||
return fetchOid(OidTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an object identifier with a specified tag.
|
||||
*
|
||||
* @param tag The expected tag.
|
||||
*
|
||||
* @return The decoded object identifier as an array of long.
|
||||
*
|
||||
* @exception BerException Current position does not point to an oid
|
||||
* or the tag is not the expected one.
|
||||
*/
|
||||
|
||||
public long[] fetchOid(int tag) throws BerException {
|
||||
long[] result = null ;
|
||||
final int backup = next ;
|
||||
try {
|
||||
if (fetchTag() != tag) {
|
||||
throw new BerException() ;
|
||||
}
|
||||
result = fetchOidValue() ;
|
||||
}
|
||||
catch(BerException e) {
|
||||
next = backup ;
|
||||
throw e ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a <CODE>NULL</CODE> value.
|
||||
*
|
||||
* @exception BerException Current position does not point to <CODE>NULL</CODE> value.
|
||||
*/
|
||||
|
||||
public void fetchNull() throws BerException {
|
||||
fetchNull(NullTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a <CODE>NULL</CODE> value with a specified tag.
|
||||
*
|
||||
* @param tag The expected tag.
|
||||
*
|
||||
* @exception BerException Current position does not point to
|
||||
* <CODE>NULL</CODE> value or the tag is not the expected one.
|
||||
*/
|
||||
|
||||
public void fetchNull(int tag) throws BerException {
|
||||
final int backup = next ;
|
||||
try {
|
||||
if (fetchTag() != tag) {
|
||||
throw new BerException() ;
|
||||
}
|
||||
final int length = fetchLength();
|
||||
if (length != 0) throw new BerException();
|
||||
}
|
||||
catch(BerException e) {
|
||||
next = backup ;
|
||||
throw e ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an <CODE>ANY</CODE> value. In fact, this method does not decode anything
|
||||
* it simply returns the next TLV as an array of bytes.
|
||||
*
|
||||
* @return The TLV as a byte array.
|
||||
*
|
||||
* @exception BerException The next TLV is really badly encoded...
|
||||
*/
|
||||
|
||||
public byte[] fetchAny() throws BerException {
|
||||
byte[] result = null ;
|
||||
final int backup = next ;
|
||||
try {
|
||||
final int tag = fetchTag() ;
|
||||
final int contentLength = fetchLength() ;
|
||||
if (contentLength < 0) throw new BerException() ;
|
||||
final int tlvLength = next + contentLength - backup ;
|
||||
if (contentLength > (bytes.length - next))
|
||||
throw new IndexOutOfBoundsException("Decoded length exceeds buffer");
|
||||
final byte[] data = new byte[tlvLength] ;
|
||||
java.lang.System.arraycopy(bytes,backup,data,0,tlvLength);
|
||||
// for (int i = 0 ; i < tlvLength ; i++) {
|
||||
// data[i] = bytes[backup + i] ;
|
||||
// }
|
||||
next = next + contentLength ;
|
||||
result = data;
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
next = backup ;
|
||||
throw new BerException() ;
|
||||
}
|
||||
// catch(Error e) {
|
||||
// debug("fetchAny: Error decoding BER: " + e);
|
||||
// throw e;
|
||||
// }
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an <CODE>ANY</CODE> value with a specific tag.
|
||||
*
|
||||
* @param tag The expected tag.
|
||||
*
|
||||
* @return The TLV as a byte array.
|
||||
*
|
||||
* @exception BerException The next TLV is really badly encoded...
|
||||
*/
|
||||
|
||||
public byte[] fetchAny(int tag) throws BerException {
|
||||
if (getTag() != tag) {
|
||||
throw new BerException() ;
|
||||
}
|
||||
return fetchAny() ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a sequence header.
|
||||
* The decoder computes the end position of the sequence and push it
|
||||
* on its stack.
|
||||
*
|
||||
* @exception BerException Current position does not point to a sequence header.
|
||||
*/
|
||||
|
||||
public void openSequence() throws BerException {
|
||||
openSequence(SequenceTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a sequence header with a specific tag.
|
||||
*
|
||||
* @param tag The expected tag.
|
||||
*
|
||||
* @exception BerException Current position does not point to a sequence header
|
||||
* or the tag is not the expected one.
|
||||
*/
|
||||
|
||||
public void openSequence(int tag) throws BerException {
|
||||
final int backup = next ;
|
||||
try {
|
||||
if (fetchTag() != tag) {
|
||||
throw new BerException() ;
|
||||
}
|
||||
final int l = fetchLength() ;
|
||||
if (l < 0) throw new BerException();
|
||||
if (l > (bytes.length - next)) throw new BerException();
|
||||
stackBuf[stackTop++] = next + l ;
|
||||
}
|
||||
catch(BerException e) {
|
||||
next = backup ;
|
||||
throw e ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close a sequence.
|
||||
* The decode pull the stack and verifies that the current position
|
||||
* matches with the calculated end of the sequence. If not it throws
|
||||
* an exception.
|
||||
*
|
||||
* @exception BerException The sequence is not expected to finish here.
|
||||
*/
|
||||
|
||||
public void closeSequence() throws BerException {
|
||||
if (stackBuf[stackTop - 1] == next) {
|
||||
stackTop-- ;
|
||||
}
|
||||
else {
|
||||
throw new BerException() ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return <CODE>true</CODE> if the end of the current sequence is not reached.
|
||||
* When this method returns <CODE>false</CODE>, <CODE>closeSequence</CODE> can (and must) be
|
||||
* invoked.
|
||||
*
|
||||
* @return <CODE>true</CODE> if there is still some data in the sequence.
|
||||
*/
|
||||
|
||||
public boolean cannotCloseSequence() {
|
||||
return (next < stackBuf[stackTop - 1]) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the tag of the data at the current position.
|
||||
* Current position is unchanged.
|
||||
*
|
||||
* @return The next tag.
|
||||
*/
|
||||
|
||||
public int getTag() throws BerException {
|
||||
int result = 0 ;
|
||||
final int backup = next ;
|
||||
try {
|
||||
result = fetchTag() ;
|
||||
}
|
||||
finally {
|
||||
next = backup ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public String toString() {
|
||||
final StringBuffer result = new StringBuffer(bytes.length * 2) ;
|
||||
for (int i = 0 ; i < bytes.length ; i++) {
|
||||
final int b = (bytes[i] > 0) ? bytes[i] : bytes[i] + 256 ;
|
||||
if (i == next) {
|
||||
result.append("(") ;
|
||||
}
|
||||
result.append(Character.forDigit(b / 16, 16)) ;
|
||||
result.append(Character.forDigit(b % 16, 16)) ;
|
||||
if (i == next) {
|
||||
result.append(")") ;
|
||||
}
|
||||
}
|
||||
if (bytes.length == next) {
|
||||
result.append("()") ;
|
||||
}
|
||||
|
||||
return new String(result) ;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Some standard tags
|
||||
//
|
||||
public final static int BooleanTag = 1 ;
|
||||
public final static int IntegerTag = 2 ;
|
||||
public final static int OctetStringTag = 4 ;
|
||||
public final static int NullTag = 5 ;
|
||||
public final static int OidTag = 6 ;
|
||||
public final static int SequenceTag = 0x30 ;
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////// PRIVATE ///////////////////////////////
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a tag and move the current position forward.
|
||||
*
|
||||
* @return The tag
|
||||
*/
|
||||
|
||||
private final int fetchTag() throws BerException {
|
||||
int result = 0 ;
|
||||
final int backup = next ;
|
||||
|
||||
try {
|
||||
final byte b0 = bytes[next++] ;
|
||||
result = (b0 >= 0) ? b0 : b0 + 256 ;
|
||||
if ((result & 31) == 31) {
|
||||
while ((bytes[next] & 128) != 0) {
|
||||
result = result << 7 ;
|
||||
result = result | (bytes[next++] & 127);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
next = backup ;
|
||||
throw new BerException() ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a length and move the current position forward.
|
||||
*
|
||||
* @return The length
|
||||
*/
|
||||
|
||||
private final int fetchLength() throws BerException {
|
||||
int result = 0 ;
|
||||
final int backup = next ;
|
||||
|
||||
try {
|
||||
final byte b0 = bytes[next++] ;
|
||||
if (b0 >= 0) {
|
||||
result = b0 ;
|
||||
}
|
||||
else {
|
||||
for (int c = 128 + b0 ; c > 0 ; c--) {
|
||||
final byte bX = bytes[next++] ;
|
||||
result = result << 8 ;
|
||||
result = result | ((bX >= 0) ? bX : bX+256) ;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
next = backup ;
|
||||
throw new BerException() ;
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an integer value and move the current position forward.
|
||||
*
|
||||
* @return The integer
|
||||
*/
|
||||
|
||||
private int fetchIntegerValue() throws BerException {
|
||||
int result = 0 ;
|
||||
final int backup = next ;
|
||||
|
||||
try {
|
||||
final int length = fetchLength() ;
|
||||
if (length <= 0) throw new BerException() ;
|
||||
if (length > (bytes.length - next)) throw
|
||||
new IndexOutOfBoundsException("Decoded length exceeds buffer");
|
||||
final int end = next + length ;
|
||||
result = bytes[next++] ;
|
||||
while (next < end) {
|
||||
final byte b = bytes[next++] ;
|
||||
if (b < 0) {
|
||||
result = (result << 8) | (256 + b) ;
|
||||
}
|
||||
else {
|
||||
result = (result << 8) | b ;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(BerException e) {
|
||||
next = backup ;
|
||||
throw e ;
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
next = backup ;
|
||||
throw new BerException() ;
|
||||
}
|
||||
catch(ArithmeticException e) {
|
||||
next = backup ;
|
||||
throw new BerException() ;
|
||||
}
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an integer value and return a long value.
|
||||
* FIX ME: someday we could have only on fetchIntegerValue() which always
|
||||
* returns a long value.
|
||||
*
|
||||
* @return The integer
|
||||
*/
|
||||
|
||||
private final long fetchIntegerValueAsLong() throws BerException {
|
||||
long result = 0 ;
|
||||
final int backup = next ;
|
||||
|
||||
try {
|
||||
final int length = fetchLength() ;
|
||||
if (length <= 0) throw new BerException() ;
|
||||
if (length > (bytes.length - next)) throw
|
||||
new IndexOutOfBoundsException("Decoded length exceeds buffer");
|
||||
|
||||
final int end = next + length ;
|
||||
result = bytes[next++] ;
|
||||
while (next < end) {
|
||||
final byte b = bytes[next++] ;
|
||||
if (b < 0) {
|
||||
result = (result << 8) | (256 + b) ;
|
||||
}
|
||||
else {
|
||||
result = (result << 8) | b ;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch(BerException e) {
|
||||
next = backup ;
|
||||
throw e ;
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
next = backup ;
|
||||
throw new BerException() ;
|
||||
}
|
||||
catch(ArithmeticException e) {
|
||||
next = backup ;
|
||||
throw new BerException() ;
|
||||
}
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Fetch a byte string and move the current position forward.
|
||||
*
|
||||
* @return The byte string
|
||||
*/
|
||||
|
||||
private byte[] fetchStringValue() throws BerException {
|
||||
byte[] result = null ;
|
||||
final int backup = next ;
|
||||
|
||||
try {
|
||||
final int length = fetchLength() ;
|
||||
if (length < 0) throw new BerException() ;
|
||||
if (length > (bytes.length - next))
|
||||
throw new IndexOutOfBoundsException("Decoded length exceeds buffer");
|
||||
final byte data[] = new byte[length] ;
|
||||
java.lang.System.arraycopy(bytes,next,data,0,length);
|
||||
next += length;
|
||||
// int i = 0 ;
|
||||
// while (i < length) {
|
||||
// result[i++] = bytes[next++] ;
|
||||
// }
|
||||
result = data;
|
||||
}
|
||||
catch(BerException e) {
|
||||
next = backup ;
|
||||
throw e ;
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
next = backup ;
|
||||
throw new BerException() ;
|
||||
}
|
||||
catch(ArithmeticException e) {
|
||||
next = backup ;
|
||||
throw new BerException() ;
|
||||
}
|
||||
// catch(Error e) {
|
||||
// debug("fetchStringValue: Error decoding BER: " + e);
|
||||
// throw e;
|
||||
// }
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Fetch an oid and move the current position forward.
|
||||
*
|
||||
* @return The oid
|
||||
*/
|
||||
|
||||
private final long[] fetchOidValue() throws BerException {
|
||||
long[] result = null ;
|
||||
final int backup = next ;
|
||||
|
||||
try {
|
||||
final int length = fetchLength() ;
|
||||
if (length <= 0) throw new BerException() ;
|
||||
if (length > (bytes.length - next))
|
||||
throw new IndexOutOfBoundsException("Decoded length exceeds buffer");
|
||||
// Count how many bytes have their 8th bit to 0
|
||||
// -> this gives the number of components in the oid
|
||||
int subidCount = 2 ;
|
||||
for (int i = 1 ; i < length ; i++) {
|
||||
if ((bytes[next + i] & 0x80) == 0) {
|
||||
subidCount++ ;
|
||||
}
|
||||
}
|
||||
final int datalen = subidCount;
|
||||
final long[] data = new long[datalen];
|
||||
final byte b0 = bytes[next++] ;
|
||||
|
||||
// bugId 4641746
|
||||
// The 8th bit of the first byte should always be set to 0
|
||||
if (b0 < 0) throw new BerException();
|
||||
|
||||
// bugId 4641746
|
||||
// The first sub Id cannot be greater than 2
|
||||
final long lb0 = b0 / 40 ;
|
||||
if (lb0 > 2) throw new BerException();
|
||||
|
||||
final long lb1 = b0 % 40;
|
||||
data[0] = lb0 ;
|
||||
data[1] = lb1 ;
|
||||
int i = 2 ;
|
||||
while (i < datalen) {
|
||||
long subid = 0 ;
|
||||
byte b = bytes[next++] ;
|
||||
while ((b & 0x80) != 0) {
|
||||
subid = (subid << 7) | (b & 0x7f) ;
|
||||
// bugId 4654674
|
||||
if (subid < 0) throw new BerException();
|
||||
b = bytes[next++] ;
|
||||
}
|
||||
subid = (subid << 7) | b ;
|
||||
// bugId 4654674
|
||||
if (subid < 0) throw new BerException();
|
||||
data[i++] = subid ;
|
||||
}
|
||||
result = data;
|
||||
}
|
||||
catch(BerException e) {
|
||||
next = backup ;
|
||||
throw e ;
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
next = backup ;
|
||||
throw new BerException() ;
|
||||
}
|
||||
// catch(Error e) {
|
||||
// debug("fetchOidValue: Error decoding BER: " + e);
|
||||
// throw e;
|
||||
// }
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
// private static final void debug(String str) {
|
||||
// System.out.println(str);
|
||||
// }
|
||||
|
||||
//
|
||||
// This is the byte array containing the encoding.
|
||||
//
|
||||
private final byte bytes[];
|
||||
|
||||
//
|
||||
// This is the current location. It is the next byte
|
||||
// to be decoded. It's an index in bytes[].
|
||||
//
|
||||
private int next = 0 ;
|
||||
|
||||
//
|
||||
// This is the stack where end of sequences are kept.
|
||||
// A value is computed and pushed in it each time openSequence()
|
||||
// is invoked.
|
||||
// A value is pulled and checked each time closeSequence() is called.
|
||||
//
|
||||
private final int stackBuf[] = new int[200] ;
|
||||
private int stackTop = 0 ;
|
||||
|
||||
}
|
||||
477
jdkSrc/jdk8/com/sun/jmx/snmp/BerEncoder.java
Normal file
477
jdkSrc/jdk8/com/sun/jmx/snmp/BerEncoder.java
Normal file
@@ -0,0 +1,477 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
/**
|
||||
* The <CODE>BerEncoder</CODE> class is used for encoding data using BER.
|
||||
*
|
||||
* A <CODE>BerEncoder</CODE> needs to be set up with a byte buffer. The encoded
|
||||
* data are stored in this byte buffer.
|
||||
* <P>
|
||||
* NOTE : the buffer is filled from end to start. This means the caller
|
||||
* needs to encode its data in the reverse order.
|
||||
*
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public class BerEncoder {
|
||||
|
||||
/**
|
||||
* Constructs a new encoder and attaches it to the specified byte string.
|
||||
*
|
||||
* @param b The byte string containing the encoded data.
|
||||
*/
|
||||
|
||||
public BerEncoder(byte b[]) {
|
||||
bytes = b ;
|
||||
start = b.length ;
|
||||
stackTop = 0 ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Trim the encoding data and returns the length of the encoding.
|
||||
*
|
||||
* The encoder does backward encoding : so the bytes buffer is
|
||||
* filled from end to start. The encoded data must be shift before
|
||||
* the buffer can be used. This is the purpose of the <CODE>trim</CODE> method.
|
||||
*
|
||||
* After a call to the <CODE>trim</CODE> method, the encoder is reinitialized and <CODE>putXXX</CODE>
|
||||
* overwrite any existing encoded data.
|
||||
*
|
||||
* @return The length of the encoded data.
|
||||
*/
|
||||
|
||||
public int trim() {
|
||||
final int result = bytes.length - start ;
|
||||
|
||||
// for (int i = start ; i < bytes.length ; i++) {
|
||||
// bytes[i-start] = bytes[i] ;
|
||||
// }
|
||||
if (result > 0)
|
||||
java.lang.System.arraycopy(bytes,start,bytes,0,result);
|
||||
|
||||
start = bytes.length ;
|
||||
stackTop = 0 ;
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Put an integer.
|
||||
*
|
||||
* @param v The integer to encode.
|
||||
*/
|
||||
|
||||
public void putInteger(int v) {
|
||||
putInteger(v, IntegerTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put an integer with the specified tag.
|
||||
*
|
||||
* @param v The integer to encode.
|
||||
* @param tag The tag to encode.
|
||||
*/
|
||||
|
||||
public void putInteger(int v, int tag) {
|
||||
putIntegerValue(v) ;
|
||||
putTag(tag) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Put an integer expressed as a long.
|
||||
*
|
||||
* @param v The long to encode.
|
||||
*/
|
||||
|
||||
public void putInteger(long v) {
|
||||
putInteger(v, IntegerTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put an integer expressed as a long with the specified tag.
|
||||
*
|
||||
* @param v The long to encode
|
||||
* @param tag The tag to encode.
|
||||
*/
|
||||
|
||||
public void putInteger(long v, int tag) {
|
||||
putIntegerValue(v) ;
|
||||
putTag(tag) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Put an octet string.
|
||||
*
|
||||
* @param s The bytes to encode
|
||||
*/
|
||||
|
||||
public void putOctetString(byte[] s) {
|
||||
putOctetString(s, OctetStringTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put an octet string with a specified tag.
|
||||
*
|
||||
* @param s The bytes to encode
|
||||
* @param tag The tag to encode.
|
||||
*/
|
||||
|
||||
public void putOctetString(byte[] s, int tag) {
|
||||
putStringValue(s) ;
|
||||
putTag(tag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put an object identifier.
|
||||
*
|
||||
* @param s The oid to encode.
|
||||
*/
|
||||
|
||||
public void putOid(long[] s) {
|
||||
putOid(s, OidTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put an object identifier with a specified tag.
|
||||
*
|
||||
* @param s The integer to encode.
|
||||
* @param tag The tag to encode.
|
||||
*/
|
||||
|
||||
public void putOid(long[] s, int tag) {
|
||||
putOidValue(s) ;
|
||||
putTag(tag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put a <CODE>NULL</CODE> value.
|
||||
*/
|
||||
|
||||
public void putNull() {
|
||||
putNull(NullTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put a <CODE>NULL</CODE> value with a specified tag.
|
||||
*
|
||||
* @param tag The tag to encode.
|
||||
*/
|
||||
|
||||
public void putNull(int tag) {
|
||||
putLength(0) ;
|
||||
putTag(tag) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Put an <CODE>ANY</CODE> value. In fact, this method does not encode anything.
|
||||
* It simply copies the specified bytes into the encoding.
|
||||
*
|
||||
* @param s The encoding of the <CODE>ANY</CODE> value.
|
||||
*/
|
||||
|
||||
public void putAny(byte[] s) {
|
||||
putAny(s, s.length) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put an <CODE>ANY</CODE> value. Only the first <CODE>byteCount</CODE> are considered.
|
||||
*
|
||||
* @param s The encoding of the <CODE>ANY</CODE> value.
|
||||
* @param byteCount The number of bytes of the encoding.
|
||||
*/
|
||||
|
||||
public void putAny(byte[] s, int byteCount) {
|
||||
java.lang.System.arraycopy(s,0,bytes,start-byteCount,byteCount);
|
||||
start -= byteCount;
|
||||
// for (int i = byteCount - 1 ; i >= 0 ; i--) {
|
||||
// bytes[--start] = s[i] ;
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Open a sequence.
|
||||
* The encoder push the current position on its stack.
|
||||
*/
|
||||
|
||||
public void openSequence() {
|
||||
stackBuf[stackTop++] = start ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close a sequence.
|
||||
* The decode pull the stack to know the end of the current sequence.
|
||||
*/
|
||||
|
||||
public void closeSequence() {
|
||||
closeSequence(SequenceTag) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Close a sequence with the specified tag.
|
||||
*/
|
||||
|
||||
public void closeSequence(int tag) {
|
||||
final int end = stackBuf[--stackTop] ;
|
||||
putLength(end - start) ;
|
||||
putTag(tag) ;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Some standard tags
|
||||
//
|
||||
public final static int BooleanTag = 1 ;
|
||||
public final static int IntegerTag = 2 ;
|
||||
public final static int OctetStringTag = 4 ;
|
||||
public final static int NullTag = 5 ;
|
||||
public final static int OidTag = 6 ;
|
||||
public final static int SequenceTag = 0x30 ;
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////// PROTECTED ///////////////////////////////
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Put a tag and move the current position backward.
|
||||
*
|
||||
* @param tag The tag to encode.
|
||||
*/
|
||||
|
||||
protected final void putTag(int tag) {
|
||||
if (tag < 256) {
|
||||
bytes[--start] = (byte)tag ;
|
||||
}
|
||||
else {
|
||||
while (tag != 0) {
|
||||
bytes[--start] = (byte)(tag & 127) ;
|
||||
tag = tag << 7 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put a length and move the current position backward.
|
||||
*
|
||||
* @param length The length to encode.
|
||||
*/
|
||||
|
||||
protected final void putLength(final int length) {
|
||||
if (length < 0) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
else if (length < 128) {
|
||||
bytes[--start] = (byte)length ;
|
||||
}
|
||||
else if (length < 256) {
|
||||
bytes[--start] = (byte)length ;
|
||||
bytes[--start] = (byte)0x81 ;
|
||||
}
|
||||
else if (length < 65536) {
|
||||
bytes[--start] = (byte)(length) ;
|
||||
bytes[--start] = (byte)(length >> 8) ;
|
||||
bytes[--start] = (byte)0x82 ;
|
||||
}
|
||||
else if (length < 16777126) {
|
||||
bytes[--start] = (byte)(length) ;
|
||||
bytes[--start] = (byte)(length >> 8) ;
|
||||
bytes[--start] = (byte)(length >> 16) ;
|
||||
bytes[--start] = (byte)0x83 ;
|
||||
}
|
||||
else {
|
||||
bytes[--start] = (byte)(length) ;
|
||||
bytes[--start] = (byte)(length >> 8) ;
|
||||
bytes[--start] = (byte)(length >> 16) ;
|
||||
bytes[--start] = (byte)(length >> 24) ;
|
||||
bytes[--start] = (byte)0x84 ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put an integer value and move the current position backward.
|
||||
*
|
||||
* @param v The integer to encode.
|
||||
*/
|
||||
|
||||
protected final void putIntegerValue(int v) {
|
||||
final int end = start ;
|
||||
int mask = 0x7f800000 ;
|
||||
int byteNeeded = 4 ;
|
||||
if (v < 0) {
|
||||
while (((mask & v) == mask) && (byteNeeded > 1)) {
|
||||
mask = mask >> 8 ;
|
||||
byteNeeded-- ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (((mask & v) == 0) && (byteNeeded > 1)) {
|
||||
mask = mask >> 8 ;
|
||||
byteNeeded-- ;
|
||||
}
|
||||
}
|
||||
for (int i = 0 ; i < byteNeeded ; i++) {
|
||||
bytes[--start] = (byte)v ;
|
||||
v = v >> 8 ;
|
||||
}
|
||||
putLength(end - start) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put an integer value expressed as a long.
|
||||
*
|
||||
* @param v The integer to encode.
|
||||
*/
|
||||
|
||||
protected final void putIntegerValue(long v) {
|
||||
final int end = start ;
|
||||
long mask = 0x7f80000000000000L ;
|
||||
int byteNeeded = 8 ;
|
||||
if (v < 0) {
|
||||
while (((mask & v) == mask) && (byteNeeded > 1)) {
|
||||
mask = mask >> 8 ;
|
||||
byteNeeded-- ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
while (((mask & v) == 0) && (byteNeeded > 1)) {
|
||||
mask = mask >> 8 ;
|
||||
byteNeeded-- ;
|
||||
}
|
||||
}
|
||||
for (int i = 0 ; i < byteNeeded ; i++) {
|
||||
bytes[--start] = (byte)v ;
|
||||
v = v >> 8 ;
|
||||
}
|
||||
putLength(end - start) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Put a byte string and move the current position backward.
|
||||
*
|
||||
* @param s The byte string to encode.
|
||||
*/
|
||||
|
||||
protected final void putStringValue(byte[] s) {
|
||||
final int datalen = s.length;
|
||||
java.lang.System.arraycopy(s,0,bytes,start-datalen,datalen);
|
||||
start -= datalen;
|
||||
// for (int i = s.length - 1 ; i >= 0 ; i--) {
|
||||
// bytes[--start] = s[i] ;
|
||||
// }
|
||||
putLength(datalen) ;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Put an oid and move the current position backward.
|
||||
*
|
||||
* @param s The oid to encode.
|
||||
*/
|
||||
|
||||
protected final void putOidValue(final long[] s) {
|
||||
final int end = start ;
|
||||
final int slength = s.length;
|
||||
|
||||
// bugId 4641746: 0, 1, and 2 are legal values.
|
||||
if ((slength < 2) || (s[0] > 2) || (s[1] >= 40)) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
for (int i = slength - 1 ; i >= 2 ; i--) {
|
||||
long c = s[i] ;
|
||||
if (c < 0) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
else if (c < 128) {
|
||||
bytes[--start] = (byte)c ;
|
||||
}
|
||||
else {
|
||||
bytes[--start] = (byte)(c & 127) ;
|
||||
c = c >> 7 ;
|
||||
while (c != 0) {
|
||||
bytes[--start] = (byte)(c | 128) ;
|
||||
c = c >> 7 ;
|
||||
}
|
||||
}
|
||||
}
|
||||
bytes[--start] = (byte)(s[0] * 40 + s[1]) ;
|
||||
putLength(end - start) ;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// This is the byte array containing the encoding.
|
||||
//
|
||||
protected final byte bytes[];
|
||||
|
||||
//
|
||||
// This is the index of the first byte of the encoding.
|
||||
// It is initialized to <CODE>bytes.length</CODE> and decrease each time
|
||||
// an value is put in the encoder.
|
||||
//
|
||||
protected int start = -1 ;
|
||||
|
||||
//
|
||||
// This is the stack where end of sequences are kept.
|
||||
// A value is computed and pushed in it each time the <CODE>openSequence</CODE> method
|
||||
// is invoked.
|
||||
// A value is pulled and checked each time the <CODE>closeSequence</CODE> method is called.
|
||||
//
|
||||
protected final int stackBuf[] = new int[200] ;
|
||||
protected int stackTop = 0 ;
|
||||
|
||||
}
|
||||
63
jdkSrc/jdk8/com/sun/jmx/snmp/BerException.java
Normal file
63
jdkSrc/jdk8/com/sun/jmx/snmp/BerException.java
Normal 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Exception thrown when a BER encoding/decoding error occurs.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public class BerException extends Exception {
|
||||
private static final long serialVersionUID = 494709767137042951L;
|
||||
|
||||
public static final int BAD_VERSION=1;
|
||||
|
||||
private int errorType= 0;
|
||||
|
||||
public BerException() {
|
||||
errorType= 0;
|
||||
}
|
||||
|
||||
public BerException(int x) {
|
||||
errorType= x;
|
||||
}
|
||||
|
||||
public boolean isInvalidSnmpVersion() {
|
||||
if (errorType == BAD_VERSION)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
}
|
||||
304
jdkSrc/jdk8/com/sun/jmx/snmp/EnumRowStatus.java
Normal file
304
jdkSrc/jdk8/com/sun/jmx/snmp/EnumRowStatus.java
Normal file
@@ -0,0 +1,304 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Hashtable;
|
||||
|
||||
|
||||
/**
|
||||
* This class is an internal class which is used to represent RowStatus
|
||||
* codes as defined in RFC 2579.
|
||||
*
|
||||
* It defines an additional code, <i>unspecified</i>, which is
|
||||
* implementation specific, and is used to identify
|
||||
* unspecified actions (when for instance the RowStatus variable
|
||||
* is not present in the varbind list) or uninitialized values.
|
||||
*
|
||||
* mibgen does not generate objects of this class but any variable
|
||||
* using the RowStatus textual convention can be converted into an
|
||||
* object of this class thanks to the
|
||||
* <code>EnumRowStatus(Enumerated valueIndex)</code> constructor.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
**/
|
||||
|
||||
public class EnumRowStatus extends Enumerated implements Serializable {
|
||||
private static final long serialVersionUID = 8966519271130162420L;
|
||||
|
||||
/**
|
||||
* This value is SNMP Runtime implementation specific, and is used to identify
|
||||
* unspecified actions (when for instance the RowStatus variable
|
||||
* is not present in the varbind list) or uninitialized values.
|
||||
*/
|
||||
public final static int unspecified = 0;
|
||||
|
||||
/**
|
||||
* This value corresponds to the <i>active</i> RowStatus, as defined in
|
||||
* RFC 2579 from SMIv2:
|
||||
* <ul>
|
||||
* <i>active</i> indicates that the conceptual row is available for
|
||||
* use by the managed device;
|
||||
* </ul>
|
||||
*/
|
||||
public final static int active = 1;
|
||||
|
||||
/**
|
||||
* This value corresponds to the <i>notInService</i> RowStatus, as
|
||||
* defined in RFC 2579 from SMIv2:
|
||||
* <ul>
|
||||
* <i>notInService</i> indicates that the conceptual
|
||||
* row exists in the agent, but is unavailable for use by
|
||||
* the managed device; <i>notInService</i> has
|
||||
* no implication regarding the internal consistency of
|
||||
* the row, availability of resources, or consistency with
|
||||
* the current state of the managed device;
|
||||
* </ul>
|
||||
**/
|
||||
public final static int notInService = 2;
|
||||
|
||||
/**
|
||||
* This value corresponds to the <i>notReady</i> RowStatus, as defined
|
||||
* in RFC 2579 from SMIv2:
|
||||
* <ul>
|
||||
* <i>notReady</i> indicates that the conceptual row
|
||||
* exists in the agent, but is missing information
|
||||
* necessary in order to be available for use by the
|
||||
* managed device (i.e., one or more required columns in
|
||||
* the conceptual row have not been instantiated);
|
||||
* </ul>
|
||||
*/
|
||||
public final static int notReady = 3;
|
||||
|
||||
/**
|
||||
* This value corresponds to the <i>createAndGo</i> RowStatus,
|
||||
* as defined in RFC 2579 from SMIv2:
|
||||
* <ul>
|
||||
* <i>createAndGo</i> is supplied by a management
|
||||
* station wishing to create a new instance of a
|
||||
* conceptual row and to have its status automatically set
|
||||
* to active, making it available for use by the managed
|
||||
* device;
|
||||
* </ul>
|
||||
*/
|
||||
public final static int createAndGo = 4;
|
||||
|
||||
/**
|
||||
* This value corresponds to the <i>createAndWait</i> RowStatus,
|
||||
* as defined in RFC 2579 from SMIv2:
|
||||
* <ul>
|
||||
* <i>createAndWait</i> is supplied by a management
|
||||
* station wishing to create a new instance of a
|
||||
* conceptual row (but not make it available for use by
|
||||
* the managed device);
|
||||
* </ul>
|
||||
*/
|
||||
public final static int createAndWait = 5;
|
||||
|
||||
/**
|
||||
* This value corresponds to the <i>destroy</i> RowStatus, as defined in
|
||||
* RFC 2579 from SMIv2:
|
||||
* <ul>
|
||||
* <i>destroy</i> is supplied by a management station
|
||||
* wishing to delete all of the instances associated with
|
||||
* an existing conceptual row.
|
||||
* </ul>
|
||||
*/
|
||||
public final static int destroy = 6;
|
||||
|
||||
/**
|
||||
* Build an <code>EnumRowStatus</code> from an <code>int</code>.
|
||||
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
|
||||
* the values defined in RFC 2579.
|
||||
* @exception IllegalArgumentException if the given
|
||||
* <code>valueIndex</code> is not valid.
|
||||
**/
|
||||
public EnumRowStatus(int valueIndex)
|
||||
throws IllegalArgumentException {
|
||||
super(valueIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an <code>EnumRowStatus</code> from an <code>Enumerated</code>.
|
||||
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
|
||||
* the values defined in RFC 2579.
|
||||
* @exception IllegalArgumentException if the given
|
||||
* <code>valueIndex</code> is not valid.
|
||||
**/
|
||||
public EnumRowStatus(Enumerated valueIndex)
|
||||
throws IllegalArgumentException {
|
||||
this(valueIndex.intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an <code>EnumRowStatus</code> from a <code>long</code>.
|
||||
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
|
||||
* the values defined in RFC 2579.
|
||||
* @exception IllegalArgumentException if the given
|
||||
* <code>valueIndex</code> is not valid.
|
||||
**/
|
||||
public EnumRowStatus(long valueIndex)
|
||||
throws IllegalArgumentException {
|
||||
this((int)valueIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an <code>EnumRowStatus</code> from an <code>Integer</code>.
|
||||
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
|
||||
* the values defined in RFC 2579.
|
||||
* @exception IllegalArgumentException if the given
|
||||
* <code>valueIndex</code> is not valid.
|
||||
**/
|
||||
public EnumRowStatus(Integer valueIndex)
|
||||
throws IllegalArgumentException {
|
||||
super(valueIndex);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an <code>EnumRowStatus</code> from a <code>Long</code>.
|
||||
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
|
||||
* the values defined in RFC 2579.
|
||||
* @exception IllegalArgumentException if the given
|
||||
* <code>valueIndex</code> is not valid.
|
||||
**/
|
||||
public EnumRowStatus(Long valueIndex)
|
||||
throws IllegalArgumentException {
|
||||
this(valueIndex.longValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an <code>EnumRowStatus</code> with <i>unspecified</i> value.
|
||||
**/
|
||||
public EnumRowStatus()
|
||||
throws IllegalArgumentException {
|
||||
this(unspecified);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an <code>EnumRowStatus</code> from a <code>String</code>.
|
||||
* @param x should be either "unspecified", or one of
|
||||
* the values defined in RFC 2579 ("active", "notReady", etc...)
|
||||
* @exception IllegalArgumentException if the given String
|
||||
* <code>x</code> is not valid.
|
||||
**/
|
||||
public EnumRowStatus(String x)
|
||||
throws IllegalArgumentException {
|
||||
super(x);
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an <code>EnumRowStatus</code> from an <code>SnmpInt</code>.
|
||||
* @param valueIndex should be either 0 (<i>unspecified</i>), or one of
|
||||
* the values defined in RFC 2579.
|
||||
* @exception IllegalArgumentException if the given
|
||||
* <code>valueIndex</code> is not valid.
|
||||
**/
|
||||
public EnumRowStatus(SnmpInt valueIndex)
|
||||
throws IllegalArgumentException {
|
||||
this(valueIndex.intValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Build an SnmpValue from this object.
|
||||
*
|
||||
* @exception IllegalArgumentException if this object holds an
|
||||
* <i>unspecified</i> value.
|
||||
* @return an SnmpInt containing this object value.
|
||||
**/
|
||||
public SnmpInt toSnmpValue()
|
||||
throws IllegalArgumentException {
|
||||
if (value == unspecified)
|
||||
throw new
|
||||
IllegalArgumentException("`unspecified' is not a valid SNMP value.");
|
||||
return new SnmpInt(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that the given <code>value</code> is valid.
|
||||
*
|
||||
* Valid values are:
|
||||
* <ul><li><i>unspecified(0)</i></li>
|
||||
* <li><i>active(1)</i></li>
|
||||
* <li><i>notInService(2)</i></li>
|
||||
* <li><i>notReady(3)</i></li>
|
||||
* <li><i>createAndGo(4)</i></li>
|
||||
* <li><i>createAndWait(5)</i></li>
|
||||
* <li><i>destroy(6)</i></li>
|
||||
* </ul>
|
||||
*
|
||||
**/
|
||||
static public boolean isValidValue(int value) {
|
||||
if (value < 0) return false;
|
||||
if (value > 6) return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Documented in Enumerated
|
||||
//
|
||||
@Override
|
||||
protected Hashtable<Integer, String> getIntTable() {
|
||||
return EnumRowStatus.getRSIntTable();
|
||||
}
|
||||
|
||||
// Documented in Enumerated
|
||||
//
|
||||
@Override
|
||||
protected Hashtable<String, Integer> getStringTable() {
|
||||
return EnumRowStatus.getRSStringTable();
|
||||
}
|
||||
|
||||
static Hashtable<Integer, String> getRSIntTable() {
|
||||
return intTable ;
|
||||
}
|
||||
|
||||
static Hashtable<String, Integer> getRSStringTable() {
|
||||
return stringTable ;
|
||||
}
|
||||
|
||||
// Initialize the mapping tables.
|
||||
//
|
||||
final static Hashtable<Integer, String> intTable = new Hashtable<>();
|
||||
final static Hashtable<String, Integer> stringTable = new Hashtable<>();
|
||||
static {
|
||||
intTable.put(new Integer(0), "unspecified");
|
||||
intTable.put(new Integer(3), "notReady");
|
||||
intTable.put(new Integer(6), "destroy");
|
||||
intTable.put(new Integer(2), "notInService");
|
||||
intTable.put(new Integer(5), "createAndWait");
|
||||
intTable.put(new Integer(1), "active");
|
||||
intTable.put(new Integer(4), "createAndGo");
|
||||
stringTable.put("unspecified", new Integer(0));
|
||||
stringTable.put("notReady", new Integer(3));
|
||||
stringTable.put("destroy", new Integer(6));
|
||||
stringTable.put("notInService", new Integer(2));
|
||||
stringTable.put("createAndWait", new Integer(5));
|
||||
stringTable.put("active", new Integer(1));
|
||||
stringTable.put("createAndGo", new Integer(4));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
221
jdkSrc/jdk8/com/sun/jmx/snmp/Enumerated.java
Normal file
221
jdkSrc/jdk8/com/sun/jmx/snmp/Enumerated.java
Normal file
@@ -0,0 +1,221 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 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;
|
||||
|
||||
|
||||
import java.io.*;
|
||||
import java.util.Hashtable;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
|
||||
/** This class is used for implementing enumerated values.
|
||||
*
|
||||
* An enumeration is represented by a class derived from Enumerated.
|
||||
* The derived class defines what are the permitted values in the enumeration.
|
||||
*
|
||||
* An enumerated value is represented by an instance of the derived class.
|
||||
* It can be represented :
|
||||
* - as an integer
|
||||
* - as a string
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
abstract public class Enumerated implements Serializable {
|
||||
|
||||
/**
|
||||
* Construct an enumerated with a default value.
|
||||
* The default value is the first available in getIntTable().
|
||||
* @exception IllegalArgumentException One of the arguments passed to the method is illegal or inappropriate.
|
||||
*/
|
||||
public Enumerated() throws IllegalArgumentException {
|
||||
Enumeration<Integer> e =getIntTable().keys();
|
||||
if (e.hasMoreElements()) {
|
||||
value = e.nextElement().intValue() ;
|
||||
}
|
||||
else {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an enumerated from its integer form.
|
||||
*
|
||||
* @param valueIndex The integer form.
|
||||
* @exception IllegalArgumentException One of the arguments passed to
|
||||
* the method is illegal or inappropriate.
|
||||
*/
|
||||
public Enumerated(int valueIndex) throws IllegalArgumentException {
|
||||
if (getIntTable().get(new Integer(valueIndex)) == null) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
value = valueIndex ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Construct an enumerated from its Integer form.
|
||||
*
|
||||
* @param valueIndex The Integer form.
|
||||
* @exception IllegalArgumentException One of the arguments passed to
|
||||
* the method is illegal or inappropriate.
|
||||
*/
|
||||
public Enumerated(Integer valueIndex) throws IllegalArgumentException {
|
||||
if (getIntTable().get(valueIndex) == null) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
value = valueIndex.intValue() ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Construct an enumerated from its string form.
|
||||
*
|
||||
* @param valueString The string form.
|
||||
* @exception IllegalArgumentException One of the arguments passed
|
||||
* to the method is illegal or inappropriate.
|
||||
*/
|
||||
public Enumerated(String valueString) throws IllegalArgumentException {
|
||||
Integer index = getStringTable().get(valueString) ;
|
||||
if (index == null) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
else {
|
||||
value = index.intValue() ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the integer form of the enumerated.
|
||||
*
|
||||
* @return The integer form
|
||||
*/
|
||||
|
||||
public int intValue() {
|
||||
return value ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an Java enumeration of the permitted integers.
|
||||
*
|
||||
* @return An enumeration of Integer instances
|
||||
*/
|
||||
|
||||
public Enumeration<Integer> valueIndexes() {
|
||||
return getIntTable().keys() ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns an Java enumeration of the permitted strings.
|
||||
*
|
||||
* @return An enumeration of String instances
|
||||
*/
|
||||
|
||||
public Enumeration<String> valueStrings() {
|
||||
return getStringTable().keys() ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compares this enumerated to the specified enumerated.
|
||||
*
|
||||
* The result is true if and only if the argument is not null
|
||||
* and is of the same class.
|
||||
*
|
||||
* @param obj The object to compare with.
|
||||
*
|
||||
* @return True if this and obj are the same; false otherwise
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
|
||||
return ((obj != null) &&
|
||||
(getClass() == obj.getClass()) &&
|
||||
(value == ((Enumerated)obj).value)) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hash code for this enumerated.
|
||||
*
|
||||
* @return A hash code value for this object.
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
String hashString = getClass().getName() + String.valueOf(value) ;
|
||||
return hashString.hashCode() ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the string form of this enumerated.
|
||||
*
|
||||
* @return The string for for this object.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return getIntTable().get(new Integer(value)) ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hashtable of the integer forms.
|
||||
* getIntTable().get(x) returns the string form associated
|
||||
* to the integer x.
|
||||
*
|
||||
* This method must be implemented by the derived class.
|
||||
*
|
||||
* @return An hashtable for read-only purpose
|
||||
*/
|
||||
|
||||
protected abstract Hashtable<Integer,String> getIntTable() ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Returns the hashtable of the string forms.
|
||||
* getStringTable().get(s) returns the integer form associated
|
||||
* to the string s.
|
||||
*
|
||||
* This method must be implemented by the derived class.
|
||||
*
|
||||
* @return An hashtable for read-only purpose
|
||||
*/
|
||||
|
||||
protected abstract Hashtable<String,Integer> getStringTable() ;
|
||||
|
||||
|
||||
/**
|
||||
* This variable keeps the integer form of the enumerated.
|
||||
* The string form is retrieved using getIntTable().
|
||||
*/
|
||||
protected int value ;
|
||||
|
||||
}
|
||||
402
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ASCII_CharStream.java
Normal file
402
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ASCII_CharStream.java
Normal 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];
|
||||
}
|
||||
|
||||
}
|
||||
263
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/AclEntryImpl.java
Normal file
263
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/AclEntryImpl.java
Normal 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;
|
||||
}
|
||||
295
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/AclImpl.java
Normal file
295
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/AclImpl.java
Normal 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());
|
||||
}
|
||||
}
|
||||
142
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/GroupImpl.java
Normal file
142
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/GroupImpl.java
Normal 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());
|
||||
}
|
||||
}
|
||||
181
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/Host.java
Normal file
181
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/Host.java
Normal 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
64
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMAccess.java
Normal file
64
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMAccess.java
Normal 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());
|
||||
}
|
||||
}
|
||||
}
|
||||
65
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMAclBlock.java
Normal file
65
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMAclBlock.java
Normal 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) {}
|
||||
}
|
||||
58
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMAclItem.java
Normal file
58
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMAclItem.java
Normal 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;
|
||||
}
|
||||
}
|
||||
53
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMCommunities.java
Normal file
53
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMCommunities.java
Normal 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());
|
||||
}
|
||||
}
|
||||
53
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMCommunity.java
Normal file
53
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMCommunity.java
Normal 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;
|
||||
}
|
||||
}
|
||||
49
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMEnterprise.java
Normal file
49
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMEnterprise.java
Normal 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);
|
||||
}
|
||||
}
|
||||
51
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMHost.java
Normal file
51
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMHost.java
Normal 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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
48
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMHostInform.java
Normal file
48
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMHostInform.java
Normal 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);
|
||||
}
|
||||
}
|
||||
62
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMHostName.java
Normal file
62
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMHostName.java
Normal 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());
|
||||
}
|
||||
}
|
||||
49
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMHostTrap.java
Normal file
49
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMHostTrap.java
Normal 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);
|
||||
}
|
||||
}
|
||||
64
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMInformBlock.java
Normal file
64
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMInformBlock.java
Normal 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) {}
|
||||
}
|
||||
51
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMInformCommunity.java
Normal file
51
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMInformCommunity.java
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
51
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMInformItem.java
Normal file
51
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMInformItem.java
Normal 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;
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMIpAddress.java
Normal file
63
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMIpAddress.java
Normal 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());
|
||||
}
|
||||
}
|
||||
63
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMIpMask.java
Normal file
63
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMIpMask.java
Normal 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());
|
||||
}
|
||||
}
|
||||
41
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMIpV6Address.java
Normal file
41
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMIpV6Address.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
47
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMManagers.java
Normal file
47
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMManagers.java
Normal 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);
|
||||
}
|
||||
}
|
||||
58
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMNetMask.java
Normal file
58
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMNetMask.java
Normal 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));
|
||||
}
|
||||
}
|
||||
46
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMNetMaskV6.java
Normal file
46
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMNetMaskV6.java
Normal 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));
|
||||
}
|
||||
}
|
||||
47
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMSecurityDefs.java
Normal file
47
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMSecurityDefs.java
Normal 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);
|
||||
}
|
||||
}
|
||||
65
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMTrapBlock.java
Normal file
65
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMTrapBlock.java
Normal 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) {}
|
||||
}
|
||||
52
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMTrapCommunity.java
Normal file
52
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMTrapCommunity.java
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
53
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMTrapItem.java
Normal file
53
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMTrapItem.java
Normal 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;
|
||||
}
|
||||
}
|
||||
50
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMTrapNum.java
Normal file
50
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JDMTrapNum.java
Normal 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);
|
||||
}
|
||||
}
|
||||
148
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JJTParserState.java
Normal file
148
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/JJTParserState.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
266
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/NetMaskImpl.java
Normal file
266
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/NetMaskImpl.java
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
60
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/Node.java
Normal file
60
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/Node.java
Normal 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();
|
||||
}
|
||||
137
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/OwnerImpl.java
Normal file
137
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/OwnerImpl.java
Normal 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);
|
||||
}
|
||||
}
|
||||
38
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ParseError.java
Normal file
38
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ParseError.java
Normal 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);
|
||||
}
|
||||
}
|
||||
217
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ParseException.java
Normal file
217
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ParseException.java
Normal 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();
|
||||
}
|
||||
|
||||
}
|
||||
1285
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/Parser.java
Normal file
1285
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/Parser.java
Normal file
File diff suppressed because it is too large
Load Diff
111
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ParserConstants.java
Normal file
111
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ParserConstants.java
Normal 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>",
|
||||
"\",\"",
|
||||
"\".\"",
|
||||
"\"!\"",
|
||||
"\"/\"",
|
||||
};
|
||||
|
||||
}
|
||||
1514
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ParserTokenManager.java
Normal file
1514
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ParserTokenManager.java
Normal file
File diff suppressed because it is too large
Load Diff
88
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ParserTreeConstants.java
Normal file
88
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/ParserTreeConstants.java
Normal 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",
|
||||
};
|
||||
}
|
||||
89
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/PermissionImpl.java
Normal file
89
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/PermissionImpl.java
Normal 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;
|
||||
}
|
||||
}
|
||||
148
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/PrincipalImpl.java
Normal file
148
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/PrincipalImpl.java
Normal 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;
|
||||
}
|
||||
}
|
||||
155
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/SimpleNode.java
Normal file
155
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/SimpleNode.java
Normal 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 + " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
486
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/SnmpAcl.java
Normal file
486
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/SnmpAcl.java
Normal 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;
|
||||
}
|
||||
107
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/Token.java
Normal file
107
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/Token.java
Normal 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();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
160
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/TokenMgrError.java
Normal file
160
jdkSrc/jdk8/com/sun/jmx/snmp/IPAcl/TokenMgrError.java
Normal 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);
|
||||
}
|
||||
}
|
||||
128
jdkSrc/jdk8/com/sun/jmx/snmp/InetAddressAcl.java
Normal file
128
jdkSrc/jdk8/com/sun/jmx/snmp/InetAddressAcl.java
Normal file
@@ -0,0 +1,128 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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;
|
||||
|
||||
// java import
|
||||
//
|
||||
import java.net.InetAddress;
|
||||
import java.util.Enumeration;
|
||||
|
||||
/**
|
||||
* Defines the IP address based ACL used by the SNMP protocol adaptor.
|
||||
* <p>
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public interface InetAddressAcl {
|
||||
|
||||
/**
|
||||
* Returns the name of the ACL.
|
||||
*
|
||||
* @return The name of the ACL.
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* 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);
|
||||
|
||||
/**
|
||||
* Returns an enumeration of trap destinations.
|
||||
*
|
||||
* @return An enumeration of the trap destinations (enumeration of <CODE>InetAddress</CODE>).
|
||||
*/
|
||||
public Enumeration<InetAddress> getTrapDestinations();
|
||||
|
||||
/**
|
||||
* Returns an enumeration of trap communities for a given host.
|
||||
*
|
||||
* @param address 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 address);
|
||||
|
||||
/**
|
||||
* Returns an enumeration of inform destinations.
|
||||
*
|
||||
* @return An enumeration of the inform destinations (enumeration of <CODE>InetAddress</CODE>).
|
||||
*/
|
||||
public Enumeration<InetAddress> getInformDestinations();
|
||||
|
||||
/**
|
||||
* Returns an enumeration of inform communities for a given host.
|
||||
*
|
||||
* @param address 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 address);
|
||||
}
|
||||
170
jdkSrc/jdk8/com/sun/jmx/snmp/ServiceName.java
Normal file
170
jdkSrc/jdk8/com/sun/jmx/snmp/ServiceName.java
Normal file
@@ -0,0 +1,170 @@
|
||||
/*
|
||||
* Copyright (c) 1999, 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.
|
||||
*/
|
||||
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
/**
|
||||
* Used for storing default values used by SNMP Runtime services.
|
||||
* <p><b>This API is an Oracle Corporation internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
public class ServiceName {
|
||||
|
||||
// private constructor defined to "hide" the default public constructor
|
||||
private ServiceName() {
|
||||
}
|
||||
|
||||
/**
|
||||
* The object name of the MBeanServer delegate object
|
||||
* <BR>
|
||||
* The value is <CODE>JMImplementation:type=MBeanServerDelegate</CODE>.
|
||||
*/
|
||||
public static final String DELEGATE = "JMImplementation:type=MBeanServerDelegate" ;
|
||||
|
||||
/**
|
||||
* The default key properties for registering the class loader of the MLet service.
|
||||
* <BR>
|
||||
* The value is <CODE>type=MLet</CODE>.
|
||||
*/
|
||||
public static final String MLET = "type=MLet";
|
||||
|
||||
/**
|
||||
* The default domain.
|
||||
* <BR>
|
||||
* The value is <CODE>DefaultDomain</CODE>.
|
||||
*/
|
||||
public static final String DOMAIN = "DefaultDomain";
|
||||
|
||||
/**
|
||||
* The default port for the RMI connector.
|
||||
* <BR>
|
||||
* The value is <CODE>1099</CODE>.
|
||||
*/
|
||||
public static final int RMI_CONNECTOR_PORT = 1099 ;
|
||||
|
||||
/**
|
||||
* The default key properties for the RMI connector.
|
||||
* <BR>
|
||||
* The value is <CODE>name=RmiConnectorServer</CODE>.
|
||||
*/
|
||||
public static final String RMI_CONNECTOR_SERVER = "name=RmiConnectorServer" ;
|
||||
|
||||
/**
|
||||
* The default port for the SNMP adaptor.
|
||||
* <BR>
|
||||
* The value is <CODE>161</CODE>.
|
||||
*/
|
||||
public static final int SNMP_ADAPTOR_PORT = 161 ;
|
||||
|
||||
/**
|
||||
* The default key properties for the SNMP protocol adaptor.
|
||||
* <BR>
|
||||
* The value is <CODE>name=SnmpAdaptorServer</CODE>.
|
||||
*/
|
||||
public static final String SNMP_ADAPTOR_SERVER = "name=SnmpAdaptorServer" ;
|
||||
|
||||
/**
|
||||
* The default port for the HTTP connector.
|
||||
* <BR>
|
||||
* The value is <CODE>8081</CODE>.
|
||||
*/
|
||||
public static final int HTTP_CONNECTOR_PORT = 8081 ;
|
||||
|
||||
/**
|
||||
* The default key properties for the HTTP connector.
|
||||
* <BR>
|
||||
* The value is <CODE>name=HttpConnectorServer</CODE>.
|
||||
*/
|
||||
public static final String HTTP_CONNECTOR_SERVER = "name=HttpConnectorServer" ;
|
||||
|
||||
/**
|
||||
* The default port for the HTTPS connector.
|
||||
* <BR>
|
||||
* The value is <CODE>8084</CODE>.
|
||||
*/
|
||||
public static final int HTTPS_CONNECTOR_PORT = 8084 ;
|
||||
|
||||
/**
|
||||
* The default key properties for the HTTPS connector.
|
||||
* <BR>
|
||||
* The value is <CODE>name=HttpsConnectorServer</CODE>.
|
||||
*/
|
||||
public static final String HTTPS_CONNECTOR_SERVER = "name=HttpsConnectorServer" ;
|
||||
|
||||
/**
|
||||
* The default port for the HTML adaptor.
|
||||
* <BR>
|
||||
* The value is <CODE>8082</CODE>.
|
||||
*/
|
||||
public static final int HTML_ADAPTOR_PORT = 8082 ;
|
||||
|
||||
/**
|
||||
* The default key properties for the HTML protocol adaptor.
|
||||
* <BR>
|
||||
* The value is <CODE>name=HtmlAdaptorServer</CODE>.
|
||||
*/
|
||||
public static final String HTML_ADAPTOR_SERVER = "name=HtmlAdaptorServer" ;
|
||||
|
||||
/**
|
||||
* The name of the JMX specification implemented by this product.
|
||||
* <BR>
|
||||
* The value is <CODE>Java Management Extensions</CODE>.
|
||||
*/
|
||||
public static final String JMX_SPEC_NAME = "Java Management Extensions";
|
||||
|
||||
/**
|
||||
* The version of the JMX specification implemented by this product.
|
||||
* <BR>
|
||||
* The value is <CODE>1.0 Final Release</CODE>.
|
||||
*/
|
||||
public static final String JMX_SPEC_VERSION = "1.2 Maintenance Release";
|
||||
|
||||
/**
|
||||
* The vendor of the JMX specification implemented by this product.
|
||||
* <BR>
|
||||
* The value is <CODE>Oracle Corporation</CODE>.
|
||||
*/
|
||||
public static final String JMX_SPEC_VENDOR = "Oracle Corporation";
|
||||
|
||||
/**
|
||||
* The name of the vendor of this product implementing the JMX specification.
|
||||
* <BR>
|
||||
* The value is <CODE>Oracle Corporation</CODE>.
|
||||
*/
|
||||
public static final String JMX_IMPL_VENDOR = "Oracle Corporation";
|
||||
|
||||
/**
|
||||
* The build number of the current product version, of the form <CODE>rXX</CODE>.
|
||||
*/
|
||||
public static final String BUILD_NUMBER = "r01";
|
||||
|
||||
/**
|
||||
* The version of this product implementing the JMX specification.
|
||||
* <BR>
|
||||
* The value is <CODE>5.1_rXX</CODE>, where <CODE>rXX</CODE> is the <CODE>BUILD_NUMBER</CODE> .
|
||||
*/
|
||||
public static final String JMX_IMPL_VERSION = "5.1_" + BUILD_NUMBER;
|
||||
|
||||
}
|
||||
39
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpAckPdu.java
Normal file
39
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpAckPdu.java
Normal file
@@ -0,0 +1,39 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
/**
|
||||
* Interface to be implemented by PDUs that are acknowledged (eg:
|
||||
* request, bulk).
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpAckPdu {
|
||||
/**
|
||||
* Returns the PDU to use for the response.
|
||||
* @return The response PDU.
|
||||
*/
|
||||
public SnmpPdu getResponsePdu();
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
/**
|
||||
* This exception is thrown when an incorrect security level is handled.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpBadSecurityLevelException extends Exception {
|
||||
private static final long serialVersionUID = 8863728413063813053L;
|
||||
|
||||
public SnmpBadSecurityLevelException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
99
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpCounter.java
Normal file
99
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpCounter.java
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Represents an SNMP counter.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpCounter extends SnmpUnsignedInt {
|
||||
private static final long serialVersionUID = 4655264728839396879L;
|
||||
|
||||
// CONSTRUCTORS
|
||||
//-------------
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpCounter</CODE> from the specified integer value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link SnmpUnsignedInt#MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpCounter(int v) throws IllegalArgumentException {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpCounter</CODE> from the specified <CODE>Integer</CODE> value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link SnmpUnsignedInt#MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpCounter(Integer v) throws IllegalArgumentException {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpCounter</CODE> from the specified long value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link SnmpUnsignedInt#MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpCounter(long v) throws IllegalArgumentException {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpCounter</CODE> from the specified <CODE>Long</CODE> value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link SnmpUnsignedInt#MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpCounter(Long v) throws IllegalArgumentException {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
// PUBLIC METHODS
|
||||
//---------------
|
||||
/**
|
||||
* Returns a textual description of the type object.
|
||||
* @return ASN.1 textual description.
|
||||
*/
|
||||
final public String getTypeName() {
|
||||
return name ;
|
||||
}
|
||||
|
||||
// VARIABLES
|
||||
//----------
|
||||
/**
|
||||
* Name of the type.
|
||||
*/
|
||||
final static String name = "Counter32" ;
|
||||
}
|
||||
214
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpCounter64.java
Normal file
214
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpCounter64.java
Normal file
@@ -0,0 +1,214 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Represents an SNMP 64bits counter.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpCounter64 extends SnmpValue {
|
||||
private static final long serialVersionUID = 8784850650494679937L;
|
||||
|
||||
// CONSTRUCTORS
|
||||
//-------------
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpCounter64</CODE> from the specified long value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than <CODE>Long.MAX_VALUE</CODE>.
|
||||
*/
|
||||
public SnmpCounter64(long v) throws IllegalArgumentException {
|
||||
|
||||
// NOTE:
|
||||
// The max value for a counter64 variable is 2^64 - 1.
|
||||
// The max value for a Long is 2^63 - 1.
|
||||
// All the allowed values for a conuter64 variable cannot be covered !!!
|
||||
//
|
||||
if ((v < 0) || (v > Long.MAX_VALUE)) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
value = v ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpCounter64</CODE> from the specified <CODE>Long</CODE> value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than <CODE>Long.MAX_VALUE</CODE>.
|
||||
*/
|
||||
public SnmpCounter64(Long v) throws IllegalArgumentException {
|
||||
this(v.longValue()) ;
|
||||
}
|
||||
|
||||
// PUBLIC METHODS
|
||||
//---------------
|
||||
/**
|
||||
* Returns the counter value of this <CODE>SnmpCounter64</CODE>.
|
||||
* @return The value.
|
||||
*/
|
||||
public long longValue() {
|
||||
return value ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the counter value to its <CODE>Long</CODE> form.
|
||||
* @return The <CODE>Long</CODE> representation of the value.
|
||||
*/
|
||||
public Long toLong() {
|
||||
return new Long(value) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the counter value to its integer form.
|
||||
* @return The integer representation of the value.
|
||||
*/
|
||||
public int intValue() {
|
||||
return (int)value ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the counter value to its <CODE>Integer</CODE> form.
|
||||
* @return The <CODE>Integer</CODE> representation of the value.
|
||||
*/
|
||||
public Integer toInteger() {
|
||||
return new Integer((int)value) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the counter value to its <CODE>String</CODE> form.
|
||||
* @return The <CODE>String</CODE> representation of the value.
|
||||
*/
|
||||
public String toString() {
|
||||
return String.valueOf(value) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the counter value to its <CODE>SnmpOid</CODE> form.
|
||||
* @return The OID representation of the value.
|
||||
*/
|
||||
public SnmpOid toOid() {
|
||||
return new SnmpOid(value) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the counter from an index OID and returns its
|
||||
* value converted as an <CODE>SnmpOid</CODE>.
|
||||
* @param index The index array.
|
||||
* @param start The position in the index array.
|
||||
* @return The OID representing the counter value.
|
||||
* @exception SnmpStatusException There is no counter value
|
||||
* available at the start position.
|
||||
*/
|
||||
public static SnmpOid toOid(long[] index, int start) throws SnmpStatusException {
|
||||
try {
|
||||
return new SnmpOid(index[start]) ;
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans an index OID, skips the counter value and returns the position
|
||||
* of the next value.
|
||||
* @param index The index array.
|
||||
* @param start The position in the index array.
|
||||
* @return The position of the next value.
|
||||
* @exception SnmpStatusException There is no counter value
|
||||
* available at the start position.
|
||||
*/
|
||||
public static int nextOid(long[] index, int start) throws SnmpStatusException {
|
||||
if (start >= index.length) {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
else {
|
||||
return start + 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an <CODE>SnmpOid</CODE> representing an <CODE>SnmpCounter64</CODE> to another OID.
|
||||
* @param source An OID representing an <CODE>SnmpCounter64</CODE> value.
|
||||
* @param dest Where source should be appended.
|
||||
*/
|
||||
public static void appendToOid(SnmpOid source, SnmpOid dest) {
|
||||
if (source.getLength() != 1) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
dest.append(source) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a clone action. This provides a workaround for the
|
||||
* <CODE>SnmpValue</CODE> interface.
|
||||
* @return The SnmpValue clone.
|
||||
*/
|
||||
final synchronized public SnmpValue duplicate() {
|
||||
return (SnmpValue)clone() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones the <CODE>SnmpCounter64</CODE> object, making a copy of its data.
|
||||
* @return The object clone.
|
||||
*/
|
||||
final synchronized public Object clone() {
|
||||
SnmpCounter64 newclone = null ;
|
||||
try {
|
||||
newclone = (SnmpCounter64) super.clone() ;
|
||||
newclone.value = value ;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError(e) ; // vm bug.
|
||||
}
|
||||
return newclone ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a textual description of the type object.
|
||||
* @return ASN.1 textual description.
|
||||
*/
|
||||
final public String getTypeName() {
|
||||
return name ;
|
||||
}
|
||||
|
||||
// VARIABLES
|
||||
//----------
|
||||
/**
|
||||
* Name of the type.
|
||||
*/
|
||||
final static String name = "Counter64" ;
|
||||
|
||||
/**
|
||||
* This is where the value is stored. This long is positive.
|
||||
* @serial
|
||||
*/
|
||||
private long value = 0 ;
|
||||
}
|
||||
70
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpEngine.java
Normal file
70
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpEngine.java
Normal file
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
/**
|
||||
* This engine is conformant with the RFC 2571. It is the main object within an SNMP entity (agent, manager...).
|
||||
* To an engine is associated an {@link SnmpEngineId}.
|
||||
* Engine instantiation is based on a factory {@link com.sun.jmx.snmp.SnmpEngineFactory SnmpEngineFactory}.
|
||||
* When an <CODE> SnmpEngine </CODE> is created, a User based Security Model (USM) is initialized. The security configuration is located in a text file.
|
||||
* The text file is read when the engine is created.
|
||||
* <p>Note that the engine is not used when the agent is SNMPv1/SNMPv2 only.
|
||||
<P> The USM configuration text file is remotely updatable using the USM Mib.</P>
|
||||
<P> User that are configured in the Usm text file are nonVolatile. </P>
|
||||
<P> Usm Mib userEntry supported storage type values are : volatile or nonVolatile only. Other values are rejected and a wrongValue is returned) </P>
|
||||
<ul>
|
||||
<li> volatile means that user entry is not flushed in security file </li>
|
||||
<li> nonVolatile means that user entry is flushed in security file </li>
|
||||
<li> If a nonVolatile row is set to be volatile, it will be not flushed in the file </li>
|
||||
<li>If a volatile row created from the UsmMib is set to nonVolatile, it will be flushed in the file (if the file exist and is writable otherwise an inconsistentValue is returned)</li>
|
||||
</ul>
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpEngine {
|
||||
/**
|
||||
* Gets the engine time in seconds. This is the time from the last reboot.
|
||||
* @return The time from the last reboot.
|
||||
*/
|
||||
public int getEngineTime();
|
||||
/**
|
||||
* Gets the engine Id. This is unique for each engine.
|
||||
* @return The engine Id object.
|
||||
*/
|
||||
public SnmpEngineId getEngineId();
|
||||
|
||||
/**
|
||||
* Gets the engine boot number. This is the number of time this engine has rebooted. Each time an <CODE>SnmpEngine</CODE> is instantiated, it will read this value in its Lcd, and store back the value incremented by one.
|
||||
* @return The engine's number of reboot.
|
||||
*/
|
||||
public int getEngineBoots();
|
||||
|
||||
/**
|
||||
* Gets the Usm key handler.
|
||||
* @return The key handler.
|
||||
*/
|
||||
public SnmpUsmKeyHandler getUsmKeyHandler();
|
||||
}
|
||||
58
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpEngineFactory.java
Normal file
58
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpEngineFactory.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
/**
|
||||
* This <CODE>SnmpEngineFactory</CODE> is instantiating an <CODE>SnmpEngine</CODE> containing :
|
||||
* <ul>
|
||||
* <li> Message Processing Sub System + V1, V2 et V3 Message Processing Models</li>
|
||||
* <li> Security Sub System + User based Security Model (Id 3)</li>
|
||||
* <li> Access Control Sub System + Ip Acl + User based Access Control Model. See <CODE> IpAcl </CODE> and <CODE> UserAcl </CODE>.</li>
|
||||
* </ul>
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpEngineFactory {
|
||||
/**
|
||||
* The engine instantiation method.
|
||||
* @param p The parameters used to instantiate a new engine.
|
||||
* @throws IllegalArgumentException Throwed if one of the configuration file file doesn't exist (Acl files, security file).
|
||||
* @return The newly created SnmpEngine.
|
||||
*/
|
||||
public SnmpEngine createEngine(SnmpEngineParameters p);
|
||||
|
||||
/**
|
||||
* The engine instantiation method.
|
||||
* @param p The parameters used to instantiate a new engine.
|
||||
* @param ipacl The Ip ACL to pass to the Access Control Model.
|
||||
* @throws IllegalArgumentException Throwed if one of the configuration
|
||||
* file file doesn't exist (Acl files, security file).
|
||||
* @return The newly created SnmpEngine.
|
||||
*/
|
||||
public SnmpEngine createEngine(SnmpEngineParameters p,
|
||||
InetAddressAcl ipacl);
|
||||
}
|
||||
489
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpEngineId.java
Normal file
489
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpEngineId.java
Normal file
@@ -0,0 +1,489 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.io.Serializable;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.StringTokenizer;
|
||||
import java.util.Arrays;
|
||||
import java.util.NoSuchElementException;
|
||||
|
||||
import com.sun.jmx.snmp.internal.SnmpTools;
|
||||
|
||||
/**
|
||||
* This class is handling an <CODE>SnmpEngineId</CODE> data. It copes with binary as well as <CODE>String</CODE> representation of an engine Id. A string format engine is an hex string starting with 0x.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpEngineId implements Serializable {
|
||||
private static final long serialVersionUID = 5434729655830763317L;
|
||||
|
||||
byte[] engineId = null;
|
||||
String hexString = null;
|
||||
String humanString = null;
|
||||
/**
|
||||
* New <CODE>SnmpEngineId</CODE> with an hex string value. Can handle engine Id format <host>:<port>.
|
||||
* @param hexString Hexa string.
|
||||
*/
|
||||
SnmpEngineId(String hexString) {
|
||||
engineId = SnmpTools.ascii2binary(hexString);
|
||||
this.hexString = hexString.toLowerCase();
|
||||
}
|
||||
/**
|
||||
* New <CODE>SnmpEngineId</CODE> with a binary value. You can use <CODE> SnmpTools </CODE> to convert from hex string to binary format.
|
||||
* @param bin Binary value
|
||||
*/
|
||||
SnmpEngineId(byte[] bin) {
|
||||
engineId = bin;
|
||||
hexString = SnmpTools.binary2ascii(bin).toLowerCase();
|
||||
}
|
||||
|
||||
/**
|
||||
* If a string of the format <address>:<port>:<IANA number> has been provided at creation time, this string is returned.
|
||||
* @return The Id as a readable string or null if not provided.
|
||||
*/
|
||||
public String getReadableId() {
|
||||
return humanString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string format engine Id.
|
||||
* @return String format value.
|
||||
*/
|
||||
public String toString() {
|
||||
return hexString;
|
||||
}
|
||||
/**
|
||||
* Returns a binary engine Id.
|
||||
* @return Binary value.
|
||||
*/
|
||||
public byte[] getBytes() {
|
||||
return engineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* In order to store the string used to create the engineId.
|
||||
*/
|
||||
void setStringValue(String val) {
|
||||
humanString = val;
|
||||
}
|
||||
|
||||
static void validateId(String str) throws IllegalArgumentException {
|
||||
byte[] arr = SnmpTools.ascii2binary(str);
|
||||
validateId(arr);
|
||||
}
|
||||
|
||||
static void validateId(byte[] arr) throws IllegalArgumentException {
|
||||
|
||||
if(arr.length < 5) throw new IllegalArgumentException("Id size lower than 5 bytes.");
|
||||
if(arr.length > 32) throw new IllegalArgumentException("Id size greater than 32 bytes.");
|
||||
|
||||
//octet strings with very first bit = 0 and length != 12 octets
|
||||
if( ((arr[0] & 0x80) == 0) && arr.length != 12)
|
||||
throw new IllegalArgumentException("Very first bit = 0 and length != 12 octets");
|
||||
|
||||
byte[] zeroedArrays = new byte[arr.length];
|
||||
if(Arrays.equals(zeroedArrays, arr)) throw new IllegalArgumentException("Zeroed Id.");
|
||||
byte[] FFArrays = new byte[arr.length];
|
||||
Arrays.fill(FFArrays, (byte)0xFF);
|
||||
if(Arrays.equals(FFArrays, arr)) throw new IllegalArgumentException("0xFF Id.");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an engine Id based on the passed array.
|
||||
* @return The created engine Id or null if given arr is null or its length == 0;
|
||||
* @exception IllegalArgumentException when:
|
||||
* <ul>
|
||||
* <li>octet string lower than 5 bytes.</li>
|
||||
* <li>octet string greater than 32 bytes.</li>
|
||||
* <li>octet string = all zeros.</li>
|
||||
* <li>octet string = all 'ff'H.</li>
|
||||
* <li>octet strings with very first bit = 0 and length != 12 octets</li>
|
||||
* </ul>
|
||||
*/
|
||||
public static SnmpEngineId createEngineId(byte[] arr) throws IllegalArgumentException {
|
||||
if( (arr == null) || arr.length == 0) return null;
|
||||
validateId(arr);
|
||||
return new SnmpEngineId(arr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an engine Id that is unique to the host the agent is running on. The engine Id unicity is system time based. The creation algorithm uses the SUN Microsystems IANA number (42).
|
||||
* @return The generated engine Id.
|
||||
*/
|
||||
public static SnmpEngineId createEngineId() {
|
||||
byte[] address = null;
|
||||
byte[] engineid = new byte[13];
|
||||
int iana = 42;
|
||||
long mask = 0xFF;
|
||||
long time = System.currentTimeMillis();
|
||||
|
||||
engineid[0] = (byte) ( (iana & 0xFF000000) >> 24 );
|
||||
engineid[0] |= 0x80;
|
||||
engineid[1] = (byte) ( (iana & 0x00FF0000) >> 16 );
|
||||
engineid[2] = (byte) ( (iana & 0x0000FF00) >> 8 );
|
||||
engineid[3] = (byte) (iana & 0x000000FF);
|
||||
engineid[4] = 0x05;
|
||||
|
||||
engineid[5] = (byte) ( (time & (mask << 56)) >>> 56 );
|
||||
engineid[6] = (byte) ( (time & (mask << 48) ) >>> 48 );
|
||||
engineid[7] = (byte) ( (time & (mask << 40) ) >>> 40 );
|
||||
engineid[8] = (byte) ( (time & (mask << 32) ) >>> 32 );
|
||||
engineid[9] = (byte) ( (time & (mask << 24) ) >>> 24 );
|
||||
engineid[10] = (byte) ( (time & (mask << 16) ) >>> 16 );
|
||||
engineid[11] = (byte) ( (time & (mask << 8) ) >>> 8 );
|
||||
engineid[12] = (byte) (time & mask);
|
||||
|
||||
return new SnmpEngineId(engineid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates an engine Id in an SnmpOid format. This is useful when dealing with USM MIB indexes.
|
||||
* The oid format is : <engine Id length>.<engine Id binary octet1>....<engine Id binary octetn - 1>.<engine Id binary octetn>
|
||||
* Eg: "0x8000002a05819dcb6e00001f96" ==> 13.128.0.0.42.5.129.157.203.110.0.0.31.150
|
||||
*
|
||||
* @return SnmpOid The oid.
|
||||
*/
|
||||
public SnmpOid toOid() {
|
||||
long[] oid = new long[engineId.length + 1];
|
||||
oid[0] = engineId.length;
|
||||
for(int i = 1; i <= engineId.length; i++)
|
||||
oid[i] = (long) (engineId[i-1] & 0xFF);
|
||||
return new SnmpOid(oid);
|
||||
}
|
||||
|
||||
/**
|
||||
* <P>Generates a unique engine Id. Hexadecimal strings as well as a textual description are supported. The textual format is as follow:
|
||||
* <BR> <address>:<port>:<IANA number></P>
|
||||
* <P>The allowed formats :</P>
|
||||
* <ul>
|
||||
* <li> <address>:<port>:<IANA number>
|
||||
* <BR> All these parameters are used to generate the Id. WARNING, this method is not compliant with IPv6 address format. Use { @link com.sun.jmx.snmp.SnmpEngineId#createEngineId(java.lang.String,java.lang.String) } instead.</li>
|
||||
* <li> <address>:<port>
|
||||
* <BR> The IANA number will be the SUN Microsystems one (42). </li>
|
||||
* <li> address
|
||||
* <BR> The port 161 will be used to generate the Id. IANA number will be the SUN Microsystems one (42). </li>
|
||||
* <li> :port
|
||||
* <BR> The host to use is localhost. IANA number will be the SUN Microsystems one (42). </li>
|
||||
* <li> ::<IANA number>
|
||||
* <BR> The port 161 and localhost will be used to generate the Id. </li>
|
||||
* <li> :<port>:<IANA number>
|
||||
* <BR> The host to use is localhost. </li>
|
||||
* <li> <address>::<IANA number>
|
||||
* <BR> The port 161 will be used to generate the Id. </li>
|
||||
* <li> ::
|
||||
* <BR> The port 161, localhost and the SUN Microsystems IANA number will be used to generate the Id. </li>
|
||||
* </ul>
|
||||
* @exception UnknownHostException if the host name contained in the textual format is unknown.
|
||||
* @exception IllegalArgumentException when :
|
||||
* <ul>
|
||||
* <li>octet string lower than 5 bytes.</li>
|
||||
* <li>octet string greater than 32 bytes.</li>
|
||||
* <li>octet string = all zeros.</li>
|
||||
* <li>octet string = all 'ff'H.</li>
|
||||
* <li>octet strings with very first bit = 0 and length != 12 octets</li>
|
||||
* <li>An IPv6 address format is used in conjonction with the ":" separator</li>
|
||||
* </ul>
|
||||
* @param str The string to parse.
|
||||
* @return The generated engine Id or null if the passed string is null.
|
||||
*
|
||||
*/
|
||||
public static SnmpEngineId createEngineId(String str)
|
||||
throws IllegalArgumentException, UnknownHostException {
|
||||
return createEngineId(str, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Idem { @link
|
||||
* com.sun.jmx.snmp.SnmpEngineId#createEngineId(java.lang.String) }
|
||||
* with the ability to provide your own separator. This allows IPv6
|
||||
* address format handling (eg: providing @ as separator).
|
||||
* @param str The string to parse.
|
||||
* @param separator the separator to use. If null is provided, the default
|
||||
* separator ":" is used.
|
||||
* @return The generated engine Id or null if the passed string is null.
|
||||
* @exception UnknownHostException if the host name contained in the
|
||||
* textual format is unknown.
|
||||
* @exception IllegalArgumentException when :
|
||||
* <ul>
|
||||
* <li>octet string lower than 5 bytes.</li>
|
||||
* <li>octet string greater than 32 bytes.</li>
|
||||
* <li>octet string = all zeros.</li>
|
||||
* <li>octet string = all 'ff'H.</li>
|
||||
* <li>octet strings with very first bit = 0 and length != 12 octets</li>
|
||||
* <li>An IPv6 address format is used in conjonction with the ":"
|
||||
* separator</li>
|
||||
* </ul>
|
||||
* @since 1.5
|
||||
*/
|
||||
public static SnmpEngineId createEngineId(String str, String separator)
|
||||
throws IllegalArgumentException, UnknownHostException {
|
||||
if(str == null) return null;
|
||||
|
||||
if(str.startsWith("0x") || str.startsWith("0X")) {
|
||||
validateId(str);
|
||||
return new SnmpEngineId(str);
|
||||
}
|
||||
separator = separator == null ? ":" : separator;
|
||||
StringTokenizer token = new StringTokenizer(str,
|
||||
separator,
|
||||
true);
|
||||
|
||||
String address = null;
|
||||
String port = null;
|
||||
String iana = null;
|
||||
int objPort = 161;
|
||||
int objIana = 42;
|
||||
InetAddress objAddress = null;
|
||||
SnmpEngineId eng = null;
|
||||
try {
|
||||
//Deal with address
|
||||
try {
|
||||
address = token.nextToken();
|
||||
}catch(NoSuchElementException e) {
|
||||
throw new IllegalArgumentException("Passed string is invalid : ["+str+"]");
|
||||
}
|
||||
if(!address.equals(separator)) {
|
||||
objAddress = InetAddress.getByName(address);
|
||||
try {
|
||||
token.nextToken();
|
||||
}catch(NoSuchElementException e) {
|
||||
//No need to go further, no port.
|
||||
eng = SnmpEngineId.createEngineId(objAddress,
|
||||
objPort,
|
||||
objIana);
|
||||
eng.setStringValue(str);
|
||||
return eng;
|
||||
}
|
||||
}
|
||||
else
|
||||
objAddress = InetAddress.getLocalHost();
|
||||
|
||||
//Deal with port
|
||||
try {
|
||||
port = token.nextToken();
|
||||
}catch(NoSuchElementException e) {
|
||||
//No need to go further, no port.
|
||||
eng = SnmpEngineId.createEngineId(objAddress,
|
||||
objPort,
|
||||
objIana);
|
||||
eng.setStringValue(str);
|
||||
return eng;
|
||||
}
|
||||
|
||||
if(!port.equals(separator)) {
|
||||
objPort = Integer.parseInt(port);
|
||||
try {
|
||||
token.nextToken();
|
||||
}catch(NoSuchElementException e) {
|
||||
//No need to go further, no iana.
|
||||
eng = SnmpEngineId.createEngineId(objAddress,
|
||||
objPort,
|
||||
objIana);
|
||||
eng.setStringValue(str);
|
||||
return eng;
|
||||
}
|
||||
}
|
||||
|
||||
//Deal with iana
|
||||
try {
|
||||
iana = token.nextToken();
|
||||
}catch(NoSuchElementException e) {
|
||||
//No need to go further, no port.
|
||||
eng = SnmpEngineId.createEngineId(objAddress,
|
||||
objPort,
|
||||
objIana);
|
||||
eng.setStringValue(str);
|
||||
return eng;
|
||||
}
|
||||
|
||||
if(!iana.equals(separator))
|
||||
objIana = Integer.parseInt(iana);
|
||||
|
||||
eng = SnmpEngineId.createEngineId(objAddress,
|
||||
objPort,
|
||||
objIana);
|
||||
eng.setStringValue(str);
|
||||
|
||||
return eng;
|
||||
|
||||
} catch(Exception e) {
|
||||
throw new IllegalArgumentException("Passed string is invalid : ["+str+"]. Check that the used separator ["+ separator + "] is compatible with IPv6 address format.");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique engine Id. The engine Id unicity is based on
|
||||
* the host IP address and port. The IP address used is the
|
||||
* localhost one. The creation algorithm uses the SUN Microsystems IANA
|
||||
* number (42).
|
||||
* @param port The TCP/IP port the SNMPv3 Adaptor Server is listening to.
|
||||
* @return The generated engine Id.
|
||||
* @exception UnknownHostException if the local host name
|
||||
* used to calculate the id is unknown.
|
||||
*/
|
||||
public static SnmpEngineId createEngineId(int port)
|
||||
throws UnknownHostException {
|
||||
int suniana = 42;
|
||||
InetAddress address = null;
|
||||
address = InetAddress.getLocalHost();
|
||||
return createEngineId(address, port, suniana);
|
||||
}
|
||||
/**
|
||||
* Generates a unique engine Id. The engine Id unicity is based on
|
||||
* the host IP address and port. The IP address used is the passed
|
||||
* one. The creation algorithm uses the SUN Microsystems IANA
|
||||
* number (42).
|
||||
* @param address The IP address the SNMPv3 Adaptor Server is listening to.
|
||||
* @param port The TCP/IP port the SNMPv3 Adaptor Server is listening to.
|
||||
* @return The generated engine Id.
|
||||
* @exception UnknownHostException. if the provided address is null.
|
||||
*/
|
||||
public static SnmpEngineId createEngineId(InetAddress address, int port)
|
||||
throws IllegalArgumentException {
|
||||
int suniana = 42;
|
||||
if(address == null)
|
||||
throw new IllegalArgumentException("InetAddress is null.");
|
||||
return createEngineId(address, port, suniana);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique engine Id. The engine Id unicity is based on
|
||||
* the host IP address and port. The IP address is the localhost one.
|
||||
* The creation algorithm uses the passed IANA number.
|
||||
* @param port The TCP/IP port the SNMPv3 Adaptor Server is listening to.
|
||||
* @param iana Your enterprise IANA number.
|
||||
* @exception UnknownHostException if the local host name used to calculate the id is unknown.
|
||||
* @return The generated engine Id.
|
||||
*/
|
||||
public static SnmpEngineId createEngineId(int port, int iana) throws UnknownHostException {
|
||||
InetAddress address = null;
|
||||
address = InetAddress.getLocalHost();
|
||||
return createEngineId(address, port, iana);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a unique engine Id. The engine Id unicity is based on the host IP address and port. The IP address is the passed one, it handles IPv4 and IPv6 hosts. The creation algorithm uses the passed IANA number.
|
||||
* @param addr The IP address the SNMPv3 Adaptor Server is listening to.
|
||||
* @param port The TCP/IP port the SNMPv3 Adaptor Server is listening to.
|
||||
* @param iana Your enterprise IANA number.
|
||||
* @return The generated engine Id.
|
||||
* @exception UnknownHostException if the provided <CODE>InetAddress </CODE> is null.
|
||||
*/
|
||||
public static SnmpEngineId createEngineId(InetAddress addr,
|
||||
int port,
|
||||
int iana) {
|
||||
if(addr == null) throw new IllegalArgumentException("InetAddress is null.");
|
||||
byte[] address = addr.getAddress();
|
||||
byte[] engineid = new byte[9 + address.length];
|
||||
engineid[0] = (byte) ( (iana & 0xFF000000) >> 24 );
|
||||
engineid[0] |= 0x80;
|
||||
engineid[1] = (byte) ( (iana & 0x00FF0000) >> 16 );
|
||||
engineid[2] = (byte) ( (iana & 0x0000FF00) >> 8 );
|
||||
|
||||
engineid[3] = (byte) (iana & 0x000000FF);
|
||||
engineid[4] = 0x05;
|
||||
|
||||
if(address.length == 4)
|
||||
engineid[4] = 0x01;
|
||||
|
||||
if(address.length == 16)
|
||||
engineid[4] = 0x02;
|
||||
|
||||
for(int i = 0; i < address.length; i++) {
|
||||
engineid[i + 5] = address[i];
|
||||
}
|
||||
|
||||
engineid[5 + address.length] = (byte) ( (port & 0xFF000000) >> 24 );
|
||||
engineid[6 + address.length] = (byte) ( (port & 0x00FF0000) >> 16 );
|
||||
engineid[7 + address.length] = (byte) ( (port & 0x0000FF00) >> 8 );
|
||||
engineid[8 + address.length] = (byte) ( port & 0x000000FF );
|
||||
|
||||
return new SnmpEngineId(engineid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an engine Id based on an InetAddress. Handles IPv4 and IPv6 addresses. The creation algorithm uses the passed IANA number.
|
||||
* @param iana Your enterprise IANA number.
|
||||
* @param addr The IP address the SNMPv3 Adaptor Server is listening to.
|
||||
* @return The generated engine Id.
|
||||
* @since 1.5
|
||||
* @exception UnknownHostException if the provided <CODE>InetAddress </CODE> is null.
|
||||
*/
|
||||
public static SnmpEngineId createEngineId(int iana, InetAddress addr)
|
||||
{
|
||||
if(addr == null) throw new IllegalArgumentException("InetAddress is null.");
|
||||
byte[] address = addr.getAddress();
|
||||
byte[] engineid = new byte[5 + address.length];
|
||||
engineid[0] = (byte) ( (iana & 0xFF000000) >> 24 );
|
||||
engineid[0] |= 0x80;
|
||||
engineid[1] = (byte) ( (iana & 0x00FF0000) >> 16 );
|
||||
engineid[2] = (byte) ( (iana & 0x0000FF00) >> 8 );
|
||||
|
||||
engineid[3] = (byte) (iana & 0x000000FF);
|
||||
if(address.length == 4)
|
||||
engineid[4] = 0x01;
|
||||
|
||||
if(address.length == 16)
|
||||
engineid[4] = 0x02;
|
||||
|
||||
for(int i = 0; i < address.length; i++) {
|
||||
engineid[i + 5] = address[i];
|
||||
}
|
||||
|
||||
return new SnmpEngineId(engineid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates an engine Id based on an InetAddress. Handles IPv4 and IPv6
|
||||
* addresses. The creation algorithm uses the sun IANA number (42).
|
||||
* @param addr The IP address the SNMPv3 Adaptor Server is listening to.
|
||||
* @return The generated engine Id.
|
||||
* @since 1.5
|
||||
* @exception UnknownHostException if the provided
|
||||
* <CODE>InetAddress</CODE> is null.
|
||||
*/
|
||||
public static SnmpEngineId createEngineId(InetAddress addr) {
|
||||
return createEngineId(42, addr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests <CODE>SnmpEngineId</CODE> instance equality. Two <CODE>SnmpEngineId</CODE> are equal if they have the same value.
|
||||
* @return <CODE>true</CODE> if the two <CODE>SnmpEngineId</CODE> are equals, <CODE>false</CODE> otherwise.
|
||||
*/
|
||||
public boolean equals(Object a) {
|
||||
if(!(a instanceof SnmpEngineId) ) return false;
|
||||
return hexString.equals(((SnmpEngineId) a).toString());
|
||||
}
|
||||
|
||||
public int hashCode() {
|
||||
return hexString.hashCode();
|
||||
}
|
||||
}
|
||||
117
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpEngineParameters.java
Normal file
117
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpEngineParameters.java
Normal file
@@ -0,0 +1,117 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* This class is used to pass some specific parameters to an <CODE>
|
||||
* SnmpEngineFactory </CODE>.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpEngineParameters implements Serializable {
|
||||
private static final long serialVersionUID = 3720556613478400808L;
|
||||
|
||||
private UserAcl uacl = null;
|
||||
private String securityFile = null;
|
||||
private boolean encrypt = false;
|
||||
private SnmpEngineId engineId = null;
|
||||
|
||||
/**
|
||||
* Sets the file to use for SNMP Runtime Lcd. If no file is provided, the default location will be checked.
|
||||
*/
|
||||
public void setSecurityFile(String securityFile) {
|
||||
this.securityFile = securityFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the file to use for SNMP Runtime Lcd.
|
||||
* @return The security file.
|
||||
*/
|
||||
public String getSecurityFile() {
|
||||
return securityFile;
|
||||
}
|
||||
/**
|
||||
* Sets a customized user ACL. User Acl is used in order to check
|
||||
* access for SNMP V3 requests. If no ACL is provided,
|
||||
* <CODE>com.sun.jmx.snmp.usm.UserAcl.UserAcl</CODE> is instantiated.
|
||||
* @param uacl The user ACL to use.
|
||||
*/
|
||||
public void setUserAcl(UserAcl uacl) {
|
||||
this.uacl = uacl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the customized user ACL.
|
||||
* @return The customized user ACL.
|
||||
*/
|
||||
public UserAcl getUserAcl() {
|
||||
return uacl;
|
||||
}
|
||||
|
||||
/**
|
||||
* Activate SNMP V3 encryption. By default the encryption is not activated. Be sure that the security provider classes needed for DES are in your classpath (eg:JCE classes)
|
||||
*
|
||||
*/
|
||||
public void activateEncryption() {
|
||||
this.encrypt = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deactivate SNMP V3 encryption. By default the encryption is not activated. Be sure that the security provider classes needed for DES are in your classpath (eg:JCE classes)
|
||||
*
|
||||
*/
|
||||
public void deactivateEncryption() {
|
||||
this.encrypt = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if encryption is activated. By default the encryption is not activated.
|
||||
* @return The encryption activation status.
|
||||
*/
|
||||
public boolean isEncryptionEnabled() {
|
||||
return encrypt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the engine Id.
|
||||
* @param engineId The engine Id to use.
|
||||
*/
|
||||
public void setEngineId(SnmpEngineId engineId) {
|
||||
this.engineId = engineId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the engine Id.
|
||||
* @return The engineId.
|
||||
*/
|
||||
public SnmpEngineId getEngineId() {
|
||||
return engineId;
|
||||
}
|
||||
}
|
||||
99
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpGauge.java
Normal file
99
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpGauge.java
Normal file
@@ -0,0 +1,99 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Represents an SNMP gauge.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpGauge extends SnmpUnsignedInt {
|
||||
private static final long serialVersionUID = -8366622742122792945L;
|
||||
|
||||
// CONSTRUCTORS
|
||||
//-------------
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpGauge</CODE> from the specified integer value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link SnmpUnsignedInt#MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpGauge(int v) throws IllegalArgumentException {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpGauge</CODE> from the specified <CODE>Integer</CODE> value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link SnmpUnsignedInt#MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpGauge(Integer v) throws IllegalArgumentException {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpGauge</CODE> from the specified long value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link SnmpUnsignedInt#MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpGauge(long v) throws IllegalArgumentException {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpGauge</CODE> from the specified <CODE>Long</CODE> value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link SnmpUnsignedInt#MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpGauge(Long v) throws IllegalArgumentException {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
// PUBLIC METHODS
|
||||
//---------------
|
||||
/**
|
||||
* Returns a textual description of the type object.
|
||||
* @return ASN.1 textual description.
|
||||
*/
|
||||
final public String getTypeName() {
|
||||
return name ;
|
||||
}
|
||||
|
||||
// VARIABLES
|
||||
//----------
|
||||
/**
|
||||
* Name of the type.
|
||||
*/
|
||||
final static String name = "Gauge32" ;
|
||||
}
|
||||
282
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpInt.java
Normal file
282
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpInt.java
Normal file
@@ -0,0 +1,282 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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;
|
||||
|
||||
|
||||
|
||||
import com.sun.jmx.snmp.Enumerated;
|
||||
|
||||
/**
|
||||
* Represents an SNMP integer.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpInt extends SnmpValue {
|
||||
private static final long serialVersionUID = -7163624758070343373L;
|
||||
|
||||
// CONSTRUCTORS
|
||||
//-------------
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpInt</CODE> from the specified integer value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is smaller than <CODE>Integer.MIN_VALUE</CODE>
|
||||
* or larger than <CODE>Integer.MAX_VALUE</CODE>.
|
||||
*/
|
||||
public SnmpInt(int v) throws IllegalArgumentException {
|
||||
if ( isInitValueValid(v) == false ) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
value = (long)v ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpInt</CODE> from the specified <CODE>Integer</CODE> value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is smaller than <CODE>Integer.MIN_VALUE</CODE>
|
||||
* or larger than <CODE>Integer.MAX_VALUE</CODE>.
|
||||
*/
|
||||
public SnmpInt(Integer v) throws IllegalArgumentException {
|
||||
this(v.intValue()) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpInt</CODE> from the specified long value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is smaller than <CODE>Integer.MIN_VALUE</CODE>
|
||||
* or larger than <CODE>Integer.MAX_VALUE</CODE>.
|
||||
*/
|
||||
public SnmpInt(long v) throws IllegalArgumentException {
|
||||
if ( isInitValueValid(v) == false ) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
value = v ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpInt</CODE> from the specified <CODE>Long</CODE> value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is smaller than <CODE>Integer.MIN_VALUE</CODE>
|
||||
* or larger than <CODE>Integer.MAX_VALUE</CODE>.
|
||||
*/
|
||||
public SnmpInt(Long v) throws IllegalArgumentException {
|
||||
this(v.longValue()) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpInt</CODE> from the specified <CODE>Enumerated</CODE> value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is smaller than <CODE>Integer.MIN_VALUE</CODE>
|
||||
* or larger than <CODE>Integer.MAX_VALUE</CODE>.
|
||||
* @see Enumerated
|
||||
*/
|
||||
public SnmpInt(Enumerated v) throws IllegalArgumentException {
|
||||
this(v.intValue()) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpInt</CODE> from the specified boolean value.
|
||||
* This constructor applies rfc1903 rule:
|
||||
* <p><blockquote><pre>
|
||||
* TruthValue ::= TEXTUAL-CONVENTION
|
||||
* STATUS current
|
||||
* DESCRIPTION
|
||||
* "Represents a boolean value."
|
||||
* SYNTAX INTEGER { true(1), false(2) }
|
||||
* </pre></blockquote>
|
||||
* @param v The initialization value.
|
||||
*/
|
||||
public SnmpInt(boolean v) {
|
||||
value = v ? 1 : 2 ;
|
||||
}
|
||||
|
||||
// PUBLIC METHODS
|
||||
//---------------
|
||||
/**
|
||||
* Returns the long value of this <CODE>SnmpInt</CODE>.
|
||||
* @return The value.
|
||||
*/
|
||||
public long longValue() {
|
||||
return value ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the integer value to its <CODE>Long</CODE> form.
|
||||
* @return The <CODE>Long</CODE> representation of the value.
|
||||
*/
|
||||
public Long toLong() {
|
||||
return new Long(value) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the integer value to its integer form.
|
||||
* @return The integer representation of the value.
|
||||
*/
|
||||
public int intValue() {
|
||||
return (int) value ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the integer value to its <CODE>Integer</CODE> form.
|
||||
* @return The <CODE>Integer</CODE> representation of the value.
|
||||
*/
|
||||
public Integer toInteger() {
|
||||
return new Integer((int)value) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the integer value to its <CODE>String</CODE> form.
|
||||
* @return The <CODE>String</CODE> representation of the value.
|
||||
*/
|
||||
public String toString() {
|
||||
return String.valueOf(value) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the integer value to its <CODE>SnmpOid</CODE> form.
|
||||
* @return The OID representation of the value.
|
||||
*/
|
||||
public SnmpOid toOid() {
|
||||
return new SnmpOid(value) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the integer from an index OID and returns its
|
||||
* value converted as an <CODE>SnmpOid</CODE>.
|
||||
* @param index The index array.
|
||||
* @param start The position in the index array.
|
||||
* @return The OID representing the integer value.
|
||||
* @exception SnmpStatusException There is no integer value
|
||||
* available at the start position.
|
||||
*/
|
||||
public static SnmpOid toOid(long[] index, int start) throws SnmpStatusException {
|
||||
try {
|
||||
return new SnmpOid(index[start]) ;
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans an index OID, skips the integer value and returns the position
|
||||
* of the next value.
|
||||
* @param index The index array.
|
||||
* @param start The position in the index array.
|
||||
* @return The position of the next value.
|
||||
* @exception SnmpStatusException There is no integer value
|
||||
* available at the start position.
|
||||
*/
|
||||
public static int nextOid(long[] index, int start) throws SnmpStatusException {
|
||||
if (start >= index.length) {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
else {
|
||||
return start + 1 ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an <CODE>SnmpOid</CODE> representing an <CODE>SnmpInt</CODE> to another OID.
|
||||
* @param source An OID representing an <CODE>SnmpInt</CODE> value.
|
||||
* @param dest Where source should be appended.
|
||||
*/
|
||||
public static void appendToOid(SnmpOid source, SnmpOid dest) {
|
||||
if (source.getLength() != 1) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
dest.append(source) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a clone action. This provides a workaround for the
|
||||
* <CODE>SnmpValue</CODE> interface.
|
||||
* @return The <CODE>SnmpValue</CODE> clone.
|
||||
*/
|
||||
final synchronized public SnmpValue duplicate() {
|
||||
return (SnmpValue) clone() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones the <CODE>SnmpInt</CODE> object, making a copy of its data.
|
||||
* @return The object clone.
|
||||
*/
|
||||
final synchronized public Object clone() {
|
||||
SnmpInt newclone = null ;
|
||||
try {
|
||||
newclone = (SnmpInt) super.clone() ;
|
||||
newclone.value = value ;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError(e) ; // vm bug.
|
||||
}
|
||||
return newclone ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a textual description of the type object.
|
||||
* @return ASN.1 textual description.
|
||||
*/
|
||||
public String getTypeName() {
|
||||
return name ;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method has been defined to allow the sub-classes
|
||||
* of SnmpInt to perform their own control at intialization time.
|
||||
*/
|
||||
boolean isInitValueValid(int v) {
|
||||
if ((v < Integer.MIN_VALUE) || (v > Integer.MAX_VALUE)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method has been defined to allow the sub-classes
|
||||
* of SnmpInt to perform their own control at intialization time.
|
||||
*/
|
||||
boolean isInitValueValid(long v) {
|
||||
if ((v < Integer.MIN_VALUE) || (v > Integer.MAX_VALUE)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// VARIABLES
|
||||
//----------
|
||||
/**
|
||||
* Name of the type.
|
||||
*/
|
||||
final static String name = "Integer32" ;
|
||||
|
||||
/**
|
||||
* This is where the value is stored. This long is signed.
|
||||
* @serial
|
||||
*/
|
||||
protected long value = 0 ;
|
||||
}
|
||||
217
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpIpAddress.java
Normal file
217
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpIpAddress.java
Normal file
@@ -0,0 +1,217 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Represents an SNMP IpAddress.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpIpAddress extends SnmpOid {
|
||||
private static final long serialVersionUID = 7204629998270874474L;
|
||||
|
||||
// CONSTRUCTORS
|
||||
//-------------
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpIpAddress</CODE> from the specified bytes array.
|
||||
* @param bytes The four bytes composing the address.
|
||||
* @exception IllegalArgumentException The length of the array is not equal to four.
|
||||
*/
|
||||
public SnmpIpAddress(byte[] bytes) throws IllegalArgumentException {
|
||||
buildFromByteArray(bytes);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpIpAddress</CODE> from the specified long value.
|
||||
* @param addr The initialization value.
|
||||
*/
|
||||
public SnmpIpAddress(long addr) {
|
||||
int address = (int)addr ;
|
||||
byte[] ipaddr = new byte[4];
|
||||
|
||||
ipaddr[0] = (byte) ((address >>> 24) & 0xFF);
|
||||
ipaddr[1] = (byte) ((address >>> 16) & 0xFF);
|
||||
ipaddr[2] = (byte) ((address >>> 8) & 0xFF);
|
||||
ipaddr[3] = (byte) (address & 0xFF);
|
||||
|
||||
buildFromByteArray(ipaddr);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpIpAddress</CODE> from a dot-formatted <CODE>String</CODE>.
|
||||
* The dot-formatted <CODE>String</CODE> is formulated x.x.x.x .
|
||||
* @param dotAddress The initialization value.
|
||||
* @exception IllegalArgumentException The string does not correspond to an ip address.
|
||||
*/
|
||||
public SnmpIpAddress(String dotAddress) throws IllegalArgumentException {
|
||||
super(dotAddress) ;
|
||||
if ((componentCount > 4) ||
|
||||
(components[0] > 255) ||
|
||||
(components[1] > 255) ||
|
||||
(components[2] > 255) ||
|
||||
(components[3] > 255)) {
|
||||
throw new IllegalArgumentException(dotAddress) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpIpAddress</CODE> from four long values.
|
||||
* @param b1 Byte 1.
|
||||
* @param b2 Byte 2.
|
||||
* @param b3 Byte 3.
|
||||
* @param b4 Byte 4.
|
||||
* @exception IllegalArgumentException A value is outside of [0-255].
|
||||
*/
|
||||
public SnmpIpAddress(long b1, long b2, long b3, long b4) {
|
||||
super(b1, b2, b3, b4) ;
|
||||
if ((components[0] > 255) ||
|
||||
(components[1] > 255) ||
|
||||
(components[2] > 255) ||
|
||||
(components[3] > 255)) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
}
|
||||
|
||||
// PUBLIC METHODS
|
||||
//---------------
|
||||
/**
|
||||
* Converts the address value to its byte array form.
|
||||
* @return The byte array representation of the value.
|
||||
*/
|
||||
public byte[] byteValue() {
|
||||
byte[] result = new byte[4] ;
|
||||
result[0] = (byte)components[0] ;
|
||||
result[1] = (byte)components[1] ;
|
||||
result[2] = (byte)components[2] ;
|
||||
result[3] = (byte)components[3] ;
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the address to its <CODE>String</CODE> form.
|
||||
* Same as <CODE>toString()</CODE>. Exists only to follow a naming scheme.
|
||||
* @return The <CODE>String</CODE> representation of the value.
|
||||
*/
|
||||
public String stringValue() {
|
||||
return toString() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the ip address from an index OID and returns its
|
||||
* value converted as an <CODE>SnmpOid</CODE>.
|
||||
* @param index The index array.
|
||||
* @param start The position in the index array.
|
||||
* @return The OID representing the ip address value.
|
||||
* @exception SnmpStatusException There is no ip address value
|
||||
* available at the start position.
|
||||
*/
|
||||
public static SnmpOid toOid(long[] index, int start) throws SnmpStatusException {
|
||||
if (start + 4 <= index.length) {
|
||||
try {
|
||||
return new SnmpOid(
|
||||
index[start],
|
||||
index[start+1],
|
||||
index[start+2],
|
||||
index[start+3]) ;
|
||||
}
|
||||
catch(IllegalArgumentException e) {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
}
|
||||
else {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans an index OID, skips the address value and returns the position
|
||||
* of the next value.
|
||||
* @param index The index array.
|
||||
* @param start The position in the index array.
|
||||
* @return The position of the next value.
|
||||
* @exception SnmpStatusException There is no address value
|
||||
* available at the start position.
|
||||
*/
|
||||
public static int nextOid(long[] index, int start) throws SnmpStatusException {
|
||||
if (start + 4 <= index.length) {
|
||||
return start + 4 ;
|
||||
}
|
||||
else {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an <CODE>SnmpOid</CODE> representing an <CODE>SnmpIpAddress</CODE> to another OID.
|
||||
* @param source An OID representing an <CODE>SnmpIpAddress</CODE> value.
|
||||
* @param dest Where source should be appended.
|
||||
*/
|
||||
public static void appendToOid(SnmpOid source, SnmpOid dest) {
|
||||
if (source.getLength() != 4) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
dest.append(source) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a textual description of the type object.
|
||||
* @return ASN.1 textual description.
|
||||
*/
|
||||
final public String getTypeName() {
|
||||
return name ;
|
||||
}
|
||||
|
||||
// PRIVATE METHODS
|
||||
//----------------
|
||||
/**
|
||||
* Build Ip address from byte array.
|
||||
*/
|
||||
private void buildFromByteArray(byte[] bytes) {
|
||||
if (bytes.length != 4) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
components = new long[4] ;
|
||||
componentCount= 4;
|
||||
components[0] = (bytes[0] >= 0) ? bytes[0] : bytes[0] + 256 ;
|
||||
components[1] = (bytes[1] >= 0) ? bytes[1] : bytes[1] + 256 ;
|
||||
components[2] = (bytes[2] >= 0) ? bytes[2] : bytes[2] + 256 ;
|
||||
components[3] = (bytes[3] >= 0) ? bytes[3] : bytes[3] + 256 ;
|
||||
}
|
||||
|
||||
// VARIABLES
|
||||
//----------
|
||||
/**
|
||||
* Name of the type.
|
||||
*/
|
||||
final static String name = "IpAddress" ;
|
||||
}
|
||||
362
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpMessage.java
Normal file
362
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpMessage.java
Normal file
@@ -0,0 +1,362 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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;
|
||||
|
||||
|
||||
|
||||
// java imports
|
||||
//
|
||||
import java.util.logging.Level;
|
||||
import java.util.Vector;
|
||||
import java.net.InetAddress;
|
||||
|
||||
import static com.sun.jmx.defaults.JmxProperties.SNMP_LOGGER;
|
||||
|
||||
/**
|
||||
* Is a partially decoded representation of an SNMP packet.
|
||||
* <P>
|
||||
* You will not normally need to use this class unless you decide to
|
||||
* implement your own {@link com.sun.jmx.snmp.SnmpPduFactory SnmpPduFactory} object.
|
||||
* <P>
|
||||
* The <CODE>SnmpMessage</CODE> class is directly mapped onto the
|
||||
* <CODE>Message</CODE> syntax defined in RFC1157 and RFC1902.
|
||||
* <BLOCKQUOTE>
|
||||
* <PRE>
|
||||
* Message ::= SEQUENCE {
|
||||
* version INTEGER { version(1) }, -- for SNMPv2
|
||||
* community OCTET STRING, -- community name
|
||||
* data ANY -- an SNMPv2 PDU
|
||||
* }
|
||||
* </PRE>
|
||||
* </BLOCKQUOTE>
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @see SnmpPduFactory
|
||||
* @see SnmpPduPacket
|
||||
*
|
||||
*/
|
||||
|
||||
public class SnmpMessage extends SnmpMsg implements SnmpDefinitions {
|
||||
/**
|
||||
* Community name.
|
||||
*/
|
||||
public byte[] community ;
|
||||
|
||||
/**
|
||||
* Encodes this message and puts the result in the specified byte array.
|
||||
* For internal use only.
|
||||
*
|
||||
* @param outputBytes An array to receive the resulting encoding.
|
||||
*
|
||||
* @exception ArrayIndexOutOfBoundsException If the result does not fit
|
||||
* into the specified array.
|
||||
*/
|
||||
public int encodeMessage(byte[] outputBytes) throws SnmpTooBigException {
|
||||
int encodingLength = 0 ;
|
||||
if (data == null)
|
||||
throw new IllegalArgumentException("Data field is null") ;
|
||||
|
||||
//
|
||||
// Reminder: BerEncoder does backward encoding !
|
||||
//
|
||||
try {
|
||||
BerEncoder benc = new BerEncoder(outputBytes) ;
|
||||
benc.openSequence() ;
|
||||
benc.putAny(data, dataLength) ;
|
||||
benc.putOctetString((community != null) ? community : new byte[0]) ;
|
||||
benc.putInteger(version) ;
|
||||
benc.closeSequence() ;
|
||||
encodingLength = benc.trim() ;
|
||||
}
|
||||
catch(ArrayIndexOutOfBoundsException x) {
|
||||
throw new SnmpTooBigException() ;
|
||||
}
|
||||
|
||||
return encodingLength ;
|
||||
}
|
||||
/**
|
||||
* Returns the associated request ID.
|
||||
* @param inputBytes The flat message.
|
||||
* @return The request ID.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public int getRequestId(byte[] inputBytes) throws SnmpStatusException {
|
||||
int requestId = 0;
|
||||
BerDecoder bdec = null;
|
||||
BerDecoder bdec2 = null;
|
||||
byte[] any = null;
|
||||
try {
|
||||
bdec = new BerDecoder(inputBytes);
|
||||
bdec.openSequence();
|
||||
bdec.fetchInteger();
|
||||
bdec.fetchOctetString();
|
||||
any = bdec.fetchAny();
|
||||
bdec2 = new BerDecoder(any);
|
||||
int type = bdec2.getTag();
|
||||
bdec2.openSequence(type);
|
||||
requestId = bdec2.fetchInteger();
|
||||
}
|
||||
catch(BerException x) {
|
||||
throw new SnmpStatusException("Invalid encoding") ;
|
||||
}
|
||||
try {
|
||||
bdec.closeSequence();
|
||||
}
|
||||
catch(BerException x) {
|
||||
}
|
||||
try {
|
||||
bdec2.closeSequence();
|
||||
}
|
||||
catch(BerException x) {
|
||||
}
|
||||
return requestId;
|
||||
}
|
||||
/**
|
||||
* Decodes the specified bytes and initializes this message.
|
||||
* For internal use only.
|
||||
*
|
||||
* @param inputBytes The bytes to be decoded.
|
||||
*
|
||||
* @exception SnmpStatusException If the specified bytes are not a valid encoding.
|
||||
*/
|
||||
public void decodeMessage(byte[] inputBytes, int byteCount)
|
||||
throws SnmpStatusException {
|
||||
try {
|
||||
BerDecoder bdec = new BerDecoder(inputBytes/*, byteCount */) ; // FIXME
|
||||
bdec.openSequence() ;
|
||||
version = bdec.fetchInteger() ;
|
||||
community = bdec.fetchOctetString() ;
|
||||
data = bdec.fetchAny() ;
|
||||
dataLength = data.length ;
|
||||
bdec.closeSequence() ;
|
||||
}
|
||||
catch(BerException x) {
|
||||
throw new SnmpStatusException("Invalid encoding") ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes this message with the specified <CODE>pdu</CODE>.
|
||||
* <P>
|
||||
* This method initializes the data field with an array of
|
||||
* <CODE>maxDataLength</CODE> bytes. It encodes the <CODE>pdu</CODE>.
|
||||
* The resulting encoding is stored in the data field
|
||||
* and the length of the encoding is stored in <CODE>dataLength</CODE>.
|
||||
* <p>
|
||||
* If the encoding length exceeds <CODE>maxDataLength</CODE>,
|
||||
* the method throws an exception.
|
||||
*
|
||||
* @param pdu The PDU to be encoded.
|
||||
* @param maxDataLength The maximum length permitted for the data field.
|
||||
*
|
||||
* @exception SnmpStatusException If the specified <CODE>pdu</CODE> is not valid.
|
||||
* @exception SnmpTooBigException If the resulting encoding does not fit
|
||||
* into <CODE>maxDataLength</CODE> bytes.
|
||||
* @exception ArrayIndexOutOfBoundsException If the encoding exceeds <CODE>maxDataLength</CODE>.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void encodeSnmpPdu(SnmpPdu pdu, int maxDataLength)
|
||||
throws SnmpStatusException, SnmpTooBigException {
|
||||
//
|
||||
// The easy work
|
||||
//
|
||||
SnmpPduPacket pdupacket = (SnmpPduPacket) pdu;
|
||||
version = pdupacket.version ;
|
||||
community = pdupacket.community ;
|
||||
address = pdupacket.address ;
|
||||
port = pdupacket.port ;
|
||||
|
||||
//
|
||||
// Allocate the array to receive the encoding.
|
||||
//
|
||||
data = new byte[maxDataLength] ;
|
||||
|
||||
//
|
||||
// Encode the pdupacket
|
||||
// Reminder: BerEncoder does backward encoding !
|
||||
//
|
||||
|
||||
try {
|
||||
BerEncoder benc = new BerEncoder(data) ;
|
||||
benc.openSequence() ;
|
||||
encodeVarBindList(benc, pdupacket.varBindList) ;
|
||||
|
||||
switch(pdupacket.type) {
|
||||
|
||||
case pduGetRequestPdu :
|
||||
case pduGetNextRequestPdu :
|
||||
case pduInformRequestPdu :
|
||||
case pduGetResponsePdu :
|
||||
case pduSetRequestPdu :
|
||||
case pduV2TrapPdu :
|
||||
case pduReportPdu :
|
||||
SnmpPduRequest reqPdu = (SnmpPduRequest)pdupacket ;
|
||||
benc.putInteger(reqPdu.errorIndex) ;
|
||||
benc.putInteger(reqPdu.errorStatus) ;
|
||||
benc.putInteger(reqPdu.requestId) ;
|
||||
break ;
|
||||
|
||||
case pduGetBulkRequestPdu :
|
||||
SnmpPduBulk bulkPdu = (SnmpPduBulk)pdupacket ;
|
||||
benc.putInteger(bulkPdu.maxRepetitions) ;
|
||||
benc.putInteger(bulkPdu.nonRepeaters) ;
|
||||
benc.putInteger(bulkPdu.requestId) ;
|
||||
break ;
|
||||
|
||||
case pduV1TrapPdu :
|
||||
SnmpPduTrap trapPdu = (SnmpPduTrap)pdupacket ;
|
||||
benc.putInteger(trapPdu.timeStamp, SnmpValue.TimeticksTag) ;
|
||||
benc.putInteger(trapPdu.specificTrap) ;
|
||||
benc.putInteger(trapPdu.genericTrap) ;
|
||||
if(trapPdu.agentAddr != null)
|
||||
benc.putOctetString(trapPdu.agentAddr.byteValue(), SnmpValue.IpAddressTag) ;
|
||||
else
|
||||
benc.putOctetString(new byte[0], SnmpValue.IpAddressTag);
|
||||
benc.putOid(trapPdu.enterprise.longValue()) ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
throw new SnmpStatusException("Invalid pdu type " + String.valueOf(pdupacket.type)) ;
|
||||
}
|
||||
benc.closeSequence(pdupacket.type) ;
|
||||
dataLength = benc.trim() ;
|
||||
}
|
||||
catch(ArrayIndexOutOfBoundsException x) {
|
||||
throw new SnmpTooBigException() ;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Gets the PDU encoded in this message.
|
||||
* <P>
|
||||
* This method decodes the data field and returns the resulting PDU.
|
||||
*
|
||||
* @return The resulting PDU.
|
||||
* @exception SnmpStatusException If the encoding is not valid.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public SnmpPdu decodeSnmpPdu()
|
||||
throws SnmpStatusException {
|
||||
//
|
||||
// Decode the pdu
|
||||
//
|
||||
SnmpPduPacket pdu = null ;
|
||||
BerDecoder bdec = new BerDecoder(data) ;
|
||||
try {
|
||||
int type = bdec.getTag() ;
|
||||
bdec.openSequence(type) ;
|
||||
switch(type) {
|
||||
|
||||
case pduGetRequestPdu :
|
||||
case pduGetNextRequestPdu :
|
||||
case pduInformRequestPdu :
|
||||
case pduGetResponsePdu :
|
||||
case pduSetRequestPdu :
|
||||
case pduV2TrapPdu :
|
||||
case pduReportPdu :
|
||||
SnmpPduRequest reqPdu = new SnmpPduRequest() ;
|
||||
reqPdu.requestId = bdec.fetchInteger() ;
|
||||
reqPdu.errorStatus = bdec.fetchInteger() ;
|
||||
reqPdu.errorIndex = bdec.fetchInteger() ;
|
||||
pdu = reqPdu ;
|
||||
break ;
|
||||
|
||||
case pduGetBulkRequestPdu :
|
||||
SnmpPduBulk bulkPdu = new SnmpPduBulk() ;
|
||||
bulkPdu.requestId = bdec.fetchInteger() ;
|
||||
bulkPdu.nonRepeaters = bdec.fetchInteger() ;
|
||||
bulkPdu.maxRepetitions = bdec.fetchInteger() ;
|
||||
pdu = bulkPdu ;
|
||||
break ;
|
||||
|
||||
case pduV1TrapPdu :
|
||||
SnmpPduTrap trapPdu = new SnmpPduTrap() ;
|
||||
trapPdu.enterprise = new SnmpOid(bdec.fetchOid()) ;
|
||||
byte []b = bdec.fetchOctetString(SnmpValue.IpAddressTag);
|
||||
if(b.length != 0)
|
||||
trapPdu.agentAddr = new SnmpIpAddress(b) ;
|
||||
else
|
||||
trapPdu.agentAddr = null;
|
||||
trapPdu.genericTrap = bdec.fetchInteger() ;
|
||||
trapPdu.specificTrap = bdec.fetchInteger() ;
|
||||
trapPdu.timeStamp = bdec.fetchInteger(SnmpValue.TimeticksTag) ;
|
||||
pdu = trapPdu ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
throw new SnmpStatusException(snmpRspWrongEncoding) ;
|
||||
}
|
||||
pdu.type = type ;
|
||||
pdu.varBindList = decodeVarBindList(bdec) ;
|
||||
bdec.closeSequence() ;
|
||||
} catch(BerException e) {
|
||||
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
|
||||
SNMP_LOGGER.logp(Level.FINEST, SnmpMessage.class.getName(),
|
||||
"decodeSnmpPdu", "BerException", e);
|
||||
}
|
||||
throw new SnmpStatusException(snmpRspWrongEncoding);
|
||||
} catch(IllegalArgumentException e) {
|
||||
// bug id 4654066
|
||||
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
|
||||
SNMP_LOGGER.logp(Level.FINEST, SnmpMessage.class.getName(),
|
||||
"decodeSnmpPdu", "IllegalArgumentException", e);
|
||||
}
|
||||
throw new SnmpStatusException(snmpRspWrongEncoding);
|
||||
}
|
||||
|
||||
//
|
||||
// The easy work
|
||||
//
|
||||
pdu.version = version ;
|
||||
pdu.community = community ;
|
||||
pdu.address = address ;
|
||||
pdu.port = port ;
|
||||
|
||||
return pdu;
|
||||
}
|
||||
/**
|
||||
* Dumps this message in a string.
|
||||
*
|
||||
* @return The string containing the dump.
|
||||
*/
|
||||
public String printMessage() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (community == null) {
|
||||
sb.append("Community: null") ;
|
||||
}
|
||||
else {
|
||||
sb.append("Community: {\n") ;
|
||||
sb.append(dumpHexBuffer(community, 0, community.length)) ;
|
||||
sb.append("\n}\n") ;
|
||||
}
|
||||
return sb.append(super.printMessage()).toString();
|
||||
}
|
||||
|
||||
}
|
||||
476
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpMsg.java
Normal file
476
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpMsg.java
Normal file
@@ -0,0 +1,476 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpSecurityParameters;
|
||||
// java imports
|
||||
//
|
||||
import java.util.Vector;
|
||||
import java.net.InetAddress;
|
||||
|
||||
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
/**
|
||||
* A partially decoded representation of an SNMP packet. It contains
|
||||
* the information contained in any SNMP message (SNMPv1, SNMPv2 or
|
||||
* SNMPv3).
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public abstract class SnmpMsg implements SnmpDefinitions {
|
||||
/**
|
||||
* The protocol version.
|
||||
* <P><CODE>decodeMessage</CODE> and <CODE>encodeMessage</CODE> do not
|
||||
* perform any check on this value.
|
||||
* <BR><CODE>decodeSnmpPdu</CODE> and <CODE>encodeSnmpPdu</CODE> only
|
||||
* accept the values 0 (for SNMPv1), 1 (for SNMPv2) and 3 (for SNMPv3).
|
||||
*/
|
||||
public int version = 0;
|
||||
|
||||
/**
|
||||
* Encoding of the PDU.
|
||||
* <P>This is usually the BER encoding of the PDU's syntax
|
||||
* defined in RFC1157 and RFC1902. However, this can be authenticated
|
||||
* or encrypted data (but you need to implemented your own
|
||||
* <CODE>SnmpPduFactory</CODE> class).
|
||||
*/
|
||||
public byte[] data = null;
|
||||
|
||||
/**
|
||||
* Number of useful bytes in the <CODE>data</CODE> field.
|
||||
*/
|
||||
public int dataLength = 0;
|
||||
|
||||
/**
|
||||
* Source or destination address.
|
||||
* <BR>For an incoming message it's the source.
|
||||
* For an outgoing message it's the destination.
|
||||
*/
|
||||
public InetAddress address = null;
|
||||
|
||||
/**
|
||||
* Source or destination port.
|
||||
* <BR>For an incoming message it's the source.
|
||||
* For an outgoing message it's the destination.
|
||||
*/
|
||||
public int port = 0;
|
||||
/**
|
||||
* Security parameters. Contain informations according to Security Model (Usm, community string based, ...).
|
||||
*/
|
||||
public SnmpSecurityParameters securityParameters = null;
|
||||
/**
|
||||
* Returns the encoded SNMP version present in the passed byte array.
|
||||
* @param data The unmarshalled SNMP message.
|
||||
* @return The SNMP version (0, 1 or 3).
|
||||
*/
|
||||
public static int getProtocolVersion(byte[] data)
|
||||
throws SnmpStatusException {
|
||||
int version = 0;
|
||||
BerDecoder bdec = null;
|
||||
try {
|
||||
bdec = new BerDecoder(data);
|
||||
bdec.openSequence();
|
||||
version = bdec.fetchInteger();
|
||||
}
|
||||
catch(BerException x) {
|
||||
throw new SnmpStatusException("Invalid encoding") ;
|
||||
}
|
||||
try {
|
||||
bdec.closeSequence();
|
||||
}
|
||||
catch(BerException x) {
|
||||
}
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the associated request ID.
|
||||
* @param data The flat message.
|
||||
* @return The request ID.
|
||||
*/
|
||||
public abstract int getRequestId(byte[] data) throws SnmpStatusException;
|
||||
|
||||
/**
|
||||
* Encodes this message and puts the result in the specified byte array.
|
||||
* For internal use only.
|
||||
*
|
||||
* @param outputBytes An array to receive the resulting encoding.
|
||||
*
|
||||
* @exception ArrayIndexOutOfBoundsException If the result does not fit
|
||||
* into the specified array.
|
||||
*/
|
||||
public abstract int encodeMessage(byte[] outputBytes)
|
||||
throws SnmpTooBigException;
|
||||
|
||||
/**
|
||||
* Decodes the specified bytes and initializes this message.
|
||||
* For internal use only.
|
||||
*
|
||||
* @param inputBytes The bytes to be decoded.
|
||||
*
|
||||
* @exception SnmpStatusException If the specified bytes are not a valid encoding.
|
||||
*/
|
||||
public abstract void decodeMessage(byte[] inputBytes, int byteCount)
|
||||
throws SnmpStatusException;
|
||||
|
||||
/**
|
||||
* Initializes this message with the specified <CODE>pdu</CODE>.
|
||||
* <P>
|
||||
* This method initializes the data field with an array of
|
||||
* <CODE>maxDataLength</CODE> bytes. It encodes the <CODE>pdu</CODE>.
|
||||
* The resulting encoding is stored in the data field
|
||||
* and the length of the encoding is stored in <CODE>dataLength</CODE>.
|
||||
* <p>
|
||||
* If the encoding length exceeds <CODE>maxDataLength</CODE>,
|
||||
* the method throws an exception.
|
||||
*
|
||||
* @param pdu The PDU to be encoded.
|
||||
* @param maxDataLength The maximum length permitted for the data field.
|
||||
*
|
||||
* @exception SnmpStatusException If the specified <CODE>pdu</CODE> is not valid.
|
||||
* @exception SnmpTooBigException If the resulting encoding does not fit
|
||||
* into <CODE>maxDataLength</CODE> bytes.
|
||||
* @exception ArrayIndexOutOfBoundsException If the encoding exceeds <CODE>maxDataLength</CODE>.
|
||||
*/
|
||||
public abstract void encodeSnmpPdu(SnmpPdu pdu, int maxDataLength)
|
||||
throws SnmpStatusException, SnmpTooBigException;
|
||||
|
||||
|
||||
/**
|
||||
* Gets the PDU encoded in this message.
|
||||
* <P>
|
||||
* This method decodes the data field and returns the resulting PDU.
|
||||
*
|
||||
* @return The resulting PDU.
|
||||
* @exception SnmpStatusException If the encoding is not valid.
|
||||
*/
|
||||
public abstract SnmpPdu decodeSnmpPdu()
|
||||
throws SnmpStatusException;
|
||||
|
||||
/**
|
||||
* Dumps the content of a byte buffer using hexadecimal form.
|
||||
*
|
||||
* @param b The buffer to dump.
|
||||
* @param offset The position of the first byte to be dumped.
|
||||
* @param len The number of bytes to be dumped starting from offset.
|
||||
*
|
||||
* @return The string containing the dump.
|
||||
*/
|
||||
public static String dumpHexBuffer(byte [] b, int offset, int len) {
|
||||
StringBuffer buf = new StringBuffer(len << 1) ;
|
||||
int k = 1 ;
|
||||
int flen = offset + len ;
|
||||
|
||||
for (int i = offset; i < flen ; i++) {
|
||||
int j = b[i] & 0xFF ;
|
||||
buf.append(Character.forDigit((j >>> 4) , 16)) ;
|
||||
buf.append(Character.forDigit((j & 0x0F), 16)) ;
|
||||
k++ ;
|
||||
if (k%16 == 0) {
|
||||
buf.append('\n') ;
|
||||
k = 1 ;
|
||||
} else
|
||||
buf.append(' ') ;
|
||||
}
|
||||
return buf.toString() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps this message in a string.
|
||||
*
|
||||
* @return The string containing the dump.
|
||||
*/
|
||||
public String printMessage() {
|
||||
StringBuffer sb = new StringBuffer() ;
|
||||
sb.append("Version: ") ;
|
||||
sb.append(version) ;
|
||||
sb.append("\n") ;
|
||||
if (data == null) {
|
||||
sb.append("Data: null") ;
|
||||
}
|
||||
else {
|
||||
sb.append("Data: {\n") ;
|
||||
sb.append(dumpHexBuffer(data, 0, dataLength)) ;
|
||||
sb.append("\n}\n") ;
|
||||
}
|
||||
|
||||
return sb.toString() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* For SNMP Runtime private use only.
|
||||
*/
|
||||
public void encodeVarBindList(BerEncoder benc,
|
||||
SnmpVarBind[] varBindList)
|
||||
throws SnmpStatusException, SnmpTooBigException {
|
||||
//
|
||||
// Remember: the encoder does backward encoding
|
||||
//
|
||||
int encodedVarBindCount = 0 ;
|
||||
try {
|
||||
benc.openSequence() ;
|
||||
if (varBindList != null) {
|
||||
for (int i = varBindList.length - 1 ; i >= 0 ; i--) {
|
||||
SnmpVarBind bind = varBindList[i] ;
|
||||
if (bind != null) {
|
||||
benc.openSequence() ;
|
||||
encodeVarBindValue(benc, bind.value) ;
|
||||
benc.putOid(bind.oid.longValue()) ;
|
||||
benc.closeSequence() ;
|
||||
encodedVarBindCount++ ;
|
||||
}
|
||||
}
|
||||
}
|
||||
benc.closeSequence() ;
|
||||
}
|
||||
catch(ArrayIndexOutOfBoundsException x) {
|
||||
throw new SnmpTooBigException(encodedVarBindCount) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For SNMP Runtime private use only.
|
||||
*/
|
||||
void encodeVarBindValue(BerEncoder benc,
|
||||
SnmpValue v)throws SnmpStatusException {
|
||||
if (v == null) {
|
||||
benc.putNull() ;
|
||||
}
|
||||
else if (v instanceof SnmpIpAddress) {
|
||||
benc.putOctetString(((SnmpIpAddress)v).byteValue(), SnmpValue.IpAddressTag) ;
|
||||
}
|
||||
else if (v instanceof SnmpCounter) {
|
||||
benc.putInteger(((SnmpCounter)v).longValue(), SnmpValue.CounterTag) ;
|
||||
}
|
||||
else if (v instanceof SnmpGauge) {
|
||||
benc.putInteger(((SnmpGauge)v).longValue(), SnmpValue.GaugeTag) ;
|
||||
}
|
||||
else if (v instanceof SnmpTimeticks) {
|
||||
benc.putInteger(((SnmpTimeticks)v).longValue(), SnmpValue.TimeticksTag) ;
|
||||
}
|
||||
else if (v instanceof SnmpOpaque) {
|
||||
benc.putOctetString(((SnmpOpaque)v).byteValue(), SnmpValue.OpaqueTag) ;
|
||||
}
|
||||
else if (v instanceof SnmpInt) {
|
||||
benc.putInteger(((SnmpInt)v).intValue()) ;
|
||||
}
|
||||
else if (v instanceof SnmpString) {
|
||||
benc.putOctetString(((SnmpString)v).byteValue()) ;
|
||||
}
|
||||
else if (v instanceof SnmpOid) {
|
||||
benc.putOid(((SnmpOid)v).longValue()) ;
|
||||
}
|
||||
else if (v instanceof SnmpCounter64) {
|
||||
if (version == snmpVersionOne) {
|
||||
throw new SnmpStatusException("Invalid value for SNMP v1 : " + v) ;
|
||||
}
|
||||
benc.putInteger(((SnmpCounter64)v).longValue(), SnmpValue.Counter64Tag) ;
|
||||
}
|
||||
else if (v instanceof SnmpNull) {
|
||||
int tag = ((SnmpNull)v).getTag() ;
|
||||
if ((version == snmpVersionOne) && (tag != SnmpValue.NullTag)) {
|
||||
throw new SnmpStatusException("Invalid value for SNMP v1 : " + v) ;
|
||||
}
|
||||
if ((version == snmpVersionTwo) &&
|
||||
(tag != SnmpValue.NullTag) &&
|
||||
(tag != SnmpVarBind.errNoSuchObjectTag) &&
|
||||
(tag != SnmpVarBind.errNoSuchInstanceTag) &&
|
||||
(tag != SnmpVarBind.errEndOfMibViewTag)) {
|
||||
throw new SnmpStatusException("Invalid value " + v) ;
|
||||
}
|
||||
benc.putNull(tag) ;
|
||||
}
|
||||
else {
|
||||
throw new SnmpStatusException("Invalid value " + v) ;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For SNMP Runtime private use only.
|
||||
*/
|
||||
public SnmpVarBind[] decodeVarBindList(BerDecoder bdec)
|
||||
throws BerException {
|
||||
bdec.openSequence() ;
|
||||
Vector<SnmpVarBind> tmp = new Vector<SnmpVarBind>() ;
|
||||
while (bdec.cannotCloseSequence()) {
|
||||
SnmpVarBind bind = new SnmpVarBind() ;
|
||||
bdec.openSequence() ;
|
||||
bind.oid = new SnmpOid(bdec.fetchOid()) ;
|
||||
bind.setSnmpValue(decodeVarBindValue(bdec)) ;
|
||||
bdec.closeSequence() ;
|
||||
tmp.addElement(bind) ;
|
||||
}
|
||||
bdec.closeSequence() ;
|
||||
SnmpVarBind[] varBindList= new SnmpVarBind[tmp.size()] ;
|
||||
tmp.copyInto(varBindList);
|
||||
return varBindList ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* For SNMP Runtime private use only.
|
||||
*/
|
||||
SnmpValue decodeVarBindValue(BerDecoder bdec)
|
||||
throws BerException {
|
||||
SnmpValue result = null ;
|
||||
int tag = bdec.getTag() ;
|
||||
|
||||
// bugId 4641696 : RuntimeExceptions must be transformed in
|
||||
// BerException.
|
||||
switch(tag) {
|
||||
|
||||
//
|
||||
// Simple syntax
|
||||
//
|
||||
case BerDecoder.IntegerTag :
|
||||
try {
|
||||
result = new SnmpInt(bdec.fetchInteger()) ;
|
||||
} catch(RuntimeException r) {
|
||||
throw new BerException();
|
||||
// BerException("Can't build SnmpInt from decoded value.");
|
||||
}
|
||||
break ;
|
||||
case BerDecoder.OctetStringTag :
|
||||
try {
|
||||
result = new SnmpString(bdec.fetchOctetString()) ;
|
||||
} catch(RuntimeException r) {
|
||||
throw new BerException();
|
||||
// BerException("Can't build SnmpString from decoded value.");
|
||||
}
|
||||
break ;
|
||||
case BerDecoder.OidTag :
|
||||
try {
|
||||
result = new SnmpOid(bdec.fetchOid()) ;
|
||||
} catch(RuntimeException r) {
|
||||
throw new BerException();
|
||||
// BerException("Can't build SnmpOid from decoded value.");
|
||||
}
|
||||
break ;
|
||||
case BerDecoder.NullTag :
|
||||
bdec.fetchNull() ;
|
||||
try {
|
||||
result = new SnmpNull() ;
|
||||
} catch(RuntimeException r) {
|
||||
throw new BerException();
|
||||
// BerException("Can't build SnmpNull from decoded value.");
|
||||
}
|
||||
break ;
|
||||
|
||||
//
|
||||
// Application syntax
|
||||
//
|
||||
case SnmpValue.IpAddressTag :
|
||||
try {
|
||||
result = new SnmpIpAddress(bdec.fetchOctetString(tag)) ;
|
||||
} catch (RuntimeException r) {
|
||||
throw new BerException();
|
||||
// BerException("Can't build SnmpIpAddress from decoded value.");
|
||||
}
|
||||
break ;
|
||||
case SnmpValue.CounterTag :
|
||||
try {
|
||||
result = new SnmpCounter(bdec.fetchIntegerAsLong(tag)) ;
|
||||
} catch(RuntimeException r) {
|
||||
throw new BerException();
|
||||
// BerException("Can't build SnmpCounter from decoded value.");
|
||||
}
|
||||
break ;
|
||||
case SnmpValue.GaugeTag :
|
||||
try {
|
||||
result = new SnmpGauge(bdec.fetchIntegerAsLong(tag)) ;
|
||||
} catch(RuntimeException r) {
|
||||
throw new BerException();
|
||||
// BerException("Can't build SnmpGauge from decoded value.");
|
||||
}
|
||||
break ;
|
||||
case SnmpValue.TimeticksTag :
|
||||
try {
|
||||
result = new SnmpTimeticks(bdec.fetchIntegerAsLong(tag)) ;
|
||||
} catch(RuntimeException r) {
|
||||
throw new BerException();
|
||||
// BerException("Can't build SnmpTimeticks from decoded value.");
|
||||
}
|
||||
break ;
|
||||
case SnmpValue.OpaqueTag :
|
||||
try {
|
||||
result = new SnmpOpaque(bdec.fetchOctetString(tag)) ;
|
||||
} catch(RuntimeException r) {
|
||||
throw new BerException();
|
||||
// BerException("Can't build SnmpOpaque from decoded value.");
|
||||
}
|
||||
break ;
|
||||
|
||||
//
|
||||
// V2 syntaxes
|
||||
//
|
||||
case SnmpValue.Counter64Tag :
|
||||
if (version == snmpVersionOne) {
|
||||
throw new BerException(BerException.BAD_VERSION) ;
|
||||
}
|
||||
try {
|
||||
result = new SnmpCounter64(bdec.fetchIntegerAsLong(tag)) ;
|
||||
} catch(RuntimeException r) {
|
||||
throw new BerException();
|
||||
// BerException("Can't build SnmpCounter64 from decoded value.");
|
||||
}
|
||||
break ;
|
||||
|
||||
case SnmpVarBind.errNoSuchObjectTag :
|
||||
if (version == snmpVersionOne) {
|
||||
throw new BerException(BerException.BAD_VERSION) ;
|
||||
}
|
||||
bdec.fetchNull(tag) ;
|
||||
result = SnmpVarBind.noSuchObject ;
|
||||
break ;
|
||||
|
||||
case SnmpVarBind.errNoSuchInstanceTag :
|
||||
if (version == snmpVersionOne) {
|
||||
throw new BerException(BerException.BAD_VERSION) ;
|
||||
}
|
||||
bdec.fetchNull(tag) ;
|
||||
result = SnmpVarBind.noSuchInstance ;
|
||||
break ;
|
||||
|
||||
case SnmpVarBind.errEndOfMibViewTag :
|
||||
if (version == snmpVersionOne) {
|
||||
throw new BerException(BerException.BAD_VERSION) ;
|
||||
}
|
||||
bdec.fetchNull(tag) ;
|
||||
result = SnmpVarBind.endOfMibView ;
|
||||
break ;
|
||||
|
||||
default:
|
||||
throw new BerException() ;
|
||||
|
||||
}
|
||||
|
||||
return result ;
|
||||
}
|
||||
|
||||
}
|
||||
183
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpNull.java
Normal file
183
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpNull.java
Normal file
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright (c) 1997, 2011, 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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Represents an SNMP null value.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpNull extends SnmpValue {
|
||||
private static final long serialVersionUID = 1783782515994279177L;
|
||||
|
||||
// CONSTRUCTORS
|
||||
//-------------
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpNull</CODE>.
|
||||
*/
|
||||
public SnmpNull() {
|
||||
tag = NullTag ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpNull</CODE>.
|
||||
* <BR>For mibgen private use only.
|
||||
*/
|
||||
public SnmpNull(String dummy) {
|
||||
this();
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpNull</CODE> from the specified tag value.
|
||||
* @param t The initialization value.
|
||||
*/
|
||||
public SnmpNull(int t) {
|
||||
tag = t ;
|
||||
}
|
||||
|
||||
// PUBLIC METHODS
|
||||
//---------------
|
||||
/**
|
||||
* Returns the tag value of this <CODE>SnmpNull</CODE>.
|
||||
* @return The value.
|
||||
*/
|
||||
public int getTag() {
|
||||
return tag ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the <CODE>NULL</CODE> value to its ASN.1 <CODE>String</CODE> form.
|
||||
* When the tag is not the universal one, it is preprended
|
||||
* to the <CODE>String</CODE> form.
|
||||
* @return The <CODE>String</CODE> representation of the value.
|
||||
*/
|
||||
public String toString() {
|
||||
String result = "" ;
|
||||
if (tag != 5) {
|
||||
result += "[" + tag + "] " ;
|
||||
}
|
||||
result += "NULL" ;
|
||||
switch(tag) {
|
||||
case errNoSuchObjectTag :
|
||||
result += " (noSuchObject)" ;
|
||||
break ;
|
||||
|
||||
case errNoSuchInstanceTag :
|
||||
result += " (noSuchInstance)" ;
|
||||
break ;
|
||||
|
||||
case errEndOfMibViewTag :
|
||||
result += " (endOfMibView)" ;
|
||||
break ;
|
||||
}
|
||||
return result ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the <CODE>NULL</CODE> value to its <CODE>SnmpOid</CODE> form.
|
||||
* Normally, a <CODE>NULL</CODE> value cannot be used as an index value,
|
||||
* this method triggers an exception.
|
||||
* @return The OID representation of the value.
|
||||
*/
|
||||
public SnmpOid toOid() {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a clone action. This provides a workaround for the
|
||||
* <CODE>SnmpValue</CODE> interface.
|
||||
* @return The SnmpValue clone.
|
||||
*/
|
||||
final synchronized public SnmpValue duplicate() {
|
||||
return (SnmpValue) clone() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones the <CODE>SnmpNull</CODE> object, making a copy of its data.
|
||||
* @return The object clone.
|
||||
*/
|
||||
final synchronized public Object clone() {
|
||||
SnmpNull newclone = null ;
|
||||
try {
|
||||
newclone = (SnmpNull) super.clone() ;
|
||||
newclone.tag = tag ;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError(e) ; // vm bug.
|
||||
}
|
||||
return newclone ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a textual description of the type object.
|
||||
* @return ASN.1 textual description.
|
||||
*/
|
||||
final public String getTypeName() {
|
||||
return name ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this <CODE>SnmpNull</CODE> object corresponds to a <CODE>noSuchObject</CODE> value.
|
||||
* @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errNoSuchObjectTag},
|
||||
* <CODE>false</CODE> otherwise.
|
||||
*/
|
||||
public boolean isNoSuchObjectValue() {
|
||||
return (tag == SnmpDataTypeEnums.errNoSuchObjectTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this <CODE>SnmpNull</CODE> object corresponds to a <CODE>noSuchInstance</CODE> value.
|
||||
* @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errNoSuchInstanceTag},
|
||||
* <CODE>false</CODE> otherwise.
|
||||
*/
|
||||
public boolean isNoSuchInstanceValue() {
|
||||
return (tag == SnmpDataTypeEnums.errNoSuchInstanceTag);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if this <CODE>SnmpNull</CODE> object corresponds to an <CODE>endOfMibView</CODE> value.
|
||||
* @return <CODE>true</CODE> if the tag equals {@link com.sun.jmx.snmp.SnmpDataTypeEnums#errEndOfMibViewTag},
|
||||
* <CODE>false</CODE> otherwise.
|
||||
*/
|
||||
public boolean isEndOfMibViewValue() {
|
||||
return (tag == SnmpDataTypeEnums.errEndOfMibViewTag);
|
||||
}
|
||||
|
||||
// VARIABLES
|
||||
//----------
|
||||
/**
|
||||
* Name of the type.
|
||||
*/
|
||||
final static String name = "Null" ;
|
||||
|
||||
/**
|
||||
* This is the tag of the NULL value. By default, it is the universal tag value.
|
||||
*/
|
||||
private int tag = 5 ;
|
||||
}
|
||||
100
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpOpaque.java
Normal file
100
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpOpaque.java
Normal file
@@ -0,0 +1,100 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Is used to represent an SNMP value.
|
||||
* The <CODE>Opaque</CODE> type is defined in RFC 1155.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpOpaque extends SnmpString {
|
||||
private static final long serialVersionUID = 380952213936036664L;
|
||||
|
||||
// CONSTRUCTORS
|
||||
//-------------
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpOpaque</CODE> from the specified bytes array.
|
||||
* @param v The bytes composing the opaque value.
|
||||
*/
|
||||
public SnmpOpaque(byte[] v) {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpOpaque</CODE> with the specified <CODE>Bytes</CODE> array.
|
||||
* @param v The <CODE>Bytes</CODE> composing the opaque value.
|
||||
*/
|
||||
public SnmpOpaque(Byte[] v) {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpOpaque</CODE> from the specified <CODE>String</CODE> value.
|
||||
* @param v The initialization value.
|
||||
*/
|
||||
public SnmpOpaque(String v) {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
// PUBLIC METHODS
|
||||
//---------------
|
||||
/**
|
||||
* Converts the opaque to its <CODE>String</CODE> form, that is, a string of
|
||||
* bytes expressed in hexadecimal form.
|
||||
* @return The <CODE>String</CODE> representation of the value.
|
||||
*/
|
||||
public String toString() {
|
||||
StringBuffer result = new StringBuffer() ;
|
||||
for (int i = 0 ; i < value.length ; i++) {
|
||||
byte b = value[i] ;
|
||||
int n = (b >= 0) ? b : b + 256 ;
|
||||
result.append(Character.forDigit(n / 16, 16)) ;
|
||||
result.append(Character.forDigit(n % 16, 16)) ;
|
||||
}
|
||||
return result.toString() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a textual description of the type object.
|
||||
* @return ASN.1 textual description.
|
||||
*/
|
||||
final public String getTypeName() {
|
||||
return name ;
|
||||
}
|
||||
|
||||
// VARIABLES
|
||||
//----------
|
||||
/**
|
||||
* Name of the type.
|
||||
*/
|
||||
final static String name = "Opaque" ;
|
||||
}
|
||||
76
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpParams.java
Normal file
76
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpParams.java
Normal file
@@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpDefinitions;
|
||||
|
||||
/**
|
||||
* This class is the base class of all parameters that are used when making SNMP requests to an <CODE>SnmpPeer</CODE>.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public abstract class SnmpParams implements SnmpDefinitions {
|
||||
private int protocolVersion = snmpVersionOne;
|
||||
SnmpParams(int version) {
|
||||
protocolVersion = version;
|
||||
}
|
||||
|
||||
SnmpParams() {}
|
||||
/**
|
||||
* Checks whether parameters are in place for an SNMP <CODE>set</CODE> operation.
|
||||
* @return <CODE>true</CODE> if parameters are in place, <CODE>false</CODE> otherwise.
|
||||
*/
|
||||
public abstract boolean allowSnmpSets();
|
||||
/**
|
||||
* Returns the version of the protocol to use.
|
||||
* The returned value is:
|
||||
* <UL>
|
||||
* <LI>{@link com.sun.jmx.snmp.SnmpDefinitions#snmpVersionOne snmpVersionOne} if the protocol is SNMPv1
|
||||
* <LI>{@link com.sun.jmx.snmp.SnmpDefinitions#snmpVersionTwo snmpVersionTwo} if the protocol is SNMPv2
|
||||
* <LI>{@link com.sun.jmx.snmp.SnmpDefinitions#snmpVersionThree snmpVersionThree} if the protocol is SNMPv3
|
||||
* </UL>
|
||||
* @return The version of the protocol to use.
|
||||
*/
|
||||
public int getProtocolVersion() {
|
||||
return protocolVersion ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the version of the protocol to be used.
|
||||
* The version should be identified using the definitions
|
||||
* contained in
|
||||
* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
|
||||
* <BR>For instance if you wish to use SNMPv2, you can call the method as follows:
|
||||
* <BLOCKQUOTE><PRE>
|
||||
* setProtocolVersion(SnmpDefinitions.snmpVersionTwo);
|
||||
* </PRE></BLOCKQUOTE>
|
||||
* @param protocolversion The version of the protocol to be used.
|
||||
*/
|
||||
|
||||
public void setProtocolVersion(int protocolversion) {
|
||||
this.protocolVersion = protocolversion ;
|
||||
}
|
||||
}
|
||||
124
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPdu.java
Normal file
124
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPdu.java
Normal file
@@ -0,0 +1,124 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
/**
|
||||
* Is the fully decoded representation of an SNMP packet.
|
||||
* <P>
|
||||
* Classes are derived from <CODE>SnmpPdu</CODE> to
|
||||
* represent the different forms of SNMP packets
|
||||
* ({@link com.sun.jmx.snmp.SnmpPduPacket SnmpPduPacket},
|
||||
* {@link com.sun.jmx.snmp.SnmpScopedPduPacket SnmpScopedPduPacket})
|
||||
* <BR>The <CODE>SnmpPdu</CODE> class defines the attributes
|
||||
* common to every form of SNMP packets.
|
||||
*
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @see SnmpMessage
|
||||
* @see SnmpPduFactory
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public abstract class SnmpPdu implements SnmpDefinitions, Serializable {
|
||||
|
||||
/**
|
||||
* PDU type. Types are defined in
|
||||
* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
|
||||
* @serial
|
||||
*/
|
||||
public int type=0 ;
|
||||
|
||||
/**
|
||||
* Protocol version. Versions are defined in
|
||||
* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
|
||||
* @serial
|
||||
*/
|
||||
public int version=0 ;
|
||||
|
||||
/**
|
||||
* List of variables.
|
||||
* @serial
|
||||
*/
|
||||
public SnmpVarBind[] varBindList ;
|
||||
|
||||
|
||||
/**
|
||||
* Request identifier.
|
||||
* Note that this field is not used by <CODE>SnmpPduTrap</CODE>.
|
||||
* @serial
|
||||
*/
|
||||
public int requestId=0 ;
|
||||
|
||||
/**
|
||||
* Source or destination address.
|
||||
* <P>For an incoming PDU it's the source.
|
||||
* <BR>For an outgoing PDU it's the destination.
|
||||
* @serial
|
||||
*/
|
||||
public InetAddress address ;
|
||||
|
||||
/**
|
||||
* Source or destination port.
|
||||
* <P>For an incoming PDU it's the source.
|
||||
* <BR>For an outgoing PDU it's the destination.
|
||||
* @serial
|
||||
*/
|
||||
public int port=0 ;
|
||||
|
||||
/**
|
||||
* Returns the <CODE>String</CODE> representation of a PDU type.
|
||||
* For instance, if the PDU type is <CODE>SnmpDefinitions.pduGetRequestPdu</CODE>,
|
||||
* the method will return "SnmpGet".
|
||||
* @param cmd The integer representation of the PDU type.
|
||||
* @return The <CODE>String</CODE> representation of the PDU type.
|
||||
*/
|
||||
public static String pduTypeToString(int cmd) {
|
||||
switch (cmd) {
|
||||
case pduGetRequestPdu :
|
||||
return "SnmpGet" ;
|
||||
case pduGetNextRequestPdu :
|
||||
return "SnmpGetNext" ;
|
||||
case pduWalkRequest :
|
||||
return "SnmpWalk(*)" ;
|
||||
case pduSetRequestPdu :
|
||||
return "SnmpSet" ;
|
||||
case pduGetResponsePdu :
|
||||
return "SnmpResponse" ;
|
||||
case pduV1TrapPdu :
|
||||
return "SnmpV1Trap" ;
|
||||
case pduV2TrapPdu :
|
||||
return "SnmpV2Trap" ;
|
||||
case pduGetBulkRequestPdu :
|
||||
return "SnmpGetBulk" ;
|
||||
case pduInformRequestPdu :
|
||||
return "SnmpInform" ;
|
||||
}
|
||||
return "Unknown Command = " + cmd ;
|
||||
}
|
||||
}
|
||||
119
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduBulk.java
Normal file
119
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduBulk.java
Normal file
@@ -0,0 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Represents a <CODE>get-bulk</CODE> PDU as defined in RFC 1448.
|
||||
* <P>
|
||||
* You will not usually need to use this class, except if you
|
||||
* decide to implement your own
|
||||
* {@link com.sun.jmx.snmp.SnmpPduFactory SnmpPduFactory} object.
|
||||
* <P>
|
||||
* The <CODE>SnmpPduBulk</CODE> extends {@link com.sun.jmx.snmp.SnmpPduPacket SnmpPduPacket}
|
||||
* and defines attributes specific to the <CODE>get-bulk</CODE> PDU (see RFC 1448).
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpPduBulk extends SnmpPduPacket
|
||||
implements SnmpPduBulkType {
|
||||
private static final long serialVersionUID = -7431306775883371046L;
|
||||
|
||||
/**
|
||||
* The <CODE>non-repeaters</CODE> value.
|
||||
* @serial
|
||||
*/
|
||||
public int nonRepeaters ;
|
||||
|
||||
|
||||
/**
|
||||
* The <CODE>max-repetitions</CODE> value.
|
||||
* @serial
|
||||
*/
|
||||
public int maxRepetitions ;
|
||||
|
||||
|
||||
/**
|
||||
* Builds a new <CODE>get-bulk</CODE> PDU.
|
||||
* <BR><CODE>type</CODE> and <CODE>version</CODE> fields are initialized with
|
||||
* {@link com.sun.jmx.snmp.SnmpDefinitions#pduGetBulkRequestPdu pduGetBulkRequestPdu}
|
||||
* and {@link com.sun.jmx.snmp.SnmpDefinitions#snmpVersionTwo snmpVersionTwo}.
|
||||
*/
|
||||
public SnmpPduBulk() {
|
||||
type = pduGetBulkRequestPdu ;
|
||||
version = snmpVersionTwo ;
|
||||
}
|
||||
/**
|
||||
* Implements the <CODE>SnmpPduBulkType</CODE> interface.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void setMaxRepetitions(int i) {
|
||||
maxRepetitions = i;
|
||||
}
|
||||
/**
|
||||
* Implements the <CODE>SnmpPduBulkType</CODE> interface.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void setNonRepeaters(int i) {
|
||||
nonRepeaters = i;
|
||||
}
|
||||
/**
|
||||
* Implements the <CODE>SnmpPduBulkType</CODE> interface.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public int getMaxRepetitions() { return maxRepetitions; }
|
||||
/**
|
||||
* Implements the <CODE>SnmpPduBulkType</CODE> interface.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public int getNonRepeaters() { return nonRepeaters; }
|
||||
/**
|
||||
* Implements the <CODE>SnmpAckPdu</CODE> interface.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public SnmpPdu getResponsePdu() {
|
||||
SnmpPduRequest result = new SnmpPduRequest();
|
||||
result.address = address;
|
||||
result.port = port;
|
||||
result.version = version;
|
||||
result.community = community;
|
||||
result.type = SnmpDefinitions.pduGetResponsePdu;
|
||||
result.requestId = requestId;
|
||||
result.errorStatus = SnmpDefinitions.snmpRspNoError;
|
||||
result.errorIndex = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
58
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduBulkType.java
Normal file
58
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduBulkType.java
Normal file
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
/**
|
||||
* Interface implemented by classes modelizing bulk pdu.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public interface SnmpPduBulkType extends SnmpAckPdu {
|
||||
|
||||
/**
|
||||
* The <CODE>max-repetitions</CODE> setter.
|
||||
* @param max Maximum repetition.
|
||||
*/
|
||||
public void setMaxRepetitions(int max);
|
||||
|
||||
/**
|
||||
* The <CODE>non-repeaters</CODE> setter.
|
||||
* @param nr Non repeaters.
|
||||
*/
|
||||
public void setNonRepeaters(int nr);
|
||||
|
||||
/**
|
||||
* The <CODE>max-repetitions</CODE> getter.
|
||||
* @return Maximum repetition.
|
||||
*/
|
||||
public int getMaxRepetitions();
|
||||
|
||||
/**
|
||||
* The <CODE>non-repeaters</CODE> getter.
|
||||
* @return Non repeaters.
|
||||
*/
|
||||
public int getNonRepeaters();
|
||||
}
|
||||
94
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduFactory.java
Normal file
94
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduFactory.java
Normal file
@@ -0,0 +1,94 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Defines the interface of the object in charge of encoding and decoding SNMP packets.
|
||||
* <P>
|
||||
* You will not usually need to use this interface, except if you
|
||||
* decide to replace the default implementation <CODE>SnmpPduFactoryBER</CODE>.
|
||||
* <P>
|
||||
* An <CODE>SnmpPduFactory</CODE> object is attached to an
|
||||
* {@link com.sun.jmx.snmp.daemon.SnmpAdaptorServer SNMP protocol adaptor}
|
||||
* or an {@link com.sun.jmx.snmp.SnmpPeer SnmpPeer}.
|
||||
* It is used each time an SNMP packet needs to be encoded or decoded.
|
||||
* <BR>{@link com.sun.jmx.snmp.SnmpPduFactoryBER SnmpPduFactoryBER} is the default
|
||||
* implementation.
|
||||
* It simply applies the standard ASN.1 encoding and decoding
|
||||
* on the bytes of the SNMP packet.
|
||||
* <P>
|
||||
* It's possible to implement your own <CODE>SnmpPduFactory</CODE>
|
||||
* object and to add authentication and/or encryption to the
|
||||
* default encoding/decoding process.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @see SnmpPduFactory
|
||||
* @see SnmpPduPacket
|
||||
* @see SnmpMessage
|
||||
*
|
||||
*/
|
||||
|
||||
public interface SnmpPduFactory {
|
||||
|
||||
/**
|
||||
* Decodes the specified <CODE>SnmpMsg</CODE> and returns the
|
||||
* resulting <CODE>SnmpPdu</CODE>. If this method returns
|
||||
* <CODE>null</CODE>, the message will be considered unsafe
|
||||
* and will be dropped.
|
||||
*
|
||||
* @param msg The <CODE>SnmpMsg</CODE> to be decoded.
|
||||
* @return Null or a fully initialized <CODE>SnmpPdu</CODE>.
|
||||
* @exception SnmpStatusException If the encoding is invalid.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public SnmpPdu decodeSnmpPdu(SnmpMsg msg) throws SnmpStatusException ;
|
||||
|
||||
/**
|
||||
* Encodes the specified <CODE>SnmpPdu</CODE> and
|
||||
* returns the resulting <CODE>SnmpMsg</CODE>. If this
|
||||
* method returns null, the specified <CODE>SnmpPdu</CODE>
|
||||
* will be dropped and the current SNMP request will be
|
||||
* aborted.
|
||||
*
|
||||
* @param p The <CODE>SnmpPdu</CODE> to be encoded.
|
||||
* @param maxDataLength The size limit of the resulting encoding.
|
||||
* @return Null or a fully encoded <CODE>SnmpMsg</CODE>.
|
||||
* @exception SnmpStatusException If <CODE>pdu</CODE> contains
|
||||
* illegal values and cannot be encoded.
|
||||
* @exception SnmpTooBigException If the resulting encoding does not
|
||||
* fit into <CODE>maxPktSize</CODE> bytes.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public SnmpMsg encodeSnmpPdu(SnmpPdu p, int maxDataLength)
|
||||
throws SnmpStatusException, SnmpTooBigException ;
|
||||
}
|
||||
131
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduFactoryBER.java
Normal file
131
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduFactoryBER.java
Normal file
@@ -0,0 +1,131 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
|
||||
// java imports
|
||||
//
|
||||
import java.io.Serializable;
|
||||
|
||||
// jmx import
|
||||
//
|
||||
import com.sun.jmx.snmp.SnmpPduFactory;
|
||||
import com.sun.jmx.snmp.SnmpMessage;
|
||||
import com.sun.jmx.snmp.SnmpPduPacket;
|
||||
import com.sun.jmx.snmp.SnmpPdu;
|
||||
import com.sun.jmx.snmp.SnmpMsg;
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpTooBigException;
|
||||
import com.sun.jmx.snmp.SnmpDefinitions;
|
||||
|
||||
// SNMP Runtime import
|
||||
//
|
||||
import com.sun.jmx.snmp.SnmpV3Message;
|
||||
|
||||
/**
|
||||
* Default implementation of the {@link com.sun.jmx.snmp.SnmpPduFactory SnmpPduFactory} interface.
|
||||
* <BR>It uses the BER (basic encoding rules) standardized encoding scheme associated with ASN.1.
|
||||
* <P>
|
||||
* This implementation of the <CODE>SnmpPduFactory</CODE> is very
|
||||
* basic: it simply calls encoding and decoding methods from
|
||||
* {@link com.sun.jmx.snmp.SnmpMsg}.
|
||||
* <BLOCKQUOTE>
|
||||
* <PRE>
|
||||
* public SnmpPdu decodeSnmpPdu(SnmpMsg msg)
|
||||
* throws SnmpStatusException {
|
||||
* return msg.decodeSnmpPdu() ;
|
||||
* }
|
||||
*
|
||||
* public SnmpMsg encodeSnmpPdu(SnmpPdu pdu, int maxPktSize)
|
||||
* throws SnmpStatusException, SnmpTooBigException {
|
||||
* SnmpMsg result = new SnmpMessage() ; // for SNMP v1/v2
|
||||
* <I>or</I>
|
||||
* SnmpMsg result = new SnmpV3Message() ; // for SNMP v3
|
||||
* result.encodeSnmpPdu(pdu, maxPktSize) ;
|
||||
* return result ;
|
||||
* }
|
||||
* </PRE>
|
||||
* </BLOCKQUOTE>
|
||||
* To implement your own object, you can implement <CODE>SnmpPduFactory</CODE>
|
||||
* or extend <CODE>SnmpPduFactoryBER</CODE>.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpPduFactoryBER implements SnmpPduFactory, Serializable {
|
||||
private static final long serialVersionUID = -3525318344000547635L;
|
||||
|
||||
/**
|
||||
* Calls {@link com.sun.jmx.snmp.SnmpMsg#decodeSnmpPdu SnmpMsg.decodeSnmpPdu}
|
||||
* on the specified message and returns the resulting <CODE>SnmpPdu</CODE>.
|
||||
*
|
||||
* @param msg The SNMP message to be decoded.
|
||||
* @return The resulting SNMP PDU packet.
|
||||
* @exception SnmpStatusException If the encoding is invalid.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public SnmpPdu decodeSnmpPdu(SnmpMsg msg) throws SnmpStatusException {
|
||||
return msg.decodeSnmpPdu();
|
||||
}
|
||||
|
||||
/**
|
||||
* Encodes the specified <CODE>SnmpPdu</CODE> and
|
||||
* returns the resulting <CODE>SnmpMsg</CODE>. If this
|
||||
* method returns null, the specified <CODE>SnmpPdu</CODE>
|
||||
* will be dropped and the current SNMP request will be
|
||||
* aborted.
|
||||
*
|
||||
* @param p The <CODE>SnmpPdu</CODE> to be encoded.
|
||||
* @param maxDataLength The size limit of the resulting encoding.
|
||||
* @return Null or a fully encoded <CODE>SnmpMsg</CODE>.
|
||||
* @exception SnmpStatusException If <CODE>pdu</CODE> contains
|
||||
* illegal values and cannot be encoded.
|
||||
* @exception SnmpTooBigException If the resulting encoding does not
|
||||
* fit into <CODE>maxPktSize</CODE> bytes.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public SnmpMsg encodeSnmpPdu(SnmpPdu p, int maxDataLength)
|
||||
throws SnmpStatusException, SnmpTooBigException {
|
||||
switch(p.version) {
|
||||
case SnmpDefinitions.snmpVersionOne:
|
||||
case SnmpDefinitions.snmpVersionTwo: {
|
||||
SnmpMessage result = new SnmpMessage();
|
||||
result.encodeSnmpPdu((SnmpPduPacket) p, maxDataLength);
|
||||
return result;
|
||||
}
|
||||
case SnmpDefinitions.snmpVersionThree: {
|
||||
SnmpV3Message result = new SnmpV3Message();
|
||||
result.encodeSnmpPdu(p, maxDataLength);
|
||||
return result;
|
||||
}
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
109
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduRequest.java
Normal file
109
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduRequest.java
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Is used to represent <CODE>get</CODE>, <CODE>get-next</CODE>, <CODE>set</CODE>, <CODE>response</CODE> and <CODE>SNMPv2-trap</CODE> PDUs.
|
||||
* <P>
|
||||
* You will not usually need to use this class, except if you
|
||||
* decide to implement your own
|
||||
* {@link com.sun.jmx.snmp.SnmpPduFactory SnmpPduFactory} object.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpPduRequest extends SnmpPduPacket
|
||||
implements SnmpPduRequestType {
|
||||
private static final long serialVersionUID = 2218754017025258979L;
|
||||
|
||||
|
||||
/**
|
||||
* Error status. Statuses are defined in
|
||||
* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
|
||||
* @serial
|
||||
*/
|
||||
public int errorStatus=0 ;
|
||||
|
||||
|
||||
/**
|
||||
* Error index. Remember that SNMP indices start from 1.
|
||||
* Thus the corresponding <CODE>SnmpVarBind</CODE> is
|
||||
* <CODE>varBindList[errorIndex-1]</CODE>.
|
||||
* @serial
|
||||
*/
|
||||
public int errorIndex=0 ;
|
||||
/**
|
||||
* Implements <CODE>SnmpPduRequestType</CODE> interface.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void setErrorIndex(int i) {
|
||||
errorIndex = i;
|
||||
}
|
||||
/**
|
||||
* Implements <CODE>SnmpPduRequestType</CODE> interface.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public void setErrorStatus(int i) {
|
||||
errorStatus = i;
|
||||
}
|
||||
/**
|
||||
* Implements <CODE>SnmpPduRequestType</CODE> interface.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public int getErrorIndex() { return errorIndex; }
|
||||
/**
|
||||
* Implements <CODE>SnmpPduRequestType</CODE> interface.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public int getErrorStatus() { return errorStatus; }
|
||||
/**
|
||||
* Implements <CODE>SnmpAckPdu</CODE> interface.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public SnmpPdu getResponsePdu() {
|
||||
SnmpPduRequest result = new SnmpPduRequest();
|
||||
result.address = address;
|
||||
result.port = port;
|
||||
result.version = version;
|
||||
result.community = community;
|
||||
result.type = SnmpDefinitions.pduGetResponsePdu;
|
||||
result.requestId = requestId;
|
||||
result.errorStatus = SnmpDefinitions.snmpRspNoError;
|
||||
result.errorIndex = 0;
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
60
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduRequestType.java
Normal file
60
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduRequestType.java
Normal file
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
/**
|
||||
* Interface implemented by classes modelizing request pdu.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpPduRequestType extends SnmpAckPdu {
|
||||
/**
|
||||
* Error index setter. Remember that SNMP indices start from 1.
|
||||
* Thus the corresponding <CODE>SnmpVarBind</CODE> is
|
||||
* <CODE>varBindList[errorIndex-1]</CODE>.
|
||||
* @param i Error index.
|
||||
*/
|
||||
public void setErrorIndex(int i);
|
||||
/**
|
||||
* Error status setter. Statuses are defined in
|
||||
* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
|
||||
* @param i Error status.
|
||||
*/
|
||||
public void setErrorStatus(int i);
|
||||
/**
|
||||
* Error index getter. Remember that SNMP indices start from 1.
|
||||
* Thus the corresponding <CODE>SnmpVarBind</CODE> is
|
||||
* <CODE>varBindList[errorIndex-1]</CODE>.
|
||||
* @return Error index.
|
||||
*/
|
||||
public int getErrorIndex();
|
||||
/**
|
||||
* Error status getter. Statuses are defined in
|
||||
* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
|
||||
* @return Error status.
|
||||
*/
|
||||
public int getErrorStatus();
|
||||
}
|
||||
93
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduTrap.java
Normal file
93
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpPduTrap.java
Normal file
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Represents an SNMPv1-trap PDU.
|
||||
* <P>
|
||||
* You will not usually need to use this class, except if you
|
||||
* decide to implement your own
|
||||
* {@link com.sun.jmx.snmp.SnmpPduFactory SnmpPduFactory} object.
|
||||
* <P>
|
||||
* The <CODE>SnmpPduTrap</CODE> extends {@link com.sun.jmx.snmp.SnmpPduPacket SnmpPduPacket}
|
||||
* and defines attributes specific to an SNMPv1 trap (see RFC1157).
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpPduTrap extends SnmpPduPacket {
|
||||
private static final long serialVersionUID = -3670886636491433011L;
|
||||
|
||||
/**
|
||||
* Enterprise object identifier.
|
||||
* @serial
|
||||
*/
|
||||
public SnmpOid enterprise ;
|
||||
|
||||
/**
|
||||
* Agent address. If the agent address source was not an IPv4 one (eg : IPv6), this field is null.
|
||||
* @serial
|
||||
*/
|
||||
public SnmpIpAddress agentAddr ;
|
||||
|
||||
/**
|
||||
* Generic trap number.
|
||||
* <BR>
|
||||
* The possible values are defined in
|
||||
* {@link com.sun.jmx.snmp.SnmpDefinitions#trapColdStart SnmpDefinitions}.
|
||||
* @serial
|
||||
*/
|
||||
public int genericTrap ;
|
||||
|
||||
/**
|
||||
* Specific trap number.
|
||||
* @serial
|
||||
*/
|
||||
public int specificTrap ;
|
||||
|
||||
/**
|
||||
* Time-stamp.
|
||||
* @serial
|
||||
*/
|
||||
public long timeStamp ;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Builds a new trap PDU.
|
||||
* <BR><CODE>type</CODE> and <CODE>version</CODE> fields are initialized with
|
||||
* {@link com.sun.jmx.snmp.SnmpDefinitions#pduV1TrapPdu pduV1TrapPdu}
|
||||
* and {@link com.sun.jmx.snmp.SnmpDefinitions#snmpVersionOne snmpVersionOne}.
|
||||
*/
|
||||
public SnmpPduTrap() {
|
||||
type = pduV1TrapPdu ;
|
||||
version = snmpVersionOne ;
|
||||
}
|
||||
}
|
||||
110
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpScopedPduBulk.java
Normal file
110
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpScopedPduBulk.java
Normal file
@@ -0,0 +1,110 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
/**
|
||||
* Represents a <CODE>get-bulk</CODE> PDU as defined in RFC 1448.
|
||||
* <P>
|
||||
* <P>
|
||||
* The <CODE>SnmpSocpedPduBulk</CODE> extends {@link com.sun.jmx.snmp.SnmpScopedPduPacket SnmpScopedPduPacket}
|
||||
* and defines attributes specific to the <CODE>get-bulk</CODE> PDU (see RFC 1448).
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public class SnmpScopedPduBulk extends SnmpScopedPduPacket
|
||||
implements SnmpPduBulkType {
|
||||
private static final long serialVersionUID = -1648623646227038885L;
|
||||
|
||||
/**
|
||||
* The <CODE>non-repeaters</CODE> value.
|
||||
* @serial
|
||||
*/
|
||||
int nonRepeaters;
|
||||
|
||||
|
||||
/**
|
||||
* The <CODE>max-repetitions</CODE> value.
|
||||
* @serial
|
||||
*/
|
||||
int maxRepetitions;
|
||||
|
||||
public SnmpScopedPduBulk() {
|
||||
type = pduGetBulkRequestPdu;
|
||||
version = snmpVersionThree;
|
||||
}
|
||||
|
||||
/**
|
||||
* The <CODE>max-repetitions</CODE> setter.
|
||||
* @param max Maximum repetition.
|
||||
*/
|
||||
public void setMaxRepetitions(int max) {
|
||||
maxRepetitions = max;
|
||||
}
|
||||
|
||||
/**
|
||||
* The <CODE>non-repeaters</CODE> setter.
|
||||
* @param nr Non repeaters.
|
||||
*/
|
||||
public void setNonRepeaters(int nr) {
|
||||
nonRepeaters = nr;
|
||||
}
|
||||
|
||||
/**
|
||||
* The <CODE>max-repetitions</CODE> getter.
|
||||
* @return Maximum repetition.
|
||||
*/
|
||||
public int getMaxRepetitions() { return maxRepetitions; }
|
||||
|
||||
/**
|
||||
* The <CODE>non-repeaters</CODE> getter.
|
||||
* @return Non repeaters.
|
||||
*/
|
||||
public int getNonRepeaters() { return nonRepeaters; }
|
||||
|
||||
/**
|
||||
* Generates the pdu to use for response.
|
||||
* @return Response pdu.
|
||||
*/
|
||||
public SnmpPdu getResponsePdu() {
|
||||
SnmpScopedPduRequest result = new SnmpScopedPduRequest();
|
||||
result.address = address ;
|
||||
result.port = port ;
|
||||
result.version = version ;
|
||||
result.requestId = requestId;
|
||||
result.msgId = msgId;
|
||||
result.msgMaxSize = msgMaxSize;
|
||||
result.msgFlags = msgFlags;
|
||||
result.msgSecurityModel = msgSecurityModel;
|
||||
result.contextEngineId = contextEngineId;
|
||||
result.contextName = contextName;
|
||||
result.securityParameters = securityParameters;
|
||||
result.type = pduGetResponsePdu ;
|
||||
result.errorStatus = SnmpDefinitions.snmpRspNoError ;
|
||||
result.errorIndex = 0 ;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
104
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpScopedPduPacket.java
Normal file
104
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpScopedPduPacket.java
Normal file
@@ -0,0 +1,104 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpSecurityParameters;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpDefinitions;
|
||||
/**
|
||||
* Is the fully decoded representation of an SNMP V3 packet.
|
||||
* <P>
|
||||
*
|
||||
* Classes are derived from <CODE>SnmpPdu</CODE> to
|
||||
* represent the different forms of SNMP pdu
|
||||
* ({@link com.sun.jmx.snmp.SnmpScopedPduRequest SnmpScopedPduRequest},
|
||||
* {@link com.sun.jmx.snmp.SnmpScopedPduBulk SnmpScopedPduBulk}).
|
||||
* <BR>The <CODE>SnmpScopedPduPacket</CODE> class defines the attributes
|
||||
* common to every scoped SNMP packets.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @see SnmpV3Message
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public abstract class SnmpScopedPduPacket extends SnmpPdu
|
||||
implements Serializable {
|
||||
/**
|
||||
* Message max size the pdu sender can deal with.
|
||||
*/
|
||||
public int msgMaxSize = 0;
|
||||
|
||||
/**
|
||||
* Message identifier.
|
||||
*/
|
||||
public int msgId = 0;
|
||||
|
||||
/**
|
||||
* Message flags. Reportable flag and security level.</P>
|
||||
*<PRE>
|
||||
* -- .... ...1 authFlag
|
||||
* -- .... ..1. privFlag
|
||||
* -- .... .1.. reportableFlag
|
||||
* -- Please observe:
|
||||
* -- .... ..00 is OK, means noAuthNoPriv
|
||||
* -- .... ..01 is OK, means authNoPriv
|
||||
* -- .... ..10 reserved, must NOT be used.
|
||||
* -- .... ..11 is OK, means authPriv
|
||||
*</PRE>
|
||||
*/
|
||||
public byte msgFlags = 0;
|
||||
|
||||
/**
|
||||
* The security model the security sub system MUST use in order to deal with this pdu (eg: User based Security Model Id = 3).
|
||||
*/
|
||||
public int msgSecurityModel = 0;
|
||||
|
||||
/**
|
||||
* The context engine Id in which the pdu must be handled (Generaly the local engine Id).
|
||||
*/
|
||||
public byte[] contextEngineId = null;
|
||||
|
||||
/**
|
||||
* The context name in which the OID have to be interpreted.
|
||||
*/
|
||||
public byte[] contextName = null;
|
||||
|
||||
/**
|
||||
* The security parameters. This is an opaque member that is
|
||||
* interpreted by the concerned security model.
|
||||
*/
|
||||
public SnmpSecurityParameters securityParameters = null;
|
||||
|
||||
/**
|
||||
* Constructor. Is only called by a son. Set the version to <CODE>SnmpDefinitions.snmpVersionThree</CODE>.
|
||||
*/
|
||||
protected SnmpScopedPduPacket() {
|
||||
version = SnmpDefinitions.snmpVersionThree;
|
||||
}
|
||||
}
|
||||
95
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpScopedPduRequest.java
Normal file
95
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpScopedPduRequest.java
Normal file
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
/**
|
||||
* Is used to represent <CODE>get</CODE>, <CODE>get-next</CODE>, <CODE>set</CODE>, <CODE>response</CODE> SNMP V3 scoped PDUs.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpScopedPduRequest extends SnmpScopedPduPacket
|
||||
implements SnmpPduRequestType {
|
||||
private static final long serialVersionUID = 6463060973056773680L;
|
||||
|
||||
int errorStatus=0 ;
|
||||
|
||||
int errorIndex=0 ;
|
||||
|
||||
/**
|
||||
* Error index setter. Remember that SNMP indices start from 1.
|
||||
* Thus the corresponding <CODE>SnmpVarBind</CODE> is
|
||||
* <CODE>varBindList[errorIndex-1]</CODE>.
|
||||
* @param i Error index.
|
||||
*/
|
||||
public void setErrorIndex(int i) {
|
||||
errorIndex = i;
|
||||
}
|
||||
/**
|
||||
* Error status setter. Statuses are defined in
|
||||
* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
|
||||
* @param s Error status.
|
||||
*/
|
||||
public void setErrorStatus(int s) {
|
||||
errorStatus = s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Error index getter. Remember that SNMP indices start from 1.
|
||||
* Thus the corresponding <CODE>SnmpVarBind</CODE> is
|
||||
* <CODE>varBindList[errorIndex-1]</CODE>.
|
||||
* @return Error index.
|
||||
*/
|
||||
public int getErrorIndex() { return errorIndex; }
|
||||
/**
|
||||
* Error status getter. Statuses are defined in
|
||||
* {@link com.sun.jmx.snmp.SnmpDefinitions SnmpDefinitions}.
|
||||
* @return Error status.
|
||||
*/
|
||||
public int getErrorStatus() { return errorStatus; }
|
||||
|
||||
/**
|
||||
* Generates the pdu to use for response.
|
||||
* @return Response pdu.
|
||||
*/
|
||||
public SnmpPdu getResponsePdu() {
|
||||
SnmpScopedPduRequest result = new SnmpScopedPduRequest();
|
||||
result.address = address ;
|
||||
result.port = port ;
|
||||
result.version = version ;
|
||||
result.requestId = requestId;
|
||||
result.msgId = msgId;
|
||||
result.msgMaxSize = msgMaxSize;
|
||||
result.msgFlags = msgFlags;
|
||||
result.msgSecurityModel = msgSecurityModel;
|
||||
result.contextEngineId = contextEngineId;
|
||||
result.contextName = contextName;
|
||||
result.securityParameters = securityParameters;
|
||||
result.type = pduGetResponsePdu ;
|
||||
result.errorStatus = SnmpDefinitions.snmpRspNoError ;
|
||||
result.errorIndex = 0 ;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
67
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpSecurityException.java
Normal file
67
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpSecurityException.java
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
/**
|
||||
* This exception is thrown when an error occurs in an <CODE> SnmpSecurityModel </CODE>.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpSecurityException extends Exception {
|
||||
private static final long serialVersionUID = 5574448147432833480L;
|
||||
|
||||
/**
|
||||
* The current request varbind list.
|
||||
*/
|
||||
public SnmpVarBind[] list = null;
|
||||
/**
|
||||
* The status of the exception. See {@link com.sun.jmx.snmp.SnmpDefinitions} for possible values.
|
||||
*/
|
||||
public int status = SnmpDefinitions.snmpReqUnknownError;
|
||||
/**
|
||||
* The current security model related security parameters.
|
||||
*/
|
||||
public SnmpSecurityParameters params = null;
|
||||
/**
|
||||
* The current context engine Id.
|
||||
*/
|
||||
public byte[] contextEngineId = null;
|
||||
/**
|
||||
* The current context name.
|
||||
*/
|
||||
public byte[] contextName = null;
|
||||
/**
|
||||
* The current flags.
|
||||
*/
|
||||
public byte flags = (byte) SnmpDefinitions.noAuthNoPriv;
|
||||
/**
|
||||
* Constructor.
|
||||
* @param msg The exception msg to display.
|
||||
*/
|
||||
public SnmpSecurityException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
54
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpSecurityParameters.java
Normal file
54
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpSecurityParameters.java
Normal file
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpTooBigException;
|
||||
|
||||
/**
|
||||
* Security parameters are security model dependent. Every security parameters class wishing to be passed to a security model must implement this marker interface.
|
||||
* This interface has to be implemented when developing customized security models.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpSecurityParameters {
|
||||
/**
|
||||
* BER encoding of security parameters.
|
||||
* @param outputBytes Array to fill.
|
||||
* @return Encoded parameters length.
|
||||
*/
|
||||
int encode(byte[] outputBytes) throws SnmpTooBigException;
|
||||
/**
|
||||
* BER decoding of security parameters.
|
||||
* @param params Encoded parameters.
|
||||
*/
|
||||
void decode(byte[] params) throws SnmpStatusException;
|
||||
|
||||
/**
|
||||
* Principal coded inside the security parameters.
|
||||
* @return The security principal.
|
||||
*/
|
||||
String getPrincipal();
|
||||
}
|
||||
146
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpStatusException.java
Normal file
146
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpStatusException.java
Normal file
@@ -0,0 +1,146 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Reports an error which occurred during a get/set operation on a mib node.
|
||||
*
|
||||
* This exception includes a status error code as defined in the SNMP protocol.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpStatusException extends Exception implements SnmpDefinitions {
|
||||
private static final long serialVersionUID = 5809485694133115675L;
|
||||
|
||||
/**
|
||||
* Error code as defined in RFC 1448 for: <CODE>noSuchName</CODE>.
|
||||
*/
|
||||
public static final int noSuchName = 2 ;
|
||||
|
||||
/**
|
||||
* Error code as defined in RFC 1448 for: <CODE>badValue</CODE>.
|
||||
*/
|
||||
public static final int badValue = 3 ;
|
||||
|
||||
/**
|
||||
* Error code as defined in RFC 1448 for: <CODE>readOnly</CODE>.
|
||||
*/
|
||||
public static final int readOnly = 4 ;
|
||||
|
||||
|
||||
/**
|
||||
* Error code as defined in RFC 1448 for: <CODE>noAccess</CODE>.
|
||||
*/
|
||||
public static final int noAccess = 6 ;
|
||||
|
||||
/**
|
||||
* Error code for reporting a no such instance error.
|
||||
*/
|
||||
public static final int noSuchInstance = 0xE0;
|
||||
|
||||
/**
|
||||
* Error code for reporting a no such object error.
|
||||
*/
|
||||
public static final int noSuchObject = 0xE1;
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpStatusException</CODE> with the specified status error.
|
||||
* @param status The error status.
|
||||
*/
|
||||
public SnmpStatusException(int status) {
|
||||
errorStatus = status ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpStatusException</CODE> with the specified status error and status index.
|
||||
* @param status The error status.
|
||||
* @param index The error index.
|
||||
*/
|
||||
public SnmpStatusException(int status, int index) {
|
||||
errorStatus = status ;
|
||||
errorIndex = index ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpStatusException</CODE> with an error message.
|
||||
* The error status is set to 0 (noError) and the index to -1.
|
||||
* @param s The error message.
|
||||
*/
|
||||
public SnmpStatusException(String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpStatusException</CODE> with an error index.
|
||||
* @param x The original <CODE>SnmpStatusException</CODE>.
|
||||
* @param index The error index.
|
||||
*/
|
||||
public SnmpStatusException(SnmpStatusException x, int index) {
|
||||
super(x.getMessage());
|
||||
errorStatus= x.errorStatus;
|
||||
errorIndex= index;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the error status.
|
||||
* @return The error status.
|
||||
*/
|
||||
public int getStatus() {
|
||||
return errorStatus ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the index of the error.
|
||||
* A value of -1 means that the index is not known/applicable.
|
||||
* @return The error index.
|
||||
*/
|
||||
public int getErrorIndex() {
|
||||
return errorIndex;
|
||||
}
|
||||
|
||||
|
||||
// PRIVATE VARIABLES
|
||||
//--------------------
|
||||
|
||||
/**
|
||||
* Status of the error.
|
||||
* @serial
|
||||
*/
|
||||
private int errorStatus = 0 ;
|
||||
|
||||
/**
|
||||
* Index of the error.
|
||||
* If different from -1, indicates the index where the error occurs.
|
||||
* @serial
|
||||
*/
|
||||
private int errorIndex= -1;
|
||||
|
||||
}
|
||||
278
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpString.java
Normal file
278
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpString.java
Normal file
@@ -0,0 +1,278 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
|
||||
/**
|
||||
* Represents an SNMP string.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpString extends SnmpValue {
|
||||
private static final long serialVersionUID = -7011986973225194188L;
|
||||
|
||||
// CONSTRUCTORS
|
||||
//-------------
|
||||
/**
|
||||
* Constructs a new empty <CODE>SnmpString</CODE>.
|
||||
*/
|
||||
public SnmpString() {
|
||||
value = new byte[0] ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpString</CODE> from the specified bytes array.
|
||||
* @param v The bytes composing the string value.
|
||||
*/
|
||||
public SnmpString(byte[] v) {
|
||||
value = v.clone() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpString</CODE> from the specified <CODE>Bytes</CODE> array.
|
||||
* @param v The <CODE>Bytes</CODE> composing the string value.
|
||||
*/
|
||||
public SnmpString(Byte[] v) {
|
||||
value = new byte[v.length] ;
|
||||
for (int i = 0 ; i < v.length ; i++) {
|
||||
value[i] = v[i].byteValue() ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpString</CODE> from the specified <CODE>String</CODE> value.
|
||||
* @param v The initialization value.
|
||||
*/
|
||||
public SnmpString(String v) {
|
||||
value = v.getBytes() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpString</CODE> from the specified <CODE> InetAddress </Code>.
|
||||
* @param address The <CODE>InetAddress </CODE>.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public SnmpString(InetAddress address) {
|
||||
value = address.getAddress();
|
||||
}
|
||||
|
||||
// PUBLIC METHODS
|
||||
//---------------
|
||||
|
||||
/**
|
||||
* Converts the string value to its <CODE> InetAddress </CODE> form.
|
||||
* @return an {@link InetAddress} defined by the string value.
|
||||
* @exception UnknownHostException If string value is not a legal address format.
|
||||
*
|
||||
* @since 1.5
|
||||
*/
|
||||
public InetAddress inetAddressValue() throws UnknownHostException {
|
||||
return InetAddress.getByAddress(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the specified binary string into a character string.
|
||||
* @param bin The binary string value to convert.
|
||||
* @return The character string representation.
|
||||
*/
|
||||
public static String BinToChar(String bin) {
|
||||
char value[] = new char[bin.length()/8];
|
||||
int binLength = value.length;
|
||||
for (int i = 0; i < binLength; i++)
|
||||
value[i] = (char)Integer.parseInt(bin.substring(8*i, 8*i+8), 2);
|
||||
return new String(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the specified hexadecimal string into a character string.
|
||||
* @param hex The hexadecimal string value to convert.
|
||||
* @return The character string representation.
|
||||
*/
|
||||
public static String HexToChar(String hex) {
|
||||
char value[] = new char[hex.length()/2];
|
||||
int hexLength = value.length;
|
||||
for (int i = 0; i < hexLength; i++)
|
||||
value[i] = (char)Integer.parseInt(hex.substring(2*i, 2*i+2), 16);
|
||||
return new String(value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the bytes array of this <CODE>SnmpString</CODE>.
|
||||
* @return The value.
|
||||
*/
|
||||
public byte[] byteValue() {
|
||||
return value.clone() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the string value to its array of <CODE>Bytes</CODE> form.
|
||||
* @return The array of <CODE>Bytes</CODE> representation of the value.
|
||||
*/
|
||||
public Byte[] toByte() {
|
||||
Byte[] result = new Byte[value.length] ;
|
||||
for (int i = 0 ; i < value.length ; i++) {
|
||||
result[i] = new Byte(value[i]) ;
|
||||
}
|
||||
return result ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the string value to its <CODE>String</CODE> form.
|
||||
* @return The <CODE>String</CODE> representation of the value.
|
||||
*/
|
||||
public String toString() {
|
||||
return new String(value) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts the string value to its <CODE>SnmpOid</CODE> form.
|
||||
* @return The OID representation of the value.
|
||||
*/
|
||||
public SnmpOid toOid() {
|
||||
long[] ids = new long[value.length] ;
|
||||
for (int i = 0 ; i < value.length ; i++) {
|
||||
ids[i] = (long)(value[i] & 0xFF) ;
|
||||
}
|
||||
return new SnmpOid(ids) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extracts the string from an index OID and returns its
|
||||
* value converted as an <CODE>SnmpOid</CODE>.
|
||||
* @param index The index array.
|
||||
* @param start The position in the index array.
|
||||
* @return The OID representing the string value.
|
||||
* @exception SnmpStatusException There is no string value
|
||||
* available at the start position.
|
||||
*/
|
||||
public static SnmpOid toOid(long[] index, int start) throws SnmpStatusException {
|
||||
try {
|
||||
if (index[start] > Integer.MAX_VALUE) {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
int strLen = (int)index[start++] ;
|
||||
long[] ids = new long[strLen] ;
|
||||
for (int i = 0 ; i < strLen ; i++) {
|
||||
ids[i] = index[start + i] ;
|
||||
}
|
||||
return new SnmpOid(ids) ;
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans an index OID, skips the string value and returns the position
|
||||
* of the next value.
|
||||
* @param index The index array.
|
||||
* @param start The position in the index array.
|
||||
* @return The position of the next value.
|
||||
* @exception SnmpStatusException There is no string value
|
||||
* available at the start position.
|
||||
*/
|
||||
public static int nextOid(long[] index, int start) throws SnmpStatusException {
|
||||
try {
|
||||
if (index[start] > Integer.MAX_VALUE) {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
int strLen = (int)index[start++] ;
|
||||
start += strLen ;
|
||||
if (start <= index.length) {
|
||||
return start ;
|
||||
}
|
||||
else {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an <CODE>SnmpOid</CODE> representing an <CODE>SnmpString</CODE> to another OID.
|
||||
* @param source An OID representing an <CODE>SnmpString</CODE> value.
|
||||
* @param dest Where source should be appended.
|
||||
*/
|
||||
public static void appendToOid(SnmpOid source, SnmpOid dest) {
|
||||
dest.append(source.getLength()) ;
|
||||
dest.append(source) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Performs a clone action. This provides a workaround for the
|
||||
* <CODE>SnmpValue</CODE> interface.
|
||||
* @return The SnmpValue clone.
|
||||
*/
|
||||
final synchronized public SnmpValue duplicate() {
|
||||
return (SnmpValue) clone() ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clones the <CODE>SnmpString</CODE> object, making a copy of its data.
|
||||
* @return The object clone.
|
||||
*/
|
||||
synchronized public Object clone() {
|
||||
SnmpString newclone = null ;
|
||||
|
||||
try {
|
||||
newclone = (SnmpString) super.clone() ;
|
||||
newclone.value = new byte[value.length] ;
|
||||
System.arraycopy(value, 0, newclone.value, 0, value.length) ;
|
||||
} catch (CloneNotSupportedException e) {
|
||||
throw new InternalError(e) ; // vm bug.
|
||||
}
|
||||
return newclone ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a textual description of the type object.
|
||||
* @return ASN.1 textual description.
|
||||
*/
|
||||
public String getTypeName() {
|
||||
return name ;
|
||||
}
|
||||
|
||||
// VARIABLES
|
||||
//----------
|
||||
/**
|
||||
* Name of the type.
|
||||
*/
|
||||
final static String name = "String" ;
|
||||
|
||||
/**
|
||||
* This is the bytes array of the string value.
|
||||
* @serial
|
||||
*/
|
||||
protected byte[] value = null ;
|
||||
}
|
||||
193
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpStringFixed.java
Normal file
193
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpStringFixed.java
Normal file
@@ -0,0 +1,193 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
// java imports
|
||||
//
|
||||
import java.lang.Math;
|
||||
|
||||
/**
|
||||
* Represents an SNMP String defined with a fixed length.
|
||||
* The class is mainly used when dealing with table indexes for which one of the keys
|
||||
* is defined as a <CODE>String</CODE>.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpStringFixed extends SnmpString {
|
||||
private static final long serialVersionUID = -9120939046874646063L;
|
||||
|
||||
// CONSTRUCTORS
|
||||
//-------------
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpStringFixed</CODE> from the specified bytes array.
|
||||
* @param v The bytes composing the fixed-string value.
|
||||
*/
|
||||
public SnmpStringFixed(byte[] v) {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpStringFixed</CODE> with the specified <CODE>Bytes</CODE> array.
|
||||
* @param v The <CODE>Bytes</CODE> composing the fixed-string value.
|
||||
*/
|
||||
public SnmpStringFixed(Byte[] v) {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpStringFixed</CODE> from the specified <CODE>String</CODE> value.
|
||||
* @param v The initialization value.
|
||||
*/
|
||||
public SnmpStringFixed(String v) {
|
||||
super(v) ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpStringFixed</CODE> from the specified <CODE>bytes</CODE> array
|
||||
* with the specified length.
|
||||
* @param l The length of the fixed-string.
|
||||
* @param v The <CODE>bytes</CODE> composing the fixed-string value.
|
||||
* @exception IllegalArgumentException Either the length or the <CODE>byte</CODE> array is not valid.
|
||||
*/
|
||||
public SnmpStringFixed(int l, byte[] v) throws IllegalArgumentException {
|
||||
if ((l <= 0) || (v == null)) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
int length = Math.min(l, v.length);
|
||||
value = new byte[l] ;
|
||||
for (int i = 0 ; i < length ; i++) {
|
||||
value[i] = v[i] ;
|
||||
}
|
||||
for (int i = length ; i < l ; i++) {
|
||||
value[i] = 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpStringFixed</CODE> from the specified <CODE>Bytes</CODE> array
|
||||
* with the specified length.
|
||||
* @param l The length of the fixed-string.
|
||||
* @param v The <CODE>Bytes</CODE> composing the fixed-string value.
|
||||
* @exception IllegalArgumentException Either the length or the <CODE>Byte</CODE> array is not valid.
|
||||
*/
|
||||
public SnmpStringFixed(int l, Byte[] v) throws IllegalArgumentException {
|
||||
if ((l <= 0) || (v == null)) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
int length = Math.min(l, v.length);
|
||||
value = new byte[l] ;
|
||||
for (int i = 0 ; i < length ; i++) {
|
||||
value[i] = v[i].byteValue() ;
|
||||
}
|
||||
for (int i = length ; i < l ; i++) {
|
||||
value[i] = 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpStringFixed</CODE> from the specified <CODE>String</CODE>
|
||||
* with the specified length.
|
||||
* @param l The length of the fixed-string.
|
||||
* @param s The <CODE>String</CODE> composing the fixed-string value.
|
||||
* @exception IllegalArgumentException Either the length or the <CODE>String</CODE> is not valid.
|
||||
*/
|
||||
public SnmpStringFixed(int l, String s) throws IllegalArgumentException {
|
||||
if ((l <= 0) || (s == null)) {
|
||||
throw new IllegalArgumentException() ;
|
||||
}
|
||||
byte[] v = s.getBytes();
|
||||
int length = Math.min(l, v.length);
|
||||
value = new byte[l] ;
|
||||
for (int i = 0 ; i < length ; i++) {
|
||||
value[i] = v[i] ;
|
||||
}
|
||||
for (int i = length ; i < l ; i++) {
|
||||
value[i] = 0 ;
|
||||
}
|
||||
}
|
||||
|
||||
// PUBLIC METHODS
|
||||
//---------------
|
||||
/**
|
||||
* Extracts the fixed-string from an index OID and returns its
|
||||
* value converted as an <CODE>SnmpOid</CODE>.
|
||||
* @param l The number of successive array elements to be retreived
|
||||
* in order to construct the OID.
|
||||
* These elements are retreived starting at the <CODE>start</CODE> position.
|
||||
* @param index The index array.
|
||||
* @param start The position in the index array.
|
||||
* @return The OID representing the fixed-string value.
|
||||
* @exception SnmpStatusException There is no string value
|
||||
* available at the start position.
|
||||
*/
|
||||
public static SnmpOid toOid(int l, long[] index, int start) throws SnmpStatusException {
|
||||
try {
|
||||
long[] ids = new long[l] ;
|
||||
for (int i = 0 ; i < l ; i++) {
|
||||
ids[i] = index[start + i] ;
|
||||
}
|
||||
return new SnmpOid(ids) ;
|
||||
}
|
||||
catch(IndexOutOfBoundsException e) {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Scans an index OID, skip the string value and returns the position
|
||||
* of the next value.
|
||||
* @param l The number of successive array elements to be passed
|
||||
* in order to get the position of the next value.
|
||||
* These elements are passed starting at the <CODE>start</CODE> position.
|
||||
* @param index The index array.
|
||||
* @param start The position in the index array.
|
||||
* @return The position of the next value.
|
||||
* @exception SnmpStatusException There is no string value
|
||||
* available at the start position.
|
||||
*/
|
||||
public static int nextOid(int l, long[] index, int start) throws SnmpStatusException {
|
||||
int result = start + l ;
|
||||
if (result > index.length) {
|
||||
throw new SnmpStatusException(SnmpStatusException.noSuchName) ;
|
||||
}
|
||||
return result ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Appends an <CODE>SnmpOid</CODE> representing an <CODE>SnmpStringFixed</CODE> to another OID.
|
||||
* @param l Unused.
|
||||
* @param source An OID representing an <CODE>SnmpStringFixed</CODE> value.
|
||||
* @param dest Where source should be appended.
|
||||
*/
|
||||
public static void appendToOid(int l, SnmpOid source, SnmpOid dest) {
|
||||
dest.append(source) ;
|
||||
}
|
||||
}
|
||||
82
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpTooBigException.java
Normal file
82
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpTooBigException.java
Normal file
@@ -0,0 +1,82 @@
|
||||
/*
|
||||
* Copyright (c) 1998, 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;
|
||||
|
||||
|
||||
/**
|
||||
* Is used internally to signal that the size of a PDU exceeds the packet size limitation.
|
||||
* <p>
|
||||
* You will not usually need to use this class, except if you
|
||||
* decide to implement your own
|
||||
* {@link com.sun.jmx.snmp.SnmpPduFactory SnmPduFactory} object.
|
||||
* <p>
|
||||
* The <CODE>varBindCount</CODE> property contains the
|
||||
* number of <CODE>SnmpVarBind</CODE> successfully encoded
|
||||
* before the exception was thrown. Its value is 0
|
||||
* when this number is unknown.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public class SnmpTooBigException extends Exception {
|
||||
private static final long serialVersionUID = 4754796246674803969L;
|
||||
|
||||
/**
|
||||
* Builds an <CODE>SnmpTooBigException</CODE> with
|
||||
* <CODE>varBindCount</CODE> set to 0.
|
||||
*/
|
||||
public SnmpTooBigException() {
|
||||
varBindCount = 0 ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds an <CODE>SnmpTooBigException</CODE> with
|
||||
* <CODE>varBindCount</CODE> set to the specified value.
|
||||
* @param n The <CODE>varBindCount</CODE> value.
|
||||
*/
|
||||
public SnmpTooBigException(int n) {
|
||||
varBindCount = n ;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of <CODE>SnmpVarBind</CODE> successfully
|
||||
* encoded before the exception was thrown.
|
||||
*
|
||||
* @return A positive integer (0 means the number is unknown).
|
||||
*/
|
||||
public int getVarBindCount() {
|
||||
return varBindCount ;
|
||||
}
|
||||
|
||||
/**
|
||||
* The <CODE>varBindCount</CODE>.
|
||||
* @serial
|
||||
*/
|
||||
private int varBindCount ;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpUnknownModelException;
|
||||
|
||||
/**
|
||||
* This exception is thrown when an
|
||||
* <CODE>SnmpAccessControlSubSystem</CODE> doesn't know the passed ID.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpUnknownAccContrModelException extends SnmpUnknownModelException {
|
||||
private static final long serialVersionUID = -8831186713954487538L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param msg The exception msg to display.
|
||||
*/
|
||||
public SnmpUnknownAccContrModelException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
42
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpUnknownModelException.java
Normal file
42
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpUnknownModelException.java
Normal file
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
/**
|
||||
* This exception is thrown when a needed model is not present in the engine.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpUnknownModelException extends Exception {
|
||||
private static final long serialVersionUID = -8667664269418048003L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param msg The exception msg to display.
|
||||
*/
|
||||
public SnmpUnknownModelException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
/**
|
||||
* This exception is thrown when an <CODE>SnmpLcd</CODE> has no ModelLcd associated to the model.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpUnknownModelLcdException extends Exception {
|
||||
private static final long serialVersionUID = 6369064741633646317L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param msg The exception msg to display.
|
||||
*/
|
||||
public SnmpUnknownModelLcdException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpUnknownModelException;
|
||||
|
||||
/**
|
||||
* This exception is thrown when an <CODE>SnmpMsgProcessingSubSystem</CODE> doesn't know the passed ID.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpUnknownMsgProcModelException extends SnmpUnknownModelException {
|
||||
private static final long serialVersionUID = -4179907244861284771L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param msg The exception msg to display.
|
||||
*/
|
||||
public SnmpUnknownMsgProcModelException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpUnknownModelException;
|
||||
|
||||
/**
|
||||
* This exception is thrown when an <CODE>SnmpSecuritySubSystem</CODE> doesn't know the passed ID.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpUnknownSecModelException extends SnmpUnknownModelException {
|
||||
private static final long serialVersionUID = -2173491650805292799L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param msg The exception msg to display.
|
||||
*/
|
||||
public SnmpUnknownSecModelException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
/**
|
||||
* This exception is thrown when the handled <CODE> SnmpSubSystem </CODE> is unknown.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpUnknownSubSystemException extends Exception {
|
||||
private static final long serialVersionUID = 4463202140045245052L;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param msg The exception msg to display.
|
||||
*/
|
||||
public SnmpUnknownSubSystemException(String msg) {
|
||||
super(msg);
|
||||
}
|
||||
}
|
||||
125
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpUnsignedInt.java
Normal file
125
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpUnsignedInt.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Is the base for all SNMP syntaxes based on unsigned integers.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public abstract class SnmpUnsignedInt extends SnmpInt {
|
||||
|
||||
/**
|
||||
* The largest value of the type <code>unsigned int</code> (2^32 - 1).
|
||||
*/
|
||||
public static final long MAX_VALUE = 0x0ffffffffL;
|
||||
|
||||
// CONSTRUCTORS
|
||||
//-------------
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified integer value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpUnsignedInt(int v) throws IllegalArgumentException {
|
||||
super(v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified <CODE>Integer</CODE> value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpUnsignedInt(Integer v) throws IllegalArgumentException {
|
||||
super(v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified long value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpUnsignedInt(long v) throws IllegalArgumentException {
|
||||
super(v);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new <CODE>SnmpUnsignedInt</CODE> from the specified <CODE>Long</CODE> value.
|
||||
* @param v The initialization value.
|
||||
* @exception IllegalArgumentException The specified value is negative
|
||||
* or larger than {@link #MAX_VALUE SnmpUnsignedInt.MAX_VALUE}.
|
||||
*/
|
||||
public SnmpUnsignedInt(Long v) throws IllegalArgumentException {
|
||||
super(v);
|
||||
}
|
||||
|
||||
// PUBLIC METHODS
|
||||
//---------------
|
||||
/**
|
||||
* Returns a textual description of the type object.
|
||||
* @return ASN.1 textual description.
|
||||
*/
|
||||
public String getTypeName() {
|
||||
return name ;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method has been defined to allow the sub-classes
|
||||
* of SnmpInt to perform their own control at intialization time.
|
||||
*/
|
||||
boolean isInitValueValid(int v) {
|
||||
if ((v < 0) || (v > SnmpUnsignedInt.MAX_VALUE)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method has been defined to allow the sub-classes
|
||||
* of SnmpInt to perform their own control at intialization time.
|
||||
*/
|
||||
boolean isInitValueValid(long v) {
|
||||
if ((v < 0) || (v > SnmpUnsignedInt.MAX_VALUE)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
// VARIABLES
|
||||
//----------
|
||||
/**
|
||||
* Name of the type.
|
||||
*/
|
||||
final static String name = "Unsigned32" ;
|
||||
}
|
||||
98
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpUsmKeyHandler.java
Normal file
98
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpUsmKeyHandler.java
Normal file
@@ -0,0 +1,98 @@
|
||||
/*
|
||||
* Copyright (c) 2002, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
/**
|
||||
* This interface allows you to compute key localization and delta generation. It is useful when adding user in USM MIB. An instance of <CODE> SnmpUsmKeyHandler </CODE> is associated to each <CODE> SnmpEngine </CODE> object.
|
||||
* When computing key, an authentication algorithm is needed. The supported ones are : usmHMACMD5AuthProtocol and usmHMACSHAAuthProtocol.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpUsmKeyHandler {
|
||||
|
||||
/**
|
||||
* DES privacy algorithm key size. To be used when localizing privacy key
|
||||
*/
|
||||
public static int DES_KEY_SIZE = 16;
|
||||
|
||||
/**
|
||||
* DES privacy algorithm delta size. To be used when calculing privacy key delta.
|
||||
*/
|
||||
public static int DES_DELTA_SIZE = 16;
|
||||
|
||||
/**
|
||||
* Translate a password to a key. It MUST be compliant to RFC 2574 description.
|
||||
* @param algoName The authentication algorithm to use.
|
||||
* @param password Password to convert.
|
||||
* @return The key.
|
||||
* @exception IllegalArgumentException If the algorithm is unknown.
|
||||
*/
|
||||
public byte[] password_to_key(String algoName, String password) throws IllegalArgumentException;
|
||||
/**
|
||||
* Localize the passed key using the passed <CODE>SnmpEngineId</CODE>. It MUST be compliant to RFC 2574 description.
|
||||
* @param algoName The authentication algorithm to use.
|
||||
* @param key The key to localize;
|
||||
* @param engineId The Id used to localize the key.
|
||||
* @return The localized key.
|
||||
* @exception IllegalArgumentException If the algorithm is unknown.
|
||||
*/
|
||||
public byte[] localizeAuthKey(String algoName, byte[] key, SnmpEngineId engineId) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Localize the passed privacy key using the passed <CODE>SnmpEngineId</CODE>. It MUST be compliant to RFC 2574 description.
|
||||
* @param algoName The authentication algorithm to use.
|
||||
* @param key The key to localize;
|
||||
* @param engineId The Id used to localize the key.
|
||||
* @param keysize The privacy algorithm key size.
|
||||
* @return The localized key.
|
||||
* @exception IllegalArgumentException If the algorithm is unknown.
|
||||
*/
|
||||
public byte[] localizePrivKey(String algoName, byte[] key, SnmpEngineId engineId,int keysize) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Calculate the delta parameter needed when processing key change. This computation is done by the key change initiator. It MUST be compliant to RFC 2574 description.
|
||||
* @param algoName The authentication algorithm to use.
|
||||
* @param oldKey The old key.
|
||||
* @param newKey The new key.
|
||||
* @param random The random value.
|
||||
* @return The delta.
|
||||
* @exception IllegalArgumentException If the algorithm is unknown.
|
||||
*/
|
||||
public byte[] calculateAuthDelta(String algoName, byte[] oldKey, byte[] newKey, byte[] random) throws IllegalArgumentException;
|
||||
|
||||
/**
|
||||
* Calculate the delta parameter needed when processing key change for a privacy algorithm. This computation is done by the key change initiator. It MUST be compliant to RFC 2574 description.
|
||||
* @param algoName The authentication algorithm to use.
|
||||
* @param oldKey The old key.
|
||||
* @param newKey The new key.
|
||||
* @param random The random value.
|
||||
* @param deltaSize The algo delta size.
|
||||
* @return The delta.
|
||||
* @exception IllegalArgumentException If the algorithm is unknown.
|
||||
*/
|
||||
public byte[] calculatePrivDelta(String algoName, byte[] oldKey, byte[] newKey, byte[] random, int deltaSize) throws IllegalArgumentException;
|
||||
|
||||
}
|
||||
511
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpV3Message.java
Normal file
511
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpV3Message.java
Normal file
@@ -0,0 +1,511 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
// java imports
|
||||
//
|
||||
import java.util.Vector;
|
||||
import java.util.logging.Level;
|
||||
import java.net.InetAddress;
|
||||
|
||||
// import debug stuff
|
||||
//
|
||||
import static com.sun.jmx.defaults.JmxProperties.SNMP_LOGGER;
|
||||
import com.sun.jmx.snmp.internal.SnmpMsgProcessingSubSystem;
|
||||
import com.sun.jmx.snmp.internal.SnmpSecurityModel;
|
||||
import com.sun.jmx.snmp.internal.SnmpDecryptedPdu;
|
||||
import com.sun.jmx.snmp.internal.SnmpSecurityCache;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpMsg;
|
||||
import com.sun.jmx.snmp.SnmpPdu;
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpTooBigException;
|
||||
import com.sun.jmx.snmp.SnmpScopedPduBulk;
|
||||
import com.sun.jmx.snmp.BerException;
|
||||
import com.sun.jmx.snmp.SnmpScopedPduRequest;
|
||||
import com.sun.jmx.snmp.BerDecoder;
|
||||
import com.sun.jmx.snmp.SnmpDefinitions;
|
||||
import com.sun.jmx.snmp.SnmpEngineId;
|
||||
import com.sun.jmx.snmp.SnmpScopedPduPacket;
|
||||
import com.sun.jmx.snmp.BerEncoder;
|
||||
import com.sun.jmx.snmp.SnmpPduRequestType;
|
||||
import com.sun.jmx.snmp.SnmpPduBulkType;
|
||||
|
||||
/**
|
||||
* Is a partially decoded representation of an SNMP V3 packet.
|
||||
* <P>
|
||||
* This class can be used when developing customized manager or agent.
|
||||
* <P>
|
||||
* The <CODE>SnmpV3Message</CODE> class is directly mapped onto the
|
||||
* message syntax defined in RFC 2572.
|
||||
* <BLOCKQUOTE>
|
||||
* <PRE>
|
||||
* SNMPv3Message ::= SEQUENCE {
|
||||
* msgVersion INTEGER ( 0 .. 2147483647 ),
|
||||
* -- administrative parameters
|
||||
* msgGlobalData HeaderData,
|
||||
* -- security model-specific parameters
|
||||
* -- format defined by Security Model
|
||||
* msgSecurityParameters OCTET STRING,
|
||||
* msgData ScopedPduData
|
||||
* }
|
||||
* HeaderData ::= SEQUENCE {
|
||||
* msgID INTEGER (0..2147483647),
|
||||
* msgMaxSize INTEGER (484..2147483647),
|
||||
*
|
||||
* msgFlags OCTET STRING (SIZE(1)),
|
||||
* -- .... ...1 authFlag
|
||||
* -- .... ..1. privFlag
|
||||
* -- .... .1.. reportableFlag
|
||||
* -- Please observe:
|
||||
* -- .... ..00 is OK, means noAuthNoPriv
|
||||
* -- .... ..01 is OK, means authNoPriv
|
||||
* -- .... ..10 reserved, must NOT be used.
|
||||
* -- .... ..11 is OK, means authPriv
|
||||
*
|
||||
* msgSecurityModel INTEGER (1..2147483647)
|
||||
* }
|
||||
* </BLOCKQUOTE>
|
||||
* </PRE>
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpV3Message extends SnmpMsg {
|
||||
|
||||
/**
|
||||
* Message identifier.
|
||||
*/
|
||||
public int msgId = 0;
|
||||
|
||||
/**
|
||||
* Message max size the pdu sender can deal with.
|
||||
*/
|
||||
public int msgMaxSize = 0;
|
||||
/**
|
||||
* Message flags. Reportable flag and security level.</P>
|
||||
*<PRE>
|
||||
* -- .... ...1 authFlag
|
||||
* -- .... ..1. privFlag
|
||||
* -- .... .1.. reportableFlag
|
||||
* -- Please observe:
|
||||
* -- .... ..00 is OK, means noAuthNoPriv
|
||||
* -- .... ..01 is OK, means authNoPriv
|
||||
* -- .... ..10 reserved, must NOT be used.
|
||||
* -- .... ..11 is OK, means authPriv
|
||||
*</PRE>
|
||||
*/
|
||||
public byte msgFlags = 0;
|
||||
/**
|
||||
* The security model the security sub system MUST use in order to deal with this pdu (eg: User based Security Model Id = 3).
|
||||
*/
|
||||
public int msgSecurityModel = 0;
|
||||
/**
|
||||
* The unmarshalled security parameters.
|
||||
*/
|
||||
public byte[] msgSecurityParameters = null;
|
||||
/**
|
||||
* The context engine Id in which the pdu must be handled (Generaly the local engine Id).
|
||||
*/
|
||||
public byte[] contextEngineId = null;
|
||||
/**
|
||||
* The context name in which the OID has to be interpreted.
|
||||
*/
|
||||
public byte[] contextName = null;
|
||||
/** The encrypted form of the scoped pdu (Only relevant when dealing with privacy).
|
||||
*/
|
||||
public byte[] encryptedPdu = null;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
*/
|
||||
public SnmpV3Message() {
|
||||
}
|
||||
/**
|
||||
* Encodes this message and puts the result in the specified byte array.
|
||||
* For internal use only.
|
||||
*
|
||||
* @param outputBytes An array to receive the resulting encoding.
|
||||
*
|
||||
* @exception ArrayIndexOutOfBoundsException If the result does not fit
|
||||
* into the specified array.
|
||||
*/
|
||||
public int encodeMessage(byte[] outputBytes)
|
||||
throws SnmpTooBigException {
|
||||
int encodingLength = 0;
|
||||
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
|
||||
SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
|
||||
"encodeMessage",
|
||||
"Can't encode directly V3Message! Need a SecuritySubSystem");
|
||||
}
|
||||
throw new IllegalArgumentException("Can't encode");
|
||||
}
|
||||
|
||||
/**
|
||||
* Decodes the specified bytes and initializes this message.
|
||||
* For internal use only.
|
||||
*
|
||||
* @param inputBytes The bytes to be decoded.
|
||||
*
|
||||
* @exception SnmpStatusException If the specified bytes are not a valid encoding.
|
||||
*/
|
||||
public void decodeMessage(byte[] inputBytes, int byteCount)
|
||||
throws SnmpStatusException {
|
||||
|
||||
try {
|
||||
BerDecoder bdec = new BerDecoder(inputBytes);
|
||||
bdec.openSequence();
|
||||
version = bdec.fetchInteger();
|
||||
bdec.openSequence();
|
||||
msgId = bdec.fetchInteger();
|
||||
msgMaxSize = bdec.fetchInteger();
|
||||
msgFlags = bdec.fetchOctetString()[0];
|
||||
msgSecurityModel =bdec.fetchInteger();
|
||||
bdec.closeSequence();
|
||||
msgSecurityParameters = bdec.fetchOctetString();
|
||||
if( (msgFlags & SnmpDefinitions.privMask) == 0 ) {
|
||||
bdec.openSequence();
|
||||
contextEngineId = bdec.fetchOctetString();
|
||||
contextName = bdec.fetchOctetString();
|
||||
data = bdec.fetchAny();
|
||||
dataLength = data.length;
|
||||
bdec.closeSequence();
|
||||
}
|
||||
else {
|
||||
encryptedPdu = bdec.fetchOctetString();
|
||||
}
|
||||
bdec.closeSequence() ;
|
||||
}
|
||||
catch(BerException x) {
|
||||
x.printStackTrace();
|
||||
throw new SnmpStatusException("Invalid encoding") ;
|
||||
}
|
||||
|
||||
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
|
||||
final StringBuilder strb = new StringBuilder()
|
||||
.append("Unmarshalled message : \n")
|
||||
.append("version : ").append(version)
|
||||
.append("\n")
|
||||
.append("msgId : ").append(msgId)
|
||||
.append("\n")
|
||||
.append("msgMaxSize : ").append(msgMaxSize)
|
||||
.append("\n")
|
||||
.append("msgFlags : ").append(msgFlags)
|
||||
.append("\n")
|
||||
.append("msgSecurityModel : ").append(msgSecurityModel)
|
||||
.append("\n")
|
||||
.append("contextEngineId : ").append(contextEngineId == null ? null :
|
||||
SnmpEngineId.createEngineId(contextEngineId))
|
||||
.append("\n")
|
||||
.append("contextName : ").append(contextName)
|
||||
.append("\n")
|
||||
.append("data : ").append(data)
|
||||
.append("\n")
|
||||
.append("dat len : ").append((data == null) ? 0 : data.length)
|
||||
.append("\n")
|
||||
.append("encryptedPdu : ").append(encryptedPdu)
|
||||
.append("\n");
|
||||
SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
|
||||
"decodeMessage", strb.toString());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the associated request Id.
|
||||
* @param data The flat message.
|
||||
* @return The request Id.
|
||||
*/
|
||||
public int getRequestId(byte[] data) throws SnmpStatusException {
|
||||
BerDecoder bdec = null;
|
||||
int msgId = 0;
|
||||
try {
|
||||
bdec = new BerDecoder(data);
|
||||
bdec.openSequence();
|
||||
bdec.fetchInteger();
|
||||
bdec.openSequence();
|
||||
msgId = bdec.fetchInteger();
|
||||
}catch(BerException x) {
|
||||
throw new SnmpStatusException("Invalid encoding") ;
|
||||
}
|
||||
try {
|
||||
bdec.closeSequence();
|
||||
}
|
||||
catch(BerException x) {
|
||||
}
|
||||
|
||||
return msgId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes this message with the specified <CODE>pdu</CODE>.
|
||||
* <P>
|
||||
* This method initializes the data field with an array of
|
||||
* <CODE>maxDataLength</CODE> bytes. It encodes the <CODE>pdu</CODE>.
|
||||
* The resulting encoding is stored in the data field
|
||||
* and the length of the encoding is stored in <CODE>dataLength</CODE>.
|
||||
* <p>
|
||||
* If the encoding length exceeds <CODE>maxDataLength</CODE>,
|
||||
* the method throws an exception.
|
||||
*
|
||||
* @param p The PDU to be encoded.
|
||||
* @param maxDataLength The maximum length permitted for the data field.
|
||||
*
|
||||
* @exception SnmpStatusException If the specified <CODE>pdu</CODE>
|
||||
* is not valid.
|
||||
* @exception SnmpTooBigException If the resulting encoding does not fit
|
||||
* into <CODE>maxDataLength</CODE> bytes.
|
||||
* @exception ArrayIndexOutOfBoundsException If the encoding exceeds
|
||||
* <CODE>maxDataLength</CODE>.
|
||||
*/
|
||||
public void encodeSnmpPdu(SnmpPdu p,
|
||||
int maxDataLength)
|
||||
throws SnmpStatusException, SnmpTooBigException {
|
||||
|
||||
SnmpScopedPduPacket pdu = (SnmpScopedPduPacket) p;
|
||||
|
||||
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
|
||||
final StringBuilder strb = new StringBuilder()
|
||||
.append("PDU to marshall: \n")
|
||||
.append("security parameters : ").append(pdu.securityParameters)
|
||||
.append("\n")
|
||||
.append("type : ").append(pdu.type)
|
||||
.append("\n")
|
||||
.append("version : ").append(pdu.version)
|
||||
.append("\n")
|
||||
.append("requestId : ").append(pdu.requestId)
|
||||
.append("\n")
|
||||
.append("msgId : ").append(pdu.msgId)
|
||||
.append("\n")
|
||||
.append("msgMaxSize : ").append(pdu.msgMaxSize)
|
||||
.append("\n")
|
||||
.append("msgFlags : ").append(pdu.msgFlags)
|
||||
.append("\n")
|
||||
.append("msgSecurityModel : ").append(pdu.msgSecurityModel)
|
||||
.append("\n")
|
||||
.append("contextEngineId : ").append(pdu.contextEngineId)
|
||||
.append("\n")
|
||||
.append("contextName : ").append(pdu.contextName)
|
||||
.append("\n");
|
||||
SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
|
||||
"encodeSnmpPdu", strb.toString());
|
||||
}
|
||||
|
||||
version = pdu.version;
|
||||
address = pdu.address;
|
||||
port = pdu.port;
|
||||
msgId = pdu.msgId;
|
||||
msgMaxSize = pdu.msgMaxSize;
|
||||
msgFlags = pdu.msgFlags;
|
||||
msgSecurityModel = pdu.msgSecurityModel;
|
||||
|
||||
contextEngineId = pdu.contextEngineId;
|
||||
contextName = pdu.contextName;
|
||||
|
||||
securityParameters = pdu.securityParameters;
|
||||
|
||||
//
|
||||
// Allocate the array to receive the encoding.
|
||||
//
|
||||
data = new byte[maxDataLength];
|
||||
|
||||
//
|
||||
// Encode the pdu
|
||||
// Reminder: BerEncoder does backward encoding !
|
||||
//
|
||||
|
||||
try {
|
||||
BerEncoder benc = new BerEncoder(data) ;
|
||||
benc.openSequence() ;
|
||||
encodeVarBindList(benc, pdu.varBindList) ;
|
||||
|
||||
switch(pdu.type) {
|
||||
|
||||
case pduGetRequestPdu :
|
||||
case pduGetNextRequestPdu :
|
||||
case pduInformRequestPdu :
|
||||
case pduGetResponsePdu :
|
||||
case pduSetRequestPdu :
|
||||
case pduV2TrapPdu :
|
||||
case pduReportPdu :
|
||||
SnmpPduRequestType reqPdu = (SnmpPduRequestType) pdu;
|
||||
benc.putInteger(reqPdu.getErrorIndex());
|
||||
benc.putInteger(reqPdu.getErrorStatus());
|
||||
benc.putInteger(pdu.requestId);
|
||||
break;
|
||||
|
||||
case pduGetBulkRequestPdu :
|
||||
SnmpPduBulkType bulkPdu = (SnmpPduBulkType) pdu;
|
||||
benc.putInteger(bulkPdu.getMaxRepetitions());
|
||||
benc.putInteger(bulkPdu.getNonRepeaters());
|
||||
benc.putInteger(pdu.requestId);
|
||||
break ;
|
||||
|
||||
default:
|
||||
throw new SnmpStatusException("Invalid pdu type " + String.valueOf(pdu.type)) ;
|
||||
}
|
||||
benc.closeSequence(pdu.type) ;
|
||||
dataLength = benc.trim() ;
|
||||
}
|
||||
catch(ArrayIndexOutOfBoundsException x) {
|
||||
throw new SnmpTooBigException() ;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Gets the PDU encoded in this message.
|
||||
* <P>
|
||||
* This method decodes the data field and returns the resulting PDU.
|
||||
*
|
||||
* @return The resulting PDU.
|
||||
* @exception SnmpStatusException If the encoding is not valid.
|
||||
*/
|
||||
|
||||
public SnmpPdu decodeSnmpPdu()
|
||||
throws SnmpStatusException {
|
||||
|
||||
SnmpScopedPduPacket pdu = null;
|
||||
|
||||
BerDecoder bdec = new BerDecoder(data) ;
|
||||
try {
|
||||
int type = bdec.getTag() ;
|
||||
bdec.openSequence(type) ;
|
||||
switch(type) {
|
||||
|
||||
case pduGetRequestPdu :
|
||||
case pduGetNextRequestPdu :
|
||||
case pduInformRequestPdu :
|
||||
case pduGetResponsePdu :
|
||||
case pduSetRequestPdu :
|
||||
case pduV2TrapPdu :
|
||||
case pduReportPdu :
|
||||
SnmpScopedPduRequest reqPdu = new SnmpScopedPduRequest() ;
|
||||
reqPdu.requestId = bdec.fetchInteger() ;
|
||||
reqPdu.setErrorStatus(bdec.fetchInteger());
|
||||
reqPdu.setErrorIndex(bdec.fetchInteger());
|
||||
pdu = reqPdu ;
|
||||
break ;
|
||||
|
||||
case pduGetBulkRequestPdu :
|
||||
SnmpScopedPduBulk bulkPdu = new SnmpScopedPduBulk() ;
|
||||
bulkPdu.requestId = bdec.fetchInteger() ;
|
||||
bulkPdu.setNonRepeaters(bdec.fetchInteger());
|
||||
bulkPdu.setMaxRepetitions(bdec.fetchInteger());
|
||||
pdu = bulkPdu ;
|
||||
break ;
|
||||
default:
|
||||
throw new SnmpStatusException(snmpRspWrongEncoding) ;
|
||||
}
|
||||
pdu.type = type;
|
||||
pdu.varBindList = decodeVarBindList(bdec);
|
||||
bdec.closeSequence() ;
|
||||
} catch(BerException e) {
|
||||
if (SNMP_LOGGER.isLoggable(Level.FINEST)) {
|
||||
SNMP_LOGGER.logp(Level.FINEST, SnmpV3Message.class.getName(),
|
||||
"decodeSnmpPdu", "BerException", e);
|
||||
}
|
||||
throw new SnmpStatusException(snmpRspWrongEncoding);
|
||||
}
|
||||
|
||||
//
|
||||
// The easy work.
|
||||
//
|
||||
pdu.address = address;
|
||||
pdu.port = port;
|
||||
pdu.msgFlags = msgFlags;
|
||||
pdu.version = version;
|
||||
pdu.msgId = msgId;
|
||||
pdu.msgMaxSize = msgMaxSize;
|
||||
pdu.msgSecurityModel = msgSecurityModel;
|
||||
pdu.contextEngineId = contextEngineId;
|
||||
pdu.contextName = contextName;
|
||||
|
||||
pdu.securityParameters = securityParameters;
|
||||
|
||||
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
|
||||
final StringBuilder strb = new StringBuilder()
|
||||
.append("Unmarshalled PDU : \n")
|
||||
.append("type : ").append(pdu.type)
|
||||
.append("\n")
|
||||
.append("version : ").append(pdu.version)
|
||||
.append("\n")
|
||||
.append("requestId : ").append(pdu.requestId)
|
||||
.append("\n")
|
||||
.append("msgId : ").append(pdu.msgId)
|
||||
.append("\n")
|
||||
.append("msgMaxSize : ").append(pdu.msgMaxSize)
|
||||
.append("\n")
|
||||
.append("msgFlags : ").append(pdu.msgFlags)
|
||||
.append("\n")
|
||||
.append("msgSecurityModel : ").append(pdu.msgSecurityModel)
|
||||
.append("\n")
|
||||
.append("contextEngineId : ").append(pdu.contextEngineId)
|
||||
.append("\n")
|
||||
.append("contextName : ").append(pdu.contextName)
|
||||
.append("\n");
|
||||
SNMP_LOGGER.logp(Level.FINER, SnmpV3Message.class.getName(),
|
||||
"decodeSnmpPdu", strb.toString());
|
||||
}
|
||||
return pdu ;
|
||||
}
|
||||
|
||||
/**
|
||||
* Dumps this message in a string.
|
||||
*
|
||||
* @return The string containing the dump.
|
||||
*/
|
||||
public String printMessage() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append("msgId : " + msgId + "\n");
|
||||
sb.append("msgMaxSize : " + msgMaxSize + "\n");
|
||||
sb.append("msgFlags : " + msgFlags + "\n");
|
||||
sb.append("msgSecurityModel : " + msgSecurityModel + "\n");
|
||||
|
||||
if (contextEngineId == null) {
|
||||
sb.append("contextEngineId : null");
|
||||
}
|
||||
else {
|
||||
sb.append("contextEngineId : {\n");
|
||||
sb.append(dumpHexBuffer(contextEngineId,
|
||||
0,
|
||||
contextEngineId.length));
|
||||
sb.append("\n}\n");
|
||||
}
|
||||
|
||||
if (contextName == null) {
|
||||
sb.append("contextName : null");
|
||||
}
|
||||
else {
|
||||
sb.append("contextName : {\n");
|
||||
sb.append(dumpHexBuffer(contextName,
|
||||
0,
|
||||
contextName.length));
|
||||
sb.append("\n}\n");
|
||||
}
|
||||
return sb.append(super.printMessage()).toString();
|
||||
}
|
||||
|
||||
}
|
||||
96
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpValue.java
Normal file
96
jdkSrc/jdk8/com/sun/jmx/snmp/SnmpValue.java
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Is an abstract representation of an SNMP Value.
|
||||
* All classes provided for dealing with SNMP types should derive from this
|
||||
* class.
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
|
||||
public abstract class SnmpValue implements Cloneable, Serializable, SnmpDataTypeEnums {
|
||||
|
||||
/**
|
||||
* Returns a <CODE>String</CODE> form containing ASN.1 tagging information.
|
||||
* @return The <CODE>String</CODE> form.
|
||||
*/
|
||||
public String toAsn1String() {
|
||||
return "[" + getTypeName() + "] " + toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the value encoded as an OID.
|
||||
* The method is particularly useful when dealing with indexed table made of
|
||||
* several SNMP variables.
|
||||
* @return The value encoded as an OID.
|
||||
*/
|
||||
public abstract SnmpOid toOid() ;
|
||||
|
||||
/**
|
||||
* Returns a textual description of the object.
|
||||
* @return ASN.1 textual description.
|
||||
*/
|
||||
public abstract String getTypeName() ;
|
||||
|
||||
/**
|
||||
* Same as clone, but you cannot perform cloning using this object because
|
||||
* clone is protected. This method should call <CODE>clone()</CODE>.
|
||||
* @return The <CODE>SnmpValue</CODE> clone.
|
||||
*/
|
||||
public abstract SnmpValue duplicate() ;
|
||||
|
||||
/**
|
||||
* This method returns <CODE>false</CODE> by default and is redefined
|
||||
* in the {@link com.sun.jmx.snmp.SnmpNull} class.
|
||||
*/
|
||||
public boolean isNoSuchObjectValue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns <CODE>false</CODE> by default and is redefined
|
||||
* in the {@link com.sun.jmx.snmp.SnmpNull} class.
|
||||
*/
|
||||
public boolean isNoSuchInstanceValue() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method returns <CODE>false</CODE> by default and is redefined
|
||||
* in the {@link com.sun.jmx.snmp.SnmpNull} class.
|
||||
*/
|
||||
public boolean isEndOfMibViewValue() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
326
jdkSrc/jdk8/com/sun/jmx/snmp/ThreadContext.java
Normal file
326
jdkSrc/jdk8/com/sun/jmx/snmp/ThreadContext.java
Normal file
@@ -0,0 +1,326 @@
|
||||
/*
|
||||
* Copyright (c) 2000, 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;
|
||||
|
||||
import java.util.Stack;
|
||||
import java.util.EmptyStackException;
|
||||
|
||||
/**
|
||||
* <p><b>Warning: The interface of this class is subject to change.
|
||||
* Use at your own risk.</b></p>
|
||||
*
|
||||
* <p>This class associates a context with each thread that
|
||||
* references it. The context is a set of mappings between Strings
|
||||
* and Objects. It is managed as a stack, typically with code like
|
||||
* this:</p>
|
||||
*
|
||||
* <pre>
|
||||
* ThreadContext oldContext = ThreadContext.push(myKey, myObject);
|
||||
* // plus possibly further calls to ThreadContext.push...
|
||||
* try {
|
||||
* doSomeOperation();
|
||||
* } finally {
|
||||
* ThreadContext.restore(oldContext);
|
||||
* }
|
||||
* </pre>
|
||||
*
|
||||
* <p>The <code>try</code>...<code>finally</code> block ensures that
|
||||
* the <code>restore</code> is done even if
|
||||
* <code>doSomeOperation</code> terminates abnormally (with an
|
||||
* exception).</p>
|
||||
*
|
||||
* <p>A thread can consult its own context using
|
||||
* <code>ThreadContext.get(myKey)</code>. The result is the
|
||||
* value that was most recently pushed with the given key.</p>
|
||||
*
|
||||
* <p>A thread cannot read or modify the context of another thread.</p>
|
||||
*
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
public class ThreadContext implements Cloneable {
|
||||
|
||||
/* The context of a thread is stored as a linked list. At the
|
||||
head of the list is the value returned by localContext.get().
|
||||
At the tail of the list is a sentinel ThreadContext value with
|
||||
"previous" and "key" both null. There is a different sentinel
|
||||
object for each thread.
|
||||
|
||||
Because a null key indicates the sentinel, we reject attempts to
|
||||
push context entries with a null key.
|
||||
|
||||
The reason for using a sentinel rather than just terminating
|
||||
the list with a null reference is to protect against incorrect
|
||||
or even malicious code. If you have a reference to the
|
||||
sentinel value, you can erase the context stack. Only the
|
||||
caller of the first "push" that put something on the stack can
|
||||
get such a reference, so if that caller does not give this
|
||||
reference away, no one else can erase the stack.
|
||||
|
||||
If the restore method took a null reference to mean an empty
|
||||
stack, anyone could erase the stack, since anyone can make a
|
||||
null reference.
|
||||
|
||||
When the stack is empty, we discard the sentinel object and
|
||||
have localContext.get() return null. Then we recreate the
|
||||
sentinel object on the first subsequent push.
|
||||
|
||||
ThreadContext objects are immutable. As a consequence, you can
|
||||
give a ThreadContext object to setInitialContext that is no
|
||||
longer current. But the interface says this can be rejected,
|
||||
in case we remove immutability later. */
|
||||
|
||||
/* We have to comment out "final" here because of a bug in the JDK1.1
|
||||
compiler. Uncomment it when we discard 1.1 compatibility. */
|
||||
private /*final*/ ThreadContext previous;
|
||||
private /*final*/ String key;
|
||||
private /*final*/ Object value;
|
||||
|
||||
private ThreadContext(ThreadContext previous, String key, Object value) {
|
||||
this.previous = previous;
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Get the Object that was most recently pushed with the given key.</p>
|
||||
*
|
||||
* @param key the key of interest.
|
||||
*
|
||||
* @return the last Object that was pushed (using
|
||||
* <code>push</code>) with that key and not subsequently canceled
|
||||
* by a <code>restore</code>; or null if there is no such object.
|
||||
* A null return value may also indicate that the last Object
|
||||
* pushed was the value <code>null</code>. Use the
|
||||
* <code>contains</code> method to distinguish this case from the
|
||||
* case where there is no Object.
|
||||
*
|
||||
* @exception IllegalArgumentException if <code>key</code> is null.
|
||||
*/
|
||||
public static Object get(String key) throws IllegalArgumentException {
|
||||
ThreadContext context = contextContaining(key);
|
||||
if (context == null)
|
||||
return null;
|
||||
else
|
||||
return context.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Check whether a value with the given key exists in the stack.
|
||||
* This means that the <code>push</code> method was called with
|
||||
* this key and it was not cancelled by a subsequent
|
||||
* <code>restore</code>. This method is useful when the
|
||||
* <code>get</code> method returns null, to distinguish between
|
||||
* the case where the key exists in the stack but is associated
|
||||
* with a null value, and the case where the key does not exist in
|
||||
* the stack.</p>
|
||||
*
|
||||
* @return true if the key exists in the stack.
|
||||
*
|
||||
* @exception IllegalArgumentException if <code>key</code> is null.
|
||||
*/
|
||||
public static boolean contains(String key)
|
||||
throws IllegalArgumentException {
|
||||
return (contextContaining(key) != null);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Find the ThreadContext in the stack that contains the given key,
|
||||
* or return null if there is none.</p>
|
||||
*
|
||||
* @exception IllegalArgumentException if <code>key</code> is null.
|
||||
*/
|
||||
private static ThreadContext contextContaining(String key)
|
||||
throws IllegalArgumentException {
|
||||
if (key == null)
|
||||
throw new IllegalArgumentException("null key");
|
||||
for (ThreadContext context = getContext();
|
||||
context != null;
|
||||
context = context.previous) {
|
||||
if (key.equals(context.key))
|
||||
return context;
|
||||
/* Note that "context.key" may be null if "context" is the
|
||||
sentinel, so don't write "if (context.key.equals(key))"! */
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * Change the value that was most recently associated with the given key
|
||||
// * in a <code>push</code> operation not cancelled by a subsequent
|
||||
// * <code>restore</code>. If there is no such association, nothing happens
|
||||
// * and the return value is null.
|
||||
// *
|
||||
// * @param key the key of interest.
|
||||
// * @param value the new value to associate with that key.
|
||||
// *
|
||||
// * @return the value that was previously associated with the key, or null
|
||||
// * if the key does not exist in the stack.
|
||||
// *
|
||||
// * @exception IllegalArgumentException if <code>key</code> is null.
|
||||
// */
|
||||
// public static Object set(String key, Object value)
|
||||
// throws IllegalArgumentException {
|
||||
// ThreadContext context = contextContaining(key);
|
||||
// if (context == null)
|
||||
// return null;
|
||||
// Object old = context.value;
|
||||
// context.value = value;
|
||||
// return old;
|
||||
// }
|
||||
|
||||
/**
|
||||
* <p>Push an object on the context stack with the given key.
|
||||
* This operation can subsequently be undone by calling
|
||||
* <code>restore</code> with the ThreadContext value returned
|
||||
* here.</p>
|
||||
*
|
||||
* @param key the key that will be used to find the object while it is
|
||||
* on the stack.
|
||||
* @param value the value to be associated with that key. It may be null.
|
||||
*
|
||||
* @return a ThreadContext that can be given to <code>restore</code> to
|
||||
* restore the stack to its state before the <code>push</code>.
|
||||
*
|
||||
* @exception IllegalArgumentException if <code>key</code> is null.
|
||||
*/
|
||||
public static ThreadContext push(String key, Object value)
|
||||
throws IllegalArgumentException {
|
||||
if (key == null)
|
||||
throw new IllegalArgumentException("null key");
|
||||
|
||||
ThreadContext oldContext = getContext();
|
||||
if (oldContext == null)
|
||||
oldContext = new ThreadContext(null, null, null); // make sentinel
|
||||
ThreadContext newContext = new ThreadContext(oldContext, key, value);
|
||||
setContext(newContext);
|
||||
return oldContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Return an object that can later be supplied to <code>restore</code>
|
||||
* to restore the context stack to its current state. The object can
|
||||
* also be given to <code>setInitialContext</code>.</p>
|
||||
*
|
||||
* @return a ThreadContext that represents the current context stack.
|
||||
*/
|
||||
public static ThreadContext getThreadContext() {
|
||||
return getContext();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Restore the context stack to an earlier state. This typically
|
||||
* undoes the effect of one or more <code>push</code> calls.</p>
|
||||
*
|
||||
* @param oldContext the state to return. This is usually the return
|
||||
* value of an earlier <code>push</code> operation.
|
||||
*
|
||||
* @exception NullPointerException if <code>oldContext</code> is null.
|
||||
* @exception IllegalArgumentException if <code>oldContext</code>
|
||||
* does not represent a context from this thread, or if that
|
||||
* context was undone by an earlier <code>restore</code>.
|
||||
*/
|
||||
public static void restore(ThreadContext oldContext)
|
||||
throws NullPointerException, IllegalArgumentException {
|
||||
/* The following test is not strictly necessary in the code as it
|
||||
stands today, since the reference to "oldContext.key" would
|
||||
generate a NullPointerException anyway. But if someone
|
||||
didn't notice that during subsequent changes, they could
|
||||
accidentally permit restore(null) with the semantics of
|
||||
trashing the context stack. */
|
||||
if (oldContext == null)
|
||||
throw new NullPointerException();
|
||||
|
||||
/* Check that the restored context is in the stack. */
|
||||
for (ThreadContext context = getContext();
|
||||
context != oldContext;
|
||||
context = context.previous) {
|
||||
if (context == null) {
|
||||
throw new IllegalArgumentException("Restored context is not " +
|
||||
"contained in current " +
|
||||
"context");
|
||||
}
|
||||
}
|
||||
|
||||
/* Discard the sentinel if the stack is empty. This means that it
|
||||
is an error to call "restore" a second time with the
|
||||
ThreadContext value that means an empty stack. That's why we
|
||||
don't say that it is all right to restore the stack to the
|
||||
state it was already in. */
|
||||
if (oldContext.key == null)
|
||||
oldContext = null;
|
||||
|
||||
setContext(oldContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Set the initial context of the calling thread to a context obtained
|
||||
* from another thread. After this call, the calling thread will see
|
||||
* the same results from the <code>get</code> method as the thread
|
||||
* from which the <code>context</code> argument was obtained, at the
|
||||
* time it was obtained.</p>
|
||||
*
|
||||
* <p>The <code>context</code> argument must be the result of an earlier
|
||||
* <code>push</code> or <code>getThreadContext</code> call. It is an
|
||||
* error (which may or may not be detected) if this context has been
|
||||
* undone by a <code>restore</code>.</p>
|
||||
*
|
||||
* <p>The context stack of the calling thread must be empty before this
|
||||
* call, i.e., there must not have been a <code>push</code> not undone
|
||||
* by a subsequent <code>restore</code>.</p>
|
||||
*
|
||||
* @exception IllegalArgumentException if the context stack was
|
||||
* not empty before the call. An implementation may also throw this
|
||||
* exception if <code>context</code> is no longer current in the
|
||||
* thread from which it was obtained.
|
||||
*/
|
||||
/* We rely on the fact that ThreadContext objects are immutable.
|
||||
This means that we don't have to check that the "context"
|
||||
argument is valid. It necessarily represents the head of a
|
||||
valid chain of ThreadContext objects, even if the thread from
|
||||
which it was obtained has subsequently been set to a point
|
||||
later in that chain using "restore". */
|
||||
public void setInitialContext(ThreadContext context)
|
||||
throws IllegalArgumentException {
|
||||
/* The following test assumes that we discard sentinels when the
|
||||
stack is empty. */
|
||||
if (getContext() != null)
|
||||
throw new IllegalArgumentException("previous context not empty");
|
||||
setContext(context);
|
||||
}
|
||||
|
||||
private static ThreadContext getContext() {
|
||||
return localContext.get();
|
||||
}
|
||||
|
||||
private static void setContext(ThreadContext context) {
|
||||
localContext.set(context);
|
||||
}
|
||||
|
||||
private static ThreadLocal<ThreadContext> localContext =
|
||||
new ThreadLocal<ThreadContext>();
|
||||
}
|
||||
97
jdkSrc/jdk8/com/sun/jmx/snmp/UserAcl.java
Normal file
97
jdkSrc/jdk8/com/sun/jmx/snmp/UserAcl.java
Normal file
@@ -0,0 +1,97 @@
|
||||
/*
|
||||
* Copyright (c) 2001, 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.
|
||||
*/
|
||||
|
||||
package com.sun.jmx.snmp;
|
||||
|
||||
|
||||
// java import
|
||||
//
|
||||
import java.util.Enumeration;
|
||||
import java.net.InetAddress;
|
||||
|
||||
/**
|
||||
* Defines the user based ACL used by the SNMP protocol adaptor.
|
||||
* <p>
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public interface UserAcl {
|
||||
|
||||
/**
|
||||
* Returns the name of the ACL.
|
||||
*
|
||||
* @return The name of the ACL.
|
||||
*/
|
||||
public String getName();
|
||||
|
||||
/**
|
||||
* Checks whether or not the specified user has <CODE>READ</CODE> access.
|
||||
*
|
||||
* @param user The user name to check.
|
||||
*
|
||||
* @return <CODE>true</CODE> if the host has read permission, <CODE>false</CODE> otherwise.
|
||||
*/
|
||||
public boolean checkReadPermission(String user);
|
||||
|
||||
/**
|
||||
* Checks whether or not the specified user and context name have <CODE>READ</CODE> access.
|
||||
*
|
||||
* @param user The user name to check.
|
||||
* @param contextName The context name associated with the user.
|
||||
* @param securityLevel The request security level.
|
||||
* @return <CODE>true</CODE> if the pair (user, context) has read permission, <CODE>false</CODE> otherwise.
|
||||
*/
|
||||
public boolean checkReadPermission(String user, String contextName, int securityLevel);
|
||||
|
||||
/**
|
||||
* Checks whether or not a context name is defined.
|
||||
*
|
||||
* @param contextName The context name to check.
|
||||
*
|
||||
* @return <CODE>true</CODE> if the context is known, <CODE>false</CODE> otherwise.
|
||||
*/
|
||||
public boolean checkContextName(String contextName);
|
||||
|
||||
/**
|
||||
* Checks whether or not the specified user has <CODE>WRITE</CODE> access.
|
||||
*
|
||||
* @param user The user to check.
|
||||
*
|
||||
* @return <CODE>true</CODE> if the user has write permission, <CODE>false</CODE> otherwise.
|
||||
*/
|
||||
public boolean checkWritePermission(String user);
|
||||
|
||||
/**
|
||||
* Checks whether or not the specified user and context name have <CODE>WRITE</CODE> access.
|
||||
*
|
||||
* @param user The user name to check.
|
||||
* @param contextName The context name associated with the user.
|
||||
* @param securityLevel The request security level.
|
||||
* @return <CODE>true</CODE> if the pair (user, context) has write permission, <CODE>false</CODE> otherwise.
|
||||
*/
|
||||
public boolean checkWritePermission(String user, String contextName, int securityLevel);
|
||||
}
|
||||
151
jdkSrc/jdk8/com/sun/jmx/snmp/agent/AcmChecker.java
Normal file
151
jdkSrc/jdk8/com/sun/jmx/snmp/agent/AcmChecker.java
Normal file
@@ -0,0 +1,151 @@
|
||||
/*
|
||||
* 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.agent;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Enumeration;
|
||||
import java.util.logging.Level;
|
||||
import java.util.Vector;
|
||||
|
||||
import javax.management.ObjectName;
|
||||
import javax.management.MBeanServer;
|
||||
import javax.management.MalformedObjectNameException;
|
||||
import javax.management.InstanceAlreadyExistsException;
|
||||
import javax.management.MBeanRegistrationException;
|
||||
import javax.management.NotCompliantMBeanException;
|
||||
|
||||
import static com.sun.jmx.defaults.JmxProperties.SNMP_ADAPTOR_LOGGER;
|
||||
import com.sun.jmx.snmp.SnmpOid;
|
||||
import com.sun.jmx.snmp.SnmpVarBind;
|
||||
import com.sun.jmx.snmp.SnmpDefinitions;
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpEngine;
|
||||
import com.sun.jmx.snmp.SnmpUnknownModelException;
|
||||
import com.sun.jmx.snmp.internal.SnmpAccessControlModel;
|
||||
import com.sun.jmx.snmp.internal.SnmpEngineImpl;
|
||||
|
||||
/**
|
||||
* Oid Checker makes use of ACM to check each OID during the getnext process.
|
||||
*/
|
||||
class AcmChecker {
|
||||
|
||||
|
||||
SnmpAccessControlModel model = null;
|
||||
String principal = null;
|
||||
int securityLevel = -1;
|
||||
int version = -1;
|
||||
int pduType = -1;
|
||||
int securityModel = -1;
|
||||
byte[] contextName = null;
|
||||
SnmpEngineImpl engine = null;
|
||||
LongList l = null;
|
||||
AcmChecker(SnmpMibRequest req) {
|
||||
engine = (SnmpEngineImpl) req.getEngine();
|
||||
//We are in V3 architecture, ACM is in the picture.
|
||||
if(engine != null) {
|
||||
if(engine.isCheckOidActivated()) {
|
||||
try {
|
||||
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
|
||||
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
|
||||
SnmpMib.class.getName(),
|
||||
"AcmChecker(SnmpMibRequest)",
|
||||
"SNMP V3 Access Control to be done");
|
||||
}
|
||||
model = (SnmpAccessControlModel)
|
||||
engine.getAccessControlSubSystem().
|
||||
getModel(SnmpDefinitions.snmpVersionThree);
|
||||
principal = req.getPrincipal();
|
||||
securityLevel = req.getSecurityLevel();
|
||||
pduType = req.getPdu().type;
|
||||
version = req.getRequestPduVersion();
|
||||
securityModel = req.getSecurityModel();
|
||||
contextName = req.getAccessContextName();
|
||||
l = new LongList();
|
||||
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
|
||||
final StringBuilder strb = new StringBuilder()
|
||||
.append("Will check oid for : principal : ")
|
||||
.append(principal)
|
||||
.append("; securityLevel : ").append(securityLevel)
|
||||
.append("; pduType : ").append(pduType)
|
||||
.append("; version : ").append(version)
|
||||
.append("; securityModel : ").append(securityModel)
|
||||
.append("; contextName : ").append(contextName);
|
||||
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
|
||||
SnmpMib.class.getName(),
|
||||
"AcmChecker(SnmpMibRequest)", strb.toString());
|
||||
}
|
||||
|
||||
}catch(SnmpUnknownModelException e) {
|
||||
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
|
||||
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST,
|
||||
SnmpMib.class.getName(),
|
||||
"AcmChecker(SnmpMibRequest)",
|
||||
"Unknown Model, no ACM check.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void add(int index, long arc) {
|
||||
if(model != null)
|
||||
l.add(index, arc);
|
||||
}
|
||||
|
||||
void remove(int index) {
|
||||
if(model != null)
|
||||
l.remove(index);
|
||||
}
|
||||
|
||||
void add(final int at,final long[] src, final int from,
|
||||
final int count) {
|
||||
if(model != null)
|
||||
l.add(at,src,from,count);
|
||||
}
|
||||
|
||||
void remove(final int from, final int count) {
|
||||
if(model != null)
|
||||
l.remove(from,count);
|
||||
}
|
||||
|
||||
void checkCurrentOid() throws SnmpStatusException {
|
||||
if(model != null) {
|
||||
SnmpOid oid = new SnmpOid(l.toArray());
|
||||
if (SNMP_ADAPTOR_LOGGER.isLoggable(Level.FINEST)) {
|
||||
SNMP_ADAPTOR_LOGGER.logp(Level.FINEST, SnmpMib.class.getName(),
|
||||
"checkCurrentOid", "Checking access for : " + oid);
|
||||
}
|
||||
model.checkAccess(version,
|
||||
principal,
|
||||
securityLevel,
|
||||
pduType,
|
||||
securityModel,
|
||||
contextName,
|
||||
oid);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user