com.mojang.authlib.Agent Java Examples

The following examples show how to use com.mojang.authlib.Agent. 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: 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 #3
Source File: PaperGameProfileRepository.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void findProfilesByNames(String[] names, Agent agent, ProfileLookupCallback callback) {
    Set<String> unfoundNames = Sets.newHashSet();
    for (String name : names) {
        PreLookupProfileEvent event = new PreLookupProfileEvent(name);
        event.callEvent();
        if (event.getUUID() != null) {
            // Plugin provided UUI, we can skip network call.
            GameProfile gameprofile = new GameProfile(event.getUUID(), name);
            // We might even have properties!
            Set<ProfileProperty> profileProperties = event.getProfileProperties();
            if (!profileProperties.isEmpty()) {
                for (ProfileProperty property : profileProperties) {
                    gameprofile.getProperties().put(property.getName(), CraftPlayerProfile.asAuthlib(property));
                }
            }
            callback.onProfileLookupSucceeded(gameprofile);
        } else {
            unfoundNames.add(name);
        }
    }

    // Some things were not found.... Proceed to look up.
    if (!unfoundNames.isEmpty()) {
        String[] namesArr = unfoundNames.toArray(new String[unfoundNames.size()]);
        super.findProfilesByNames(namesArr, agent, new PreProfileLookupCallback(callback));
    }
}
 
Example #4
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 #5
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 #6
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 #7
Source File: PaperAuthenticationService.java    From Kettle with GNU General Public License v3.0 4 votes vote down vote up
@Override
public UserAuthentication createUserAuthentication(Agent agent) {
    return new PaperUserAuthentication(this, agent);
}
 
Example #8
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 #9
Source File: YggdrasilAuthenticationService.java    From Launcher with GNU General Public License v3.0 4 votes vote down vote up
@Override
public UserAuthentication createUserAuthentication(Agent agent) {
    throw new UnsupportedOperationException("createUserAuthentication is used only by Mojang Launcher");
}
 
Example #10
Source File: MojangAuthenticationFactory.java    From EggCrack with GNU General Public License v2.0 4 votes vote down vote up
public MojangAuthenticationFactory(Agent agent) {
    this.agent = agent;
}