com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService Java Examples

The following examples show how to use com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AccountManager.java    From The-5zig-Mod with GNU General Public License v3.0 6 votes vote down vote up
public AccountManager() {
    // The client generates a random UUID for authentication.
    UUID uuid = UUID.randomUUID();

    AuthenticationService service = new YggdrasilAuthenticationService(The5zigMod.getVars().getProxy(), uuid.toString());
    userAuth = service.createUserAuthentication(Agent.MINECRAFT);
    service.createMinecraftSessionService();

    isNewManager = !new File(The5zigMod.getModDirectory(), "accounts.enc").exists();
}
 
Example #2
Source File: PacketEncryption.java    From The-5zig-Mod with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void handle() {
	final SecretKey secretKey = CryptManager.createNewSharedKey();
	String hash = (new BigInteger(CryptManager.getServerIdHash("", publicKey, secretKey))).toString(16);
	MinecraftSessionService yggdrasil = new YggdrasilAuthenticationService(The5zigMod.getVars().getProxy(), UUID.randomUUID().toString()).createMinecraftSessionService();
	try {
		yggdrasil.joinServer(The5zigMod.getVars().getGameProfile(), The5zigMod.getDataManager().getSession(), hash);
	} catch (AuthenticationException e) {
		The5zigMod.getNetworkManager().disconnect(I18n.translate("connection.bad_login"));
		throw new RuntimeException(e);
	}
	The5zigMod.getNetworkManager().sendPacket(new PacketEncryption(secretKey, publicKey, verifyToken), new ChannelFutureListener() {
		@Override
		public void operationComplete(ChannelFuture channelFuture) throws Exception {
			The5zigMod.getNetworkManager().enableEncryption(secretKey);
		}
	});
}
 
Example #3
Source File: PacketEncryption.java    From The-5zig-Mod with MIT License 6 votes vote down vote up
@Override
public void handle() {
	final SecretKey secretKey = CryptManager.createNewSharedKey();
	String hash = (new BigInteger(CryptManager.getServerIdHash("", publicKey, secretKey))).toString(16);
	MinecraftSessionService yggdrasil = new YggdrasilAuthenticationService(The5zigMod.getVars().getProxy(), UUID.randomUUID().toString()).createMinecraftSessionService();
	try {
		yggdrasil.joinServer(The5zigMod.getVars().getGameProfile(), The5zigMod.getDataManager().getSession(), hash);
	} catch (AuthenticationException e) {
		The5zigMod.getNetworkManager().disconnect(I18n.translate("connection.bad_login"));
		throw new RuntimeException(e);
	}
	The5zigMod.getNetworkManager().sendPacket(new PacketEncryption(secretKey, publicKey, verifyToken), new ChannelFutureListener() {
		@Override
		public void operationComplete(ChannelFuture channelFuture) throws Exception {
			The5zigMod.getNetworkManager().enableEncryption(secretKey);
		}
	});
}
 
Example #4
Source File: Utils.java    From ClientBase with MIT License 5 votes vote down vote up
public static Session createSession(String username, String password, @NotNull Proxy proxy) throws Exception {
    YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(proxy, "");
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) service
            .createUserAuthentication(Agent.MINECRAFT);

    auth.setUsername(username);
    auth.setPassword(password);

    auth.logIn();
    return new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(),
            auth.getAuthenticatedToken(), "mojang");
}
 
Example #5
Source File: NMSAuthService.java    From AlwaysOnline with GNU General Public License v2.0 5 votes vote down vote up
public static void setUp(SpigotLoader spigotLoader) throws Exception {

		String nmsVersion = spigotLoader.getServer().getClass().getPackage().getName().replace(".", ",").split(",")[3];

		String sessionServiceVariableName;
		String sessionAuthVariableName;

		switch (nmsVersion) {

			case "v1_8_R3":
				sessionServiceVariableName = "W";
				sessionAuthVariableName = "V";
				break;
			case "v1_9_R1":
				sessionServiceVariableName = "V";
				sessionAuthVariableName = "U";
				break;
			default:
				spigotLoader.getLogger().severe("AlwaysOnline currently does not support spigot version " + spigotLoader.getServer().getVersion());
				spigotLoader.getLogger().severe("This build of AlwaysOnline only supports minecraft versions 1.8 and 1.9");
				spigotLoader.getPluginLoader().disablePlugin(spigotLoader);
				return;

		}

		Method method = Class.forName("net.minecraft.server." + nmsVersion + ".MinecraftServer").getMethod("getServer");

		Object minecraftServer = method.invoke(null);

		Field sessionServiceVariable = minecraftServer.getClass().getSuperclass().getDeclaredField(sessionServiceVariableName);

		sessionServiceVariable.setAccessible(true);

		Field sessionAuthVariable = minecraftServer.getClass().getSuperclass().getDeclaredField(sessionAuthVariableName);

		sessionAuthVariable.setAccessible(true);

		sessionServiceVariable.set(minecraftServer,
				new NMSAuthService((YggdrasilAuthenticationService) sessionAuthVariable.get(minecraftServer), spigotLoader.alwaysOnline.database));
	}
 
Example #6
Source File: MixinGuiDisconnected.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Inject(method = "actionPerformed", at = @At("HEAD"))
private void actionPerformed(GuiButton button, CallbackInfo callbackInfo) {
    switch (button.id) {
        case 1:
            ServerUtils.connectToLastServer();
            break;
        case 3:
            if (!GuiTheAltening.Companion.getApiKey().isEmpty()) {
                final String apiKey = GuiTheAltening.Companion.getApiKey();
                final TheAltening theAltening = new TheAltening(apiKey);

                try {
                    final AccountData account = theAltening.getAccountData();
                    GuiAltManager.altService.switchService(AltService.EnumAltService.THEALTENING);

                    final YggdrasilUserAuthentication yggdrasilUserAuthentication = new YggdrasilUserAuthentication(new YggdrasilAuthenticationService(Proxy.NO_PROXY, ""), Agent.MINECRAFT);
                    yggdrasilUserAuthentication.setUsername(account.getToken());
                    yggdrasilUserAuthentication.setPassword(LiquidBounce.CLIENT_NAME);
                    yggdrasilUserAuthentication.logIn();

                    mc.session = new Session(yggdrasilUserAuthentication.getSelectedProfile().getName(), yggdrasilUserAuthentication.getSelectedProfile().getId().toString(), yggdrasilUserAuthentication.getAuthenticatedToken(), "mojang");
                    LiquidBounce.eventManager.callEvent(new SessionEvent());
                    ServerUtils.connectToLastServer();
                    break;
                } catch (final Throwable throwable) {
                    ClientUtils.getLogger().error("Failed to login into random account from TheAltening.", throwable);
                }
            }

            final List<MinecraftAccount> accounts = LiquidBounce.fileManager.accountsConfig.getAccounts();
            if (accounts.isEmpty()) break;

            final MinecraftAccount minecraftAccount = accounts.get(new Random().nextInt(accounts.size()));
            GuiAltManager.login(minecraftAccount);
            ServerUtils.connectToLastServer();
            break;
        case 4:
            LoginUtils.loginCracked(RandomUtils.randomString(RandomUtils.nextInt(5, 16)));
            ServerUtils.connectToLastServer();
            break;
        case 5:
            AntiForge.enabled = !AntiForge.enabled;
            forgeBypassButton.displayString = "Bypass AntiForge: " + (AntiForge.enabled ? "On" : "Off");
            LiquidBounce.fileManager.saveConfig(LiquidBounce.fileManager.valuesConfig);
            break;
    }
}
 
Example #7
Source File: GuiAdd.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
private void addAccount(final String name, final String password) {
    if (LiquidBounce.fileManager.accountsConfig.accountExists(name)) {
        status = "§cThe account has already been added.";
        return;
    }

    addButton.enabled = clipboardButton.enabled = false;

    final MinecraftAccount account = new MinecraftAccount(name, password);

    new Thread(() -> {
        if (!account.isCracked()) {
            status = "§aChecking...";

            try {
                final AltService.EnumAltService oldService = GuiAltManager.altService.getCurrentService();

                if (oldService != AltService.EnumAltService.MOJANG) {
                    GuiAltManager.altService.switchService(AltService.EnumAltService.MOJANG);
                }

                final YggdrasilUserAuthentication userAuthentication = (YggdrasilUserAuthentication)
                        new YggdrasilAuthenticationService(Proxy.NO_PROXY, "")
                                .createUserAuthentication(Agent.MINECRAFT);

                userAuthentication.setUsername(account.getName());
                userAuthentication.setPassword(account.getPassword());

                userAuthentication.logIn();
                account.setAccountName(userAuthentication.getSelectedProfile().getName());

                if (oldService == AltService.EnumAltService.THEALTENING)
                    GuiAltManager.altService.switchService(AltService.EnumAltService.THEALTENING);
            } catch (NullPointerException | AuthenticationException | NoSuchFieldException | IllegalAccessException e) {
                status = "§cThe account doesn't work.";
                addButton.enabled = clipboardButton.enabled = true;
                return;
            }
        }


        LiquidBounce.fileManager.accountsConfig.getAccounts().add(account);
        LiquidBounce.fileManager.saveConfig(LiquidBounce.fileManager.accountsConfig);

        status = "§aThe account has been added.";
        prevGui.status = status;
        mc.displayGuiScreen(prevGui);
    }).start();
}
 
Example #8
Source File: MixinGuiDisconnect.java    From LiquidBounce with GNU General Public License v3.0 4 votes vote down vote up
@Inject(method = "actionPerformed", at = @At("HEAD"))
private void actionPerformed(GuiButton button, CallbackInfo callbackInfo) {
    switch (button.id) {
        case 1:
            ServerUtils.connectToLastServer();
            break;
        case 2:
            AntiForge.enabled = !AntiForge.enabled;
            forgeBypassButton.displayString = "Bypass AntiForge: " + (AntiForge.enabled ? "On" : "Off");
            LiquidBounce.fileManager.saveConfig(LiquidBounce.fileManager.valuesConfig);
            break;
        case 3:
            if (!GuiTheAltening.Companion.getApiKey().isEmpty()) {
                final String apiKey = GuiTheAltening.Companion.getApiKey();
                final TheAltening theAltening = new TheAltening(apiKey);

                try {
                    final AccountData account = theAltening.getAccountData();
                    GuiAltManager.altService.switchService(AltService.EnumAltService.THEALTENING);

                    final YggdrasilUserAuthentication yggdrasilUserAuthentication = new YggdrasilUserAuthentication(new YggdrasilAuthenticationService(Proxy.NO_PROXY, ""), Agent.MINECRAFT);
                    yggdrasilUserAuthentication.setUsername(account.getToken());
                    yggdrasilUserAuthentication.setPassword(LiquidBounce.CLIENT_NAME);
                    yggdrasilUserAuthentication.logIn();

                    // TODO: no transformer rip
                    // mc.session = new Session(yggdrasilUserAuthentication.getSelectedProfile().getName(), yggdrasilUserAuthentication.getSelectedProfile().getId().toString(), yggdrasilUserAuthentication.getAuthenticatedToken(), "mojang");
                    LiquidBounce.eventManager.callEvent(new SessionEvent());
                    ServerUtils.connectToLastServer();
                    break;
                } catch (final Throwable throwable) {
                    ClientUtils.getLogger().error("Failed to login into random account from TheAltening.", throwable);
                }
            }

            final List<MinecraftAccount> accounts = LiquidBounce.fileManager.accountsConfig.altManagerMinecraftAccounts;
            if (accounts.isEmpty()) break;

            final MinecraftAccount minecraftAccount = accounts.get(new Random().nextInt(accounts.size()));
            GuiAltManager.login(minecraftAccount);
            ServerUtils.connectToLastServer();
            break;
        case 4:
            LoginUtils.loginCracked(RandomUtils.randomString(RandomUtils.nextInt(5, 16)));
            ServerUtils.connectToLastServer();
            break;
    }
}
 
Example #9
Source File: PaperGameProfileRepository.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public PaperGameProfileRepository(YggdrasilAuthenticationService authenticationService) {
    super(authenticationService);
}
 
Example #10
Source File: PaperUserAuthentication.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
public PaperUserAuthentication(YggdrasilAuthenticationService authenticationService, Agent agent) {
    super(authenticationService, agent);
}
 
Example #11
Source File: PaperMinecraftSessionService.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
protected PaperMinecraftSessionService(YggdrasilAuthenticationService authenticationService) {
    super(authenticationService);
}
 
Example #12
Source File: MixinIntegratedServer.java    From litematica with GNU Lesser General Public License v3.0 4 votes vote down vote up
private MixinIntegratedServer(File anvilFileIn, Proxy proxyIn, DataFixer dataFixerIn,
        YggdrasilAuthenticationService authServiceIn, MinecraftSessionService sessionServiceIn,
        GameProfileRepository profileRepoIn, PlayerProfileCache profileCacheIn)
{
    super(anvilFileIn, proxyIn, dataFixerIn, authServiceIn, sessionServiceIn, profileRepoIn, profileCacheIn);
}
 
Example #13
Source File: MojangAuthenticationFactory.java    From EggCrack with GNU General Public License v2.0 4 votes vote down vote up
public UserAuthentication createUserAuthentication(Proxy proxy) {
    return new YggdrasilAuthenticationService(
                    proxy,
                    UUID.randomUUID().toString()
    ).createUserAuthentication(agent);
}
 
Example #14
Source File: NMSAuthService.java    From AlwaysOnline with GNU General Public License v2.0 4 votes vote down vote up
public NMSAuthService(YggdrasilAuthenticationService authenticationService, Database database) {
	super(authenticationService);
	this.database = database;
}