Class SecretOctetString
java.lang.Object
org.snmp4j.smi.AbstractVariable
org.snmp4j.smi.OctetString
org.snmp4j.security.SecretOctetString
- All Implemented Interfaces:
Serializable, Cloneable, Comparable<Variable>, BERSerializable, AssignableFromByteArray, AssignableFromString, Variable
The
SecretOctetString is an OctetString for secret data like keys and passwords.
It behaves like a regular OctetString except that the toString() method
does not reveal any security information but returns a AuthHMAC192SHA256 hash of the real
security information.- Since:
- 3.6.1
- Version:
- 3.12.2
- Author:
- Frank Fock
- See Also:
-
Field Summary
Fields inherited from class AbstractVariable
SMISYNTAXES_PROPERTIES -
Constructor Summary
ConstructorsConstructorDescriptionSecretOctetString(byte[] rawValue) SecretOctetString(byte[] rawValue, int offset, int length) Creates an octet string from a byte array.SecretOctetString(OctetString secret) -
Method Summary
Modifier and TypeMethodDescriptionclone()Creates a copy of thisSecretOctetString.static SecretOctetStringfromOctetString(OctetString octetString) toHexString(char separator) toString()Returns a String representation of thisOctetString.toString(char separator, int radix) toString(int radix) Returns a string representation of this octet string in the radix specified.Methods inherited from class OctetString
append, append, append, append, clear, compareTo, decodeBER, encodeBER, equals, equalsValue, fromByteArray, fromCharArray, fromCharArray, fromHexString, fromHexString, fromHexStringPairs, fromIndex, fromString, fromString, fromString, fromSubIndex, get, getBERLength, getBERPayloadLength, getSyntax, getValue, hashCode, isPrintable, length, mask, set, setValue, setValue, split, startsWith, substring, toASCII, toByteArray, toByteArray, toInt, toLong, toSubIndexMethods inherited from class AbstractVariable
createFromBER, createFromSyntax, equal, getSyntaxFromString, getSyntaxFromStringOrNull, getSyntaxString, getSyntaxString, isDynamic, isException
-
Constructor Details
-
SecretOctetString
-
SecretOctetString
public SecretOctetString(byte[] rawValue) -
SecretOctetString
public SecretOctetString(byte[] rawValue, int offset, int length) Creates an octet string from a byte array.- Parameters:
rawValue- an array of bytes.offset- the position (zero-based) of the first byte to be copied fromrawValueinto the newOctetString.length- the number of bytes to be copied.
-
SecretOctetString
public SecretOctetString()
-
-
Method Details
-
fromOctetString
- Parameters:
octetString- anOctetStringwhoseto*Stringmethods needs to be protected against disclosing sensitive information.- Returns:
- the new
SecretOctetStringornull.
-
clone
Creates a copy of thisSecretOctetString. This override is required so that the secret nature of the value is preserved when the value is cloned, for example byVariableBinding.setVariable(org.snmp4j.smi.Variable). Without it, the inheritedOctetString.clone()would return a plainOctetStringand any downstreaminstanceof SecretOctetStringchecks (e.g. transparent encryption on persistent storage) would no longer recognize the value as a secret.- Specified by:
clonein interfaceVariable- Overrides:
clonein classOctetString- Returns:
- a new
SecretOctetStringwith the same value as this one. - Since:
- 3.12.2
-
toString
Description copied from class:OctetStringReturns a String representation of thisOctetString. If theOctetStringcontains non-printable characters, a hex-string representation is returned unlessSNMP4JSettings.getDefaultNonPrintableEscapeCharacter()returns a non-nullcharacter that is then used to replace all non-printable characters in the output.- Specified by:
toStringin interfaceVariable- Overrides:
toStringin classOctetString- Returns:
- a String representation of this
OctetString.
-
toHexString
- Overrides:
toHexStringin classOctetString
-
toHexString
- Overrides:
toHexStringin classOctetString
-
toString
- Overrides:
toStringin classOctetString
-
toString
Description copied from class:OctetStringReturns a string representation of this octet string in the radix specified. There will be no separation characters, but each byte will be represented byround(log(256)/log(radix))digits.- Overrides:
toStringin classOctetString- Parameters:
radix- the radix to use in the string representation.- Returns:
- a string representation of this ocetet string in the specified radix.
-