From e081bf5a7688b1af86ce2de856af87ecb6421ec6 Mon Sep 17 00:00:00 2001 From: Gravit Date: Sat, 30 Nov 2019 02:41:27 +0700 Subject: [PATCH] =?UTF-8?q?[FEATURE]=20=D0=9F=D0=BE=D0=B4=D0=B4=D0=B5?= =?UTF-8?q?=D1=80=D0=B6=D0=BA=D0=B0=202FA=20=D0=B8=20=D0=BD=D0=B5=D0=BE?= =?UTF-8?q?=D0=B1=D1=8B=D1=87=D0=BD=D1=8B=D1=85=20=D1=81=D0=BF=D0=BE=D1=81?= =?UTF-8?q?=D0=BE=D0=B1=D0=B0=D1=85=20=D0=B0=D0=B2=D1=82=D0=BE=D1=80=D0=B8?= =?UTF-8?q?=D0=B7=D0=B0=D1=86=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../auth/provider/AuthProvider.java | 8 ++++++ .../auth/GetAvailabilityAuthResponse.java | 2 +- .../GetAvailabilityAuthRequestEvent.java | 25 ++++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java index 03cd0462..019a1d75 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/auth/provider/AuthProvider.java @@ -1,5 +1,6 @@ package pro.gravit.launchserver.auth.provider; +import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent; import pro.gravit.launcher.request.auth.AuthRequest; import pro.gravit.launchserver.LaunchServer; import pro.gravit.launchserver.auth.AuthException; @@ -12,6 +13,13 @@ public abstract class AuthProvider implements AutoCloseable { private static boolean registredProv = false; protected transient LaunchServer srv = null; + public GetAvailabilityAuthRequestEvent.AuthAvailability.AuthType getFirstAuthType() { + return GetAvailabilityAuthRequestEvent.AuthAvailability.AuthType.PASSWORD; + } + public GetAvailabilityAuthRequestEvent.AuthAvailability.AuthType getSecondAuthType() { + return GetAvailabilityAuthRequestEvent.AuthAvailability.AuthType.NONE; + } + public static AuthProviderResult authError(String message) throws AuthException { throw new AuthException(message); } diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/GetAvailabilityAuthResponse.java b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/GetAvailabilityAuthResponse.java index 9ed8d242..79e63047 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/GetAvailabilityAuthResponse.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/socket/response/auth/GetAvailabilityAuthResponse.java @@ -19,7 +19,7 @@ public String getType() { public void execute(ChannelHandlerContext ctx, Client client) { List list = new ArrayList<>(); for (AuthProviderPair pair : server.config.auth) { - list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName)); + list.add(new GetAvailabilityAuthRequestEvent.AuthAvailability(pair.name, pair.displayName, pair.provider.getFirstAuthType(), pair.provider.getSecondAuthType())); } sendResult(new GetAvailabilityAuthRequestEvent(list)); } diff --git a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java index 28df28df..684d0485 100644 --- a/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java +++ b/LauncherAPI/src/main/java/pro/gravit/launcher/events/request/GetAvailabilityAuthRequestEvent.java @@ -11,10 +11,33 @@ public static class AuthAvailability { public final String name; @LauncherNetworkAPI public final String displayName; + @LauncherNetworkAPI + public final AuthType firstType; + @LauncherNetworkAPI + public final AuthType secondType; - public AuthAvailability(String name, String displayName) { + public AuthAvailability(String name, String displayName, AuthType firstType, AuthType secondType) { this.name = name; this.displayName = displayName; + this.firstType = firstType; + this.secondType = secondType; + } + + + public enum AuthType + { + @LauncherNetworkAPI + PASSWORD, + @LauncherNetworkAPI + KEY, + @LauncherNetworkAPI + TOTP, + @LauncherNetworkAPI + OAUTH, + @LauncherNetworkAPI + NONE, + @LauncherNetworkAPI + OTHER } }