Class Auth


  • public class Auth
    extends Object
    Class contains helper methods for authenticating to a BUS OpenWebNet gateway using a numeric (OPEN) or alphanumeric (HMAC) password. Encoding algorithm for OPEN numeric password can be found at this link: https://rosettacode.org/wiki/OpenWebNet_Password#JavaScript HMAC authentication algorithm can be found at this Legrand/BTicino link: https://developer.legrand.com/documentation/open-web-net-for-myhome/
    Author:
    M. Valla - Initial contribution
    • Constructor Detail

      • Auth

        public Auth()
    • Method Detail

      • digitToHex

        protected static String digitToHex​(String digits)
        Convert [0-9] digits string to hex string
        Parameters:
        digits - string to convert
        Returns:
        hex string
      • hexToDigit

        protected static String hexToDigit​(String hexString)
        Convert hex string to [0-9] digits string
        Parameters:
        hexString - string to convert
        Returns:
        digits string
      • bytesToHex

        protected static String bytesToHex​(byte[] bytes)
        Convert bytes array to hex string
        Parameters:
        bytes - array to convert
        Returns:
        hex string
      • calcHmacRb

        protected static String calcHmacRb()
        Generate Rb HMAC random hex string from: key=timeMSEC_SINCE_EPOCH using SHA-256
        Returns:
        the generated Rb HMAC
      • calcSHA256

        protected static String calcSHA256​(String message)
        Return SHA-256 hash of the input string
        Parameters:
        message - string to hash
        Returns:
        the hash string
      • calcOpenPass

        protected static String calcOpenPass​(String pass,
                                             String nonce)
        Encodes a numeric OPEN password
        Parameters:
        pass - numeric password to encode
        nonce - received from the gateway
        Returns:
        the encoded password