avoiding crash when recorded AI server url is malformed
This commit is contained in:
@@ -17,10 +17,11 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.auth.authlibinjector;
|
package org.jackhuang.hmcl.auth.authlibinjector;
|
||||||
|
|
||||||
|
import org.jackhuang.hmcl.auth.AuthenticationException;
|
||||||
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilProvider;
|
import org.jackhuang.hmcl.auth.yggdrasil.YggdrasilProvider;
|
||||||
import org.jackhuang.hmcl.util.gson.UUIDTypeAdapter;
|
import org.jackhuang.hmcl.util.gson.UUIDTypeAdapter;
|
||||||
import org.jackhuang.hmcl.util.io.NetworkUtils;
|
|
||||||
|
|
||||||
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -33,32 +34,40 @@ public class AuthlibInjectorProvider implements YggdrasilProvider {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getAuthenticationURL() {
|
public URL getAuthenticationURL() throws AuthenticationException {
|
||||||
return NetworkUtils.toURL(apiRoot + "authserver/authenticate");
|
return toURL(apiRoot + "authserver/authenticate");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getRefreshmentURL() {
|
public URL getRefreshmentURL() throws AuthenticationException {
|
||||||
return NetworkUtils.toURL(apiRoot + "authserver/refresh");
|
return toURL(apiRoot + "authserver/refresh");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getValidationURL() {
|
public URL getValidationURL() throws AuthenticationException {
|
||||||
return NetworkUtils.toURL(apiRoot + "authserver/validate");
|
return toURL(apiRoot + "authserver/validate");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getInvalidationURL() {
|
public URL getInvalidationURL() throws AuthenticationException {
|
||||||
return NetworkUtils.toURL(apiRoot + "authserver/invalidate");
|
return toURL(apiRoot + "authserver/invalidate");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public URL getProfilePropertiesURL(UUID uuid) {
|
public URL getProfilePropertiesURL(UUID uuid) throws AuthenticationException {
|
||||||
return NetworkUtils.toURL(apiRoot + "sessionserver/session/minecraft/profile/" + UUIDTypeAdapter.fromUUID(uuid));
|
return toURL(apiRoot + "sessionserver/session/minecraft/profile/" + UUIDTypeAdapter.fromUUID(uuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return apiRoot;
|
return apiRoot;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private URL toURL(String url) throws AuthenticationException {
|
||||||
|
try {
|
||||||
|
return new URL(url);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
throw new AuthenticationException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
package org.jackhuang.hmcl.auth.yggdrasil;
|
package org.jackhuang.hmcl.auth.yggdrasil;
|
||||||
|
|
||||||
|
import org.jackhuang.hmcl.auth.AuthenticationException;
|
||||||
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@@ -25,14 +27,14 @@ import java.util.UUID;
|
|||||||
*/
|
*/
|
||||||
public interface YggdrasilProvider {
|
public interface YggdrasilProvider {
|
||||||
|
|
||||||
URL getAuthenticationURL();
|
URL getAuthenticationURL() throws AuthenticationException;
|
||||||
|
|
||||||
URL getRefreshmentURL();
|
URL getRefreshmentURL() throws AuthenticationException;
|
||||||
|
|
||||||
URL getValidationURL();
|
URL getValidationURL() throws AuthenticationException;
|
||||||
|
|
||||||
URL getInvalidationURL();
|
URL getInvalidationURL() throws AuthenticationException;
|
||||||
|
|
||||||
URL getProfilePropertiesURL(UUID uuid);
|
URL getProfilePropertiesURL(UUID uuid) throws AuthenticationException;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user