// Path: hack023/src/com/manning/androidhacks/hack023/api/LoginServiceImpl.java
// public class LoginServiceImpl {
// 
//   private static final String TAG = LoginServiceImpl.class.getCanonicalName();
// 
//   public static boolean login(String username, String password)
//       throws AndroidHacksException {
//     String response = sendCredentials(username, password);
//     return hasLoggedIn(response);
//   }
// 
//   public static String sendCredentials(String username,
//       String password) throws AndroidHacksException {
//     String fmt = AndroidHacksUrlFactory.getInstance().getLoginUrlFmt();
//     String url = String.format(fmt, username, password);
//     String ret = HttpHelper.getHttpResponseAsString(url, null);
// 
//     return ret;
//   }
// 
//   public static boolean hasLoggedIn(String response) {
//     Log.d(TAG, "response: " + response);
//     return  "{\"result\": \"ok\"}".equals(response);
//   }
// 
//   public boolean logout() {
//     return false;
//   }
// }
// 
// Path: hack023/src/com/manning/androidhacks/hack023/exception/AndroidHacksException.java
// public class AndroidHacksException extends Exception {
// 
//   private static final long serialVersionUID = 1L;
// 
//   public AndroidHacksException(String msg) {
//     super(msg);
//   }
// 
// }


import com.manning.androidhacks.hack023.api.LoginServiceImpl;
import com.manning.androidhacks.hack023.exception.AndroidHacksException;
import com.manning.androidhacks.hack023.provider.DatabaseHelper;
import com.manning.androidhacks.hack023.provider.TodoContentProvider;
import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
import android.accounts.NetworkErrorException;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;

        return result;
      }
    }
    // Password is missing or incorrect
    final Intent intent = new Intent(mContext,
        AuthenticatorActivity.class);
    intent.putExtra(AuthenticatorActivity.PARAM_USER, account.name);
    intent.putExtra(AuthenticatorActivity.PARAM_AUTHTOKEN_TYPE,
        authTokenType);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE,
        response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
  }

  @Override
  public String getAuthTokenLabel(String authTokenType) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public Bundle hasFeatures(AccountAuthenticatorResponse response,
      Account account, String[] features) throws NetworkErrorException {
    // TODO Auto-generated method stub
    return null;
  }

// Path: hack023/src/com/manning/androidhacks/hack023/api/LoginServiceImpl.java
// public class LoginServiceImpl {
// 
//   private static final String TAG = LoginServiceImpl.class.getCanonicalName();
// 
//   public static boolean login(String username, String password)
//       throws AndroidHacksException {
//     String response = sendCredentials(username, password);
//     return hasLoggedIn(response);
//   }
// 
//   public static String sendCredentials(String username,
//       String password) throws AndroidHacksException {
//     String fmt = AndroidHacksUrlFactory.getInstance().getLoginUrlFmt();
//     String url = String.format(fmt, username, password);
//     String ret = HttpHelper.getHttpResponseAsString(url, null);
// 
//     return ret;
//   }
// 
//   public static boolean hasLoggedIn(String response) {
//     Log.d(TAG, "response: " + response);
//     return  "{\"result\": \"ok\"}".equals(response);
//   }
// 
//   public boolean logout() {
//     return false;
//   }
// }
// 
// Path: hack023/src/com/manning/androidhacks/hack023/exception/AndroidHacksException.java
// public class AndroidHacksException extends Exception {
// 
//   private static final long serialVersionUID = 1L;
// 
//   public AndroidHacksException(String msg) {
//     super(msg);
//   }
// 
// }


// Path: hack023/src/com/manning/androidhacks/hack023/authenticator/Authenticator.java
import com.manning.androidhacks.hack023.api.LoginServiceImpl;
import com.manning.androidhacks.hack023.exception.AndroidHacksException;
import com.manning.androidhacks.hack023.provider.DatabaseHelper;
import com.manning.androidhacks.hack023.provider.TodoContentProvider;
import android.accounts.AbstractAccountAuthenticator;
import android.accounts.Account;
import android.accounts.AccountAuthenticatorResponse;
import android.accounts.AccountManager;
import android.accounts.NetworkErrorException;
import android.content.ContentResolver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;


        return result;
      }
    }
    // Password is missing or incorrect
    final Intent intent = new Intent(mContext,
        AuthenticatorActivity.class);
    intent.putExtra(AuthenticatorActivity.PARAM_USER, account.name);
    intent.putExtra(AuthenticatorActivity.PARAM_AUTHTOKEN_TYPE,
        authTokenType);
    intent.putExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE,
        response);
    final Bundle bundle = new Bundle();
    bundle.putParcelable(AccountManager.KEY_INTENT, intent);
    return bundle;
  }

  @Override
  public String getAuthTokenLabel(String authTokenType) {
    // TODO Auto-generated method stub
    return null;
  }

  @Override
  public Bundle hasFeatures(AccountAuthenticatorResponse response,
      Account account, String[] features) throws NetworkErrorException {
    // TODO Auto-generated method stub
    return null;
  }

  @Override