public class SecurityProtocols extends Object implements Serializable
SecurityProtocols class holds all authentication and
privacy protocols for a SNMP entity.
To register security protocols other than the default, set the system
property SECURITY_PROTOCOLS_PROPERTIES to a customized version
of the SecurityProtocols.properties file. The path has to
be specified relatively to this class.
| Modifier and Type | Field and Description |
|---|---|
static String |
SECURITY_PROTOCOLS_PROPERTIES |
| Modifier | Constructor and Description |
|---|---|
protected |
SecurityProtocols() |
| Modifier and Type | Method and Description |
|---|---|
void |
addAuthenticationProtocol(AuthenticationProtocol auth)
Add the given
AuthenticationProtocol. |
SecurityProtocols |
addDefaultProtocols()
Add the default SecurityProtocols.
|
void |
addPrivacyProtocol(PrivacyProtocol priv)
Add the given
PrivacyProtocol. |
AuthenticationProtocol |
getAuthenticationProtocol(OID id)
Get the
AuthenticationProtocol with the given ID. |
static SecurityProtocols |
getInstance()
Get an instance of class SecurityProtocols.
|
int |
getMaxAuthDigestLength()
Gets the maximum authentication key length of the all known
authentication protocols.
|
int |
getMaxPrivDecryptParamsLength()
Gets the maximum privacy key length of the currently known
privacy protocols.
|
PrivacyProtocol |
getPrivacyProtocol(OID id)
Get the PrivacyProtocol with the given ID.
|
byte[] |
passwordToKey(OID authProtocolID,
OctetString passwordString,
byte[] engineID)
Generates the localized key for the given password and engine id for the
authentication protocol specified by the supplied OID.
|
byte[] |
passwordToKey(OID privProtocolID,
OID authProtocolID,
OctetString passwordString,
byte[] engineID)
Generates the localized key for the given password and engine id for the
privacy protocol specified by the supplied OID.
|
void |
removeAuthenticationProtocol(AuthenticationProtocol auth)
Remove the given
AuthenticationProtocol. |
void |
removePrivacyProtocol(PrivacyProtocol priv)
Remove the given
PrivacyProtocol. |
static void |
setSecurityProtocols(SecurityProtocols securityProtocols)
Set the
SecurityProtocols |
byte[] |
truncateKey(byte[] key,
int maxKeyLength)
Limits the supplied key value to the specified maximum length
|
public static final String SECURITY_PROTOCOLS_PROPERTIES
public static SecurityProtocols getInstance()
public static void setSecurityProtocols(SecurityProtocols securityProtocols)
SecurityProtocolssecurityProtocols - SecurityProtocolspublic SecurityProtocols addDefaultProtocols()
InternalError - if SNMP4JSettings.isExtensibilityEnabled() is true
and corresponding properties file with the security protocols configuration cannot be opened/read.public void addAuthenticationProtocol(AuthenticationProtocol auth)
AuthenticationProtocol. If an authentication protocol
with the supplied ID already exists, the supplied authentication protocol
will not be added and the security protocols will not be unchang.auth - the AuthenticationProtocol to add (an existing authentication protcol
with auth's ID remains unchanged).public AuthenticationProtocol getAuthenticationProtocol(OID id)
AuthenticationProtocol with the given ID.id - The unique ID (specified as OID) of the AuthenticationProtocol.public void removeAuthenticationProtocol(AuthenticationProtocol auth)
AuthenticationProtocol.auth - The protocol to removepublic void addPrivacyProtocol(PrivacyProtocol priv)
PrivacyProtocol. If a privacy protocol
with the supplied ID already exists, the supplied privacy protocol
will not be added and the security protocols will not be changed.priv - the PrivacyProtocol to add (an existing privacy protcol
with priv's ID remains unchanged).public PrivacyProtocol getPrivacyProtocol(OID id)
id - The unique ID (specified as OID) of the PrivacyProtocol.PrivacyProtocol object if it was added before,
or null if not.public void removePrivacyProtocol(PrivacyProtocol priv)
PrivacyProtocol.priv - The protocol to removepublic byte[] passwordToKey(OID authProtocolID, OctetString passwordString, byte[] engineID)
authProtocolID - an OID identifying the authentication protocol to
use.passwordString - the authentication pass phrase.engineID - the engine ID of the authoritative engine.public byte[] passwordToKey(OID privProtocolID, OID authProtocolID, OctetString passwordString, byte[] engineID)
privProtocolID - an OID identifying the privacy protocol the key should
be created for.authProtocolID - an OID identifying the authentication protocol to use.passwordString - the authentication pass phrase.engineID - the engine ID of the authoritative engine.public int getMaxAuthDigestLength()
SecurityProtocols
instance.public int getMaxPrivDecryptParamsLength()
SecurityProtocols
instance.public byte[] truncateKey(byte[] key,
int maxKeyLength)
key - the key to truncate.maxKeyLength - the maximum length of the returned key.min(key.length, maxKeyLength).Copyright © 2016 SNMP4J.org. All Rights Reserved.