Search in sources :

Example 6 with EncryptionManager

use of jgnash.util.EncryptionManager in project jgnash by ccavanaugh.

the class DistributedLockServer method startServer.

public boolean startServer(final char[] password) {
    boolean result = false;
    // If a password has been specified, create an EncryptionManager
    if (password != null && password.length > 0) {
        encryptionManager = new EncryptionManager(password);
    }
    eventLoopGroup = new NioEventLoopGroup();
    final ServerBootstrap bootstrap = new ServerBootstrap();
    try {
        bootstrap.group(eventLoopGroup).channel(NioServerSocketChannel.class).childHandler(new Initializer()).childOption(ChannelOption.SO_KEEPALIVE, true);
        final ChannelFuture future = bootstrap.bind(port);
        future.sync();
        if (future.isDone() && future.isSuccess()) {
            logger.info("Distributed Lock Server started successfully");
            result = true;
        } else {
            logger.info("Failed to start the Distributed Lock Server");
        }
    } catch (final InterruptedException e) {
        logger.log(Level.SEVERE, e.getLocalizedMessage(), e);
        stopServer();
    }
    return result;
}
Also used : ChannelFuture(io.netty.channel.ChannelFuture) EncryptionManager(jgnash.util.EncryptionManager) ChannelInitializer(io.netty.channel.ChannelInitializer) NioEventLoopGroup(io.netty.channel.nio.NioEventLoopGroup) ServerBootstrap(io.netty.bootstrap.ServerBootstrap)

Aggregations

EncryptionManager (jgnash.util.EncryptionManager)6 NioEventLoopGroup (io.netty.channel.nio.NioEventLoopGroup)5 Bootstrap (io.netty.bootstrap.Bootstrap)3 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)3 ChannelFuture (io.netty.channel.ChannelFuture)3 ChannelInitializer (io.netty.channel.ChannelInitializer)3 NioSocketChannel (io.netty.channel.socket.nio.NioSocketChannel)3 SocketChannel (io.netty.channel.socket.SocketChannel)1 NioServerSocketChannel (io.netty.channel.socket.nio.NioServerSocketChannel)1 DelimiterBasedFrameDecoder (io.netty.handler.codec.DelimiterBasedFrameDecoder)1 Base64Decoder (io.netty.handler.codec.base64.Base64Decoder)1 Base64Encoder (io.netty.handler.codec.base64.Base64Encoder)1 StringDecoder (io.netty.handler.codec.string.StringDecoder)1 StringEncoder (io.netty.handler.codec.string.StringEncoder)1 NettyTransferHandler (jgnash.engine.attachment.NettyTransferHandler)1