Search in sources :

Example 1 with CookieManager

use of org.stepik.plugin.auth.webkit.network.CookieManager in project intellij-plugins by StepicOrg.

the class AuthDialog method initCookieManager.

@NotNull
private CookieManager initCookieManager(boolean clearCookies) {
    CookieHandler cookieManager = CookieManager.getDefault();
    if (!(cookieManager instanceof CookieManager)) {
        cookieManager = new CookieManager();
    }
    if (clearCookies) {
        ((CookieManager) cookieManager).clear();
        clearedCookies = true;
    }
    CookieManager.setDefault(cookieManager);
    return (CookieManager) cookieManager;
}
Also used : CookieManager(org.stepik.plugin.auth.webkit.network.CookieManager) CookieHandler(java.net.CookieHandler) NotNull(org.jetbrains.annotations.NotNull)

Example 2 with CookieManager

use of org.stepik.plugin.auth.webkit.network.CookieManager in project intellij-plugins by StepicOrg.

the class AuthDialog method showAuthForm.

@NotNull
public static Map<String, String> showAuthForm() {
    AuthDialog instance = new AuthDialog();
    instance.setVisible(true);
    boolean isCanceled = instance.map.isEmpty() || instance.map.containsKey("error");
    if (!instance.clearedCookies || !isCanceled) {
        instance.saveCookies();
    } else {
        // Restore cookies from store
        CookieManager.setDefault(new CookieManager());
    }
    return instance.map;
}
Also used : CookieManager(org.stepik.plugin.auth.webkit.network.CookieManager) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

NotNull (org.jetbrains.annotations.NotNull)2 CookieManager (org.stepik.plugin.auth.webkit.network.CookieManager)2 CookieHandler (java.net.CookieHandler)1