feat(jdk8): move files to new folder to avoid resources compiled.
This commit is contained in:
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpOid;
|
||||
import com.sun.jmx.snmp.SnmpPdu;
|
||||
/**
|
||||
* Access Control Model interface. Every access control model must implement this interface in order to be integrated in the engine based framework.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpAccessControlModel extends SnmpModel {
|
||||
/**
|
||||
* Method called by the dispatcher in order to control the access at an <CODE>SnmpOid</CODE> Level. If access is not allowed, an <CODE>SnmpStatusException</CODE> is thrown.
|
||||
* This method is called after the <CODE>checkPduAccess</CODE> pdu based method.
|
||||
* @param version The SNMP protocol version number.
|
||||
* @param principal The request principal.
|
||||
* @param securityLevel The request security level as defined in <CODE>SnmpEngine</CODE>.
|
||||
* @param pduType The pdu type (get, set, ...).
|
||||
* @param securityModel The security model ID.
|
||||
* @param contextName The access control context name.
|
||||
* @param oid The OID to check.
|
||||
*/
|
||||
public void checkAccess(int version,
|
||||
String principal,
|
||||
int securityLevel,
|
||||
int pduType,
|
||||
int securityModel,
|
||||
byte[] contextName,
|
||||
SnmpOid oid)
|
||||
throws SnmpStatusException;
|
||||
/**
|
||||
* Method called by the dispatcher in order to control the access at an SNMP pdu Level. If access is not allowed, an <CODE>SnmpStatusException</CODE> is thrown. In case of exception, the access control is aborted. OIDs are not checked.
|
||||
* This method should be called prior to the <CODE>checkAccess</CODE> OID based method.
|
||||
* @param version The SNMP protocol version number.
|
||||
* @param principal The request principal.
|
||||
* @param securityLevel The request security level as defined in <CODE>SnmpEngine</CODE>.
|
||||
* @param pduType The pdu type (get, set, ...).
|
||||
* @param securityModel The security model ID.
|
||||
* @param contextName The access control context name.
|
||||
* @param pdu The pdu to check.
|
||||
*/
|
||||
public void checkPduAccess(int version,
|
||||
String principal,
|
||||
int securityLevel,
|
||||
int pduType,
|
||||
int securityModel,
|
||||
byte[] contextName,
|
||||
SnmpPdu pdu)
|
||||
throws SnmpStatusException;
|
||||
|
||||
/**
|
||||
* Enable SNMP V1 and V2 set requests. Be aware that can lead to a security hole in a context of SNMP V3 management. By default SNMP V1 and V2 set requests are not authorized.
|
||||
* @return boolean True the activation suceeded.
|
||||
*/
|
||||
public boolean enableSnmpV1V2SetRequest();
|
||||
/**
|
||||
* Disable SNMP V1 and V2 set requests. By default SNMP V1 and V2 set requests are not authorized.
|
||||
* @return boolean True the deactivation suceeded.
|
||||
*/
|
||||
public boolean disableSnmpV1V2SetRequest();
|
||||
|
||||
/**
|
||||
* The SNMP V1 and V2 set requests authorization status. By default SNMP V1 and V2 set requests are not authorized.
|
||||
* @return boolean True SNMP V1 and V2 requests are authorized.
|
||||
*/
|
||||
public boolean isSnmpV1V2SetRequestAuthorized();
|
||||
}
|
||||
@@ -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.internal;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpOid;
|
||||
import com.sun.jmx.snmp.SnmpPdu;
|
||||
import com.sun.jmx.snmp.SnmpUnknownAccContrModelException;
|
||||
/**
|
||||
* Access Control sub system interface. To allow engine integration, an Access Control sub system must implement this interface.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpAccessControlSubSystem extends SnmpSubSystem {
|
||||
|
||||
/**
|
||||
* Method called by the dispatcher in order to control the access at an SNMP pdu Level.
|
||||
* <P> This call is routed by the sub system to the target model according to the SNMP protocol version number.</P>
|
||||
* @param version The SNMP protocol version number.
|
||||
* @param principal The request principal.
|
||||
* @param securityLevel The request security level as defined in <CODE>SnmpEngine</CODE>.
|
||||
* @param pduType The pdu type (get, set, ...).
|
||||
* @param securityModel The security model ID.
|
||||
* @param contextName The access control context name.
|
||||
* @param pdu The pdu to check.
|
||||
*/
|
||||
public void checkPduAccess(int version,
|
||||
String principal,
|
||||
int securityLevel,
|
||||
int pduType,
|
||||
int securityModel,
|
||||
byte[] contextName,
|
||||
SnmpPdu pdu) throws SnmpStatusException, SnmpUnknownAccContrModelException;
|
||||
/**
|
||||
* Method called by the dispatcher in order to control the access at an <CODE>SnmpOid</CODE> Level.
|
||||
* This method is called after the <CODE>checkPduAccess</CODE> pdu based method.
|
||||
* <P> This call is routed by the sub system to the target model according to the SNMP protocol version number.</P>
|
||||
* @param version The SNMP protocol version number.
|
||||
* @param principal The request principal.
|
||||
* @param securityLevel The request security level as defined in <CODE>SnmpEngine</CODE>.
|
||||
* @param pduType The pdu type (get, set, ...).
|
||||
* @param securityModel The security model ID.
|
||||
* @param contextName The access control context name.
|
||||
* @param oid The OID to check.
|
||||
*/
|
||||
public void checkAccess(int version,
|
||||
String principal,
|
||||
int securityLevel,
|
||||
int pduType,
|
||||
int securityModel,
|
||||
byte[] contextName,
|
||||
SnmpOid oid) throws SnmpStatusException, SnmpUnknownAccContrModelException;
|
||||
}
|
||||
50
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpDecryptedPdu.java
Normal file
50
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpDecryptedPdu.java
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
/**
|
||||
* Class returned by <CODE>SnmpSecuritySubSystem</CODE> and <CODE>SnmpSecurityModel</CODE>. If privacy is applied, the received pdu must be decrypted. This class contains the field of of a decrypted scoped pdu.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
|
||||
public class SnmpDecryptedPdu {
|
||||
/**
|
||||
* Decrypted pdu data.
|
||||
*/
|
||||
public byte[] data = null;
|
||||
/**
|
||||
* Decrypted pdu data length.
|
||||
*/
|
||||
public int dataLength = 0;
|
||||
/**
|
||||
* Decrypted context name.
|
||||
*/
|
||||
public byte[] contextName = null;
|
||||
/**
|
||||
* Decrypted context engine Id.
|
||||
*/
|
||||
public byte[] contextEngineId = null;
|
||||
}
|
||||
424
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpEngineImpl.java
Normal file
424
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpEngineImpl.java
Normal file
@@ -0,0 +1,424 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.Hashtable;
|
||||
import java.util.logging.Level;
|
||||
import java.io.Serializable;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpDefinitions;
|
||||
import com.sun.jmx.snmp.SnmpEngineId;
|
||||
import com.sun.jmx.snmp.SnmpEngine;
|
||||
import com.sun.jmx.snmp.SnmpUsmKeyHandler;
|
||||
import com.sun.jmx.snmp.SnmpEngineFactory;
|
||||
import com.sun.jmx.snmp.SnmpUnknownModelException;
|
||||
|
||||
import com.sun.jmx.snmp.internal.SnmpTools;
|
||||
import com.sun.jmx.snmp.SnmpBadSecurityLevelException;
|
||||
import static com.sun.jmx.defaults.JmxProperties.SNMP_LOGGER;
|
||||
|
||||
/**
|
||||
* 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 com.sun.jmx.snmp.SnmpEngineId}.
|
||||
* The way the engineId is retrieved is linked to the way the engine is
|
||||
* instantiated. See each <CODE>SnmpEngine</CODE> constructor for more details.
|
||||
* An engine is composed of a set of sub systems
|
||||
* {@link com.sun.jmx.snmp.internal.SnmpSubSystem}. An <CODE>SNMP</CODE>
|
||||
* engine can contain a:
|
||||
*<ul>
|
||||
*<li> Message Processing Sub System :
|
||||
* {@link com.sun.jmx.snmp.internal.SnmpMsgProcessingSubSystem}</li>
|
||||
*<li> Security Sub System :
|
||||
* {@link com.sun.jmx.snmp.internal.SnmpSecuritySubSystem} </li>
|
||||
*<li> Access Control Sub System :
|
||||
* {@link com.sun.jmx.snmp.internal.SnmpAccessControlSubSystem}</li>
|
||||
*</ul>
|
||||
*<P> Each sub system contains a set of models. A model is an implementation
|
||||
* of a particular treatement (eg: the User based Security Model defined in
|
||||
* RFC 2574 is a functional element dealing with authentication and privacy).
|
||||
*</P>
|
||||
* Engine instantiation is based on a factory. This factory, implementing
|
||||
* mandatorily {@link com.sun.jmx.snmp.SnmpEngineFactory SnmpEngineFactory}
|
||||
* is set in the method <CODE>setFactory</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 SnmpEngineImpl implements SnmpEngine, Serializable {
|
||||
private static final long serialVersionUID = -2564301391365614725L;
|
||||
|
||||
/**
|
||||
* Security level. No authentication, no privacy. Value is 0,
|
||||
* as defined in RFC 2572
|
||||
*/
|
||||
public static final int noAuthNoPriv = 0;
|
||||
/**
|
||||
* Security level. Authentication, no privacy. Value is 1, as
|
||||
* defined in RFC 2572
|
||||
*/
|
||||
public static final int authNoPriv = 1;
|
||||
/**
|
||||
* Security level. Authentication, privacy. Value is 3,
|
||||
* as defined in RFC 2572
|
||||
*/
|
||||
public static final int authPriv = 3;
|
||||
/**
|
||||
* Flag that indicates that a report is to be sent. Value is 4, as defined in RFC 2572
|
||||
*/
|
||||
public static final int reportableFlag = 4;
|
||||
|
||||
/**
|
||||
* Mask used to isolate authentication information within a message flag.
|
||||
*/
|
||||
public static final int authMask = 1;
|
||||
/**
|
||||
* Mask used to isolate privacy information within a message flag.
|
||||
*/
|
||||
public static final int privMask = 2;
|
||||
/**
|
||||
* Mask used to isolate authentication and privacy information within a message flag.
|
||||
*/
|
||||
public static final int authPrivMask = 3;
|
||||
|
||||
private SnmpEngineId engineid = null;
|
||||
private SnmpEngineFactory factory = null;
|
||||
private long startTime = 0;
|
||||
|
||||
private int boot = 0;
|
||||
private boolean checkOid = false;
|
||||
|
||||
transient private SnmpUsmKeyHandler usmKeyHandler = null;
|
||||
transient private SnmpLcd lcd = null;
|
||||
|
||||
transient private SnmpSecuritySubSystem securitySub = null;
|
||||
|
||||
transient private SnmpMsgProcessingSubSystem messageSub = null;
|
||||
|
||||
transient private SnmpAccessControlSubSystem accessSub = null;
|
||||
|
||||
/**
|
||||
* Gets the engine time in seconds. This is the time from the last reboot.
|
||||
* @return The time from the last reboot.
|
||||
*/
|
||||
public synchronized int getEngineTime() {
|
||||
//We do the counter wrap in a lazt way. Each time Engine is asked for his time it checks. So if nobody use the Engine, the time can wrap and wrap again without incrementing nb boot. We can imagine that it is irrelevant due to the amount of time needed to wrap.
|
||||
long delta = (System.currentTimeMillis() / 1000) - startTime;
|
||||
if(delta > 0x7FFFFFFF) {
|
||||
//67 years of running. That is a great thing!
|
||||
//Reinitialize startTime.
|
||||
startTime = System.currentTimeMillis() / 1000;
|
||||
|
||||
//Can't do anything with this counter.
|
||||
if(boot != 0x7FFFFFFF)
|
||||
boot += 1;
|
||||
//Store for future use.
|
||||
storeNBBoots(boot);
|
||||
}
|
||||
|
||||
return (int) ((System.currentTimeMillis() / 1000) - startTime);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the engine Id. This is unique for each engine.
|
||||
* @return The engine Id object.
|
||||
*/
|
||||
public SnmpEngineId getEngineId() {
|
||||
return engineid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Usm key handler.
|
||||
* @return The key handler.
|
||||
*/
|
||||
public SnmpUsmKeyHandler getUsmKeyHandler() {
|
||||
return usmKeyHandler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the engine Lcd.
|
||||
* @return The engine Lcd.
|
||||
*/
|
||||
public SnmpLcd getLcd() {
|
||||
return lcd;
|
||||
}
|
||||
/**
|
||||
* 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() {
|
||||
return boot;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. A Local Configuration Datastore is passed to the engine. It will be used to store and retrieve data (engine Id, engine boots).
|
||||
* <P> WARNING : The SnmpEngineId is computed as follow:
|
||||
* <ul>
|
||||
* <li> If an lcd file is provided containing the property "localEngineID", this property value is used.</li>.
|
||||
* <li> If not, if the passed engineID is not null, this engine ID is used.</li>
|
||||
* <li> If not, a time based engineID is computed.</li>
|
||||
* </ul>
|
||||
* This constructor should be called by an <CODE>SnmpEngineFactory</CODE>. Don't call it directly.
|
||||
* @param fact The factory used to instantiate this engine.
|
||||
* @param lcd The local configuration datastore.
|
||||
* @param engineid The engine ID to use. If null is provided, an SnmpEngineId is computed using the current time.
|
||||
* @throws UnknownHostException Exception thrown, if the host name located in the property "localEngineID" is invalid.
|
||||
*/
|
||||
public SnmpEngineImpl(SnmpEngineFactory fact,
|
||||
SnmpLcd lcd,
|
||||
SnmpEngineId engineid) throws UnknownHostException {
|
||||
|
||||
init(lcd, fact);
|
||||
initEngineID();
|
||||
if(this.engineid == null) {
|
||||
if(engineid != null)
|
||||
this.engineid = engineid;
|
||||
else
|
||||
this.engineid = SnmpEngineId.createEngineId();
|
||||
}
|
||||
lcd.storeEngineId(this.engineid);
|
||||
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
|
||||
SNMP_LOGGER.logp(Level.FINER, SnmpEngineImpl.class.getName(),
|
||||
"SnmpEngineImpl(SnmpEngineFactory,SnmpLcd,SnmpEngineId)",
|
||||
"LOCAL ENGINE ID: " + this.engineid);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Constructor. A Local Configuration Datastore is passed to the engine. It will be used to store and retrieve data (engine ID, engine boots).
|
||||
* <P> WARNING : The SnmpEngineId is computed as follow:
|
||||
* <ul>
|
||||
* <li> If an lcd file is provided containing the property "localEngineID", this property value is used.</li>.
|
||||
* <li> If not, the passed address and port are used to compute one.</li>
|
||||
* </ul>
|
||||
* This constructor should be called by an <CODE>SnmpEngineFactory</CODE>. Don't call it directly.
|
||||
* @param fact The factory used to instantiate this engine.
|
||||
* @param lcd The local configuration datastore.
|
||||
* @param port UDP port to use in order to calculate the engine ID.
|
||||
* @param address An IP address used to calculate the engine ID.
|
||||
* @throws UnknownHostException Exception thrown, if the host name located in the property "localEngineID" is invalid.
|
||||
*/
|
||||
public SnmpEngineImpl(SnmpEngineFactory fact,
|
||||
SnmpLcd lcd,
|
||||
InetAddress address,
|
||||
int port) throws UnknownHostException {
|
||||
init(lcd, fact);
|
||||
initEngineID();
|
||||
if(engineid == null)
|
||||
engineid = SnmpEngineId.createEngineId(address, port);
|
||||
|
||||
lcd.storeEngineId(engineid);
|
||||
|
||||
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
|
||||
SNMP_LOGGER.logp(Level.FINER, SnmpEngineImpl.class.getName(),
|
||||
"SnmpEngineImpl(SnmpEngineFactory,SnmpLcd,InetAddress,int)",
|
||||
"LOCAL ENGINE ID: " + engineid + " / " +
|
||||
"LOCAL ENGINE NB BOOTS: " + boot + " / " +
|
||||
"LOCAL ENGINE START TIME: " + getEngineTime());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. A Local Configuration Datastore is passed to the engine. It will be used to store and retrieve data (engine ID, engine boots).
|
||||
* <P> WARNING : The SnmpEngineId is computed as follow:
|
||||
* <ul>
|
||||
* <li> If an lcd file is provided containing the property "localEngineID", this property value is used.</li>.
|
||||
* <li> If not, The passed port is used to compute one.</li>
|
||||
* </ul>
|
||||
* This constructor should be called by an <CODE>SnmpEngineFactory</CODE>. Don't call it directly.
|
||||
* @param fact The factory used to instantiate this engine.
|
||||
* @param lcd The local configuration datastore
|
||||
* @param port UDP port to use in order to calculate the engine ID.
|
||||
* @throws UnknownHostException Exception thrown, if the host name located in the property "localEngineID" is invalid.
|
||||
*/
|
||||
public SnmpEngineImpl(SnmpEngineFactory fact,
|
||||
SnmpLcd lcd,
|
||||
int port) throws UnknownHostException {
|
||||
init(lcd, fact);
|
||||
initEngineID();
|
||||
if(engineid == null)
|
||||
engineid = SnmpEngineId.createEngineId(port);
|
||||
|
||||
lcd.storeEngineId(engineid);
|
||||
|
||||
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
|
||||
SNMP_LOGGER.logp(Level.FINER, SnmpEngineImpl.class.getName(),
|
||||
"SnmpEngineImpl(SnmpEngineFactory,SnmpLcd,int)",
|
||||
"LOCAL ENGINE ID: " + engineid + " / " +
|
||||
"LOCAL ENGINE NB BOOTS: " + boot + " / " +
|
||||
"LOCAL ENGINE START TIME: " + getEngineTime());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. A Local Configuration Datastore is passed to the engine. It will be used to store and retrieve data (engine ID, engine boots).
|
||||
* <P> WARNING : The SnmpEngineId is computed as follow:
|
||||
* <ul>
|
||||
* <li> If an lcd file is provided containing the property "localEngineID", this property value is used.</li>.
|
||||
* <li> If not, a time based engineID is computed.</li>
|
||||
* </ul>
|
||||
* When no configuration nor java property is set for the engine ID value, a unique time based engine ID will be generated.
|
||||
* This constructor should be called by an <CODE>SnmpEngineFactory</CODE>. Don't call it directly.
|
||||
* @param fact The factory used to instantiate this engine.
|
||||
* @param lcd The local configuration datastore.
|
||||
*/
|
||||
public SnmpEngineImpl(SnmpEngineFactory fact,
|
||||
SnmpLcd lcd) throws UnknownHostException {
|
||||
init(lcd, fact);
|
||||
initEngineID();
|
||||
if(engineid == null)
|
||||
engineid = SnmpEngineId.createEngineId();
|
||||
|
||||
lcd.storeEngineId(engineid);
|
||||
|
||||
if (SNMP_LOGGER.isLoggable(Level.FINER)) {
|
||||
SNMP_LOGGER.logp(Level.FINER, SnmpEngineImpl.class.getName(),
|
||||
"SnmpEngineImpl(SnmpEngineFactory,SnmpLcd)",
|
||||
"LOCAL ENGINE ID: " + engineid + " / " +
|
||||
"LOCAL ENGINE NB BOOTS: " + boot + " / " +
|
||||
"LOCAL ENGINE START TIME: " + getEngineTime());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Access Control will check the oids. By default is false.
|
||||
*/
|
||||
public synchronized void activateCheckOid() {
|
||||
checkOid = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access Control will not check the oids. By default is false.
|
||||
*/
|
||||
public synchronized void deactivateCheckOid() {
|
||||
checkOid = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Access Control check or not the oids. By default is false.
|
||||
*/
|
||||
public synchronized boolean isCheckOidActivated() {
|
||||
return checkOid;
|
||||
}
|
||||
|
||||
//Do some check and store the nb boots value.
|
||||
private void storeNBBoots(int boot) {
|
||||
if(boot < 0 || boot == 0x7FFFFFFF) {
|
||||
boot = 0x7FFFFFFF;
|
||||
lcd.storeEngineBoots(boot);
|
||||
}
|
||||
else
|
||||
lcd.storeEngineBoots(boot + 1);
|
||||
}
|
||||
|
||||
// Initialize internal status.
|
||||
private void init(SnmpLcd lcd, SnmpEngineFactory fact) {
|
||||
this.factory = fact;
|
||||
this.lcd = lcd;
|
||||
boot = lcd.getEngineBoots();
|
||||
|
||||
if(boot == -1 || boot == 0)
|
||||
boot = 1;
|
||||
|
||||
storeNBBoots(boot);
|
||||
|
||||
startTime = System.currentTimeMillis() / 1000;
|
||||
|
||||
}
|
||||
|
||||
void setUsmKeyHandler(SnmpUsmKeyHandler usmKeyHandler) {
|
||||
this.usmKeyHandler = usmKeyHandler;
|
||||
}
|
||||
|
||||
//Initialize the engineID.
|
||||
private void initEngineID() throws UnknownHostException {
|
||||
String id = lcd.getEngineId();
|
||||
if(id != null) {
|
||||
engineid = SnmpEngineId.createEngineId(id);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the Message Processing Sub System.
|
||||
* @return The Message Processing Sub System.
|
||||
*/
|
||||
public SnmpMsgProcessingSubSystem getMsgProcessingSubSystem() {
|
||||
return messageSub;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the Message Processing Sub System.
|
||||
* @param sys The Message Processing Sub System.
|
||||
*/
|
||||
public void setMsgProcessingSubSystem(SnmpMsgProcessingSubSystem sys) {
|
||||
messageSub = sys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Security Sub System.
|
||||
* @return The Security Sub System.
|
||||
*/
|
||||
public SnmpSecuritySubSystem getSecuritySubSystem() {
|
||||
return securitySub;
|
||||
}
|
||||
/**
|
||||
* Sets the Security Sub System.
|
||||
* @param sys The Security Sub System.
|
||||
*/
|
||||
public void setSecuritySubSystem(SnmpSecuritySubSystem sys) {
|
||||
securitySub = sys;
|
||||
}
|
||||
/**
|
||||
* Sets the Access Control Sub System.
|
||||
* @param sys The Access Control Sub System.
|
||||
*/
|
||||
public void setAccessControlSubSystem(SnmpAccessControlSubSystem sys) {
|
||||
accessSub = sys;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the Access Control Sub System.
|
||||
* @return The Access Control Sub System.
|
||||
*/
|
||||
public SnmpAccessControlSubSystem getAccessControlSubSystem() {
|
||||
return accessSub;
|
||||
}
|
||||
/**
|
||||
* Checks the passed msg flags according to the rules specified in RFC 2572.
|
||||
* @param msgFlags The msg flags.
|
||||
*/
|
||||
public static void checkSecurityLevel(byte msgFlags)
|
||||
throws SnmpBadSecurityLevelException {
|
||||
int secLevel = msgFlags & SnmpDefinitions.authPriv;
|
||||
if((secLevel & SnmpDefinitions.privMask) != 0)
|
||||
if((secLevel & SnmpDefinitions.authMask) == 0) {
|
||||
throw new SnmpBadSecurityLevelException("Security level:"+
|
||||
" noAuthPriv!!!");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
164
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpIncomingRequest.java
Normal file
164
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpIncomingRequest.java
Normal file
@@ -0,0 +1,164 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpSecurityParameters;
|
||||
import com.sun.jmx.snmp.SnmpTooBigException;
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpPdu;
|
||||
import com.sun.jmx.snmp.SnmpMsg;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpUnknownSecModelException;
|
||||
import com.sun.jmx.snmp.SnmpBadSecurityLevelException;
|
||||
|
||||
/**
|
||||
<P> An <CODE>SnmpIncomingRequest</CODE> handles both sides of an incoming SNMP request:
|
||||
<ul>
|
||||
<li> The request. Unmarshalling of the received message. </li>
|
||||
<li> The response. Marshalling of the message to send. </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 SnmpIncomingRequest {
|
||||
/**
|
||||
* Once the incoming request decoded, returns the decoded security parameters.
|
||||
* @return The decoded security parameters.
|
||||
*/
|
||||
public SnmpSecurityParameters getSecurityParameters();
|
||||
/**
|
||||
* Tests if a report is expected.
|
||||
* @return boolean indicating if a report is to be sent.
|
||||
*/
|
||||
public boolean isReport();
|
||||
/**
|
||||
* Tests if a response is expected.
|
||||
* @return boolean indicating if a response is to be sent.
|
||||
*/
|
||||
public boolean isResponse();
|
||||
|
||||
/**
|
||||
* Tells this request that no response will be sent.
|
||||
*/
|
||||
public void noResponse();
|
||||
/**
|
||||
* Gets the incoming request principal.
|
||||
* @return The request principal.
|
||||
**/
|
||||
public String getPrincipal();
|
||||
/**
|
||||
* Gets the incoming request security level. This level is defined in {@link com.sun.jmx.snmp.SnmpEngine SnmpEngine}.
|
||||
* @return The security level.
|
||||
*/
|
||||
public int getSecurityLevel();
|
||||
/**
|
||||
* Gets the incoming request security model.
|
||||
* @return The security model.
|
||||
*/
|
||||
public int getSecurityModel();
|
||||
/**
|
||||
* Gets the incoming request context name.
|
||||
* @return The context name.
|
||||
*/
|
||||
public byte[] getContextName();
|
||||
/**
|
||||
* Gets the incoming request context engine Id.
|
||||
* @return The context engine Id.
|
||||
*/
|
||||
public byte[] getContextEngineId();
|
||||
/**
|
||||
* Gets the incoming request context name used by Access Control Model in order to allow or deny the access to OIDs.
|
||||
*/
|
||||
public byte[] getAccessContext();
|
||||
/**
|
||||
* Encodes the response message to send and puts the result in the specified byte array.
|
||||
*
|
||||
* @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;
|
||||
|
||||
/**
|
||||
* Decodes the specified bytes and initializes the request with the incoming message.
|
||||
*
|
||||
* @param inputBytes The bytes to be decoded.
|
||||
*
|
||||
* @exception SnmpStatusException If the specified bytes are not a valid encoding or if the security applied to this request failed and no report is to be sent (typically trap PDU).
|
||||
*/
|
||||
public void decodeMessage(byte[] inputBytes,
|
||||
int byteCount,
|
||||
InetAddress address,
|
||||
int port)
|
||||
throws SnmpStatusException, SnmpUnknownSecModelException,
|
||||
SnmpBadSecurityLevelException;
|
||||
|
||||
/**
|
||||
* Initializes the response to send with the passed Pdu.
|
||||
* <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 SnmpMsg encodeSnmpPdu(SnmpPdu p,
|
||||
int maxDataLength)
|
||||
throws SnmpStatusException, SnmpTooBigException;
|
||||
|
||||
/**
|
||||
* Gets the request PDU encoded in the received 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;
|
||||
|
||||
/**
|
||||
* Returns a stringified form of the received message.
|
||||
* @return The message state string.
|
||||
*/
|
||||
public String printRequestMessage();
|
||||
/**
|
||||
* Returns a stringified form of the message to send.
|
||||
* @return The message state string.
|
||||
*/
|
||||
public String printResponseMessage();
|
||||
}
|
||||
122
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpIncomingResponse.java
Normal file
122
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpIncomingResponse.java
Normal file
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import com.sun.jmx.snmp.SnmpPduFactory;
|
||||
import com.sun.jmx.snmp.SnmpSecurityParameters;
|
||||
import com.sun.jmx.snmp.SnmpSecurityException;
|
||||
import com.sun.jmx.snmp.SnmpTooBigException;
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpPdu;
|
||||
import com.sun.jmx.snmp.SnmpMsg;
|
||||
|
||||
import com.sun.jmx.snmp.internal.SnmpSecurityCache;
|
||||
import com.sun.jmx.snmp.SnmpBadSecurityLevelException;
|
||||
/**
|
||||
* <P> An <CODE>SnmpIncomingResponse</CODE> handles the unmarshalling of the received response.</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 SnmpIncomingResponse {
|
||||
/**
|
||||
* Returns the source address.
|
||||
* @return The source address.
|
||||
*/
|
||||
public InetAddress getAddress();
|
||||
|
||||
/**
|
||||
* Returns the source port.
|
||||
* @return The source port.
|
||||
*/
|
||||
public int getPort();
|
||||
|
||||
/**
|
||||
* Gets the incoming response security parameters.
|
||||
* @return The security parameters.
|
||||
**/
|
||||
public SnmpSecurityParameters getSecurityParameters();
|
||||
/**
|
||||
* Call this method in order to reuse <CODE>SnmpOutgoingRequest</CODE> cache.
|
||||
* @param cache The security cache.
|
||||
*/
|
||||
public void setSecurityCache(SnmpSecurityCache cache);
|
||||
/**
|
||||
* Gets the incoming response security level. This level is defined in
|
||||
* {@link com.sun.jmx.snmp.SnmpEngine SnmpEngine}.
|
||||
* @return The security level.
|
||||
*/
|
||||
public int getSecurityLevel();
|
||||
/**
|
||||
* Gets the incoming response security model.
|
||||
* @return The security model.
|
||||
*/
|
||||
public int getSecurityModel();
|
||||
/**
|
||||
* Gets the incoming response context name.
|
||||
* @return The context name.
|
||||
*/
|
||||
public byte[] getContextName();
|
||||
|
||||
/**
|
||||
* Decodes the specified bytes and initializes itself with the received
|
||||
* response.
|
||||
*
|
||||
* @param inputBytes The bytes to be decoded.
|
||||
*
|
||||
* @exception SnmpStatusException If the specified bytes are not a valid encoding.
|
||||
*/
|
||||
public SnmpMsg decodeMessage(byte[] inputBytes,
|
||||
int byteCount,
|
||||
InetAddress address,
|
||||
int port)
|
||||
throws SnmpStatusException, SnmpSecurityException;
|
||||
|
||||
/**
|
||||
* Gets the request PDU encoded in the received response.
|
||||
* <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;
|
||||
|
||||
/**
|
||||
* Returns the response request Id.
|
||||
* @param data The flat message.
|
||||
* @return The request Id.
|
||||
*/
|
||||
public int getRequestId(byte[] data) throws SnmpStatusException;
|
||||
|
||||
/**
|
||||
* Returns a stringified form of the message to send.
|
||||
* @return The message state string.
|
||||
*/
|
||||
public String printMessage();
|
||||
}
|
||||
136
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpLcd.java
Normal file
136
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpLcd.java
Normal file
@@ -0,0 +1,136 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import java.util.Hashtable;
|
||||
import com.sun.jmx.snmp.SnmpEngineId;
|
||||
import com.sun.jmx.snmp.SnmpUnknownModelLcdException;
|
||||
import com.sun.jmx.snmp.SnmpUnknownSubSystemException;
|
||||
/**
|
||||
* Class to extend in order to develop a customized Local Configuration Datastore. The Lcd is used by the <CODE>SnmpEngine</CODE> to store and retrieve data.
|
||||
*<P> <CODE>SnmpLcd</CODE> manages the Lcds needed by every {@link com.sun.jmx.snmp.internal.SnmpModel SnmpModel}. It is possible to add and remove {@link com.sun.jmx.snmp.internal.SnmpModelLcd SnmpModelLcd}.</P>
|
||||
* <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 SnmpLcd {
|
||||
|
||||
class SubSysLcdManager {
|
||||
private Hashtable<Integer, SnmpModelLcd> models =
|
||||
new Hashtable<Integer, SnmpModelLcd>();
|
||||
|
||||
public void addModelLcd(int id,
|
||||
SnmpModelLcd usmlcd) {
|
||||
models.put(new Integer(id), usmlcd);
|
||||
}
|
||||
|
||||
public SnmpModelLcd getModelLcd(int id) {
|
||||
return models.get(new Integer(id));
|
||||
}
|
||||
|
||||
public SnmpModelLcd removeModelLcd(int id) {
|
||||
return models.remove(new Integer(id));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private Hashtable<SnmpSubSystem, SubSysLcdManager> subs =
|
||||
new Hashtable<SnmpSubSystem, SubSysLcdManager>();
|
||||
|
||||
/**
|
||||
* Returns the number of time the engine rebooted.
|
||||
* @return The number of reboots or -1 if the information is not present in the Lcd.
|
||||
*/
|
||||
public abstract int getEngineBoots();
|
||||
/**
|
||||
* Returns the engine Id located in the Lcd.
|
||||
* @return The engine Id or null if the information is not present in the Lcd.
|
||||
*/
|
||||
public abstract String getEngineId();
|
||||
|
||||
/**
|
||||
* Persists the number of reboots.
|
||||
* @param i Reboot number.
|
||||
*/
|
||||
public abstract void storeEngineBoots(int i);
|
||||
|
||||
/**
|
||||
* Persists the engine Id.
|
||||
* @param id The engine Id.
|
||||
*/
|
||||
public abstract void storeEngineId(SnmpEngineId id);
|
||||
/**
|
||||
* Adds an Lcd model.
|
||||
* @param sys The subsytem managing the model.
|
||||
* @param id The model Id.
|
||||
* @param lcd The Lcd model.
|
||||
*/
|
||||
public void addModelLcd(SnmpSubSystem sys,
|
||||
int id,
|
||||
SnmpModelLcd lcd) {
|
||||
|
||||
SubSysLcdManager subsys = subs.get(sys);
|
||||
if( subsys == null ) {
|
||||
subsys = new SubSysLcdManager();
|
||||
subs.put(sys, subsys);
|
||||
}
|
||||
|
||||
subsys.addModelLcd(id, lcd);
|
||||
}
|
||||
/**
|
||||
* Removes an Lcd model.
|
||||
* @param sys The subsytem managing the model.
|
||||
* @param id The model Id.
|
||||
*/
|
||||
public void removeModelLcd(SnmpSubSystem sys,
|
||||
int id)
|
||||
throws SnmpUnknownModelLcdException, SnmpUnknownSubSystemException {
|
||||
|
||||
SubSysLcdManager subsys = subs.get(sys);
|
||||
if( subsys != null ) {
|
||||
SnmpModelLcd lcd = subsys.removeModelLcd(id);
|
||||
if(lcd == null) {
|
||||
throw new SnmpUnknownModelLcdException("Model : " + id);
|
||||
}
|
||||
}
|
||||
else
|
||||
throw new SnmpUnknownSubSystemException(sys.toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets an Lcd model.
|
||||
* @param sys The subsytem managing the model
|
||||
* @param id The model Id.
|
||||
* @return The Lcd model or null if no Lcd model were found.
|
||||
*/
|
||||
public SnmpModelLcd getModelLcd(SnmpSubSystem sys,
|
||||
int id) {
|
||||
SubSysLcdManager subsys = subs.get(sys);
|
||||
|
||||
if(subsys == null) return null;
|
||||
|
||||
return subsys.getModelLcd(id);
|
||||
}
|
||||
}
|
||||
44
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpModel.java
Normal file
44
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpModel.java
Normal file
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
/**
|
||||
* Interface that every SNMP model must implement in order to be integrated in the engine framework.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpModel {
|
||||
|
||||
/**
|
||||
* Returns the sub system that manages this model.
|
||||
* @return The sub system.
|
||||
*/
|
||||
public SnmpSubSystem getSubSystem();
|
||||
/**
|
||||
* A human readable model name.
|
||||
* @return The model name.
|
||||
*/
|
||||
public String getName();
|
||||
}
|
||||
35
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpModelLcd.java
Normal file
35
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpModelLcd.java
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
/**
|
||||
* An interface to implement when developping customized model configuration datastore.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpModelLcd {
|
||||
}
|
||||
@@ -0,0 +1,147 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
|
||||
import com.sun.jmx.snmp.mpm.SnmpMsgTranslator;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpTooBigException;
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpPdu;
|
||||
import com.sun.jmx.snmp.SnmpPduFactory;
|
||||
import com.sun.jmx.snmp.SnmpSecurityParameters;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpParams;
|
||||
/**
|
||||
* The message processing model interface. Any message processing model must implement this interface in order to be integrated in the engine framework.
|
||||
* The model is called by the dispatcher when a call is received or when a call is sent.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpMsgProcessingModel extends SnmpModel {
|
||||
/**
|
||||
* This method is called when a call is to be sent to the network.
|
||||
* @param factory The pdu factory to use to encode and decode pdu.
|
||||
* @return The object that will handle every steps of the sending (mainly marshalling and security).
|
||||
*/
|
||||
public SnmpOutgoingRequest getOutgoingRequest(SnmpPduFactory factory);
|
||||
/**
|
||||
* This method is called when a call is received from the network.
|
||||
* @param factory The pdu factory to use to encode and decode pdu.
|
||||
* @return The object that will handle every steps of the receiving (mainly unmarshalling and security).
|
||||
*/
|
||||
public SnmpIncomingRequest getIncomingRequest(SnmpPduFactory factory);
|
||||
|
||||
/**
|
||||
* This method is called when a response is received from the network.
|
||||
* @param factory The pdu factory to use to encode and decode pdu.
|
||||
* @return The object that will handle every steps of the receiving (mainly unmarshalling and security).
|
||||
*/
|
||||
public SnmpIncomingResponse getIncomingResponse(SnmpPduFactory factory);
|
||||
/**
|
||||
* This method is called to instantiate a pdu according to the passed pdu type and parameters.
|
||||
* @param p The request parameters.
|
||||
* @param type The pdu type.
|
||||
* @return The pdu.
|
||||
*/
|
||||
public SnmpPdu getRequestPdu(SnmpParams p, int type) throws SnmpStatusException;
|
||||
|
||||
/**
|
||||
* This method is called to encode a full scoped pdu that has not been encrypted. <CODE>contextName</CODE>, <CODE>contextEngineID</CODE> and data are known.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The SNMP message ID.
|
||||
* @param msgMaxSize The max message size.
|
||||
* @param msgFlags The message flags.
|
||||
* @param msgSecurityModel The message security model.
|
||||
* @param params The security parameters.
|
||||
* @param contextEngineID The context engine ID.
|
||||
* @param contextName The context name.
|
||||
* @param data The encoded data.
|
||||
* @param dataLength The encoded data length.
|
||||
* @param outputBytes The buffer containing the encoded message.
|
||||
* @return The encoded bytes number.
|
||||
*/
|
||||
public int encode(int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
SnmpSecurityParameters params,
|
||||
byte[] contextEngineID,
|
||||
byte[] contextName,
|
||||
byte[] data,
|
||||
int dataLength,
|
||||
byte[] outputBytes) throws SnmpTooBigException;
|
||||
/**
|
||||
* This method is called to encode a full scoped pdu that as been encrypted. <CODE>contextName</CODE>, <CODE>contextEngineID</CODE> and data are known.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The SNMP message ID.
|
||||
* @param msgMaxSize The max message size.
|
||||
* @param msgFlags The message flags.
|
||||
* @param msgSecurityModel The message security model.
|
||||
* @param params The security parameters.
|
||||
* @param encryptedPdu The encrypted pdu.
|
||||
* @param outputBytes The buffer containing the encoded message.
|
||||
* @return The encoded bytes number.
|
||||
*/
|
||||
public int encodePriv(int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
SnmpSecurityParameters params,
|
||||
byte[] encryptedPdu,
|
||||
byte[] outputBytes) throws SnmpTooBigException;
|
||||
/**
|
||||
* This method returns a decoded scoped pdu. This method decodes only the <CODE>contextEngineID</CODE>, <CODE>contextName</CODE> and data. It is needed by the <CODE>SnmpSecurityModel</CODE> after decryption.
|
||||
* @param pdu The encoded pdu.
|
||||
* @return The partialy scoped pdu.
|
||||
*/
|
||||
public SnmpDecryptedPdu decode(byte[] pdu) throws SnmpStatusException;
|
||||
|
||||
/**
|
||||
* This method returns an encoded scoped pdu. This method encode only the <CODE>contextEngineID</CODE>, <CODE>contextName</CODE> and data. It is needed by the <CODE>SnmpSecurityModel</CODE> for decryption.
|
||||
* @param pdu The pdu to encode.
|
||||
* @param outputBytes The partialy scoped pdu.
|
||||
* @return The encoded bytes number.
|
||||
*/
|
||||
public int encode(SnmpDecryptedPdu pdu,
|
||||
byte[] outputBytes) throws SnmpTooBigException;
|
||||
|
||||
/**
|
||||
* In order to change the behavior of the translator, set it.
|
||||
* @param translator The translator that will be used.
|
||||
*/
|
||||
public void setMsgTranslator(SnmpMsgTranslator translator);
|
||||
|
||||
/**
|
||||
* Returns the current translator.
|
||||
* @return The current translator.
|
||||
*/
|
||||
public SnmpMsgTranslator getMsgTranslator();
|
||||
}
|
||||
@@ -0,0 +1,162 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import java.util.Vector;
|
||||
import com.sun.jmx.snmp.SnmpMsg;
|
||||
import com.sun.jmx.snmp.SnmpParams;
|
||||
import com.sun.jmx.snmp.SnmpPdu;
|
||||
import com.sun.jmx.snmp.SnmpVarBind;
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpTooBigException;
|
||||
import com.sun.jmx.snmp.SnmpPduFactory;
|
||||
import com.sun.jmx.snmp.SnmpSecurityParameters;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpUnknownMsgProcModelException;
|
||||
|
||||
/**
|
||||
* Message processing sub system interface. To allow engine integration, a message processing sub system must implement this interface. This sub system is called by the dispatcher when receiving or sending calls.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpMsgProcessingSubSystem extends SnmpSubSystem {
|
||||
|
||||
/**
|
||||
* Attaches the security sub system to this sub system. Message processing model are making usage of various security sub systems. This direct attachement avoid the need of accessing the engine to retrieve the Security sub system.
|
||||
* @param security The security sub system.
|
||||
*/
|
||||
public void setSecuritySubSystem(SnmpSecuritySubSystem security);
|
||||
/** Gets the attached security sub system.
|
||||
* @return The security sub system.
|
||||
*/
|
||||
public SnmpSecuritySubSystem getSecuritySubSystem();
|
||||
|
||||
/**
|
||||
* This method is called when a call is received from the network.
|
||||
* @param model The model ID.
|
||||
* @param factory The pdu factory to use to encode and decode pdu.
|
||||
* @return The object that will handle every steps of the receiving (mainly unmarshalling and security).
|
||||
*/
|
||||
public SnmpIncomingRequest getIncomingRequest(int model,
|
||||
SnmpPduFactory factory)
|
||||
throws SnmpUnknownMsgProcModelException;
|
||||
/**
|
||||
* This method is called when a call is to be sent to the network. The sub system routes the call to the dedicated model according to the model ID.
|
||||
* @param model The model ID.
|
||||
* @param factory The pdu factory to use to encode and decode pdu.
|
||||
* @return The object that will handle every steps of the sending (mainly marshalling and security).
|
||||
*/
|
||||
public SnmpOutgoingRequest getOutgoingRequest(int model,
|
||||
SnmpPduFactory factory) throws SnmpUnknownMsgProcModelException ;
|
||||
/**
|
||||
* This method is called to instantiate a pdu according to the passed pdu type and parameters. The sub system routes the call to the dedicated model according to the model ID.
|
||||
* @param model The model ID.
|
||||
* @param p The request parameters.
|
||||
* @param type The pdu type.
|
||||
* @return The pdu.
|
||||
*/
|
||||
public SnmpPdu getRequestPdu(int model, SnmpParams p, int type) throws SnmpUnknownMsgProcModelException, SnmpStatusException ;
|
||||
/**
|
||||
* This method is called when a call is received from the network. The sub system routes the call to the dedicated model according to the model ID.
|
||||
* @param model The model ID.
|
||||
* @param factory The pdu factory to use to decode pdu.
|
||||
* @return The object that will handle every steps of the receiving (mainly marshalling and security).
|
||||
*/
|
||||
public SnmpIncomingResponse getIncomingResponse(int model,
|
||||
SnmpPduFactory factory) throws SnmpUnknownMsgProcModelException;
|
||||
/**
|
||||
* This method is called to encode a full scoped pdu that as not been encrypted. <CODE>contextName</CODE>, <CODE>contextEngineID</CODE> and data are known. It will be routed to the dedicated model according to the version value.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The SNMP message ID.
|
||||
* @param msgMaxSize The max message size.
|
||||
* @param msgFlags The message flags.
|
||||
* @param msgSecurityModel The message security model.
|
||||
* @param params The security parameters.
|
||||
* @param contextEngineID The context engine ID.
|
||||
* @param contextName The context name.
|
||||
* @param data The encoded data.
|
||||
* @param dataLength The encoded data length.
|
||||
* @param outputBytes The buffer containing the encoded message.
|
||||
* @return The encoded bytes number.
|
||||
*/
|
||||
public int encode(int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
SnmpSecurityParameters params,
|
||||
byte[] contextEngineID,
|
||||
byte[] contextName,
|
||||
byte[] data,
|
||||
int dataLength,
|
||||
byte[] outputBytes)
|
||||
throws SnmpTooBigException,
|
||||
SnmpUnknownMsgProcModelException ;
|
||||
/**
|
||||
* This method is called to encode a full scoped pdu that as been encrypted. <CODE>contextName</CODE>, <CODE>contextEngineID</CODE> and data are not known. It will be routed to the dedicated model according to the version value.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The SNMP message ID.
|
||||
* @param msgMaxSize The max message size.
|
||||
* @param msgFlags The message flags.
|
||||
* @param msgSecurityModel The message security model.
|
||||
* @param params The security parameters.
|
||||
* @param encryptedPdu The encrypted pdu.
|
||||
* @param outputBytes The buffer containing the encoded message.
|
||||
* @return The encoded bytes number.
|
||||
*/
|
||||
public int encodePriv(int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
SnmpSecurityParameters params,
|
||||
byte[] encryptedPdu,
|
||||
byte[] outputBytes) throws SnmpTooBigException, SnmpUnknownMsgProcModelException;
|
||||
|
||||
/**
|
||||
* This method returns a decoded scoped pdu. This method decodes only the <CODE>contextEngineID</CODE>, <CODE>contextName</CODE> and data. It is needed by the <CODE>SnmpSecurityModel</CODE> after decryption. It will be routed to the dedicated model according to the version value.
|
||||
* @param version The SNMP protocol version.
|
||||
* @param pdu The encoded pdu.
|
||||
* @return the partialy scoped pdu.
|
||||
*/
|
||||
public SnmpDecryptedPdu decode(int version,
|
||||
byte[] pdu)
|
||||
throws SnmpStatusException, SnmpUnknownMsgProcModelException;
|
||||
|
||||
/**
|
||||
* This method returns an encoded scoped pdu. This method encodes only the <CODE>contextEngineID</CODE>, <CODE>contextName</CODE> and data. It is needed by the <CODE>SnmpSecurityModel</CODE> for decryption. It will be routed to the dedicated model according to the version value.
|
||||
* @param version The SNMP protocol version.
|
||||
* @param pdu The pdu to encode.
|
||||
* @param outputBytes The partialy scoped pdu.
|
||||
* @return The encoded bytes number.
|
||||
*/
|
||||
public int encode(int version,
|
||||
SnmpDecryptedPdu pdu,
|
||||
byte[] outputBytes)
|
||||
throws SnmpTooBigException, SnmpUnknownMsgProcModelException;
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpSecurityException;
|
||||
import com.sun.jmx.snmp.SnmpTooBigException;
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpPdu;
|
||||
import com.sun.jmx.snmp.SnmpMsg;
|
||||
|
||||
import com.sun.jmx.snmp.internal.SnmpSecurityCache;
|
||||
import com.sun.jmx.snmp.SnmpUnknownSecModelException;
|
||||
import com.sun.jmx.snmp.SnmpBadSecurityLevelException;
|
||||
/**
|
||||
* <P> An <CODE>SnmpOutgoingRequest</CODE> handles the marshalling of the message to send.</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 SnmpOutgoingRequest {
|
||||
/**
|
||||
* Returns the cached security data used when marshalling the call as a secure one.
|
||||
* @return The cached data.
|
||||
*/
|
||||
public SnmpSecurityCache getSecurityCache();
|
||||
/**
|
||||
* Encodes the message to send and puts the result in the specified byte array.
|
||||
*
|
||||
* @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 SnmpStatusException,
|
||||
SnmpTooBigException, SnmpSecurityException,
|
||||
SnmpUnknownSecModelException, SnmpBadSecurityLevelException;
|
||||
/**
|
||||
* Initializes the message to send with the passed Pdu.
|
||||
* <P>
|
||||
* If the encoding length exceeds <CODE>maxDataLength</CODE>,
|
||||
* the method throws an exception.</P>
|
||||
*
|
||||
* @param p The PDU to be encoded.
|
||||
* @param maxDataLength The maximum length permitted for the data field.
|
||||
*
|
||||
* @exception SnmpStatusException If the specified PDU <CODE>p</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 SnmpMsg encodeSnmpPdu(SnmpPdu p,
|
||||
int maxDataLength)
|
||||
throws SnmpStatusException, SnmpTooBigException;
|
||||
/**
|
||||
* Returns a stringified form of the message to send.
|
||||
* @return The message state string.
|
||||
*/
|
||||
public String printMessage();
|
||||
}
|
||||
34
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpSecurityCache.java
Normal file
34
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpSecurityCache.java
Normal file
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
/**
|
||||
* Cache is returned by <CODE>SnmpSecurityModel</CODE> when handling requests. The cache contants is security dependant. This interface is a marker that every cache classes must implement.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpSecurityCache {
|
||||
}
|
||||
176
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpSecurityModel.java
Normal file
176
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpSecurityModel.java
Normal file
@@ -0,0 +1,176 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpSecurityException;
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpTooBigException;
|
||||
import com.sun.jmx.snmp.SnmpSecurityParameters;
|
||||
|
||||
/**
|
||||
* Security model interface. Any security model implementation must implement this interface in order to be integrated in the engine framework. Security models are called when SNMP messages are received or sent. They deal with security (authentication and privacy).
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public interface SnmpSecurityModel extends SnmpModel {
|
||||
/**
|
||||
* Called when a request is to be sent to the network. It must be securized.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The current request id.
|
||||
* @param msgMaxSize The message max size.
|
||||
* @param msgFlags The message flags (reportable, Auth and Priv).
|
||||
* @param msgSecurityModel This current security model.
|
||||
* @param params The security parameters that contain the model dependant parameters.
|
||||
* @param contextEngineID The context engine ID.
|
||||
* @param contextName The context name.
|
||||
* @param data The marshalled varbind list.
|
||||
* @param dataLength The marshalled varbind list length.
|
||||
* @param outputBytes The buffer to fill with securized request. This is a representation independant marshalled format. This buffer will be sent to the network.
|
||||
* @return The marshalled byte number.
|
||||
*/
|
||||
public int generateRequestMsg(SnmpSecurityCache cache,
|
||||
int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
SnmpSecurityParameters params,
|
||||
byte[] contextEngineID,
|
||||
byte[] contextName,
|
||||
byte[] data,
|
||||
int dataLength,
|
||||
byte[] outputBytes)
|
||||
throws SnmpTooBigException, SnmpStatusException,
|
||||
SnmpSecurityException;
|
||||
|
||||
/**
|
||||
* Called when a response is to be sent to the network. It must be securized.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The current request id.
|
||||
* @param msgMaxSize The message max size.
|
||||
* @param msgFlags The message flags (reportable, Auth and Priv)
|
||||
* @param msgSecurityModel This current security model.
|
||||
* @param params The security parameters that contain the model dependant parameters.
|
||||
* @param contextEngineID The context engine ID.
|
||||
* @param contextName The context name.
|
||||
* @param data The marshalled varbind list.
|
||||
* @param dataLength The marshalled varbind list length.
|
||||
* @param outputBytes The buffer to fill with securized request. This is a representation independant marshalled format. This buffer will be sent to the network.
|
||||
* @return The marshalled byte number.
|
||||
*/
|
||||
public int generateResponseMsg(SnmpSecurityCache cache,
|
||||
int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
SnmpSecurityParameters params,
|
||||
byte[] contextEngineID,
|
||||
byte[] contextName,
|
||||
byte[] data,
|
||||
int dataLength,
|
||||
byte[] outputBytes)
|
||||
throws SnmpTooBigException, SnmpStatusException,
|
||||
SnmpSecurityException;
|
||||
/**
|
||||
* Called when a request is received from the network. It handles authentication and privacy.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The current request id.
|
||||
* @param msgMaxSize The message max size.
|
||||
* @param msgFlags The message flags (reportable, Auth and Priv)
|
||||
* @param msgSecurityModel This current security model.
|
||||
* @param params The security parameters in a marshalled format. The informations contained in this array are model dependant.
|
||||
* @param contextEngineID The context engine ID or null if encrypted.
|
||||
* @param contextName The context name or null if encrypted.
|
||||
* @param data The marshalled varbind list or null if encrypted
|
||||
* @param encryptedPdu The encrypted pdu or null if not encrypted.
|
||||
* @param decryptedPdu The decrypted pdu. If no decryption is to be done, the passed context engine ID, context name and data could be used to fill this object.
|
||||
* @return The decoded security parameters.
|
||||
|
||||
*/
|
||||
public SnmpSecurityParameters
|
||||
processIncomingRequest(SnmpSecurityCache cache,
|
||||
int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
byte[] params,
|
||||
byte[] contextEngineID,
|
||||
byte[] contextName,
|
||||
byte[] data,
|
||||
byte[] encryptedPdu,
|
||||
SnmpDecryptedPdu decryptedPdu)
|
||||
throws SnmpStatusException, SnmpSecurityException;
|
||||
/**
|
||||
* Called when a response is received from the network. It handles authentication and privacy.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The current request id.
|
||||
* @param msgMaxSize The message max size.
|
||||
* @param msgFlags The message flags (reportable, Auth and Priv)
|
||||
* @param msgSecurityModel This current security model.
|
||||
* @param params The security parameters in a marshalled format. The informations cointained in this array are model dependant.
|
||||
* @param contextEngineID The context engine ID or null if encrypted.
|
||||
* @param contextName The context name or null if encrypted.
|
||||
* @param data The marshalled varbind list or null if encrypted
|
||||
* @param encryptedPdu The encrypted pdu or null if not encrypted.
|
||||
* @param decryptedPdu The decrypted pdu. If no decryption is to be done, the passed context engine ID, context name and data could be used to fill this object.
|
||||
* @return The security parameters.
|
||||
|
||||
*/
|
||||
public SnmpSecurityParameters processIncomingResponse(SnmpSecurityCache cache,
|
||||
int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
byte[] params,
|
||||
byte[] contextEngineID,
|
||||
byte[] contextName,
|
||||
byte[] data,
|
||||
byte[] encryptedPdu,
|
||||
SnmpDecryptedPdu decryptedPdu)
|
||||
throws SnmpStatusException, SnmpSecurityException;
|
||||
|
||||
/**
|
||||
* Instantiate an <CODE>SnmpSecurityCache</CODE> that is dependant to the model implementation.
|
||||
* @return The model dependant security cache.
|
||||
*/
|
||||
public SnmpSecurityCache createSecurityCache();
|
||||
/**
|
||||
* Release the previously created cache.
|
||||
* @param cache The security cache to release.
|
||||
*/
|
||||
public void releaseSecurityCache(SnmpSecurityCache cache);
|
||||
}
|
||||
178
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpSecuritySubSystem.java
Normal file
178
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpSecuritySubSystem.java
Normal file
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpTooBigException;
|
||||
import com.sun.jmx.snmp.SnmpStatusException;
|
||||
import com.sun.jmx.snmp.SnmpUnknownSecModelException;
|
||||
import com.sun.jmx.snmp.SnmpSecurityException;
|
||||
import com.sun.jmx.snmp.SnmpSecurityParameters;
|
||||
|
||||
/**
|
||||
* Security sub system interface. To allow engine integration, a security sub system must implement this interface.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
public interface SnmpSecuritySubSystem extends SnmpSubSystem {
|
||||
/**
|
||||
* Instantiates an <CODE>SnmpSecurityCache</CODE> that is dependant to the model implementation. This call is routed to the dedicated model according to the model ID.
|
||||
* @param id The model ID.
|
||||
* @return The model dependant security cache.
|
||||
*/
|
||||
public SnmpSecurityCache createSecurityCache(int id) throws SnmpUnknownSecModelException;
|
||||
/**
|
||||
* To release the previously created cache. This call is routed to the dedicated model according to the model ID.
|
||||
* @param id The model ID.
|
||||
* @param cache The security cache to release.
|
||||
*/
|
||||
public void releaseSecurityCache(int id,
|
||||
SnmpSecurityCache cache) throws SnmpUnknownSecModelException;
|
||||
|
||||
/**
|
||||
* Called when a request is to be sent to the network. It must be securized. This call is routed to the dedicated model according to the model ID.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The current request id.
|
||||
* @param msgMaxSize The message max size.
|
||||
* @param msgFlags The message flags (reportable, Auth and Priv).
|
||||
* @param msgSecurityModel This current security model.
|
||||
* @param params The security parameters that contain the model dependant parameters.
|
||||
* @param contextEngineID The context engine ID.
|
||||
* @param contextName The context name.
|
||||
* @param data The marshalled varbind list
|
||||
* @param dataLength The marshalled varbind list length.
|
||||
* @param outputBytes The buffer to fill with securized request. This is a representation independant marshalled format. This buffer will be sent to the network.
|
||||
* @return The marshalled byte number.
|
||||
*/
|
||||
public int generateRequestMsg(SnmpSecurityCache cache,
|
||||
int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
SnmpSecurityParameters params,
|
||||
byte[] contextEngineID,
|
||||
byte[] contextName,
|
||||
byte[] data,
|
||||
int dataLength,
|
||||
byte[] outputBytes)
|
||||
throws SnmpTooBigException, SnmpStatusException, SnmpSecurityException, SnmpUnknownSecModelException;
|
||||
|
||||
/**
|
||||
* Called when a response is to be sent to the network. It must be securized. This call is routed to the dedicated model according to the model ID.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The current request id.
|
||||
* @param msgMaxSize The message max size.
|
||||
* @param msgFlags The message flags (reportable, Auth and Priv).
|
||||
* @param msgSecurityModel This current security model.
|
||||
* @param params The security parameters that contain the model dependant parameters.
|
||||
* @param contextEngineID The context engine ID.
|
||||
* @param contextName The context name.
|
||||
* @param data The marshalled varbind list
|
||||
* @param dataLength The marshalled varbind list length.
|
||||
* @param outputBytes The buffer to fill with securized request. This is a representation independant marshalled format. This buffer will be sent to the network.
|
||||
* @return The marshalled byte number.
|
||||
*/
|
||||
public int generateResponseMsg(SnmpSecurityCache cache,
|
||||
int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
SnmpSecurityParameters params,
|
||||
byte[] contextEngineID,
|
||||
byte[] contextName,
|
||||
byte[] data,
|
||||
int dataLength,
|
||||
byte[] outputBytes)
|
||||
throws SnmpTooBigException, SnmpStatusException,
|
||||
SnmpSecurityException, SnmpUnknownSecModelException;
|
||||
/**
|
||||
* Called when a request is received from the network. It handles authentication and privacy. This call is routed to the dedicated model according to the model ID.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The current request id.
|
||||
* @param msgMaxSize The message max size.
|
||||
* @param msgFlags The message flags (reportable, Auth and Priv)
|
||||
* @param msgSecurityModel This current security model.
|
||||
* @param params The security parameters in a marshalled format. The informations cointained in this array are model dependant.
|
||||
* @param contextEngineID The context engine ID or null if encrypted.
|
||||
* @param contextName The context name or null if encrypted.
|
||||
* @param data The marshalled varbind list or null if encrypted.
|
||||
* @param encryptedPdu The encrypted pdu or null if not encrypted.
|
||||
* @param decryptedPdu The decrypted pdu. If no decryption is to be done, the passed context engine ID, context name and data could be used to fill this object.
|
||||
* @return The decoded security parameters.
|
||||
|
||||
*/
|
||||
public SnmpSecurityParameters
|
||||
processIncomingRequest(SnmpSecurityCache cache,
|
||||
int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
byte[] params,
|
||||
byte[] contextEngineID,
|
||||
byte[] contextName,
|
||||
byte[] data,
|
||||
byte[] encryptedPdu,
|
||||
SnmpDecryptedPdu decryptedPdu)
|
||||
throws SnmpStatusException, SnmpSecurityException, SnmpUnknownSecModelException;
|
||||
/**
|
||||
* Called when a response is received from the network. It handles authentication and privacy. This call is routed to the dedicated model according to the model ID.
|
||||
* <BR>The specified parameters are defined in RFC 2572 (see also the {@link com.sun.jmx.snmp.SnmpV3Message} class).
|
||||
* @param cache The cache that has been created by calling <CODE>createSecurityCache</CODE> on this model.
|
||||
* @param version The SNMP protocol version.
|
||||
* @param msgID The current request id.
|
||||
* @param msgMaxSize The message max size.
|
||||
* @param msgFlags The message flags (reportable, Auth and Priv).
|
||||
* @param msgSecurityModel This current security model.
|
||||
* @param params The security parameters in a marshalled format. The informations cointained in this array are model dependant.
|
||||
* @param contextEngineID The context engine ID or null if encrypted.
|
||||
* @param contextName The context name or null if encrypted.
|
||||
* @param data The marshalled varbind list or null if encrypted.
|
||||
* @param encryptedPdu The encrypted pdu or null if not encrypted.
|
||||
* @param decryptedPdu The decrypted pdu. If no decryption is to be done, the passed context engine ID, context name and data could be used to fill this object.
|
||||
* @return The security parameters.
|
||||
|
||||
*/
|
||||
public SnmpSecurityParameters processIncomingResponse(SnmpSecurityCache cache,
|
||||
int version,
|
||||
int msgID,
|
||||
int msgMaxSize,
|
||||
byte msgFlags,
|
||||
int msgSecurityModel,
|
||||
byte[] params,
|
||||
byte[] contextEngineID,
|
||||
byte[] contextName,
|
||||
byte[] data,
|
||||
byte[] encryptedPdu,
|
||||
SnmpDecryptedPdu decryptedPdu)
|
||||
throws SnmpStatusException, SnmpSecurityException, SnmpUnknownSecModelException;
|
||||
}
|
||||
73
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpSubSystem.java
Normal file
73
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpSubSystem.java
Normal file
@@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpEngine;
|
||||
import com.sun.jmx.snmp.SnmpUnknownModelException;
|
||||
import java.util.Hashtable;
|
||||
/**
|
||||
* SNMP sub system interface. To allow engine framework integration, a sub system must implement this interface. A sub system is a model manager. Every model is identified by an ID. A sub system can retrieve a previously registered model using this ID.
|
||||
* <P> Every sub system is associated to its SNMP engine.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
*/
|
||||
public interface SnmpSubSystem {
|
||||
/**
|
||||
* Returns the associated engine.
|
||||
* @return The engine.
|
||||
*/
|
||||
public SnmpEngine getEngine();
|
||||
|
||||
/**
|
||||
* Adds a model to this sub system.
|
||||
* @param id The model ID.
|
||||
* @param model The model to add.
|
||||
*/
|
||||
public void addModel(int id, SnmpModel model);
|
||||
|
||||
/**
|
||||
* Removes a model from this sub system.
|
||||
* @param id The model ID to remove.
|
||||
* @return The removed model.
|
||||
*/
|
||||
public SnmpModel removeModel(int id) throws SnmpUnknownModelException;
|
||||
|
||||
/**
|
||||
* Gets a model from this sub system.
|
||||
* @param id The model ID to get.
|
||||
* @return The model.
|
||||
*/
|
||||
public SnmpModel getModel(int id) throws SnmpUnknownModelException;
|
||||
|
||||
/**
|
||||
* Returns the set of model Ids that have been registered within the sub system.
|
||||
*/
|
||||
public int[] getModelIds();
|
||||
|
||||
/**
|
||||
* Returns the set of model names that have been registered within the sub system.
|
||||
*/
|
||||
public String[] getModelNames();
|
||||
}
|
||||
125
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpTools.java
Normal file
125
jdkSrc/jdk8/com/sun/jmx/snmp/internal/SnmpTools.java
Normal file
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* 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.internal;
|
||||
|
||||
import com.sun.jmx.snmp.SnmpDefinitions;
|
||||
/**
|
||||
* Utility class used to deal with various data representations.
|
||||
* <p><b>This API is a Sun Microsystems internal API and is subject
|
||||
* to change without notice.</b></p>
|
||||
* @since 1.5
|
||||
*/
|
||||
public class SnmpTools implements SnmpDefinitions {
|
||||
|
||||
/**
|
||||
* Translates a binary representation in an ASCII one. The returned string is an hexadecimal string starting with 0x.
|
||||
* @param data Binary to translate.
|
||||
* @return Translated binary.
|
||||
*/
|
||||
static public String binary2ascii(byte[] data, int length)
|
||||
{
|
||||
if(data == null) return null;
|
||||
final int size = (length * 2) + 2;
|
||||
byte[] asciiData = new byte[size];
|
||||
asciiData[0] = (byte) '0';
|
||||
asciiData[1] = (byte) 'x';
|
||||
for (int i=0; i < length; i++) {
|
||||
int j = i*2;
|
||||
int v = (data[i] & 0xf0);
|
||||
v = v >> 4;
|
||||
if (v < 10)
|
||||
asciiData[j+2] = (byte) ('0' + v);
|
||||
else
|
||||
asciiData[j+2] = (byte) ('A' + (v - 10));
|
||||
v = ((data[i] & 0xf));
|
||||
if (v < 10)
|
||||
asciiData[j+1+2] = (byte) ('0' + v);
|
||||
else
|
||||
asciiData[j+1+2] = (byte) ('A' + (v - 10));
|
||||
}
|
||||
return new String(asciiData);
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a binary representation in an ASCII one. The returned string is an hexadecimal string starting with 0x.
|
||||
* @param data Binary to translate.
|
||||
* @return Translated binary.
|
||||
*/
|
||||
static public String binary2ascii(byte[] data)
|
||||
{
|
||||
return binary2ascii(data, data.length);
|
||||
}
|
||||
/**
|
||||
* Translates a stringified representation in a binary one. The passed string is an hexadecimal one starting with 0x.
|
||||
* @param str String to translate.
|
||||
* @return Translated string.
|
||||
*/
|
||||
static public byte[] ascii2binary(String str) {
|
||||
if(str == null) return null;
|
||||
String val = str.substring(2);
|
||||
|
||||
int size = val.length();
|
||||
byte []buf = new byte[size/2];
|
||||
byte []p = val.getBytes();
|
||||
|
||||
for(int i = 0; i < (size / 2); i++)
|
||||
{
|
||||
int j = i * 2;
|
||||
byte v = 0;
|
||||
if (p[j] >= '0' && p[j] <= '9') {
|
||||
v = (byte) ((p[j] - '0') << 4);
|
||||
}
|
||||
else if (p[j] >= 'a' && p[j] <= 'f') {
|
||||
v = (byte) ((p[j] - 'a' + 10) << 4);
|
||||
}
|
||||
else if (p[j] >= 'A' && p[j] <= 'F') {
|
||||
v = (byte) ((p[j] - 'A' + 10) << 4);
|
||||
}
|
||||
else
|
||||
throw new Error("BAD format :" + str);
|
||||
|
||||
if (p[j+1] >= '0' && p[j+1] <= '9') {
|
||||
//System.out.println("ascii : " + p[j+1]);
|
||||
v += (p[j+1] - '0');
|
||||
//System.out.println("binary : " + v);
|
||||
}
|
||||
else if (p[j+1] >= 'a' && p[j+1] <= 'f') {
|
||||
//System.out.println("ascii : " + p[j+1]);
|
||||
v += (p[j+1] - 'a' + 10);
|
||||
//System.out.println("binary : " + v+1);
|
||||
}
|
||||
else if (p[j+1] >= 'A' && p[j+1] <= 'F') {
|
||||
//System.out.println("ascii : " + p[j+1]);
|
||||
v += (p[j+1] - 'A' + 10);
|
||||
//System.out.println("binary : " + v);
|
||||
}
|
||||
else
|
||||
throw new Error("BAD format :" + str);
|
||||
|
||||
buf[i] = v;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user