Module org.snmp4j

Class SecretOctetString

All Implemented Interfaces:
Serializable, Cloneable, Comparable<Variable>, BERSerializable, AssignableFromByteArray, AssignableFromString, Variable

public class SecretOctetString extends OctetString
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.6.1
Author:
Frank Fock
See Also:
  • Constructor Details

    • 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 from rawValueinto the new OctetString.
      length - the number of bytes to be copied.
    • SecretOctetString

      public SecretOctetString()
  • Method Details

    • fromOctetString

      public static SecretOctetString fromOctetString(OctetString octetString)
      Create a SecretOctetString from a OctetString but return null if the given OctetString is null.
      Parameters:
      octetString - an OctetString whose to*String methods needs to be protected against disclosing sensitive information.
      Returns:
      the new SecretOctetString or null.
    • toString

      public String toString()
      Description copied from class: OctetString
      Returns a String representation of this OctetString. If the OctetString contains non-printable characters, a hex-string representation is returned unless SNMP4JSettings.getDefaultNonPrintableEscapeCharacter() returns a non-null character that is then used to replace all non-printable characters in the output.
      Specified by:
      toString in interface Variable
      Overrides:
      toString in class OctetString
      Returns:
      a String representation of this OctetString.
    • toHexString

      public String toHexString()
      Overrides:
      toHexString in class OctetString
    • toHexString

      public String toHexString(char separator)
      Overrides:
      toHexString in class OctetString
    • toString

      public String toString(char separator, int radix)
      Overrides:
      toString in class OctetString
    • toString

      public String toString(int radix)
      Description copied from class: OctetString
      Returns a string representation of this octet string in the radix specified. There will be no separation characters, but each byte will be represented by round(log(256)/log(radix)) digits.
      Overrides:
      toString in class OctetString
      Parameters:
      radix - the radix to use in the string representation.
      Returns:
      a string representation of this ocetet string in the specified radix.