1
0
mirror of https://github.com/owncloud/android-library.git synced 2025-06-07 16:06:08 +00:00

Show cookies information in log, when saving a cookie

This commit is contained in:
masensio 2014-06-10 12:00:36 +02:00
parent 9a5b41e803
commit 057758671f

View File

@ -53,6 +53,7 @@ import com.owncloud.android.lib.common.accounts.AccountUtils.Constants;
public class OwnCloudClientMap { public class OwnCloudClientMap {
private static final String TAG = OwnCloudClientMap.class.getSimpleName();
private static ConcurrentMap<String, OwnCloudClient> mClients = private static ConcurrentMap<String, OwnCloudClient> mClients =
new java.util.concurrent.ConcurrentHashMap<String, OwnCloudClient>(); new java.util.concurrent.ConcurrentHashMap<String, OwnCloudClient>();
@ -81,7 +82,7 @@ public class OwnCloudClientMap {
mClients.clear(); mClients.clear();
} }
public static synchronized void saveClient(Account account, Context context) { private static synchronized void saveClient(Account account, Context context) {
// Account Manager // Account Manager
AccountManager ac = AccountManager.get(context.getApplicationContext()); AccountManager ac = AccountManager.get(context.getApplicationContext());
@ -93,21 +94,34 @@ public class OwnCloudClientMap {
String cookiesString =""; String cookiesString ="";
for (Cookie cookie: cookies) { for (Cookie cookie: cookies) {
cookiesString = cookiesString + cookie.toString() + ";"; cookiesString = cookiesString + cookie.toString() + ";";
logCookie(cookie);
} }
ac.setUserData(account, Constants.KEY_COOKIES, cookiesString); ac.setUserData(account, Constants.KEY_COOKIES, cookiesString);
Log.d("OwnCloudClientMap", "Saving Cookies: "+ cookiesString ); Log.d(TAG, "Saving Cookies: "+ cookiesString );
} }
} }
public static synchronized void saveAllClients(Context context, String accountType) { public static synchronized void saveAllClients(Context context, String accountType) {
// Get all accounts // Get all accounts
Account [] accounts = AccountManager.get(context.getApplicationContext()).getAccountsByType(accountType); Account [] accounts = AccountManager.get(context.getApplicationContext())
.getAccountsByType(accountType);
// Save cookies for all accounts // Save cookies for all accounts
for(Account account: accounts){ for(Account account: accounts){
saveClient(account, context.getApplicationContext()); saveClient(account, context.getApplicationContext());
} }
} }
private static void logCookie(Cookie cookie) {
Log.d(TAG, "Cookie name: "+ cookie.getName() );
Log.d(TAG, " value: "+ cookie.getValue() );
Log.d(TAG, " domain: "+ cookie.getDomain());
Log.d(TAG, " path: "+ cookie.getPath() );
Log.d(TAG, " version: "+ cookie.getVersion() );
Log.d(TAG, " expiryDate: " +
(cookie.getExpiryDate() != null ? cookie.getExpiryDate().toString() : "--"));
Log.d(TAG, " comment: "+ cookie.getComment() );
Log.d(TAG, " secure: "+ cookie.getSecure() );
}
} }