- java.lang.Object
-
- org.snmp4j.AbstractTarget<A>
-
- org.snmp4j.CommunityTarget<A>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,Target<A>
public class CommunityTarget<A extends Address> extends AbstractTarget<A>
ACommunityTargetrepresents SNMP target properties for community based message processing models (SNMPv1 and SNMPv2c).- Version:
- 3.1
- Author:
- Frank Fock
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.snmp4j.AbstractTarget
securityLevel, securityModel, securityName
-
-
Constructor Summary
Constructors Constructor Description CommunityTarget()Default constructor.CommunityTarget(A address, OctetString community)Creates a fully specified community target.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Target<A>duplicate()Creates a new copy of this target with the same address type.OctetStringgetCommunity()Gets the community octet string (which is the same as the security name).intgetSecurityModel()Gets the security model associated with this target.voidsetCommunity(OctetString community)Sets the community octet sting.voidsetSecurityLevel(int securityLevel)Sets the security level for this target.voidsetSecurityModel(int securityModel)Sets the security model for this target.java.lang.StringtoString()-
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 Detail
-
CommunityTarget
public CommunityTarget()
Default constructor.
-
CommunityTarget
public CommunityTarget(A address, OctetString community)
Creates a fully specified community target.- Parameters:
address- the transportAddressof the target.community- the community to be used for the target.
-
-
Method Detail
-
getCommunity
public OctetString getCommunity()
Gets the community octet string (which is the same as the security name). Thus, you can (and should) useAbstractTarget.getSecurityName()directly.- Returns:
- an
OctetStringinstance, should be nevernullwhen using this target to send messages over community based SNMP (v1 and v2c).
-
setCommunity
public void setCommunity(OctetString community)
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 notnulland then callsAbstractTarget.setSecurityName(org.snmp4j.smi.OctetString)with the supplied parameter.- Parameters:
community- anOctetStringinstance which must not benull.
-
duplicate
public Target<A> duplicate()
Description copied from interface:TargetCreates 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:TargetGets the security model associated with this target.- Specified by:
getSecurityModelin interfaceTarget<A extends Address>- Overrides:
getSecurityModelin classAbstractTarget<A extends Address>- Returns:
- an
intvalue as defined in theSecurityModelinterface or any third party subclass thereof.
-
setSecurityLevel
public void setSecurityLevel(int securityLevel)
Description copied from class:AbstractTargetSets 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:
setSecurityLevelin interfaceTarget<A extends Address>- Overrides:
setSecurityLevelin classAbstractTarget<A extends Address>- Parameters:
securityLevel- one of
-
setSecurityModel
public void setSecurityModel(int securityModel)
Description copied from class:AbstractTargetSets the security model for this target.- Specified by:
setSecurityModelin interfaceTarget<A extends Address>- Overrides:
setSecurityModelin classAbstractTarget<A extends Address>- Parameters:
securityModel- anintvalue as defined in theSecurityModelinterface or any third party subclass thereof.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classAbstractTarget<A extends Address>
-
-