code: public static SecretKey hmacShaKeyFor(byte[] bytes) throws WeakKeyException {
  
          if (bytes == null) {
              throw new InvalidKeyException("SecretKey byte array cannot be null.");
          }
  
          int bitLength = bytes.length * 8;
  
          for (SignatureAlgorithm alg : PREFERRED_HMAC_ALGS) {
              if (bitLength >= alg.getMinKeyLength()) {
                  return new SecretKeySpec(bytes, alg.getJcaName());
              }
          }
  
          String msg = "The specified key byte array is " + bitLength + " bits which " +
              "is not secure enough for any JWT HMAC-SHA algorithm.  The JWT " +
              "JWA Specification (RFC 7518, Section 3.2) states that keys used with HMAC-SHA algorithms MUST have a " +
              "size >= 256 bits (the key size must be greater than or equal to the hash " +
              "output size).  Consider using the " + Keys.class.getName() + "#secretKeyFor(SignatureAlgorithm) method " +
              "to create a key guaranteed to be secure enough for your preferred HMAC-SHA algorithm.  See " +
              "https://tools.ietf.org/html/rfc7518#section-3.2 for more information.";
          throw new WeakKeyException(msg);
      }
docs: Creates a new SecretKey instance for use with HMAC-SHA algorithms based on the specified key byte array.
  
  @param bytes the key byte array
  @return a new SecretKey instance for use with HMAC-SHA algorithms based on the specified key byte array.
  @throws WeakKeyException if the key byte array length is less than 256 bits (32 bytes) as mandated by the
  <a href="https://tools.ietf.org/html/rfc7518#section-3.2">JWT JWA Specification
  (RFC 7518, Section 3.2)</a>