Java源码示例:com.mojang.authlib.exceptions.AuthenticationException

示例1
public void addAccount(String email, String password) throws AuthenticationException {
    userAuth.logOut();
    userAuth.setUsername(email);
    userAuth.setPassword(password);

    userAuth.logIn();
    String token = userAuth.getAuthenticatedToken();

    Account account = new Account(email, password, userAuth.getSelectedProfile().getId().toString(),
            userAuth.getSelectedProfile().getName(),
            userAuth.getUserType().getName());
    accounts.add(account);

    GameProfile profile = userAuth.getSelectedProfile();
    The5zigMod.getVars().setSession(profile.getName(), profile.getId().toString(),
            token, userAuth.getUserType().getName());
    updateSettings();
    account.setSelected(true);
    try {
        save();
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
示例2
@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);
		}
	});
}
 
示例3
@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);
		}
	});
}
 
示例4
@Override
public void joinServer(GameProfile profile, String accessToken, String serverID) throws AuthenticationException {

    // Join server
    String username = profile.getName();
    if (LogHelper.isDebugEnabled()) {
        LogHelper.debug("joinServer, Username: '%s', Access token: %s, Server ID: %s", username, accessToken, serverID);
    }

    // Make joinServer request
    boolean success;
    try {
        success = new JoinServerRequest(username, accessToken, serverID).request().allow;
    } catch (Exception e) {
        LogHelper.error(e);
        throw new AuthenticationUnavailableException(e);
    }

    // Verify is success
    if (!success)
        throw new AuthenticationException("Bad Login (Clientside)");
}
 
示例5
public void login(Account account) throws AuthenticationException {
    userAuth.logOut();
    if("legacy".equals(account.getAccountType())) {
        userAuth.setUsername(account.getName());
        The5zigMod.getVars().setSession(account.getName(), account.getName(), "0", "legacy");
    }
    else {
        userAuth.setUsername(account.getEmail());
        userAuth.setPassword(account.getPassword());

        userAuth.logIn();

        GameProfile profile = userAuth.getSelectedProfile();

        The5zigMod.getVars().setSession(profile.getName(), profile.getId().toString(), userAuth.getAuthenticatedToken(),
                userAuth.getUserType().getName());

        account.setName(profile.getName());
        try {
            save();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    account.setSelected(true);
    updateSettings();
    The5zigMod.getOverlayMessage().displayMessage("Login Success", "Logged in as " + account.getName());
}
 
示例6
@Override
protected void actionPerformed(IButton button) {
    if(button.getId() == 201) {
        String user = userField.callGetText();
        String password = passwordField.callGetText();

        if(user == null || user.isEmpty()) {
            The5zigMod.getVars().displayScreen(lastScreen);
            return;
        }

        if(account != null) {
            if(password == null || password.isEmpty()) {
                account.setName(user);
            }
            else {
                account.setEmail(user);
                account.setPassword(password);
            }

            The5zigMod.getAccountManager().save();
        }
        else {
            if (password == null || password.isEmpty()) {
                The5zigMod.getAccountManager().addOfflineAccount(user);
            } else {
                try {
                    The5zigMod.getAccountManager().addAccount(user, password);
                } catch (AuthenticationException e) {
                    e.printStackTrace();
                    The5zigMod.getOverlayMessage().displayMessage("Auth error", "Bad login");
                    return;
                }
            }
        }

        The5zigMod.getVars().displayScreen(lastScreen);
    }
}
 
示例7
@Override
public void onSelect(int id, Account row, boolean doubleClick) {
    if(!row.isClickable()) return;
    if(doubleClick) {
        try {
            The5zigMod.getAccountManager().login(row);
        } catch (AuthenticationException e) {
            e.printStackTrace();
            The5zigMod.getOverlayMessage().displayMessage("Auth error", "Bad login");
        }
    }
}
 
示例8
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();
}