Refactored using IntelliJ
This commit is contained in:
@@ -211,11 +211,10 @@ public final class ProtocolBridge {
|
||||
private void registerListeners() throws Exception {
|
||||
// Classic listeners
|
||||
if (isClassicSupported()) {
|
||||
Classic_ClientListener classicListener = new Classic_ClientListener();
|
||||
Classic_ClientListener classicListener = new Classic_ClientListener();
|
||||
classicListener.setProtocolBridge(this);
|
||||
protocolSettings.eventManager.registerListener(classicListener.getClass());
|
||||
}
|
||||
else protocolSettings.eventManager.unregisterListener(Classic_ClientListener.class);
|
||||
} else protocolSettings.eventManager.unregisterListener(Classic_ClientListener.class);
|
||||
|
||||
// INS Listeners
|
||||
if (isRunningAsINSServer()) {
|
||||
|
||||
@@ -5,7 +5,6 @@ import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.ClientConnectedEvent;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.events.ClientDisconnectedEvent;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.beta.AuthPacket;
|
||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
||||
@@ -27,6 +26,7 @@ public final class ClientListener extends EventListener {
|
||||
|
||||
/**
|
||||
* Sets the client variable
|
||||
*
|
||||
* @param client The Instance of the ProtocolClient
|
||||
*/
|
||||
public void setClient(ProtocolClient client) {
|
||||
@@ -58,7 +58,7 @@ public final class ClientListener extends EventListener {
|
||||
*/
|
||||
@Listener
|
||||
public void onDisconnect(ClientDisconnectedEvent event) {
|
||||
client.onINSDisconnect(event);
|
||||
client.onINSDisconnect(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -5,9 +5,7 @@ import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerConnectedEvent;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerDisconnectedEvent;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
||||
import org.openautonomousconnection.protocol.side.ins.ConnectedProtocolClient;
|
||||
import org.openautonomousconnection.protocol.side.ins.ProtocolINSServer;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
@@ -26,6 +24,7 @@ public final class INSServerListener extends EventListener {
|
||||
|
||||
/**
|
||||
* Sets the insServer variable
|
||||
*
|
||||
* @param insServer The Instance of the INSServer
|
||||
*/
|
||||
public void setINSServer(ProtocolINSServer insServer) {
|
||||
|
||||
@@ -5,9 +5,7 @@ import dev.unlegitdqrk.unlegitlibrary.event.Listener;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerConnectedEvent;
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.events.ConnectionHandlerDisconnectedEvent;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
||||
import org.openautonomousconnection.protocol.side.web.ConnectedWebClient;
|
||||
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
@@ -26,6 +24,7 @@ public final class WebServerListener extends EventListener {
|
||||
|
||||
/**
|
||||
* Sets the webServer variable
|
||||
*
|
||||
* @param webServer The Instance of the ProtocolWebServer
|
||||
*/
|
||||
public void setWebServer(ProtocolWebServer webServer) {
|
||||
|
||||
@@ -86,7 +86,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
/**
|
||||
* Creates a web connection to the specified InfoName and ports.
|
||||
*
|
||||
* @param infoName the target InfoName for the web connection.
|
||||
* @param infoName the target InfoName for the web connection.
|
||||
* @param pipelinePort the port used for the pipeline connection.
|
||||
* @param webPort the port used for the web connection.
|
||||
* @throws Exception if there are issues creating the web connection or if the protocol is unsupported.
|
||||
@@ -133,7 +133,8 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
|
||||
// Validate each file in the folder
|
||||
for (File file : files) {
|
||||
if (!file.getName().startsWith(prefix)) throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
||||
if (!file.getName().startsWith(prefix))
|
||||
throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
||||
|
||||
// Check for specific files
|
||||
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
|
||||
@@ -320,8 +321,8 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
/**
|
||||
* Requests the destination for the specified InfoName from the INS server.
|
||||
*
|
||||
* @param infoName the InfoName for which to request the destination.
|
||||
* @param responseCode the expected INSResponseCode for the request.
|
||||
* @param infoName the InfoName for which to request the destination.
|
||||
* @param responseCode the expected INSResponseCode for the request.
|
||||
* @throws IOException if there are I/O issues during the request process.
|
||||
* @throws ClassNotFoundException if there are issues with class loading during packet handling.
|
||||
*/
|
||||
@@ -336,6 +337,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
|
||||
/**
|
||||
* Set protocol bridge.
|
||||
*
|
||||
* @param protocolBridge The ProtocolBridge object.
|
||||
*/
|
||||
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
||||
@@ -345,7 +347,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
/**
|
||||
* Callback method invoked when InfoName validation is completed.
|
||||
*
|
||||
* @param infoName the InfoName that was validated.
|
||||
* @param infoName the InfoName that was validated.
|
||||
* @param responseCode the INSResponseCode resulting from the validation.
|
||||
*/
|
||||
public abstract void validationCompleted(InfoName infoName, INSResponseCode responseCode);
|
||||
@@ -353,7 +355,7 @@ public abstract class ProtocolClient extends DefaultMethodsOverrider {
|
||||
/**
|
||||
* Callback method invoked when the destination retrieval is completed.
|
||||
*
|
||||
* @param infoName the InfoName for which the destination was requested.
|
||||
* @param infoName the InfoName for which the destination was requested.
|
||||
* @param destination the retrieved destination as a string.
|
||||
* @param validationResponse the INSResponseCode resulting from the destination retrieval.
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.openautonomousconnection.protocol.side.client;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.client.NetworkClient;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
import org.openautonomousconnection.protocol.versions.v1_0_0.beta.InfoName;
|
||||
@@ -28,12 +27,15 @@ public final class WebClient {
|
||||
* NetworkClient instance for managing the pipeline connection to the web server.
|
||||
*/
|
||||
private final NetworkClient clientToWebPipeline;
|
||||
|
||||
/**
|
||||
* The Protocol Client associated with this protocol client.
|
||||
*/
|
||||
@Getter
|
||||
private final ProtocolClient protocolClient;
|
||||
/**
|
||||
* SSLSocket for secure communication with the web server.
|
||||
*/
|
||||
private SSLSocket clientToWebServer;
|
||||
|
||||
/**
|
||||
* Streams for object serialization over the SSL connection.
|
||||
*/
|
||||
@@ -43,18 +45,12 @@ public final class WebClient {
|
||||
*/
|
||||
private ObjectInputStream inputStream;
|
||||
|
||||
/**
|
||||
* The Protocol Client associated with this protocol client.
|
||||
*/
|
||||
@Getter
|
||||
private final ProtocolClient protocolClient;
|
||||
|
||||
/**
|
||||
* Constructs a WebClient instance and establishes a secure connection to the web server.
|
||||
*
|
||||
* @param infoName The InfoName information for the web server.
|
||||
* @param pipelinePort The port for the pipeline connection.
|
||||
* @param webPort The port for the web server connection.
|
||||
* @param pipelinePort The port for the pipeline connection.
|
||||
* @param webPort The port for the web server connection.
|
||||
* @param protocolClient The Protocol Client associated with this protocol client.
|
||||
* @throws Exception If an error occurs during connection setup.
|
||||
*/
|
||||
@@ -154,10 +150,7 @@ public final class WebClient {
|
||||
*/
|
||||
public NetworkClient getClientPipelineConnection() {
|
||||
return clientToWebPipeline;
|
||||
} /**
|
||||
* Thread for receiving data from the web server.
|
||||
*/
|
||||
private final Thread receiveThread = new Thread(this::receive);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the SSLSocket used for communication with the web server.
|
||||
@@ -166,7 +159,10 @@ public final class WebClient {
|
||||
*/
|
||||
public SSLSocket getClientWebConnection() {
|
||||
return clientToWebServer;
|
||||
}
|
||||
} /**
|
||||
* Thread for receiving data from the web server.
|
||||
*/
|
||||
private final Thread receiveThread = new Thread(this::receive);
|
||||
|
||||
/**
|
||||
* Checks if the WebClient is currently connected to the web server.
|
||||
|
||||
@@ -131,7 +131,8 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
|
||||
|
||||
// Validate each file in the folder
|
||||
for (File file : files) {
|
||||
if (!file.getName().startsWith(prefix)) throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
||||
if (!file.getName().startsWith(prefix))
|
||||
throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
||||
|
||||
// Check if the file matches the expected naming convention
|
||||
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
|
||||
@@ -155,6 +156,7 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
|
||||
|
||||
/**
|
||||
* Set protocol bridge
|
||||
*
|
||||
* @param protocolBridge The ProtocolBridge object
|
||||
*/
|
||||
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
||||
@@ -195,8 +197,8 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
|
||||
public abstract String getInfoNameDestination(InfoName infoName);
|
||||
|
||||
/**
|
||||
* @param infoName The parent InfoName.
|
||||
* @param subname The subname to look up.
|
||||
* @param infoName The parent InfoName.
|
||||
* @param subname The subname to look up.
|
||||
* @return The destination associated with the subname.
|
||||
* @see InfoName#getDestination(ProtocolBridge)
|
||||
* Abstract method to get the destination for a given subname under a specific InfoName.
|
||||
@@ -221,7 +223,8 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
|
||||
|
||||
/**
|
||||
* Abstract method called when a validation packet fails to send.
|
||||
* @param infoName The InfoName associated with the validation.
|
||||
*
|
||||
* @param infoName The InfoName associated with the validation.
|
||||
* @param client The connected protocol client.
|
||||
* @param exception The exception that occurred during sending.
|
||||
*/
|
||||
@@ -229,8 +232,9 @@ public abstract class ProtocolINSServer extends DefaultMethodsOverrider {
|
||||
|
||||
/**
|
||||
* Abstract method called when a InfoName destination packet fails to send.
|
||||
*
|
||||
* @param client The connected protocol client.
|
||||
* @param infoName The InfoName associated with the packet.
|
||||
* @param infoName The InfoName associated with the packet.
|
||||
* @param validationResponse The INS response code from validation.
|
||||
* @param exception The exception that occurred during sending.
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.openautonomousconnection.protocol.side.web;
|
||||
|
||||
import dev.unlegitdqrk.unlegitlibrary.network.system.server.ConnectionHandler;
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||
import org.openautonomousconnection.protocol.packets.OACPacket;
|
||||
import org.openautonomousconnection.protocol.side.web.managers.AuthManager;
|
||||
@@ -56,6 +55,12 @@ public final class ConnectedWebClient {
|
||||
*/
|
||||
@Getter
|
||||
private boolean clientVersionLoaded = false;
|
||||
/**
|
||||
* The reference to the ProtocolWebServer Object
|
||||
*/
|
||||
@Getter
|
||||
private ProtocolWebServer protocolWebServer;
|
||||
|
||||
/**
|
||||
* Constructs a ConnectedWebClient with the given connection handler.
|
||||
*
|
||||
@@ -68,12 +73,6 @@ public final class ConnectedWebClient {
|
||||
*/
|
||||
private final Thread receiveThread = new Thread(this::receive);
|
||||
|
||||
/**
|
||||
* The reference to the ProtocolWebServer Object
|
||||
*/
|
||||
@Getter
|
||||
private ProtocolWebServer protocolWebServer;
|
||||
|
||||
/**
|
||||
* Sends an HTTP redirect response to the client.
|
||||
*
|
||||
@@ -709,6 +708,7 @@ public final class ConnectedWebClient {
|
||||
|
||||
/**
|
||||
* Set protocol bridge
|
||||
*
|
||||
* @param protocolWebServer The ProtocolWebServer object
|
||||
*/
|
||||
public void setProtocolWebServer(ProtocolWebServer protocolWebServer) {
|
||||
|
||||
@@ -185,6 +185,7 @@ public final class ProtocolWebServer {
|
||||
|
||||
/**
|
||||
* Set protocol bridge
|
||||
*
|
||||
* @param protocolBridge The ProtocolBridge object
|
||||
*/
|
||||
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
||||
@@ -270,7 +271,7 @@ public final class ProtocolWebServer {
|
||||
* @throws CertificateException If a required certificate file is missing or invalid.
|
||||
* @throws IOException If an I/O error occurs while checking the files.
|
||||
*/
|
||||
private final void checkFileExists(File folder, String prefix, String extension) throws CertificateException, IOException {
|
||||
private void checkFileExists(File folder, String prefix, String extension) throws CertificateException, IOException {
|
||||
boolean found = false;
|
||||
|
||||
// Ensure the folder exists
|
||||
@@ -283,7 +284,8 @@ public final class ProtocolWebServer {
|
||||
|
||||
// Check for the required certificate file
|
||||
for (File file : files) {
|
||||
if (!file.getName().startsWith(prefix)) throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
||||
if (!file.getName().startsWith(prefix))
|
||||
throw new CertificateException(file.getAbsolutePath() + " is not valid");
|
||||
|
||||
// Check for file matching the public IP address
|
||||
if (!found) found = file.getName().equalsIgnoreCase(prefix + NetworkUtils.getPublicIPAddress() + extension);
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.openautonomousconnection.protocol.side.web.managers;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||
import org.openautonomousconnection.protocol.side.web.ProtocolWebServer;
|
||||
import org.openautonomousconnection.protocol.versions.ProtocolVersion;
|
||||
@@ -32,9 +31,9 @@ public final class SessionManager {
|
||||
/**
|
||||
* Creates a new session for the given user.
|
||||
*
|
||||
* @param login The username associated with the session.
|
||||
* @param ip The IP address of the client.
|
||||
* @param userAgent The User-Agent string of the client.
|
||||
* @param login The username associated with the session.
|
||||
* @param ip The IP address of the client.
|
||||
* @param userAgent The User-Agent string of the client.
|
||||
* @param protocolWebServer The Protocol WebServer for the unique Session
|
||||
* @return The generated session ID.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
@@ -55,9 +54,9 @@ public final class SessionManager {
|
||||
/**
|
||||
* Validates a session ID against the provided IP and User-Agent.
|
||||
*
|
||||
* @param sessionId The session ID to validate.
|
||||
* @param ip The IP address of the client.
|
||||
* @param userAgent The User-Agent string of the client.
|
||||
* @param sessionId The session ID to validate.
|
||||
* @param ip The IP address of the client.
|
||||
* @param userAgent The User-Agent string of the client.
|
||||
* @param protocolWebServer The Protocol WebServer to get the config for refreshing
|
||||
* @return True if the session is valid, false otherwise.
|
||||
* @throws IOException If an I/O error occurs.
|
||||
@@ -154,6 +153,7 @@ public final class SessionManager {
|
||||
|
||||
/**
|
||||
* Refreshes the session's expiration time.
|
||||
*
|
||||
* @param protocolWebServer The Protocol WebServer to get the Config setting
|
||||
* @throws IOException If an I/O error occurs.
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.openautonomousconnection.protocol.versions.v1_0_0.classic.handlers;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.openautonomousconnection.protocol.ProtocolBridge;
|
||||
import org.openautonomousconnection.protocol.annotations.ProtocolInfo;
|
||||
import org.openautonomousconnection.protocol.packets.v1_0_0.classic.Classic_MessagePacket;
|
||||
import org.openautonomousconnection.protocol.side.client.ProtocolClient;
|
||||
|
||||
@@ -24,7 +24,7 @@ public final class ClassicConverter {
|
||||
/**
|
||||
* Converts a InfoName object to a Classic_Domain object.
|
||||
*
|
||||
* @param newInfoName the InfoName object to convert
|
||||
* @param newInfoName the InfoName object to convert
|
||||
* @param protocolBridge The reference to the ProtocolBridge object.
|
||||
* @return the converted Classic_Domain object
|
||||
*/
|
||||
|
||||
@@ -33,6 +33,7 @@ public final class Classic_ClientListener extends EventListener {
|
||||
|
||||
/**
|
||||
* Set protocol bridge
|
||||
*
|
||||
* @param protocolBridge The ProtocolBridge object
|
||||
*/
|
||||
public void setProtocolBridge(ProtocolBridge protocolBridge) {
|
||||
|
||||
Reference in New Issue
Block a user