mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-12-23 00:51:01 +03:00
[FEATURE] isAllowSave support
This commit is contained in:
parent
8ea134dc27
commit
d01c27177c
12 changed files with 62 additions and 9 deletions
|
@ -14,11 +14,11 @@
|
||||||
|
|
||||||
public final class AuthProviderPair {
|
public final class AuthProviderPair {
|
||||||
public boolean isDefault = true;
|
public boolean isDefault = true;
|
||||||
|
public AuthCoreProvider core;
|
||||||
|
public AuthSocialProvider social;
|
||||||
public AuthProvider provider;
|
public AuthProvider provider;
|
||||||
public AuthHandler handler;
|
public AuthHandler handler;
|
||||||
public TextureProvider textureProvider;
|
public TextureProvider textureProvider;
|
||||||
public AuthCoreProvider core;
|
|
||||||
public AuthSocialProvider social;
|
|
||||||
public Map<String, String> links;
|
public Map<String, String> links;
|
||||||
public transient String name;
|
public transient String name;
|
||||||
public transient Set<String> features;
|
public transient Set<String> features;
|
||||||
|
@ -30,9 +30,28 @@ public AuthProviderPair(AuthProvider provider, AuthHandler handler, TextureProvi
|
||||||
this.textureProvider = textureProvider;
|
this.textureProvider = textureProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public AuthProviderPair(AuthCoreProvider core, TextureProvider textureProvider) {
|
||||||
|
this.core = core;
|
||||||
|
this.textureProvider = textureProvider;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthProviderPair(AuthCoreProvider core, AuthSocialProvider social) {
|
||||||
|
this.core = core;
|
||||||
|
this.social = social;
|
||||||
|
}
|
||||||
|
|
||||||
|
public AuthProviderPair(AuthCoreProvider core, AuthSocialProvider social, TextureProvider textureProvider) {
|
||||||
|
this.core = core;
|
||||||
|
this.social = social;
|
||||||
|
this.textureProvider = textureProvider;
|
||||||
|
}
|
||||||
|
|
||||||
public final <T> T isSupport(Class<T> clazz) {
|
public final <T> T isSupport(Class<T> clazz) {
|
||||||
if (core == null) return null;
|
if (core == null) return null;
|
||||||
return core.isSupport(clazz);
|
T result = null;
|
||||||
|
if (social != null) result = social.isSupport(clazz);
|
||||||
|
if (result == null) result = core.isSupport(clazz);
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void init(LaunchServer srv, String name) {
|
public final void init(LaunchServer srv, String name) {
|
||||||
|
|
|
@ -50,6 +50,12 @@ public static SocialResult ofUser(User user) {
|
||||||
|
|
||||||
public abstract SocialResult preAuth(AuthResponse.AuthContext context, AuthRequest.AuthPasswordInterface password) throws AuthException;
|
public abstract SocialResult preAuth(AuthResponse.AuthContext context, AuthRequest.AuthPasswordInterface password) throws AuthException;
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public <T> T isSupport(Class<T> clazz) {
|
||||||
|
if (clazz.isAssignableFrom(getClass())) return (T) this;
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract void close() throws IOException;
|
public abstract void close() throws IOException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ public Path process(Path inputFile) throws IOException {
|
||||||
.getCertificate(bcCertificate);
|
.getCertificate(bcCertificate);
|
||||||
ArrayList<Certificate> chain = new ArrayList<>();
|
ArrayList<Certificate> chain = new ArrayList<>();
|
||||||
chain.add(certificate);
|
chain.add(certificate);
|
||||||
signedDataGenerator = SignHelper.createSignedDataGenerator(server.privateKey, certificate, chain, "SHA256WITHECDSA");
|
signedDataGenerator = SignHelper.createSignedDataGenerator(server.keyAgreementManager.ecdsaPrivateKey, certificate, chain, "SHA256WITHECDSA");
|
||||||
} catch (OperatorCreationException | CMSException | CertificateException e) {
|
} catch (OperatorCreationException | CMSException | CertificateException e) {
|
||||||
logger.error(e);
|
logger.error(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,10 +8,9 @@
|
||||||
import pro.gravit.launcher.LauncherConfig;
|
import pro.gravit.launcher.LauncherConfig;
|
||||||
import pro.gravit.launchserver.LaunchServer;
|
import pro.gravit.launchserver.LaunchServer;
|
||||||
import pro.gravit.launchserver.auth.AuthProviderPair;
|
import pro.gravit.launchserver.auth.AuthProviderPair;
|
||||||
import pro.gravit.launchserver.auth.handler.MemoryAuthHandler;
|
import pro.gravit.launchserver.auth.core.RejectAuthCoreProvider;
|
||||||
import pro.gravit.launchserver.auth.protect.ProtectHandler;
|
import pro.gravit.launchserver.auth.protect.ProtectHandler;
|
||||||
import pro.gravit.launchserver.auth.protect.StdProtectHandler;
|
import pro.gravit.launchserver.auth.protect.StdProtectHandler;
|
||||||
import pro.gravit.launchserver.auth.provider.RejectAuthProvider;
|
|
||||||
import pro.gravit.launchserver.auth.session.MemorySessionStorage;
|
import pro.gravit.launchserver.auth.session.MemorySessionStorage;
|
||||||
import pro.gravit.launchserver.auth.session.SessionStorage;
|
import pro.gravit.launchserver.auth.session.SessionStorage;
|
||||||
import pro.gravit.launchserver.auth.texture.RequestTextureProvider;
|
import pro.gravit.launchserver.auth.texture.RequestTextureProvider;
|
||||||
|
@ -70,8 +69,7 @@ public static LaunchServerConfig getDefault(LaunchServer.LaunchServerEnv env) {
|
||||||
newConfig.env = LauncherConfig.LauncherEnvironment.STD;
|
newConfig.env = LauncherConfig.LauncherEnvironment.STD;
|
||||||
newConfig.startScript = JVMHelper.OS_TYPE.equals(JVMHelper.OS.MUSTDIE) ? "." + File.separator + "start.bat" : "." + File.separator + "start.sh";
|
newConfig.startScript = JVMHelper.OS_TYPE.equals(JVMHelper.OS.MUSTDIE) ? "." + File.separator + "start.bat" : "." + File.separator + "start.sh";
|
||||||
newConfig.auth = new HashMap<>();
|
newConfig.auth = new HashMap<>();
|
||||||
AuthProviderPair a = new AuthProviderPair(new RejectAuthProvider("Настройте authProvider"),
|
AuthProviderPair a = new AuthProviderPair(new RejectAuthCoreProvider(),
|
||||||
new MemoryAuthHandler(),
|
|
||||||
new RequestTextureProvider("http://example.com/skins/%username%.png", "http://example.com/cloaks/%username%.png")
|
new RequestTextureProvider("http://example.com/skins/%username%.png", "http://example.com/cloaks/%username%.png")
|
||||||
);
|
);
|
||||||
a.displayName = "Default";
|
a.displayName = "Default";
|
||||||
|
|
|
@ -21,6 +21,7 @@ public class DebugMain {
|
||||||
public static final AtomicBoolean IS_DEBUG = new AtomicBoolean(false);
|
public static final AtomicBoolean IS_DEBUG = new AtomicBoolean(false);
|
||||||
public static String webSocketURL = System.getProperty("launcherdebug.websocket", "ws://localhost:9274/api");
|
public static String webSocketURL = System.getProperty("launcherdebug.websocket", "ws://localhost:9274/api");
|
||||||
public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft");
|
public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft");
|
||||||
|
public static String unlockKey = System.getProperty("launcherdebug.unlockkey", "0000");
|
||||||
public static String[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(",");
|
public static String[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(",");
|
||||||
public static String[] moduleFiles = System.getProperty("launcherdebug.modulefiles", "").split(",");
|
public static String[] moduleFiles = System.getProperty("launcherdebug.modulefiles", "").split(",");
|
||||||
public static LauncherConfig.LauncherEnvironment environment = LauncherConfig.LauncherEnvironment.valueOf(System.getProperty("launcherdebug.env", "STD"));
|
public static LauncherConfig.LauncherEnvironment environment = LauncherConfig.LauncherEnvironment.valueOf(System.getProperty("launcherdebug.env", "STD"));
|
||||||
|
@ -32,6 +33,7 @@ public static void main(String[] args) throws Throwable {
|
||||||
LogHelper.info("Launcher start in DEBUG mode (Only for developers)");
|
LogHelper.info("Launcher start in DEBUG mode (Only for developers)");
|
||||||
LogHelper.debug("Initialization LauncherConfig");
|
LogHelper.debug("Initialization LauncherConfig");
|
||||||
LauncherConfig config = new LauncherConfig(webSocketURL, new HashMap<>(), projectName, environment, new DebugLauncherTrustManager(DebugLauncherTrustManager.TrustDebugMode.TRUST_ALL));
|
LauncherConfig config = new LauncherConfig(webSocketURL, new HashMap<>(), projectName, environment, new DebugLauncherTrustManager(DebugLauncherTrustManager.TrustDebugMode.TRUST_ALL));
|
||||||
|
config.oemUnlockKey = unlockKey;
|
||||||
Launcher.setConfig(config);
|
Launcher.setConfig(config);
|
||||||
Launcher.applyLauncherEnv(environment);
|
Launcher.applyLauncherEnv(environment);
|
||||||
LauncherEngine.modulesManager = new ClientModuleManager();
|
LauncherEngine.modulesManager = new ClientModuleManager();
|
||||||
|
|
|
@ -99,5 +99,9 @@ public enum ConnectTypes {
|
||||||
|
|
||||||
public interface AuthPasswordInterface {
|
public interface AuthPasswordInterface {
|
||||||
boolean check();
|
boolean check();
|
||||||
|
|
||||||
|
default boolean isAllowSave() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
|
|
||||||
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
|
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
|
||||||
import pro.gravit.launcher.request.Request;
|
import pro.gravit.launcher.request.Request;
|
||||||
|
import pro.gravit.launcher.request.auth.details.AuthLoginOnlyDetails;
|
||||||
import pro.gravit.launcher.request.auth.details.AuthPasswordDetails;
|
import pro.gravit.launcher.request.auth.details.AuthPasswordDetails;
|
||||||
import pro.gravit.launcher.request.auth.details.AuthTotpDetails;
|
import pro.gravit.launcher.request.auth.details.AuthTotpDetails;
|
||||||
import pro.gravit.launcher.request.auth.details.AuthWebViewDetails;
|
import pro.gravit.launcher.request.auth.details.AuthWebViewDetails;
|
||||||
|
@ -18,6 +19,7 @@ public static void registerProviders() {
|
||||||
providers.register("password", AuthPasswordDetails.class);
|
providers.register("password", AuthPasswordDetails.class);
|
||||||
providers.register("webview", AuthWebViewDetails.class);
|
providers.register("webview", AuthWebViewDetails.class);
|
||||||
providers.register("totp", AuthTotpDetails.class);
|
providers.register("totp", AuthTotpDetails.class);
|
||||||
|
providers.register("loginonly", AuthLoginOnlyDetails.class);
|
||||||
registeredProviders = true;
|
registeredProviders = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
package pro.gravit.launcher.request.auth.details;
|
||||||
|
|
||||||
|
import pro.gravit.launcher.events.request.GetAvailabilityAuthRequestEvent;
|
||||||
|
|
||||||
|
public class AuthLoginOnlyDetails implements GetAvailabilityAuthRequestEvent.AuthAvailabilityDetails {
|
||||||
|
@Override
|
||||||
|
public String getType() {
|
||||||
|
return "loginonly";
|
||||||
|
}
|
||||||
|
}
|
|
@ -7,4 +7,6 @@ public class AuthPasswordDetails implements GetAvailabilityAuthRequestEvent.Auth
|
||||||
public String getType() {
|
public String getType() {
|
||||||
return "password";
|
return "password";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,4 +10,9 @@ public class Auth2FAPassword implements AuthRequest.AuthPasswordInterface {
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
return firstPassword != null && firstPassword.check() && secondPassword != null && secondPassword.check();
|
return firstPassword != null && firstPassword.check() && secondPassword != null && secondPassword.check();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAllowSave() {
|
||||||
|
return firstPassword.isAllowSave() && secondPassword.isAllowSave();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,4 +11,9 @@ public class AuthMultiPassword implements AuthRequest.AuthPasswordInterface {
|
||||||
public boolean check() {
|
public boolean check() {
|
||||||
return list != null && list.stream().allMatch(l -> l != null && l.check());
|
return list != null && list.stream().allMatch(l -> l != null && l.check());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isAllowSave() {
|
||||||
|
return list != null && list.stream().allMatch(l -> l != null && l.isAllowSave());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
2
modules
2
modules
|
@ -1 +1 @@
|
||||||
Subproject commit ca22fda40f690015edf7650f4365b8efa8e96ec8
|
Subproject commit 8b616fff0946652ebba6d6dd432b73b8075421a5
|
Loading…
Reference in a new issue