- java.lang.Object
-
- org.snmp4j.smi.AbstractVariable
-
- org.snmp4j.smi.OctetString
-
- org.snmp4j.security.SecretOctetString
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Comparable<Variable>,BERSerializable,AssignableFromByteArray,AssignableFromString,Variable
public class SecretOctetString extends OctetString
TheSecretOctetStringis anOctetStringfor secret data like keys and passwords. It behaves like a regularOctetStringexcept that thetoString()method does not reveal any security information but returns aAuthHMAC192SHA256hash of the real security information.- Since:
- 3.6.1
- Version:
- 3.6.1
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static AuthHMAC192SHA256digesterprivate static longserialVersionUID-
Fields inherited from class org.snmp4j.smi.AbstractVariable
SMISYNTAXES_PROPERTIES
-
-
Constructor Summary
Constructors Constructor Description SecretOctetString()SecretOctetString(byte[] rawValue)SecretOctetString(byte[] rawValue, int offset, int length)Creates an octet string from an byte array.SecretOctetString(OctetString secret)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static SecretOctetStringfromOctetString(OctetString octetString)private java.lang.StringgetDigest()java.lang.StringtoHexString()java.lang.StringtoHexString(char separator)java.lang.StringtoString()Returns a String representation of thisOctetString.java.lang.StringtoString(char separator, int radix)java.lang.StringtoString(int radix)Returns a string representation of this octet string in the radix specified.-
Methods inherited from class org.snmp4j.smi.OctetString
append, append, append, append, clear, clone, 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, toSubIndex
-
Methods inherited from class org.snmp4j.smi.AbstractVariable
createFromBER, createFromSyntax, equal, getSyntaxFromString, getSyntaxString, getSyntaxString, isDynamic, isException
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
digester
private static final AuthHMAC192SHA256 digester
-
-
Constructor Detail
-
SecretOctetString
public SecretOctetString(OctetString secret)
-
SecretOctetString
public SecretOctetString(byte[] rawValue)
-
SecretOctetString
public SecretOctetString(byte[] rawValue, int offset, int length)Creates an octet string from an 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 Detail
-
fromOctetString
public static SecretOctetString fromOctetString(OctetString octetString)
- Parameters:
octetString- anOctetStringwhoseto*Stringmethods needs to be protected against disclosing sensitive information.- Returns:
- the new
SecretOctetStringornull.
-
toString
public java.lang.String 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.
-
getDigest
private java.lang.String getDigest()
-
toHexString
public java.lang.String toHexString()
- Overrides:
toHexStringin classOctetString
-
toHexString
public java.lang.String toHexString(char separator)
- Overrides:
toHexStringin classOctetString
-
toString
public java.lang.String toString(char separator, int radix)- Overrides:
toStringin classOctetString
-
toString
public java.lang.String toString(int radix)
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.
-
-