7.12 ProviderLogin

In the Limax framework, the Provider provides the service for the applications. In some application scenarios, there is a requirement that Endpoint switches Provider, carring the specific Session data from the source Provider and delivering to the destiontion Provider, which essentially is Session migration. Using the ProviderLogin mechanism, the source Session data is safely transferred to the destiontion Provider before the destiontion Provider creates the Session, which greatly simplifies the development of Session migration applications.


  • 7.12.1 Fundamental

    • Process considerations

      The usual login process is:

      1. The Endpoint connects to the Switcher, and initiates a login request, which contains all the Providers that needs to be accessed.

      2. The Switcher forwards the login request to Auany.

      3. After obtaining the Auany authorization, the Switcher issues an online notification to all the requesting Providers.

      4. The Provider which receives the online notification sends an OK reponse to Switcher after successfully initiating the Session.

      5. The Switcher collects the response sent from the Provider, and sends the online notification to the Endpoint if all the response is OK.


      The ProviderLogin mechanism extends the step 3 of the login process. After obtaining the Auany authorization, the Switcher determines whether the requesting Provider needs the LoginData one by one. If necessary, the Switcher queries LoginData from Endpoint, then sends the online notification to Provider, attaching the LoginData.


    • Safety considerations

      There are two forms of LoginData, safe and unsafe.

      1. The tunnel data sent from the same trusted Provider can be used to create safe LoginData, including label and data. Please refer "Data exchange between Providers" for the detail.

      2. The data specified by the application by other means can only create unsafe LoginData.


  • 7.12.2 Server development


    When implementing limax.provider.ProviderListener, the Provider implements limax.provider.LoginDataSupport interface at the same time.


    public interface LoginDataSupport {
    }
    

    The LoginData interface is only a label interface, and does not need to implement any method. When connecting to the Switcher, the Provider which implements this interface will report the Switcher that this Provider requires LoginData.


    In the source code of ProviderListener.onTransportAdded method, the LoginData can be obtained from Transport.


    @Override
    public void onTransportAdded(Transport transport) throws Exception {
        ProviderTransport pt = (ProviderTransport) transport;
        LoginData loginData = pt.getLoginData();
        String message;
        if (loginData != null) {
            if (loginData.isSafe())
                message = "SAFE LoginData " + loginData.getLabel() + " " + Helper.toHexString(loginData.getData().getBytes());
            else
                message = "UNSAFE LoginData " + Helper.toHexString(loginData.getData().getBytes());
        } else
            message = "NO LoginData";
        System.out.println(message);
    }
    

    It should be decided by application itself whether it is error that the returned LoginData is null, if the Provider needs LoginData and the client side does not provide, and the network connection of client can be closed through throwing exception. It should be noted that after onTransportAdded, the LoginData stored on Transport is cleared immediately; the reason is that the potentially large amount of LoginData data will waste the memory space if the application forgets to clear.


  • 7.12.3 Client development

    • All clients except HTML5

      Use limax.endpoint.ProviderLoginDataManager to organize LoginData, and provide 3 add methods.


      void add(int pvid, Octets unsafedata);
      void add(int pvid, int label, Octets data);
      void add(int pvid, int label, String data);
      

      The meothod without using label indicates that the unsafe LoginData is provided. The add method with a String parameter is used to create the tunnel data of LoginData which comes from script system.

      If the string is expected as unsafe LoginData, the Octets can be encoded as UTF8 format and then add, and the server uses UTF8 to decode, which is helpful to get the best compatibility.


      Use static create-method with ProviderLoginDataManager parameter of LoginConfig to create login info.


    • HTML5 client

      The login parameter object is defined as follows.


      var login = {
          scheme : 'ws',
          host : '127.0.0.1:10001',
          username : 'testabc',
          token : '123456',
          platflag : 'test',
          pvids : [100],
          logindatas : {
              100 : {
                  data : 'unsafedata' 
              },
              101 : {
                  label : 0,
                  data : <base64tunneldatastring>   
              }
          }
      }
      var connector = WebSocketConnector(limax, login);
      
      

Prev Next