Package org.snmp4j
Class CommunityTarget
java.lang.Object
org.snmp4j.AbstractTarget
org.snmp4j.CommunityTarget
- All Implemented Interfaces:
Serializable
,Cloneable
,Target
A
CommunityTarget
represents SNMP target properties for
community based message processing models (SNMPv1 and SNMPv2c).- Version:
- 1.1
- Author:
- Frank Fock
- See Also:
-
Field Summary
Fields inherited from class org.snmp4j.AbstractTarget
securityLevel, securityModel, securityName
-
Constructor Summary
ConstructorDescriptionDefault constructor.CommunityTarget
(Address address, OctetString community) Creates a fully specified community target. -
Method Summary
Modifier and TypeMethodDescriptionCreates a new copy of this target with the same address type.Gets the community octet string (which is the same as the security name).int
Gets the security model associated with this target.void
setCommunity
(OctetString community) Sets the community octet sting.void
setSecurityLevel
(int securityLevel) Sets the security level for this target.void
setSecurityModel
(int securityModel) Sets the security model for this target.toString()
Methods inherited from class org.snmp4j.AbstractTarget
clone, equals, getAddress, getMaxSizeRequestPDU, getPreferredTransports, getRetries, getSecurityLevel, getSecurityName, getTimeout, getVersion, hashCode, setAddress, setMaxSizeRequestPDU, setPreferredTransports, setRetries, setSecurityName, setTimeout, setVersion, toStringAbstractTarget
-
Constructor Details
-
CommunityTarget
public CommunityTarget()Default constructor. -
CommunityTarget
Creates a fully specified community target.- Parameters:
address
- the transportAddress
of the target.community
- the community to be used for the target.
-
-
Method Details
-
duplicate
Description copied from interface:Target
Creates a new copy of this target with the same address type.- Returns:
- a copy of this target with the same address type.
-
getCommunity
Gets the community octet string (which is the same as the security name). Thus, you can (and should) useAbstractTarget.getSecurityName()
directly.- Returns:
- an
OctetString
instance, should be nevernull
when using this target to send messages over community based SNMP (v1 and v2c).
-
setCommunity
Sets the community octet sting. This is a convenience method to set the security name for community based SNMP (v1 and v2c). It basically checks that the community is notnull
and then callsAbstractTarget.setSecurityName(org.snmp4j.smi.OctetString)
with the supplied parameter.- Parameters:
community
- anOctetString
instance which must not benull
.
-
getSecurityModel
public int getSecurityModel()Description copied from interface:Target
Gets the security model associated with this target.- Specified by:
getSecurityModel
in interfaceTarget
- Overrides:
getSecurityModel
in classAbstractTarget
- Returns:
- an
int
value as defined in theSecurityModel
interface or any third party subclass thereof.
-
setSecurityLevel
public void setSecurityLevel(int securityLevel) Description copied from class:AbstractTarget
Sets the security level for this target. The supplied security level must be supported by the security model dependent information associated with the security name set for this target.- Specified by:
setSecurityLevel
in interfaceTarget
- Overrides:
setSecurityLevel
in classAbstractTarget
- Parameters:
securityLevel
- one of
-
setSecurityModel
public void setSecurityModel(int securityModel) Description copied from class:AbstractTarget
Sets the security model for this target.- Specified by:
setSecurityModel
in interfaceTarget
- Overrides:
setSecurityModel
in classAbstractTarget
- Parameters:
securityModel
- anint
value as defined in theSecurityModel
interface or any third party subclass thereof.
-
toString
- Overrides:
toString
in classAbstractTarget
-