Skip to content
This repository has been archived by the owner on Mar 11, 2024. It is now read-only.

Commit

Permalink
Fixed project not compiling
Browse files Browse the repository at this point in the history
  • Loading branch information
BelgianDev committed Dec 8, 2023
1 parent 2362dc9 commit 82c7398
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 11 deletions.
4 changes: 4 additions & 0 deletions api/src/main/java/fr/atlasworld/network/api/AtlasNetwork.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package fr.atlasworld.network.api;

/**
* The AtlasNetwork class is the main class that represents the AtlasNetwork framework.
* It provides functionality to set and get the server instance.
*/
public class AtlasNetwork {
private static AtlasNetworkServer server;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@
import java.util.concurrent.TimeUnit;
import java.util.function.Supplier;


/**
* Abstract representation of AtlasNetwork's server system.
* This is your start point.
* You will find everything you need here to make your module work properly.
* AtlasNetworkServer is an interface representing a server in the AtlasNetwork system.
* It provides methods to access various components and functionalities of the server.
*/
public interface AtlasNetworkServer {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
import java.util.jar.JarEntry;

/**
* Abstract Network Module, used to implement and setup modules at startup or at runtime.
* The NetworkModule class is an abstract class that represents a network module.
* It provides basic functionality for initializing, activating, deactivating, and managing the module's lifecycle.
*/
public abstract class NetworkModule implements Module {
private ModuleMeta meta = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
import fr.atlasworld.network.api.security.Encryptor;
import fr.atlasworld.network.api.security.exceptions.CryptographyException;
import fr.atlasworld.network.api.services.database.Database;
import fr.atlasworld.network.core.AtlasNetwork;
import fr.atlasworld.network.core.networking.codec.NetworkCodec;
import fr.atlasworld.network.core.networking.codec.exception.DecodeException;
import fr.atlasworld.network.core.networking.packet.PacketByteBufImpl;
Expand Down Expand Up @@ -131,7 +130,6 @@ private void handleEncryption(ChannelHandlerContext ctx, PacketByteBuf buffer) t

ctx.writeAndFlush(response);
this.manager.enableEncryption(new SecretKeyEncryptor(this.AESChallengeKey));
w
} catch (CryptographyException e) {
throw new NetworkAuthenticationException("Could not decrypt received bytes.", e,
PacketExecutionException.SERVER_ERROR, true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
import io.netty.channel.ChannelPromise;

public class EncodeHandler extends ChannelOutboundHandlerAdapter {
private final NetworkCodec codec;
private final EncryptionManager encryptionManager;
private final NetworkCodec codec;

public EncodeHandler(NetworkCodec codec, EncryptionManager encryptionManager) {
this.codec = codec;
public EncodeHandler(EncryptionManager encryptionManager, NetworkCodec codec) {
this.encryptionManager = encryptionManager;
this.codec = codec;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
package fr.atlasworld.network.core.networking.security.encryption;

import fr.atlasworld.network.api.security.Encryptor;
import fr.atlasworld.network.api.security.SecurityManager;
import fr.atlasworld.network.api.security.exceptions.CryptographyException;
import fr.atlasworld.network.core.networking.packet.PacketByteBufImpl;
import io.netty.buffer.ByteBuf;

public class SystemEncryptionManager implements EncryptionManager {
private final SecurityManager securityManager;

private Encryptor encryptor;

public SystemEncryptionManager(SecurityManager securityManager) {
this.securityManager = securityManager;
}

@Override
public boolean encryptionEnabled() {
return this.encryptor != null;
Expand Down Expand Up @@ -35,4 +42,9 @@ public ByteBuf decrypt(ByteBuf encryptedSource) throws CryptographyException {
public void enableEncryption(Encryptor encryptor) {
this.encryptor = encryptor;
}

@Override
public SecurityManager getSecurityManager() {
return this.securityManager;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,18 @@
import fr.atlasworld.network.api.concurrent.action.SimpleFutureAction;
import fr.atlasworld.network.api.networking.packet.NetworkPacket;
import fr.atlasworld.network.api.networking.packet.PacketRegistry;
import fr.atlasworld.network.api.services.database.Database;
import fr.atlasworld.network.api.services.database.DatabaseService;
import fr.atlasworld.network.core.AtlasNetwork;
import fr.atlasworld.network.core.concurrent.action.ActionUtilities;
import fr.atlasworld.network.core.file.configuration.SocketConfiguration;
import fr.atlasworld.network.core.networking.codec.ApiConverterCodec;
import fr.atlasworld.network.core.networking.codec.NetworkCodec;
import fr.atlasworld.network.core.networking.handler.DecodeHandler;
import fr.atlasworld.network.core.networking.handler.EncodeHandler;
import fr.atlasworld.network.core.networking.handler.ResourceHandler;
import fr.atlasworld.network.core.networking.packet.registry.SystemPacketRegistry;
import fr.atlasworld.network.core.networking.security.authentication.AuthenticationProfile;
import fr.atlasworld.network.core.networking.security.encryption.EncryptionManager;
import fr.atlasworld.network.core.networking.security.encryption.SystemEncryptionManager;
import io.netty.bootstrap.ServerBootstrap;
Expand Down Expand Up @@ -54,9 +61,13 @@ public SystemSocket(SocketConfiguration socketConfiguration) {
.childHandler(new ChannelInitializer<SocketChannel>() {
@Override
protected void initChannel(@NotNull SocketChannel ch) throws Exception {
NetworkCodec codec = new ApiConverterCodec();
EncryptionManager encryptionManager = new SystemEncryptionManager();
DatabaseService databaseService = AtlasNetwork.getInstance().getServiceManager().getService(DatabaseService.class);
Database<AuthenticationProfile> database = databaseService.getDatabase("auth", new AuthenticationProfile.AuthenticationProfileFactory());
EncryptionManager encryptionManager = new SystemEncryptionManager(AtlasNetwork.getInstance().getSecurityManager());

ch.pipeline().addLast(new DecodeHandler(database, encryptionManager, new ApiConverterCodec()));
ch.pipeline().addLast(new ResourceHandler());
ch.pipeline().addLast(new EncodeHandler(encryptionManager, new ApiConverterCodec()));
}
});

Expand Down

0 comments on commit 82c7398

Please sign in to comment.