mirror of
https://github.com/LamGC/ContentGrabbingJi.git
synced 2025-07-02 05:17:26 +00:00
[Update] * 更新年份; [Fix] * 由 AGPLv3-Later 更新为 AGPLv3-Only; 2021, 新年快乐! (新的一年继续努力吧! :D)
61 lines
1.6 KiB
Java
61 lines
1.6 KiB
Java
/*
|
|
* Copyright (C) 2021 LamGC
|
|
*
|
|
* ContentGrabbingJi is free software: you can redistribute it and/or modify
|
|
* it under the terms of the GNU Affero General Public License as
|
|
* published by the Free Software Foundation, either version 3 of the
|
|
* License.
|
|
*
|
|
* ContentGrabbingJi is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU Affero General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU Affero General Public License
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
package net.lamgc.pixiv;
|
|
|
|
import org.apache.http.client.CookieStore;
|
|
|
|
import java.io.IOException;
|
|
import java.util.Objects;
|
|
|
|
/**
|
|
* Pixiv 会话.
|
|
* @author LamGC
|
|
*/
|
|
public abstract class PixivSession {
|
|
|
|
private final CookieStore cookieStore;
|
|
|
|
protected PixivSession(CookieStore cookieStore) {
|
|
this.cookieStore = Objects.requireNonNull(cookieStore);
|
|
}
|
|
|
|
/**
|
|
* 登出当前会话.
|
|
*
|
|
* <p>登出后该会话 Cookies 将会失效.
|
|
* @return 如果登出成功, 返回 true.
|
|
* @throws IOException 当尝试登出发生异常时抛出.
|
|
*/
|
|
public abstract boolean logOut() throws IOException;
|
|
|
|
/**
|
|
* 检查是否已登录, 或者说会话是否有效.
|
|
* @return 如果会话已登出(失效), 返回 false.
|
|
*/
|
|
public abstract boolean isLogin();
|
|
|
|
/**
|
|
* 获取 CookieStore 对象.
|
|
* @return 返回 CookieStore.
|
|
*/
|
|
public CookieStore getCookies() {
|
|
return cookieStore;
|
|
}
|
|
|
|
}
|