Example usage for org.apache.http.auth AuthenticationException getLocalizedMessage

List of usage examples for org.apache.http.auth AuthenticationException getLocalizedMessage

Introduction

In this page you can find the example usage for org.apache.http.auth AuthenticationException getLocalizedMessage.

Prototype

public String getLocalizedMessage() 

Source Link

Document

Creates a localized description of this throwable.

Usage

From source file:com.ntsync.android.sync.client.ClientKeyHelper.java

/**
 * Checks if the key-data is ready for sync: Private Key is available for
 * encryption or not another key is already save on the server.
 * /*from  w w  w. ja  v  a  2s  .  c om*/
 * @param context
 * @param account
 * @param am
 * @param authToken
 * @return false is Sync is not ready. Additionally input will be required.
 * @throws AuthenticatorException
 * @throws OperationCanceledException
 */
public static PrivateKeyState isReadyForSync(Context context, Account account, AccountManager am,
        String authToken) throws OperationCanceledException {
    SecretKey key = getPrivateKey(account, am);
    PrivateKeyState state = PrivateKeyState.READY;
    if (key == null || !ClientKeyHelper.isSaltSaved(account, am)) {
        try {
            // Check ob PwdSalt von einem anderen Client vorhanden
            // ist
            byte[] saltPwdCheck = NetworkUtilities.getKeySalt(context, account.name, authToken);
            if (saltPwdCheck != null && saltPwdCheck.length > SALT_LENGHT) {
                // Ein Key ist bereits vorhanden -> Key muss eingegeben
                // werden.
                state = PrivateKeyState.MISSING_KEY;
                state.setCurrSalt(saltPwdCheck);
            }
        } catch (AuthenticationException e) {
            Log.w(TAG, "Check for PwdSalt failed with Authentification error", e);
            am.invalidateAuthToken(Constants.ACCOUNT_TYPE, authToken);
            state = PrivateKeyState.AUTH_FAILED;
        } catch (NetworkErrorException e) {
            Log.w(TAG, "Check for PwdSalt failed with NetworkErrorException.", e);
            state = PrivateKeyState.NETWORK_ERROR;
            state.setErrorMsg(e.getLocalizedMessage());
        } catch (ServerException e) {
            Log.w(TAG, "Check for PwdSalt failed with ServerError.", e);
            state = PrivateKeyState.CHECK_FAILED;
        }
    }
    return state;
}

From source file:at.ac.tuwien.detlef.gpodder.SyncEpisodeActionsAsyncTask.java

@Override
public void run() {
    Context context = Detlef.getAppContext();

    /* Retrieve settings.*/
    GpodderSettings gps = Singletons.i().getGpodderSettings();

    DeviceId devId = gps.getDeviceId();/*  www .  j av  a  2s. c o  m*/
    if (devId == null) {
        sendError(context.getString(R.string.no_gpodder_account_configured));
        return;
    }
    String username = gps.getUsername();
    String password = gps.getPassword();

    MygPodderClient gpc = new MygPodderClient(username, password, gps.getApiHostname());

    EpisodeActionChanges changes = null;
    try {
        /* Send our episode actions */
        EpisodeActionDAO eaDao = Singletons.i().getEpisodeActionDAO();
        List<RemoteEpisodeAction> localChanges = eaDao.getAllEpisodeActions();

        List<EpisodeAction> sndLocalChanges = new ArrayList<EpisodeAction>(localChanges.size());
        for (EpisodeAction a : localChanges) {
            sndLocalChanges.add(a);
        }

        long since = gpc.uploadEpisodeActions(sndLocalChanges);

        /* Get episode actions. */
        changes = gpc.downloadEpisodeActions(gps.getLastEpisodeActionUpdate());

        applyActionChanges(Detlef.getAppContext(), changes);

        /* Sadly, changes.since is always 0, hence we can't use it to fetch new
         * episode actions. So we use the timestamp returned by the upload. */
        gps.setLastEpisodeActionUpdate(since);

        Singletons.i().getGpodderSettingsDAO().writeSettings(gps);

    } catch (AuthenticationException e) {
        sendError(e.getLocalizedMessage());
    } catch (ClientProtocolException e) {
        sendError(e.getLocalizedMessage());
    } catch (IOException e) {
        sendError(e.getLocalizedMessage());
    }

    if (changes == null) {
        return;
    }

    /* Tell receiver we're done.. */
    callback.sendEvent(new NoDataResultHandler.NoDataSuccessEvent(callback));
}