com.mojang.authlib.exceptions.AuthenticationException Java Examples
The following examples show how to use
com.mojang.authlib.exceptions.AuthenticationException.
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 |
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(); } }
Example #2
Source File: PacketEncryption.java From The-5zig-Mod with GNU General Public License v3.0 | 6 votes |
@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 |
@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: YggdrasilMinecraftSessionService.java From Launcher with GNU General Public License v3.0 | 6 votes |
@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)"); }
Example #5
Source File: AccountManager.java From The-5zig-Mod with GNU General Public License v3.0 | 5 votes |
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()); }
Example #6
Source File: GuiAccount.java From The-5zig-Mod with GNU General Public License v3.0 | 5 votes |
@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); } }
Example #7
Source File: GuiAccountManager.java From The-5zig-Mod with GNU General Public License v3.0 | 5 votes |
@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"); } } }
Example #8
Source File: GuiAdd.java From LiquidBounce with GNU General Public License v3.0 | 4 votes |
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(); }