diff --git a/mywust-core/pom.xml b/mywust-core/pom.xml index feb773a..7ae6a88 100644 --- a/mywust-core/pom.xml +++ b/mywust-core/pom.xml @@ -70,8 +70,8 @@ - 11 - 11 + 1.8 + 1.8 UTF-8 \ No newline at end of file diff --git a/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/GraduateLogin.java b/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/GraduateLogin.java index 724b24d..d7fbf30 100644 --- a/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/GraduateLogin.java +++ b/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/GraduateLogin.java @@ -3,7 +3,6 @@ package cn.linghang.mywust.core.service.auth; import cn.linghang.mywust.captcha.SolvedImageCaptcha; import cn.linghang.mywust.captcha.UnsolvedImageCaptcha; import cn.linghang.mywust.core.exception.ApiException; -import cn.linghang.mywust.core.exception.BasicException; import cn.linghang.mywust.core.request.graduate.GraduateRequestFactory; import cn.linghang.mywust.core.service.captcha.solver.CaptchaSolver; import cn.linghang.mywust.network.RequestClientOption; @@ -28,7 +27,7 @@ public class GraduateLogin { this.captchaSolver = captchaSolver; } - public String getLoginCookie(String username, String password, RequestClientOption option) throws IOException, BasicException { + public String getLoginCookie(String username, String password, RequestClientOption option) throws IOException, ApiException { // 请求获取验证码 HttpRequest captchaImageRequest = GraduateRequestFactory.captchaRequest(); HttpResponse captchaImageResponse = requester.get(captchaImageRequest, option); @@ -87,7 +86,7 @@ class ImageUtil { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); ImageIO.write(bufferedImage, "png", outputStream); - return byteArrayInputStream.readAllBytes(); + return outputStream.toByteArray(); } catch (Exception e) { throw new ApiException(ApiException.Code.INTERNAL_EXCEPTION); } diff --git a/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/JwcLogin.java b/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/JwcLogin.java index 99522dc..1c3a95b 100644 --- a/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/JwcLogin.java +++ b/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/JwcLogin.java @@ -2,6 +2,7 @@ package cn.linghang.mywust.core.service.auth; import cn.linghang.mywust.core.api.Bkjx; import cn.linghang.mywust.core.api.UnionAuth; +import cn.linghang.mywust.core.exception.ApiException; import cn.linghang.mywust.core.exception.BasicException; import cn.linghang.mywust.core.request.undergrade.BkjxRequestFactory; import cn.linghang.mywust.network.RequestClientOption; @@ -25,7 +26,7 @@ public class JwcLogin { this.unionLogin = new UnionLogin(requester); } - public String getLoginCookie(String username, String password, RequestClientOption requestOption) throws IOException, BasicException { + public String getLoginCookie(String username, String password, RequestClientOption requestOption) throws IOException, ApiException { // 获取service ticket以进行进一步的登录 String serviceTicket = unionLogin.getServiceTicket(username, password, UnionAuth.Service.BKJX_SSO_SERVICE, requestOption); @@ -35,7 +36,7 @@ public class JwcLogin { String cookies = sessionResponse.getCookies(); if (roughCheckCookie(cookies)) { - throw new BasicException(); + throw new ApiException(ApiException.Code.UNKNOWN_EXCEPTION); } return cookies; diff --git a/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/LibraryLogin.java b/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/LibraryLogin.java index bb78c41..1ae65f1 100644 --- a/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/LibraryLogin.java +++ b/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/LibraryLogin.java @@ -2,6 +2,7 @@ package cn.linghang.mywust.core.service.auth; import cn.linghang.mywust.core.api.Library; import cn.linghang.mywust.core.api.UnionAuth; +import cn.linghang.mywust.core.exception.ApiException; import cn.linghang.mywust.core.exception.BasicException; import cn.linghang.mywust.core.request.library.LibraryRequestFactory; import cn.linghang.mywust.network.RequestClientOption; @@ -21,7 +22,7 @@ public class LibraryLogin { this.unionLogin = new UnionLogin(requester); } - public String getLibraryLoginCookie(String username, String password, RequestClientOption requestOption) throws BasicException, IOException { + public String getLibraryLoginCookie(String username, String password, RequestClientOption requestOption) throws ApiException, IOException { // 获取service ticket以进行进一步的登录 String serviceTicket = unionLogin.getServiceTicket(username, password, UnionAuth.Service.LIBRARY_SSO_SERVICE, requestOption); diff --git a/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/PhysicsLogin.java b/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/PhysicsLogin.java index a06c75f..4360cf6 100644 --- a/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/PhysicsLogin.java +++ b/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/PhysicsLogin.java @@ -2,6 +2,7 @@ package cn.linghang.mywust.core.service.auth; import cn.linghang.mywust.core.exception.ApiException; import cn.linghang.mywust.core.exception.BasicException; +import cn.linghang.mywust.core.exception.ParseException; import cn.linghang.mywust.core.parser.physics.PhysicsIndexPageParser; import cn.linghang.mywust.core.request.physics.PhysicsSystemRequestFactory; import cn.linghang.mywust.network.RequestClientOption; @@ -24,7 +25,7 @@ public class PhysicsLogin { this.requester = requester; } - public String getLoginCookie(String username, String password, RequestClientOption requestClientOption) throws IOException, BasicException { + public String getLoginCookie(String username, String password, RequestClientOption requestClientOption) throws IOException, ApiException, ParseException { // 直接登录,ASP.NET_SessionId其实在这步就能获取到,不需要再请求一遍首页获取 HttpRequest loginCookieRequest = PhysicsSystemRequestFactory.loginCookiesRequest(username, password, null); HttpResponse loginCookieResponse = requester.post(loginCookieRequest, requestClientOption); diff --git a/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/UnionLogin.java b/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/UnionLogin.java index 73bd6d1..82b0197 100644 --- a/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/UnionLogin.java +++ b/mywust-core/src/main/java/cn/linghang/mywust/core/service/auth/UnionLogin.java @@ -27,7 +27,7 @@ public class UnionLogin { this.requester = requester; } - public String getServiceTicket(String username, String password, String serviceUrl, RequestClientOption requestOption) throws IOException, BasicException { + public String getServiceTicket(String username, String password, String serviceUrl, RequestClientOption requestOption) throws IOException, ApiException { String encodedPassword = PasswordEncoder.encodePassword(password); // 获取ticket granting ticket(TGT),以获取ServiceTicket diff --git a/mywust-core/src/main/java/cn/linghang/mywust/core/service/graduate/GraduateCourseTableApiService.java b/mywust-core/src/main/java/cn/linghang/mywust/core/service/graduate/GraduateCourseTableApiService.java index 91156da..fdb9f7c 100644 --- a/mywust-core/src/main/java/cn/linghang/mywust/core/service/graduate/GraduateCourseTableApiService.java +++ b/mywust-core/src/main/java/cn/linghang/mywust/core/service/graduate/GraduateCourseTableApiService.java @@ -17,6 +17,9 @@ public class GraduateCourseTableApiService extends GraduateApiService{ public String getCourseTablePage(String cookie, RequestClientOption option) throws IOException, ApiException { HttpRequest request = GraduateRequestFactory.courseTableRequest(cookie); + request.addHeaders("Referer", "http://59.68.177.189/pyxx/pygl/kbcx_xs.aspx"); + request.addHeaders("Origin", "http://59.68.177.189"); + HttpResponse response = requester.get(request, option); super.checkResponse(response); diff --git a/mywust-core/src/main/java/cn/linghang/mywust/core/service/graduate/GraduateScoreApiService.java b/mywust-core/src/main/java/cn/linghang/mywust/core/service/graduate/GraduateScoreApiService.java index 18e5766..5976674 100644 --- a/mywust-core/src/main/java/cn/linghang/mywust/core/service/graduate/GraduateScoreApiService.java +++ b/mywust-core/src/main/java/cn/linghang/mywust/core/service/graduate/GraduateScoreApiService.java @@ -15,8 +15,10 @@ public class GraduateScoreApiService extends GraduateApiService{ super(requester); } - public String getCourseTablePage(String cookie, RequestClientOption option) throws IOException, ApiException { + public String getScorePage(String cookie, RequestClientOption option) throws IOException, ApiException { HttpRequest request = GraduateRequestFactory.examScoreInfoRequest(cookie); + request.addHeaders("Referer", "http://59.68.177.189/pyxx/leftmenu.aspx"); + HttpResponse response = requester.get(request, option); super.checkResponse(response); diff --git a/mywust-model/pom.xml b/mywust-model/pom.xml index 96cf158..257f514 100644 --- a/mywust-model/pom.xml +++ b/mywust-model/pom.xml @@ -20,8 +20,8 @@ - 11 - 11 + 1.8 + 1.8 UTF-8 diff --git a/mywust-network-httpclient/pom.xml b/mywust-network-httpclient/pom.xml index 136ac6b..f80ebb2 100644 --- a/mywust-network-httpclient/pom.xml +++ b/mywust-network-httpclient/pom.xml @@ -9,11 +9,11 @@ 1.0-SNAPSHOT - 11 - 11 + 1.8 + 1.8 UTF-8 - + github diff --git a/mywust-network-okhttp/pom.xml b/mywust-network-okhttp/pom.xml index 30d97eb..cbd8d86 100644 --- a/mywust-network-okhttp/pom.xml +++ b/mywust-network-okhttp/pom.xml @@ -9,8 +9,8 @@ 1.0-SNAPSHOT - 11 - 11 + 1.8 + 1.8 UTF-8 diff --git a/mywust-network/pom.xml b/mywust-network/pom.xml index f5fd847..99aa584 100644 --- a/mywust-network/pom.xml +++ b/mywust-network/pom.xml @@ -12,8 +12,8 @@ mywust-network - 11 - 11 + 1.8 + 1.8 UTF-8 diff --git a/mywust-test/pom.xml b/mywust-test/pom.xml index 5d73425..0f52487 100644 --- a/mywust-test/pom.xml +++ b/mywust-test/pom.xml @@ -61,8 +61,8 @@ - 11 - 11 + 1.8 + 1.8 UTF-8 diff --git a/mywust-util/pom.xml b/mywust-util/pom.xml index 04b9193..ef61444 100644 --- a/mywust-util/pom.xml +++ b/mywust-util/pom.xml @@ -12,8 +12,8 @@ mywust-util - 11 - 11 + 1.8 + 8 UTF-8 diff --git a/mywust-util/src/main/java/cn/linghang/mywust/util/StringUtil.java b/mywust-util/src/main/java/cn/linghang/mywust/util/StringUtil.java index c6997d4..c4e7fca 100644 --- a/mywust-util/src/main/java/cn/linghang/mywust/util/StringUtil.java +++ b/mywust-util/src/main/java/cn/linghang/mywust/util/StringUtil.java @@ -3,6 +3,7 @@ package cn.linghang.mywust.util; import com.google.common.base.Joiner; import org.apache.commons.codec.binary.Base64; +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.*; @@ -19,7 +20,12 @@ public class StringUtil { public static String generateQueryString(Map queryParams) { // 自动对value值进行url编码 Map urlEncodedQueryParams = new TreeMap<>(REPEATABLE_COMPARATOR); - queryParams.forEach((k, v) -> urlEncodedQueryParams.put(k, URLEncoder.encode(v, StandardCharsets.UTF_8))); + queryParams.forEach((k, v) -> { + try { + urlEncodedQueryParams.put(k, URLEncoder.encode(v, StandardCharsets.UTF_8.name())); + } catch (UnsupportedEncodingException ignored) { + } + }); return Joiner.on('&') .useForNull("") diff --git a/pom.xml b/pom.xml index 1916d79..7849722 100644 --- a/pom.xml +++ b/pom.xml @@ -19,10 +19,9 @@ - 11 - 11 + 1.8 + 8 UTF-8 - @@ -32,4 +31,22 @@ https://maven.pkg.github.com/LingHangStudio/mywust + + + + + org.apache.maven.plugins + maven-source-plugin + 3.2.1 + + + attach-sources + + jar + + + + + + \ No newline at end of file