// Path: src/main/java/com/github/javawow/auth/AuthServer.java
// public final class AuthServer {
// 	private static final int PORT = 3724;
// 	private static final Logger LOGGER = LoggerFactory.getLogger(AuthServer.class);
// 	private static final Scanner sc = new Scanner(System.in);
// 	private static final EventLoopGroup bossGroup = new NioEventLoopGroup();
// 	private static final EventLoopGroup workerGroup = new NioEventLoopGroup();
// 	public static final AttributeKey<WoWSRP6Server> SRP_ATTR = AttributeKey.newInstance("SRP");
// 
// 	private AuthServer() {
// 	}
// 
// 	public static final void main(String[] args) {
// 		ServerBootstrap b = new ServerBootstrap()
// 				.group(bossGroup, workerGroup)
// 				.channel(NioServerSocketChannel.class)
// 				.childHandler(new ChannelInitializer<Channel>() {
// 					@Override
// 					protected void initChannel(Channel ch) throws Exception {
// 						ch.pipeline().addLast("encoder", AuthEncoder.getInstance());
// 						ch.pipeline().addLast("decoder", new AuthDecoder());
// 						ch.pipeline().addLast("handler", AuthServerHandler.getInstance());
// 					}
// 				})
// 				.option(ChannelOption.SO_BACKLOG, Integer.valueOf(NetUtil.SOMAXCONN))
// 				.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
// 				.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
// 				.childOption(ChannelOption.TCP_NODELAY, Boolean.TRUE)
// 				.childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE);
// 		ChannelFuture cf = b.bind(PORT).addListener(f -> {
// 			if (f.isSuccess()) {
// 				LOGGER.info("Auth Server listening on port {}.", PORT);
// 			} else {
// 				LOGGER.error("Binding to port {} failed", Integer.valueOf(PORT), f.cause());
// 			}
// 		});
// 		// Wait for the bind to complete
// 		try {
// 			cf.await();
// 		} catch (InterruptedException e) {
// 			// Restore interrupted status
// 			Thread.currentThread().interrupt();
// 		}
// 		while (sc.hasNextLine()) {
// 			if (sc.nextLine().equalsIgnoreCase("q")) {
// 				System.out.println("Shutting down...");
// 				workerGroup.shutdownGracefully();
// 				bossGroup.shutdownGracefully();
// 				break;
// 			}
// 		}
// 	}
// }
// 
// Path: src/main/java/com/github/javawow/auth/message/ReconnectProofMessage.java
// @Immutable
// public final class ReconnectProofMessage {
// 	@SuppressWarnings("Immutable")
// 	private final byte[] R1;
// 	@SuppressWarnings("Immutable")
// 	private final byte[] R2;
// 	@SuppressWarnings("Immutable")
// 	private final byte[] R3;
// 	private final byte numKeys; // number of keys
// 
// 	public ReconnectProofMessage(byte[] r1, byte[] r2, byte[] r3, byte numKeys) {
// 		Objects.requireNonNull(r1, "r1 must not be null");
// 		Objects.requireNonNull(r2, "r2 must not be null");
// 		Objects.requireNonNull(r3, "r3 must not be null");
// 		if (r1.length != 16) {
// 			throw new IllegalArgumentException("r1 must be length 16");
// 		}
// 		if (r2.length != 20) {
// 			throw new IllegalArgumentException("r2 must be length 20");
// 		}
// 		if (r3.length != 20) {
// 			throw new IllegalArgumentException("r3 must be length 20");
// 		}
// 		this.R1 = Arrays.copyOf(r1, 16);
// 		this.R2 = Arrays.copyOf(r2, 16);
// 		this.R3 = Arrays.copyOf(r3, 16);
// 		this.numKeys = numKeys;
// 	}
// 
// 	public final byte[] getR1() {
// 		return Arrays.copyOf(R1, R1.length);
// 	}
// 
// 	public final byte[] getR2() {
// 		return Arrays.copyOf(R2, R2.length);
// 	}
// 
// 	public final byte[] getR3() {
// 		return Arrays.copyOf(R3, R3.length);
// 	}
// 
// 	public final byte getNumKeys() {
// 		return numKeys;
// 	}
// }


import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.javawow.auth.AuthServer;
import com.github.javawow.auth.message.ReconnectProofMessage;
import io.netty.channel.Channel;
/*
 * Java World of Warcraft Emulation Project
 * Copyright (C) 2015-2020 JavaWoW
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.github.javawow.auth.handler;




public final class ReconnectVerifyHandler implements BasicAuthHandler<ReconnectProofMessage> {
	private static final Logger LOGGER = LoggerFactory.getLogger(ReconnectVerifyHandler.class);
	private static final ReconnectVerifyHandler INSTANCE = new ReconnectVerifyHandler();

	private ReconnectVerifyHandler() {
		// singleton
	}

	public static final ReconnectVerifyHandler getInstance() {
		return INSTANCE;
	}

	@Override
	public final boolean hasValidState(Channel channel) {
// Path: src/main/java/com/github/javawow/auth/AuthServer.java
// public final class AuthServer {
// 	private static final int PORT = 3724;
// 	private static final Logger LOGGER = LoggerFactory.getLogger(AuthServer.class);
// 	private static final Scanner sc = new Scanner(System.in);
// 	private static final EventLoopGroup bossGroup = new NioEventLoopGroup();
// 	private static final EventLoopGroup workerGroup = new NioEventLoopGroup();
// 	public static final AttributeKey<WoWSRP6Server> SRP_ATTR = AttributeKey.newInstance("SRP");
// 
// 	private AuthServer() {
// 	}
// 
// 	public static final void main(String[] args) {
// 		ServerBootstrap b = new ServerBootstrap()
// 				.group(bossGroup, workerGroup)
// 				.channel(NioServerSocketChannel.class)
// 				.childHandler(new ChannelInitializer<Channel>() {
// 					@Override
// 					protected void initChannel(Channel ch) throws Exception {
// 						ch.pipeline().addLast("encoder", AuthEncoder.getInstance());
// 						ch.pipeline().addLast("decoder", new AuthDecoder());
// 						ch.pipeline().addLast("handler", AuthServerHandler.getInstance());
// 					}
// 				})
// 				.option(ChannelOption.SO_BACKLOG, Integer.valueOf(NetUtil.SOMAXCONN))
// 				.option(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
// 				.childOption(ChannelOption.ALLOCATOR, PooledByteBufAllocator.DEFAULT)
// 				.childOption(ChannelOption.TCP_NODELAY, Boolean.TRUE)
// 				.childOption(ChannelOption.SO_KEEPALIVE, Boolean.TRUE);
// 		ChannelFuture cf = b.bind(PORT).addListener(f -> {
// 			if (f.isSuccess()) {
// 				LOGGER.info("Auth Server listening on port {}.", PORT);
// 			} else {
// 				LOGGER.error("Binding to port {} failed", Integer.valueOf(PORT), f.cause());
// 			}
// 		});
// 		// Wait for the bind to complete
// 		try {
// 			cf.await();
// 		} catch (InterruptedException e) {
// 			// Restore interrupted status
// 			Thread.currentThread().interrupt();
// 		}
// 		while (sc.hasNextLine()) {
// 			if (sc.nextLine().equalsIgnoreCase("q")) {
// 				System.out.println("Shutting down...");
// 				workerGroup.shutdownGracefully();
// 				bossGroup.shutdownGracefully();
// 				break;
// 			}
// 		}
// 	}
// }
// 
// Path: src/main/java/com/github/javawow/auth/message/ReconnectProofMessage.java
// @Immutable
// public final class ReconnectProofMessage {
// 	@SuppressWarnings("Immutable")
// 	private final byte[] R1;
// 	@SuppressWarnings("Immutable")
// 	private final byte[] R2;
// 	@SuppressWarnings("Immutable")
// 	private final byte[] R3;
// 	private final byte numKeys; // number of keys
// 
// 	public ReconnectProofMessage(byte[] r1, byte[] r2, byte[] r3, byte numKeys) {
// 		Objects.requireNonNull(r1, "r1 must not be null");
// 		Objects.requireNonNull(r2, "r2 must not be null");
// 		Objects.requireNonNull(r3, "r3 must not be null");
// 		if (r1.length != 16) {
// 			throw new IllegalArgumentException("r1 must be length 16");
// 		}
// 		if (r2.length != 20) {
// 			throw new IllegalArgumentException("r2 must be length 20");
// 		}
// 		if (r3.length != 20) {
// 			throw new IllegalArgumentException("r3 must be length 20");
// 		}
// 		this.R1 = Arrays.copyOf(r1, 16);
// 		this.R2 = Arrays.copyOf(r2, 16);
// 		this.R3 = Arrays.copyOf(r3, 16);
// 		this.numKeys = numKeys;
// 	}
// 
// 	public final byte[] getR1() {
// 		return Arrays.copyOf(R1, R1.length);
// 	}
// 
// 	public final byte[] getR2() {
// 		return Arrays.copyOf(R2, R2.length);
// 	}
// 
// 	public final byte[] getR3() {
// 		return Arrays.copyOf(R3, R3.length);
// 	}
// 
// 	public final byte getNumKeys() {
// 		return numKeys;
// 	}
// }


// Path: src/main/java/com/github/javawow/auth/handler/ReconnectVerifyHandler.java
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.github.javawow.auth.AuthServer;
import com.github.javawow.auth.message.ReconnectProofMessage;
import io.netty.channel.Channel;

/*
 * Java World of Warcraft Emulation Project
 * Copyright (C) 2015-2020 JavaWoW
 * 
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU Affero General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * 
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Affero General Public License for more details.
 * 
 * You should have received a copy of the GNU Affero General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.github.javawow.auth.handler;




public final class ReconnectVerifyHandler implements BasicAuthHandler<ReconnectProofMessage> {
	private static final Logger LOGGER = LoggerFactory.getLogger(ReconnectVerifyHandler.class);
	private static final ReconnectVerifyHandler INSTANCE = new ReconnectVerifyHandler();

	private ReconnectVerifyHandler() {
		// singleton
	}

	public static final ReconnectVerifyHandler getInstance() {
		return INSTANCE;
	}

	@Override
	public final boolean hasValidState(Channel channel) {
		return channel.attr(AuthServer.SRP_ATTR).get() != null;