Updated on 2022-08-16 GMT+08:00

Login Authentication

Function

Implement basic authentication for login and return the HTTP client after login.

Prerequisites

User cluster information and login account have been configured.

  • Configuration file: Sample project folder\conf\UserInfo.properties
  • Parameters:
    • userName: username for logging in to FusionInsight Manager.
    • password: password of the username.
    • webUrl: address of the Manager home page.

    In the following example, IP_Address indicates the floating IP address of the cluster.

    If you want to use another user to perform operations, you need log in to FusionInsight Manager to create a user.

    userName= admin 
    password= adminPassWord 
    webUrl= https://IP_Address:28443/web/

Example code

The following provides an example code of invoking the firstAccess interface to perform login authentication, which is included in the main method of the rest.UserManager class.

   BasicAuthAccess authAccess = new BasicAuthAccess(); 
   HttpClient httpClient = authAccess.loginAndAccess(webUrl, userName, password, userTLSVersion); 
   LOG.info("Start to access REST API."); 
   HttpManager httpManager = new HttpManager(); 
   String operationName = ""; 
   String operationUrl = ""; 
   String jsonFilePath = "";