Class DeviceParameter

java.lang.Object
com.iizix.device.DeviceParameter
Direct Known Subclasses:
DeviceAutoSignIn

public sealed class DeviceParameter extends Object permits DeviceAutoSignIn
Class used to send parameters between the server and the client. Support for sensitive information by means of encryption is supported. Parameters that are sensitive are stored in a secure space on the client side.

This class is not thread safe and gets the value and state updated in calls to the method to set to retrieve parameters.

Valid parameter name

The valid name of a device parameter are the characters A-Z, a-z, 0-9 and any of the following characters !#$%&*+-^_`|~. Please note that the single or double-quotes are not allowed. The name must start with a character A-Z, a-z or 0-9. The name must also have a length of 1 to 64 characters.

Author:
Christopher Mindus
  • Constructor Details

    • DeviceParameter

      public DeviceParameter(String name)
      Constructs a normal (unsecured) parameter to retrieve, set or remove from the client depending on if the getValue() is null. Default value is null and is generally used when retrieving the parameter.
      Parameters:
      name - The parameter name, see Valid parameter name.
      Throws:
      NullPointerException - If the name is null.
      IllegalArgumentException - If the name is not valid.
    • DeviceParameter

      public DeviceParameter(String name, boolean isSensitive)
      Constructs a secured (or sensitive) parameter to retrieve, set or remove from the client depending on if the getValue() is null. Default value is null and is generally used when retrieving the parameter.
      Parameters:
      name - The parameter name, see Valid parameter name.
      isSensitive - Flag indicating the value is a sensitive value, i.e. it must be encrypted and saved securely.
      Throws:
      NullPointerException - If the name is null.
      IllegalArgumentException - If the name is not valid.
    • DeviceParameter

      public DeviceParameter(String name, String value)
      Constructs a normal (unsecured) parameter to retrieve, set or remove from the client depending on if the value is null.
      Parameters:
      name - The parameter name, see Valid parameter name.
      value - The value, null if it the device parameter should be removed.
      Throws:
      NullPointerException - If the name is null.
      IllegalArgumentException - If the name is not valid.
    • DeviceParameter

      public DeviceParameter(String name, String value, boolean isSensitive)
      Constructs a secured (or sensitive) parameter to retrieve, set or remove from the client depending on if the value is null.
      Parameters:
      name - The parameter name, see Valid parameter name.
      value - The value, null if it the device parameter should be removed.
      isSensitive - Flag indicating the value is a sensitive value, i.e. it must be encrypted and saved securely.
      Throws:
      NullPointerException - If the name is null.
      IllegalArgumentException - If the name is not valid.
    • DeviceParameter

      public DeviceParameter(String name, String value, boolean isSensitive, DeviceParameter.State state)
      Constructs a secured (or sensitive) parameter to retrieve, set or remove from the client depending on if the value is null.
      Parameters:
      name - The parameter name must be a valid Atom name without leading '$' or '-'.
      value - The value, null to remove it.
      isSensitive - Flag indicating the value is a sensitive value, i.e. it must be encrypted and saved securely.
      Throws:
      IllegalArgumentException - If the name is not valid.
  • Method Details

    • getName

      public String getName()
      Gets the name of the device parameter.
      Returns:
      The name.
    • isSensitive

      public final boolean isSensitive()
      Flag for sensitive value, i.e. it must be encrypted and saved securely.
      Returns:
      true if the value is encrypted with device exchanges, false otherwise.
    • setValue

      public final void setValue(String value, DeviceParameter.State state)
      Assigns the value and the state.
      Parameters:
      value - The value, null if it the device parameter should be removed.
      state - The new state.
    • setState

      public final void setState(DeviceParameter.State state)
      Assigns the state.
      Parameters:
      state - The new state.
    • getValue

      public final String getValue()
      Gets the value.
      Returns:
      The value, null if removed.
    • getState

      public final DeviceParameter.State getState()
      Gets the state of the device parameter.
      Returns:
      The state.
    • equals

      public final boolean equals(Object o)
      Checks if two parameters are equal. The state is not used in the comparison.
      Overrides:
      equals in class Object
      Parameters:
      o - Object to compare with.
      Returns:
      true if equal, false otherwise.
    • hashCode

      public final int hashCode()
      Hash code.
      Overrides:
      hashCode in class Object
      Returns:
      Returns the hash code.
    • toString

      public final String toString()
      Outputs a debug string.
      Overrides:
      toString in class Object
      Returns:
      String as com.iizix.gyro.DeviceParameter[name=NN,value=VV[,sensitive],state=SS]