[FIX] SessionStorage NPE

This commit is contained in:
Gravita 2020-12-17 01:39:24 +07:00
parent aced575921
commit 62c8ca878e
2 changed files with 9 additions and 0 deletions

View file

@ -10,6 +10,7 @@
import pro.gravit.launchserver.auth.protect.ProtectHandler; import pro.gravit.launchserver.auth.protect.ProtectHandler;
import pro.gravit.launchserver.auth.protect.hwid.HWIDProvider; import pro.gravit.launchserver.auth.protect.hwid.HWIDProvider;
import pro.gravit.launchserver.auth.provider.AuthProvider; import pro.gravit.launchserver.auth.provider.AuthProvider;
import pro.gravit.launchserver.auth.session.SessionStorage;
import pro.gravit.launchserver.auth.texture.TextureProvider; import pro.gravit.launchserver.auth.texture.TextureProvider;
import pro.gravit.launchserver.components.Component; import pro.gravit.launchserver.components.Component;
import pro.gravit.launchserver.config.LaunchServerConfig; import pro.gravit.launchserver.config.LaunchServerConfig;
@ -215,6 +216,7 @@ public static void registerAll() {
AuthRequest.registerProviders(); AuthRequest.registerProviders();
HWIDProvider.registerProviders(); HWIDProvider.registerProviders();
OptionalAction.registerProviders(); OptionalAction.registerProviders();
SessionStorage.registerProviders();
} }
public static void generateConfigIfNotExists(Path configFile, CommandHandler commandHandler, LaunchServer.LaunchServerEnv env) throws IOException { public static void generateConfigIfNotExists(Path configFile, CommandHandler commandHandler, LaunchServer.LaunchServerEnv env) throws IOException {

View file

@ -10,6 +10,7 @@
public abstract class SessionStorage { public abstract class SessionStorage {
protected transient LaunchServer server; protected transient LaunchServer server;
public static ProviderMap<SessionStorage> providers = new ProviderMap<>(); public static ProviderMap<SessionStorage> providers = new ProviderMap<>();
private static boolean registeredProviders = false;
public abstract byte[] getSessionData(UUID session); public abstract byte[] getSessionData(UUID session);
public abstract Stream<UUID> getSessionsFromUserUUID(UUID userUUID); public abstract Stream<UUID> getSessionsFromUserUUID(UUID userUUID);
public abstract boolean writeSession(UUID userUUID, UUID sessionUUID, byte[] data); public abstract boolean writeSession(UUID userUUID, UUID sessionUUID, byte[] data);
@ -23,4 +24,10 @@ public void init(LaunchServer server)
{ {
this.server = server; this.server = server;
} }
public static void registerProviders() {
if(!registeredProviders) {
providers.register("memory", MemorySessionStorage.class);
registeredProviders = true;
}
}
} }