test_class.declarator: mSessionManager
test_class.modifier: private
test_class.original_string: private HaloSessionManager mSessionManager;
test_class.type: HaloSessionManager
test_class.var_name: mSessionManager
test_class.declarator: mFramework
test_class.modifier: private
test_class.original_string: private HaloFramework mFramework;
test_class.type: HaloFramework
test_class.var_name: mFramework
test_class.declarator: mAuthenticator
test_class.modifier: private
test_class.original_string: private HaloAuthenticator mAuthenticator;
test_class.type: HaloAuthenticator
test_class.var_name: mAuthenticator
test_class.declarator: mHalo
test_class.modifier: private
test_class.original_string: private Halo mHalo;
test_class.type: Halo
test_class.var_name: mHalo
test_class.declarator: mMockServer
test_class.modifier: private
test_class.original_string: private MockServer mMockServer;
test_class.type: MockServer
test_class.var_name: mMockServer
test_class.declarator: mCallbackFlag
test_class.modifier: private
test_class.original_string: private CallbackFlag mCallbackFlag;
test_class.type: CallbackFlag
test_class.var_name: mCallbackFlag
test_class.file: sdk/halo-sdk/src/test/java/com/mobgen/halo/android/sdk/core/management/authentication/HaloAuthenticatorTest.java
test_class.identifier: HaloAuthenticatorTest
test_class.superclass: extends HaloRobolectricTest
test_case.body: @Test
      public void thatRenewTokenIsNotCalledToAvoidLoopWithClientToken() throws IOException {
          enqueueServerError(mMockServer, 401);
          Response response = givenA401ClientTokenResponse();
          Request newRequest = mAuthenticator.authenticate(null, response);
          assertThat(newRequest).isNull();
      }
test_case.class_method_signature: HaloAuthenticatorTest.thatRenewTokenIsNotCalledToAvoidLoopWithClientToken()
test_case.full_signature: @Test public void thatRenewTokenIsNotCalledToAvoidLoopWithClientToken()
test_case.identifier: thatRenewTokenIsNotCalledToAvoidLoopWithClientToken
test_case.invocations: enqueueServerError givenA401ClientTokenResponse authenticate isNull assertThat
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void thatRenewTokenIsNotCalledToAvoidLoopWithClientToken()
focal_class.declarator: HALO_SESSION_NAME = "halo-session"
focal_class.modifier: @Keep
      public static final
focal_class.original_string: @Keep
      public static final String HALO_SESSION_NAME = "halo-session";
focal_class.type: String
focal_class.var_name: HALO_SESSION_NAME
focal_class.declarator: AUTHENTICATION_HEADER = "Authorization"
focal_class.modifier: public static final
focal_class.original_string: public static final String AUTHENTICATION_HEADER = "Authorization";
focal_class.type: String
focal_class.var_name: AUTHENTICATION_HEADER
focal_class.declarator: mSessionManager
focal_class.modifier: @NonNull
      private
focal_class.original_string: @NonNull
      private HaloSessionManager mSessionManager;
focal_class.type: HaloSessionManager
focal_class.var_name: mSessionManager
focal_class.declarator: mFramework
focal_class.modifier: @NonNull
      private final
focal_class.original_string: @NonNull
      private final HaloFramework mFramework;
focal_class.type: HaloFramework
focal_class.var_name: mFramework
focal_class.declarator: mClientCredentials
focal_class.modifier: private
focal_class.original_string: private Credentials mClientCredentials;
focal_class.type: Credentials
focal_class.var_name: mClientCredentials
focal_class.declarator: mUserCredentials
focal_class.modifier: private
focal_class.original_string: private Credentials mUserCredentials;
focal_class.type: Credentials
focal_class.var_name: mUserCredentials
focal_class.declarator: mManagementApi
focal_class.modifier: private
focal_class.original_string: private HaloManagerApi mManagementApi;
focal_class.type: HaloManagerApi
focal_class.var_name: mManagementApi
focal_class.declarator: mAuthenticationRecover
focal_class.modifier: private
focal_class.original_string: private AuthenticationRecover mAuthenticationRecover;
focal_class.type: AuthenticationRecover
focal_class.var_name: mAuthenticationRecover
focal_class.file: sdk/halo-sdk/src/main/java/com/mobgen/halo/android/sdk/core/management/authentication/HaloAuthenticator.java
focal_class.identifier: HaloAuthenticator
focal_class.interfaces: implements Authenticator
focal_class.class_method_signature: HaloAuthenticator.HaloAuthenticator(@NonNull HaloFramework framework,
                               @NonNull HaloManagerApi managerApi,
                               @NonNull HaloSessionManager sessionManager,
                               @NonNull Credentials credentials)
focal_class.full_signature: public  HaloAuthenticator(@NonNull HaloFramework framework,
                               @NonNull HaloManagerApi managerApi,
                               @NonNull HaloSessionManager sessionManager,
                               @NonNull Credentials credentials)
focal_class.identifier: HaloAuthenticator
focal_class.modifiers: public
focal_class.parameters: (@NonNull HaloFramework framework,
                               @NonNull HaloManagerApi managerApi,
                               @NonNull HaloSessionManager sessionManager,
                               @NonNull Credentials credentials)
focal_class.signature:  HaloAuthenticator(@NonNull HaloFramework framework,
                               @NonNull HaloManagerApi managerApi,
                               @NonNull HaloSessionManager sessionManager,
                               @NonNull Credentials credentials)
focal_class.class_method_signature: HaloAuthenticator.authenticate(Route route, Response response)
focal_class.full_signature: @Override public synchronized Request authenticate(Route route, Response response)
focal_class.identifier: authenticate
focal_class.modifiers: @Override public synchronized
focal_class.parameters: (Route route, Response response)
focal_class.return: Request
focal_class.signature: Request authenticate(Route route, Response response)
focal_class.class_method_signature: HaloAuthenticator.setAuthenticationRecover(@NonNull AuthenticationRecover authenticationRecover)
focal_class.full_signature: public void setAuthenticationRecover(@NonNull AuthenticationRecover authenticationRecover)
focal_class.identifier: setAuthenticationRecover
focal_class.modifiers: public
focal_class.parameters: (@NonNull AuthenticationRecover authenticationRecover)
focal_class.return: void
focal_class.signature: void setAuthenticationRecover(@NonNull AuthenticationRecover authenticationRecover)
focal_class.class_method_signature: HaloAuthenticator.getAuthenticationRecover()
focal_class.full_signature: @Nullable public AuthenticationRecover getAuthenticationRecover()
focal_class.identifier: getAuthenticationRecover
focal_class.modifiers: @Nullable public
focal_class.parameters: ()
focal_class.return: AuthenticationRecover
focal_class.signature: AuthenticationRecover getAuthenticationRecover()
focal_class.class_method_signature: HaloAuthenticator.requestToken()
focal_class.full_signature: private Token requestToken()
focal_class.identifier: requestToken
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Token
focal_class.signature: Token requestToken()
focal_class.class_method_signature: HaloAuthenticator.attachToFramework()
focal_class.full_signature: private void attachToFramework()
focal_class.identifier: attachToFramework
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void attachToFramework()
focal_class.class_method_signature: HaloAuthenticator.setCredentials(@NonNull Credentials credentials)
focal_class.full_signature: public synchronized void setCredentials(@NonNull Credentials credentials)
focal_class.identifier: setCredentials
focal_class.modifiers: public synchronized
focal_class.parameters: (@NonNull Credentials credentials)
focal_class.return: void
focal_class.signature: void setCredentials(@NonNull Credentials credentials)
focal_class.class_method_signature: HaloAuthenticator.logout()
focal_class.full_signature: public void logout()
focal_class.identifier: logout
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void logout()
focal_class.class_method_signature: HaloAuthenticator.getCredentials()
focal_class.full_signature: @NonNull public synchronized Credentials getCredentials()
focal_class.identifier: getCredentials
focal_class.modifiers: @NonNull public synchronized
focal_class.parameters: ()
focal_class.return: Credentials
focal_class.signature: Credentials getCredentials()
focal_class.class_method_signature: HaloAuthenticator.flushSession()
focal_class.full_signature: public void flushSession()
focal_class.identifier: flushSession
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void flushSession()
focal_class.class_method_signature: HaloAuthenticator.getSessionManager()
focal_class.full_signature: public HaloSessionManager getSessionManager()
focal_class.identifier: getSessionManager
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: HaloSessionManager
focal_class.signature: HaloSessionManager getSessionManager()
focal_method.body: @Override
      public synchronized Request authenticate(Route route, Response response) throws IOException {
          HaloSession session = mSessionManager.getSession(HALO_SESSION_NAME);
          try {
              if (session == null || session.isSessionExpired() || session.mayBeServerExpired()) {
                  flushSession();
                  //Do auth
                  Token token = null;
                  if (!response.request().url().toString().endsWith(TokenRemoteDatasource.URL_GET_CLIENT_TOKEN) &&
                          !response.request().url().toString().endsWith(TokenRemoteDatasource.URL_GET_USER_TOKEN)) {
                      //request app token
                      token = requestToken();
                      if (token != null) {
                          session = new Session(token);
                      }
                  }
              }
          } catch (Exception e) {
              Halog.e(getClass(), "The token could not be obtained. " + e.getMessage());
              throw e;
          }
  
          //The request authentication finished successfully
          if (session != null) {
              //check if its a client based login to recover account
              if(getCredentials().getLoginType()==Credentials.CLIENT_BASED_LOGIN) {
                  //recover from logged user if there is a halo auth api
                  if (mAuthenticationRecover != null && !mAuthenticationRecover.recoverStatus()) {
                      mAuthenticationRecover.recoverAccount();
                  }
              }
              //Store the session
              mSessionManager.setSession(HALO_SESSION_NAME, session);
              return response.request()
                      .newBuilder()
                      .header(AUTHENTICATION_HEADER, session.getSessionAuthentication())
                      .build();
          }
          //Do not reconnect, we can not authenticate with the current token
          return null;
      }
focal_method.class_method_signature: HaloAuthenticator.authenticate(Route route, Response response)
focal_method.full_signature: @Override public synchronized Request authenticate(Route route, Response response)
focal_method.identifier: authenticate
focal_method.invocations: getSession isSessionExpired mayBeServerExpired flushSession endsWith toString url request endsWith toString url request requestToken e getClass getMessage getLoginType getCredentials recoverStatus recoverAccount setSession build header newBuilder request getSessionAuthentication
focal_method.modifiers: @Override public synchronized
focal_method.parameters: (Route route, Response response)
focal_method.return: Request
focal_method.signature: Request authenticate(Route route, Response response)