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

Add getCookiesString method in OwnCloudClient

This commit is contained in:
masensio 2014-06-12 11:07:49 +02:00
parent a42f6b5d6d
commit e7a0e30a27
2 changed files with 30 additions and 22 deletions

View File

@ -415,6 +415,31 @@ public class OwnCloudClient extends HttpClient {
} }
} }
public String getCookiesString(){
Cookie[] cookies = getState().getCookies();
String cookiesString ="";
for (Cookie cookie: cookies) {
cookiesString = cookiesString + cookie.toString() + ";";
logCookie(cookie);
}
return cookiesString;
}
private 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() );
}
} }

View File

@ -166,16 +166,11 @@ public class SingleSessionManager implements OwnCloudClientManager {
OwnCloudClient client = clientsPerAccount.get(credentials); OwnCloudClient client = clientsPerAccount.get(credentials);
if (client != null) { if (client != null) {
String cookiesString = client.getCookiesString();
Cookie[] cookies = client.getState().getCookies(); if (cookiesString != "") {
String cookiesString =""; ac.setUserData(savedAccount, Constants.KEY_COOKIES, cookiesString);
for (Cookie cookie: cookies) { Log.d(TAG, "Saving Cookies: "+ cookiesString );
cookiesString = cookiesString + cookie.toString() + ";"; }
logCookie(cookie);
}
ac.setUserData(savedAccount, Constants.KEY_COOKIES, cookiesString);
Log.d(TAG, "Saving Cookies: "+ cookiesString );
} }
} }
} }
@ -197,18 +192,6 @@ public class SingleSessionManager implements OwnCloudClientManager {
} }
} }
private 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() );
}
} }