private VAccount getAccount(int userId, Account account) { return this.getAccount(userId, account.name, account.type); }
@Override public final String getPreviousName(int userId, Account account) { if (account == null) throw new IllegalArgumentException("account is null"); synchronized (accountsByUserId) { String previousName = null; VAccount vAccount = getAccount(userId, account); if (vAccount != null) { previousName = vAccount.previousName; } return previousName; } }
@Override public String getPassword(int userId, Account account) { if (account == null) throw new IllegalArgumentException("account is null"); synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { return vAccount.password; } return null; } }
@Override public String getUserData(int userId, Account account, String key) { if (account == null) throw new IllegalArgumentException("account is null"); if (key == null) throw new IllegalArgumentException("key is null"); synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { return vAccount.userDatas.get(key); } return null; } }
@Override public String peekAuthToken(int userId, Account account, String authTokenType) { if (account == null) throw new IllegalArgumentException("account is null"); if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null"); synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { return vAccount.authTokens.get(authTokenType); } return null; } }
@Override public void setUserData(int userId, Account account, String key, String value) { if (key == null) throw new IllegalArgumentException("key is null"); if (account == null) throw new IllegalArgumentException("account is null"); VAccount vAccount = getAccount(userId, account); if (vAccount != null) { synchronized (accountsByUserId) { vAccount.userDatas.put(key, value); saveAllAccounts(); } } }
@Override public void setAuthToken(int userId, Account account, String authTokenType, String authToken) { if (account == null) throw new IllegalArgumentException("account is null"); if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null"); synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { // FIXME: cancelNotification vAccount.authTokens.put(authTokenType, authToken); this.saveAllAccounts(); } } }
@Override public boolean accountAuthenticated(int userId, final Account account) { if (account == null) { throw new IllegalArgumentException("account is null"); } synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { vAccount.lastAuthenticatedTime = System.currentTimeMillis(); saveAllAccounts(); return true; } return false; } }
private void setPasswordInternal(int userId, Account account, String password) { synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { vAccount.password = password; vAccount.authTokens.clear(); saveAllAccounts(); synchronized (authTokenRecords) { Iterator<AuthTokenRecord> iterator = authTokenRecords.iterator(); while (iterator.hasNext()) { AuthTokenRecord record = iterator.next(); if (record.userId == userId && record.account.equals(account)) { iterator.remove(); } } } sendAccountsChangedBroadcast(userId); } } }
private Account renameAccountInternal(int userId, Account accountToRename, String newName) { // TODO: Cancel Notification synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, accountToRename); if (vAccount != null) { vAccount.previousName = vAccount.name; vAccount.name = newName; saveAllAccounts(); Account newAccount = new Account(vAccount.name, vAccount.type); synchronized (authTokenRecords) { for (AuthTokenRecord record : authTokenRecords) { if (record.userId == userId && record.account.equals(accountToRename)) { record.account = newAccount; } } } sendAccountsChangedBroadcast(userId); return newAccount; } } return accountToRename; }
VAccount vAccount; synchronized (accountsByUserId) { vAccount = getAccount(userId, account);
@Override public final String getPreviousName(int userId, Account account) { if (account == null) throw new IllegalArgumentException("account is null"); synchronized (accountsByUserId) { String previousName = null; VAccount vAccount = getAccount(userId, account); if (vAccount != null) { previousName = vAccount.previousName; } return previousName; } }
@Override public String getPassword(int userId, Account account) { if (account == null) throw new IllegalArgumentException("account is null"); synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { return vAccount.password; } return null; } }
@Override public final String getPreviousName(int userId, Account account) { if (account == null) throw new IllegalArgumentException("account is null"); synchronized (accountsByUserId) { String previousName = null; VAccount vAccount = getAccount(userId, account); if (vAccount != null) { previousName = vAccount.previousName; } return previousName; } }
@Override public String getPassword(int userId, Account account) { if (account == null) throw new IllegalArgumentException("account is null"); synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { return vAccount.password; } return null; } }
@Override public String getUserData(int userId, Account account, String key) { if (account == null) throw new IllegalArgumentException("account is null"); if (key == null) throw new IllegalArgumentException("key is null"); synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { return vAccount.userDatas.get(key); } return null; } }
@Override public String peekAuthToken(int userId, Account account, String authTokenType) { if (account == null) throw new IllegalArgumentException("account is null"); if (authTokenType == null) throw new IllegalArgumentException("authTokenType is null"); synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { return vAccount.authTokens.get(authTokenType); } return null; } }
@Override public String getUserData(int userId, Account account, String key) { if (account == null) throw new IllegalArgumentException("account is null"); if (key == null) throw new IllegalArgumentException("key is null"); synchronized (accountsByUserId) { VAccount vAccount = getAccount(userId, account); if (vAccount != null) { return vAccount.userDatas.get(key); } return null; } }
@Override public void setUserData(int userId, Account account, String key, String value) { if (key == null) throw new IllegalArgumentException("key is null"); if (account == null) throw new IllegalArgumentException("account is null"); VAccount vAccount = getAccount(userId, account); if (vAccount != null) { synchronized (accountsByUserId) { vAccount.userDatas.put(key, value); saveAllAccounts(); } } }
@Override public void setUserData(int userId, Account account, String key, String value) { if (key == null) throw new IllegalArgumentException("key is null"); if (account == null) throw new IllegalArgumentException("account is null"); VAccount vAccount = getAccount(userId, account); if (vAccount != null) { synchronized (accountsByUserId) { vAccount.userDatas.put(key, value); saveAllAccounts(); } } }