Source:
public int authenticate(String[] credentials, boolean isUpdatePasswordRequired) { String username = credentials[0].trim(); String password = credentials[1]; String server = credentials[2]; Context muzimaContext = muzimaApplication.getMuzimaContext(); try { muzimaContext.openSession(); if (!muzimaContext.isAuthenticated()){ if(isUpdatePasswordRequired && !NetworkUtils.isConnectedToNetwork(muzimaApplication)) { return SyncStatusConstants.LOCAL_CONNECTION_ERROR; } else { muzimaContext.authenticate(username, password, server, isUpdatePasswordRequired); } } } catch (ConnectException e) { Log.e(getClass().getSimpleName(), "ConnectException Exception thrown while authentication.", e); return SyncStatusConstants.SERVER_CONNECTION_ERROR; } catch (ParseException e) { Log.e(getClass().getSimpleName(), "ParseException Exception thrown while authentication.", e); return SyncStatusConstants.PARSING_ERROR; } catch (MalformedURLException e) { Log.e(getClass().getSimpleName(), "IOException Exception thrown while authentication.", e); return SyncStatusConstants.MALFORMED_URL_ERROR; } catch (IOException e) { Log.e(getClass().getSimpleName(), "IOException Exception thrown while authentication.", e); return SyncStatusConstants.AUTHENTICATION_ERROR; } catch (AuthenticationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while authentication.", e); return SyncStatusConstants.INVALID_CREDENTIALS_ERROR; } catch (IllegalArgumentException e) { Log.e(getClass().getSimpleName(),"IllegalArgumentException Exception thrown while authenticating.",e); return 0; }finally { if (muzimaContext != null) muzimaContext.closeSession(); } return SyncStatusConstants.AUTHENTICATION_SUCCESS; }

Target:
public int authenticate(String[] credentials, boolean isUpdatePasswordRequired) { String username = credentials[0].trim(); String password = credentials[1]; String server = credentials[2]; Context muzimaContext = muzimaApplication.getMuzimaContext(); try { muzimaContext.openSession(); if (!muzimaContext.isAuthenticated()){ if(isUpdatePasswordRequired && !NetworkUtils.isConnectedToNetwork(muzimaApplication)) { return SyncStatusConstants.LOCAL_CONNECTION_ERROR; } else { muzimaContext.authenticate(username, password, server, isUpdatePasswordRequired); } } } catch (ConnectException e) { Log.e(getClass().getSimpleName(), "ConnectException Exception thrown while authentication.", e); return SyncStatusConstants.SERVER_CONNECTION_ERROR; } catch (ParseException e) { Log.e(getClass().getSimpleName(), "ParseException Exception thrown while authentication.", e); return SyncStatusConstants.PARSING_ERROR; } catch (MalformedURLException e) { Log.e(getClass().getSimpleName(), "IOException Exception thrown while authentication.", e); return SyncStatusConstants.MALFORMED_URL_ERROR; } catch (IOException e) { Log.e(getClass().getSimpleName(), "IOException Exception thrown while authentication.", e); return SyncStatusConstants.AUTHENTICATION_ERROR; } catch (AuthenticationException e) { Log.e(getClass().getSimpleName(), "Exception thrown while authentication.", e); return SyncStatusConstants.INVALID_CREDENTIALS_ERROR; } catch (IllegalArgumentException e) { Log.e(getClass().getSimpleName(),"IllegalArgumentException Exception thrown while authenticating.",e); return SyncStatusConstants.UNKNOWN_ERROR; }finally { if (muzimaContext != null) muzimaContext.closeSession(); } return SyncStatusConstants.AUTHENTICATION_SUCCESS; }