Updated on 2024-06-21 GMT+08:00

Publishing Screens

After a screen is developed, you can share your screen with other users by publishing it.

Publishing Screens

  1. Log in to the DLV console.
  2. On the Screens page, locate the screen to be published and click on the screen.

    Figure 1 Publishing a screen

    You can also click in the upper right corner of the screen development page to publish the screen.

  3. On the displayed page, configure publish parameters.

    Figure 2 Configuring publish parameters

    Publish

    Specifies whether others can share your created screens (see Figure 2). After the screen is published, other users can access the screen without logging in to DLV. They only need to open the browser and enter the shared link in the address box to access the screen.

    Version Management

    Specifies a sharable version.

    • Real-time version: When the current version of screen is modified, users who are sharing it can synchronously use the latest version of screen. It is the default option and cannot be deleted.
    • Historical version: When the current version of screen is modified, users who are sharing it cannot use the latest version of screen but can only use the original one.

    Share Key

    Specifies a screen sharing mode.

    • Public sharing: If a user does not configure password access or token authentication for a screen, the screen is accessed through the shared link. The basic edition of DLV supports only the public sharing mode.
    • Password access: On the Set Access Password tab page, enable password access and set a password. After the password is set successfully, other users need to enter the password when they want to access the screen through the shared link.

      After Validity Period is enabled, you do not need to perform verification again within the validity period after successful verification unless the validity period expires. If this function is disabled, each access requires verification.

      Figure 3 Setting the access password
    • Token access: On the Set Token tab page, enable token verification.

      The system randomly generates a token. You need to record it for future use. After Validity Period is enabled, you do not need to perform verification again within the validity period after successful verification unless the validity period expires. If this function is disabled, each access requires verification.

      Figure 4 Setting a token

      After the token for the screen is generated, you have to perform the following steps before accessing the screen:

      To prevent replay attacks, ensure that your server time is GMT +08:00. DLV allows only one minute difference. If the time difference exceeds one minute, authentication fails.

      1. Publish the screen and record the shared screen code (a character string behind share in the shared link).
      2. Connect the screen code with the current time (millisecond) and separate them with a vertical bar (|).
      3. Use the token to encrypt the character string in 3.b through HMAC-SHA256 base64.
      4. Name the time and the encrypted signature dlv_time and dlv_signature, respectively.
      5. Add them to querystring of the shared link.

      An example is provided as follows:

      Java:

       package com.test;
       import java.security.*;
       import javax.crypto.*;
       import javax.crypto.spec.SecretKeySpec;
       import org.apache.commons.codec.binary.Base64;
       import java.net.URLEncoder;
      
       public class ShareWithTokenTest {
      
           public static void main(String[] args) throws Exception {
               System.out.println(getShareUrlWithToken("********722467a9477b5b*******", "*******r1tyy1C7Jenni3p*********"));
           }
      
           public static String getShareUrlWithToken(String shareID, String token){
               long time = System.currentTimeMillis();
               String data = shareID + "|" + time;
               String signature = HMACSHA256(data.getBytes(), token.getBytes());
               String url = "https://console.huaweicloud.com/dlv/vision/share/?id="+shareID +"&dlv_time="+time+"&dlv_signature="+ signature+"&locale=zh-cn&region=cn-north-4";
               return url;
           }
      
      //Use HmacSHA256 for signature.
           public static String HMACSHA256(byte[] data, byte[] key)
           {
               try  {
                   SecretKeySpec signingKey = new SecretKeySpec(key, "HmacSHA256");
                   Mac mac = Mac.getInstance("HmacSHA256");
                   mac.init(signingKey);
                   return URLEncoder.encode(Base64.encodeBase64String(mac.doFinal(data)));
               } catch (NoSuchAlgorithmException e) {
                   e.printStackTrace();
               } catch (InvalidKeyException e) {
                   e.printStackTrace();
               }
               return null;
           }
       }
    Replace the following parameters in the preceding code based on the site requirements:
    In System.out.println(getShareUrlWithToken("*****3b44722********5b888211bca", "******er1tyy1C7J*******JxeIlPz8P"), *******4722467a9477*******11bca indicates the parameter value following share in the URL, and *****er1tyy1C7******pzJxe***8P indicates the parameter value in the shared key.
    In String url = "https://console.huaweicloud.com/dlv/vision/share/?id="+shareID +"&dlv_time="+time+"&dlv_signature="+ signature+"&locale=zh-cn&region=cn-north-4, locale=zh-cn indicates the language ID, en-us indicates the English language, and region=cn-north-4 indicates the area where the service is deployed.