java.lang.Object
org.snmp4j.AbstractTarget<A>
org.snmp4j.CommunityTarget<A>
- All Implemented Interfaces:
Serializable
,Cloneable
,Target<A>
A
CommunityTarget
represents SNMP target properties for community based message processing models
(SNMPv1 and SNMPv2c).- Version:
- 3.1
- Author:
- Frank Fock
- See Also:
-
Field Summary
Fields inherited from class org.snmp4j.AbstractTarget
securityLevel, securityModel, securityName
-
Constructor Summary
ConstructorDescriptionDefault constructor.CommunityTarget
(A 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
-
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
.
-
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.
-
getSecurityModel
public int getSecurityModel()Description copied from interface:Target
Gets the security model associated with this target.- Specified by:
getSecurityModel
in interfaceTarget<A extends Address>
- Overrides:
getSecurityModel
in classAbstractTarget<A extends Address>
- 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<A extends Address>
- Overrides:
setSecurityLevel
in classAbstractTarget<A extends Address>
- 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<A extends Address>
- Overrides:
setSecurityModel
in classAbstractTarget<A extends Address>
- Parameters:
securityModel
- anint
value as defined in theSecurityModel
interface or any third party subclass thereof.
-
toString
- Overrides:
toString
in classAbstractTarget<A extends Address>
-