当前位置: 首页>>代码示例>>Java>>正文


Java YggdrasilUserAuthentication类代码示例

本文整理汇总了Java中com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication的典型用法代码示例。如果您正苦于以下问题:Java YggdrasilUserAuthentication类的具体用法?Java YggdrasilUserAuthentication怎么用?Java YggdrasilUserAuthentication使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


YggdrasilUserAuthentication类属于com.mojang.authlib.yggdrasil包,在下文中一共展示了YggdrasilUserAuthentication类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: attemptLogin

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
private void attemptLogin(Map<String, String> argMap)
{
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(argMap.get("username"));
    auth.setPassword(argMap.get("password"));
    argMap.put("password", null);

    try {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LOGGER.error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // dont set other variables
    }

    LOGGER.info("Login Succesful!");
    argMap.put("accessToken", auth.getAuthenticatedToken());
    argMap.put("uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
    argMap.put("username", auth.getSelectedProfile().getName());
    argMap.put("userType", auth.getUserType().getName());
    
    // 1.8 only apperantly.. -_-
    argMap.put("userProperties", new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(auth.getUserProperties()));
}
 
开发者ID:Yarichi,项目名称:Proyecto-DASI,代码行数:27,代码来源:GradleStart.java

示例2: createSession

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
private final Session createSession(String username, String password) {
    if (password.isEmpty()) {
        return new Session(username, mc.getSession().getPlayerID(),
                "topkek memes", "mojang");
    }
    final YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(
            Proxy.NO_PROXY, "");
    final YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) service
            .createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(username);
    auth.setPassword(password);
    try {
        auth.logIn();
        return new Session(auth.getSelectedProfile().getName(), UUIDTypeAdapter.fromUUID(auth
                .getSelectedProfile().getId()),
                auth.getAuthenticatedToken(), "mojang");
    } catch (final Exception e) {
        return null;
    }
}
 
开发者ID:SerenityEnterprises,项目名称:SerenityCE,代码行数:21,代码来源:LoginThread.java

示例3: loginPassword

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
public static Session loginPassword(String username, String password)
{
    if(username == null || username.length() <= 0 || password == null || password.length() <= 0)
        return null;

    YggdrasilAuthenticationService a = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
    YggdrasilUserAuthentication b = (YggdrasilUserAuthentication)a.createUserAuthentication(Agent.MINECRAFT);
    b.setUsername(username);
    b.setPassword(password);
    try
    {
        b.logIn();
        return new Session(b.getSelectedProfile().getName(), b.getSelectedProfile().getId().toString(), b.getAuthenticatedToken(), "LEGACY");
    } catch (AuthenticationException e)
    {
    	altScreen.dispErrorString = "".concat("\247cBad Login \2477(").concat(username).concat(")");
        e.printStackTrace();
    }
    return null;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:21,代码来源:Manager.java

示例4: loginPassword

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
public static Session loginPassword(String username, String password) {
    if (username == null || username.length() <= 0 || password == null || password.length() <= 0)
        return null;

    YggdrasilAuthenticationService a = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
    YggdrasilUserAuthentication b = (YggdrasilUserAuthentication) a.createUserAuthentication(Agent.MINECRAFT);
    b.setUsername(username);
    b.setPassword(password);
    try {
        b.logIn();
        return new Session(b.getSelectedProfile().getName(), b.getSelectedProfile().getId().toString(), b.getAuthenticatedToken(), "LEGACY");
    } catch (AuthenticationException e) {
        e.printStackTrace();
        System.out.println("Failed login: " + username + ":" + password);
    }
    return null;
}
 
开发者ID:sudofox,项目名称:Backmemed,代码行数:18,代码来源:YggdrasilPayload.java

示例5: login

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
public static void login(Map<String, String> args)
{
    if (!args.containsKey("--username") || !args.containsKey("--password")) return;
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(args.get("--username"));
    auth.setPassword(args.remove("--password"));

    try
    {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LogManager.getLogger("FMLTWEAK").error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // don't set other variables
    }

    args.put("--username",       auth.getSelectedProfile().getName());
    args.put("--uuid",           auth.getSelectedProfile().getId().toString().replace("-", ""));
    args.put("--accessToken",    auth.getAuthenticatedToken());
    args.put("--userProperties", auth.getUserProperties().toString());
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:24,代码来源:Yggdrasil.java

示例6: login

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
public static void login(Map<String, String> args)
{
    if (!args.containsKey("--username") || !args.containsKey("--password")) return;
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(args.get("--username"));
    auth.setPassword(args.remove("--password"));

    try
    {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LogManager.getLogger("FMLTWEAK").error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // dont set other variables
    }

    args.put("--username",       auth.getSelectedProfile().getName());
    args.put("--uuid",           auth.getSelectedProfile().getId().toString().replace("-", ""));
    args.put("--accessToken",    auth.getAuthenticatedToken());
    args.put("--userProperties", auth.getUserProperties().toString());
}
 
开发者ID:SchrodingersSpy,项目名称:TRHS_Club_Mod_2016,代码行数:24,代码来源:Yggdrasil.java

示例7: attemptLogin

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
private static void attemptLogin(GradleStart args)
{
    YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1").createUserAuthentication(Agent.MINECRAFT);
    auth.setUsername(args.values.get("username"));
    auth.setPassword(args.values.get("password"));
    args.values.put("password", null);

    try {
        auth.logIn();
    }
    catch (AuthenticationException e)
    {
        LOGGER.error("-- Login failed!  " + e.getMessage());
        Throwables.propagate(e);
        return; // dont set other variables
    }

    LOGGER.info("Login Succesful!");
    args.values.put("accessToken", auth.getAuthenticatedToken());
    args.values.put("uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
    args.values.put("username", auth.getSelectedProfile().getName());
    //@@[email protected]@
    args.values.put("userProperties", auth.getUserProperties().toString());
}
 
开发者ID:mathmods,项目名称:Forbidden,代码行数:25,代码来源:GradleStart.java

示例8: createSession

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
private Session createSession(String email, String pass) {
    YggdrasilAuthenticationService service = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
    YggdrasilUserAuthentication authentication = (YggdrasilUserAuthentication)service.createUserAuthentication(Agent.MINECRAFT);
    authentication.setUsername(email);
    authentication.setPassword(pass);
    try {
        authentication.logIn();
        return new Session(authentication.getSelectedProfile().getName(), authentication.getSelectedProfile().getId().toString(), authentication.getAuthenticatedToken(), "legacy");
    }
    catch (AuthenticationException e) {
        return null;
    }
}
 
开发者ID:SkidJava,项目名称:BaseClient,代码行数:14,代码来源:LoginThread.java

示例9: login

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
public void login(YggdrasilUserAuthentication auth) throws Exception {
	if(!auth.isLoggedIn()){
		throw new Exception("You must be logged with with mojang before you can log into hearth");
	}
	HttpResponse<String> response = Unirest.post(HearthApi.API_URL + "/auth/login/" + auth.getAuthenticatedToken() + "/" + auth.getAuthenticationService().getClientToken()).asString();
	if (response.getStatus() == 403) {
		throw new Exception(response.getBody());
	}
	OneClientLogging.logger.info("Successfully logged into hearth");
	authentication = JsonUtil.GSON.fromJson(response.getBody(), ClientAuthentication.class);
	MinecraftAuthController.setAccessToken(auth, authentication.accessToken);
	ContentPanes.PRIVATE_PACK_PANE.onLogin();
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:14,代码来源:HearthAuthentication.java

示例10: main

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
public static void main(String[] args) {
    File file = new File(".gradle/minecraft/natives/");
    if (!file.exists()) {
        file = new File("../.gradle/minecraft/natives/");
    }
    System.setProperty("org.lwjgl.librarypath", file.getAbsolutePath());
    OMLStrippableTransformer.SIDE = Side.CLIENT;
    LaunchArguments arguments = new LaunchArguments(args);

    if (arguments.containsArgument("password")) {
        YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication) (new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1")).createUserAuthentication(Agent.MINECRAFT);
        auth.setUsername(arguments.getArgument("username"));
        auth.setPassword(arguments.getArgument("password"));
        arguments.removeArgument("password");

        try {
            auth.logIn();
        } catch (AuthenticationException e) {
            e.printStackTrace();
            return;
        }

        arguments.addArgument("accessToken", auth.getAuthenticatedToken());
        arguments.addArgument("uuid", auth.getSelectedProfile().getId().toString().replace("-", ""));
        arguments.addArgument("username", auth.getSelectedProfile().getName());
        arguments.addArgument("userType", auth.getUserType().getName());
        arguments.addArgument("userProperties", new GsonBuilder().registerTypeAdapter(PropertyMap.class, new PropertyMap.Serializer()).create().toJson(auth.getUserProperties()));
    }

    arguments.addArgument("version", "1.10.2");
    arguments.addArgument("assetIndex", "1.10");
    arguments.addArgument("tweakClass", "xyz.openmodloader.launcher.OMLTweaker");

    if (arguments.containsArgument("accessToken")) {
        arguments.addArgument("accessToken", "OpenModLoader");
    }

    Launch.main(arguments.getArguments());
}
 
开发者ID:OpenModLoader,项目名称:OpenModLoader,代码行数:40,代码来源:OpenModLoaderClient.java

示例11: login

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
public static void login(String username, String password) {
    try {
        YggdrasilUserAuthentication auth = new YggdrasilUserAuthentication(new YggdrasilAuthenticationService(Proxy.NO_PROXY, UUID
                .randomUUID().toString()), Agent.MINECRAFT);
        auth.setUsername(username);
        auth.setPassword(password);
        auth.logIn();
        Session session = new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId().toString(),
                auth.getAuthenticatedToken(), Session.Type.MOJANG.name());
        Minecraft.getMinecraft().session = session;
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:hvze,项目名称:Providence,代码行数:15,代码来源:Client.java

示例12: getName

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
public static String getName(String email, String password) {
    YggdrasilAuthenticationService authenticationService = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
    YggdrasilUserAuthentication authentication =
            (YggdrasilUserAuthentication) authenticationService.createUserAuthentication(Agent.MINECRAFT);
    authentication.setUsername(email);
    authentication.setPassword(password);
    try {
        authentication.logIn();
        return authentication.getSelectedProfile().getName();
    } catch (Exception e) {
        return null;
    }
}
 
开发者ID:null-dev,项目名称:EvenWurse,代码行数:14,代码来源:LoginManager.java

示例13: setSessionData

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
public static final String setSessionData(String user, String pass) {
       YggdrasilAuthenticationService authentication = new YggdrasilAuthenticationService(Proxy.NO_PROXY, "");
       YggdrasilUserAuthentication auth = (YggdrasilUserAuthentication)authentication.createUserAuthentication(Agent.MINECRAFT);
       auth.setUsername(user);
       auth.setPassword(pass);
       try{
           auth.logIn();
           Resilience.getInstance().getWrapper().getMinecraft().session = new Session(auth.getSelectedProfile().getName(), auth.getSelectedProfile().getId(), auth.getAuthenticatedToken());
           return "\247bSuccess!";
       }catch(AuthenticationException e){
       	return "\247cBad Login";
       }
}
 
开发者ID:MinecraftModdedClients,项目名称:Resilience-Client-Source,代码行数:14,代码来源:Utils.java

示例14: login

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
public YggdrasilUserAuthentication login(Account account) {
    final YggdrasilUserAuthentication userAuthentication =
            (YggdrasilUserAuthentication) authenticationService.createUserAuthentication(Agent.MINECRAFT);

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

    try {
        userAuthentication.logIn();
    } catch (AuthenticationException e) {
        LexLauncher.log.error("Failed to login to account: " + account.getUsername(), e);
    }

    return userAuthentication;
}
 
开发者ID:jamierocks,项目名称:LexLauncher,代码行数:16,代码来源:AccountService.java

示例15: load

import com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication; //导入依赖的package包/类
public static void load() {
	authentication = (YggdrasilUserAuthentication) (new YggdrasilAuthenticationService(Proxy.NO_PROXY, "1")).createUserAuthentication(Agent.MINECRAFT);
	Optional<AuthStore> authStore = getAuthStore();
	if (authStore.isPresent()) {
		isAtemptingLogin = true;
		updateGui();
		OneClientLogging.info("Logging in with saved details");
		//Disabled as it doesnt seem to work great
		//			if (authStore.get().authStorage != null) {
		//				authentication.loadFromStorage(authStore.get().authStorage);
		//			}
		authentication.setPassword(authStore.get().password);
		authentication.setUsername(authStore.get().username);
		try {
			doLogin(true);
		} catch (Exception e) {
			if (authStore.get().authStorage != null) {
				authentication.loadFromStorage(authStore.get().authStorage);
			}
			if (authentication.isLoggedIn() && !authentication.canPlayOnline()) {
				OneClientLogging.error(e);
				Alert alert = new Alert(Alert.AlertType.CONFIRMATION);
				alert.setTitle("Failed to login");
				alert.setHeaderText("Failed to login");
				alert.setContentText("The OneClient could not log you into minecraft. "
					+ "\n You select a few options"
					+ "\n - Offline mode (Single Player only)"
					+ "\n - Login again"
					+ "\n - Logout, you can relogin at anytime");

				ButtonType buttonOffline = new ButtonType("Play Offline");
				ButtonType buttonLogin = new ButtonType("Login Again");
				ButtonType buttonLogout = new ButtonType("Logout", ButtonBar.ButtonData.CANCEL_CLOSE);

				alert.getButtonTypes().setAll(buttonOffline, buttonLogin, buttonLogout);

				Optional<ButtonType> result = alert.showAndWait();
				if (result.get() == buttonOffline) {
					OneClientLogging.info("Launching in offline mode");
				} else if (result.get() == buttonLogin) {
					openLoginGui();
				} else {
					doLogout();
				}

			} else {
				OneClientLogging.logUserError(e, "Failed to login, you will need to re-log in");
			}

			isAtemptingLogin = false;
			updateGui();
		}
	} else {
		isAtemptingLogin = false;
		updateGui();
	}
}
 
开发者ID:HearthProject,项目名称:OneClient,代码行数:58,代码来源:MinecraftAuthController.java


注:本文中的com.mojang.authlib.yggdrasil.YggdrasilUserAuthentication类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。