use of android.webkit.CookieSyncManager in project facebook-android-sdk by facebook.
the class Utility method clearCookiesForDomain.
private static void clearCookiesForDomain(Context context, String domain) {
// This is to work around a bug where CookieManager may fail to instantiate if
// CookieSyncManager has never been created.
CookieSyncManager syncManager = CookieSyncManager.createInstance(context);
syncManager.sync();
CookieManager cookieManager = CookieManager.getInstance();
String cookies = cookieManager.getCookie(domain);
if (cookies == null) {
return;
}
String[] splitCookies = cookies.split(";");
for (String cookie : splitCookies) {
String[] cookieParts = cookie.split("=");
if (cookieParts.length > 0) {
String newCookie = cookieParts[0].trim() + "=;expires=Sat, 1 Jan 2000 00:00:01 UTC;";
cookieManager.setCookie(domain, newCookie);
}
}
cookieManager.removeExpiredCookie();
}
use of android.webkit.CookieSyncManager in project phonegap-facebook-plugin by Wizcorp.
the class Utility method clearCookiesForDomain.
private static void clearCookiesForDomain(Context context, String domain) {
// This is to work around a bug where CookieManager may fail to instantiate if CookieSyncManager
// has never been created.
CookieSyncManager syncManager = CookieSyncManager.createInstance(context);
syncManager.sync();
CookieManager cookieManager = CookieManager.getInstance();
String cookies = cookieManager.getCookie(domain);
if (cookies == null) {
return;
}
String[] splitCookies = cookies.split(";");
for (String cookie : splitCookies) {
String[] cookieParts = cookie.split("=");
if (cookieParts.length > 0) {
String newCookie = cookieParts[0].trim() + "=;expires=Sat, 1 Jan 2000 00:00:01 UTC;";
cookieManager.setCookie(domain, newCookie);
}
}
cookieManager.removeExpiredCookie();
}
use of android.webkit.CookieSyncManager in project openkit-android by OpenKit.
the class Utility method clearCookiesForDomain.
private static void clearCookiesForDomain(Context context, String domain) {
// This is to work around a bug where CookieManager may fail to instantiate if CookieSyncManager
// has never been created.
CookieSyncManager syncManager = CookieSyncManager.createInstance(context);
syncManager.sync();
CookieManager cookieManager = CookieManager.getInstance();
String cookies = cookieManager.getCookie(domain);
if (cookies == null) {
return;
}
String[] splitCookies = cookies.split(";");
for (String cookie : splitCookies) {
String[] cookieParts = cookie.split("=");
if (cookieParts.length > 0) {
String newCookie = cookieParts[0].trim() + "=;expires=Sat, 1 Jan 2000 00:00:01 UTC;";
cookieManager.setCookie(domain, newCookie);
}
}
cookieManager.removeExpiredCookie();
}
use of android.webkit.CookieSyncManager in project LiveSDK-for-Android by liveservices.
the class LiveAuthClient method logout.
/**
* Logs out the given user.
*
* Also, this method clears the previously created {@link LiveConnectSession}.
* {@link LiveAuthListener#onAuthComplete(LiveStatus, LiveConnectSession, Object)} will be
* called on completion. Otherwise,
* {@link LiveAuthListener#onAuthError(LiveAuthException, Object)} will be called.
*
* @param listener called on either completion or error during the logout process.
* @param userState arbitrary object that is used to determine the caller of the method.
*/
public void logout(LiveAuthListener listener, Object userState) {
if (listener == null) {
listener = NULL_LISTENER;
}
session.setAccessToken(null);
session.setAuthenticationToken(null);
session.setRefreshToken(null);
session.setScopes(null);
session.setTokenType(null);
clearRefreshTokenFromPreferences();
CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(this.applicationContext);
CookieManager manager = CookieManager.getInstance();
Uri logoutUri = Config.INSTANCE.getOAuthLogoutUri();
String url = logoutUri.toString();
String domain = logoutUri.getHost();
List<String> cookieKeys = this.getCookieKeysFromPreferences();
for (String cookieKey : cookieKeys) {
String value = TextUtils.join("", new String[] { cookieKey, "=; expires=Thu, 30-Oct-1980 16:00:00 GMT;domain=", domain, ";path=/;version=1" });
manager.setCookie(url, value);
}
cookieSyncManager.sync();
listener.onAuthComplete(LiveStatus.UNKNOWN, null, userState);
}
use of android.webkit.CookieSyncManager in project socialauth-android by 3pillarlabs.
the class SocialAuthAdapter method signOut.
/**
* Signs out the user out of current provider
*
* @return Status of signing out
*/
public boolean signOut(Context ctx, String providerName) {
// remove cookies
Context appContext = ctx.getApplicationContext();
CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(appContext);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
if (providerName != null) {
if (socialAuthManager.getConnectedProvidersIds().contains(providerName))
socialAuthManager.disconnectProvider(providerName);
Editor edit = PreferenceManager.getDefaultSharedPreferences(appContext).edit();
edit.remove(providerName + " key");
edit.commit();
Log.d("SocialAuthAdapter", "Disconnecting Provider");
return true;
} else {
Log.d("SocialAuthAdapter", "The provider name should be same");
return false;
}
}
Aggregations