本文整理汇总了Java中com.mojang.authlib.exceptions.AuthenticationException类的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationException类的具体用法?Java AuthenticationException怎么用?Java AuthenticationException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AuthenticationException类属于com.mojang.authlib.exceptions包,在下文中一共展示了AuthenticationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: build
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的package包/类
/**
* Attempts to login with the specified username and password.
* If the login is successful then a session will be created. If
* not, {@code null} will be returned
*
* @return A valid session, if able to login, otherwise {@code null}
*/
@Override
public Session build() {
UserAuthentication auth = new YggdrasilAuthenticationService(this.proxy, "").createUserAuthentication(Agent.MINECRAFT);
auth.setUsername(this.username);
auth.setPassword(this.password);
try {
auth.logIn();
} catch (AuthenticationException e) {
return null;
}
GameProfile profile = auth.getSelectedProfile();
return new Session(profile.getName(), profile.getId().toString(), auth.getAuthenticatedToken(), "MOJANG");
}
示例2: attemptLogin
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的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()));
}
示例3: loginPassword
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的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;
}
示例4: loginPassword
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的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;
}
示例5: login
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的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());
}
示例6: getUnCachedName
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的package包/类
private static String getUnCachedName(UUID uuid){
MinecraftProfilePropertiesResponse jsonResult;
try {
jsonResult = getResponse(downloadJsonData(getURL(UUIDUtils.fromUUID(uuid), RequestType.UUIDTONAME)));
} catch (AuthenticationException e) {
e.printStackTrace();
return ERROR;
}
if(jsonResult == null)return ERROR;
String name = jsonResult.getName();
if(!Strings.isNullOrEmpty(name)){
return name;
}
return ERROR;
}
示例7: login
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的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());
}
示例8: fillGameProfile
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的package包/类
protected GameProfile fillGameProfile(GameProfile profile, boolean requireSecure) {
try {
URL url = HttpAuthenticationService.constantURL("https://sessionserver.mojang.com/session/minecraft/profile/" + UUIDTypeAdapter.fromUUID(profile.getId()));
url = HttpAuthenticationService.concatenateURL(url, "unsigned=" + !requireSecure);
MinecraftProfilePropertiesResponse response = (MinecraftProfilePropertiesResponse)this.getAuthenticationService().makeRequest(url, (Object)null, MinecraftProfilePropertiesResponse.class);
if (response == null) {
LOGGER.debug("Couldn't fetch profile properties for " + profile + " as the profile does not exist");
return profile;
} else {
GameProfile result = new GameProfile(response.getId(), response.getName());
result.getProperties().putAll(response.getProperties());
profile.getProperties().putAll(response.getProperties());
LOGGER.debug("Successfully fetched profile properties for " + profile);
return result;
}
} catch (AuthenticationException var6) {
LOGGER.warn("Couldn't look up profile properties for " + profile, var6);
return profile;
}
}
示例9: auth
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的package包/类
@Override
public AuthResult auth(final String password, boolean force) {
if (this.userAuthentication.isLoggedIn() && !force) {
return AuthResult.ALREADY_LOGGED_IN;
} else {
this.userAuthentication.logOut();
this.userAuthentication.setUsername(this.client.getName());
this.userAuthentication.setPassword(password);
try {
this.userAuthentication.logIn();
this.accessToken = this.userAuthentication.getAuthenticatedToken();
this.selectedProfile = this.userAuthentication.getSelectedProfile();
return AuthResult.SUCCESS;
} catch (UserMigratedException ex) {
return AuthResult.USER_MIGRATED;
} catch (InvalidCredentialsException ex2) {
return AuthResult.INVALID_CREDENTIALS;
} catch (AuthenticationException ex3) {
return AuthResult.AUTH_EXCEPTION;
}
}
}
示例10: attemptLogin
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的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());
}
示例11: createSession
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的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;
}
}
示例12: getUnCachedUUID
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的package包/类
private static UUID getUnCachedUUID(String username){
NameResponse jsonResult;
try {
jsonResult = getNameResponse(downloadJsonData(getURL(username, RequestType.NAMETOUUID)));
} catch (AuthenticationException e) {
e.printStackTrace();
return null;
}
if(jsonResult == null)return null;
UUID uuid = UUIDUtils.fromString(jsonResult.getId());
return uuid;
}
示例13: getProfileData
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的package包/类
public static MinecraftProfilePropertiesResponse getProfileData(UUID uuid){
if(!propertiesCache.containsKey(uuid)){
String jsonResult = downloadJsonData(getURL(UUIDUtils.fromUUID(uuid), RequestType.UUIDTONAME));
MinecraftProfilePropertiesResponse response = null;
try {
response = getResponse(jsonResult);
if(response !=null)propertiesCache.put(uuid, response);
} catch (AuthenticationException e) {
e.printStackTrace();
}
return response;
}
return propertiesCache.get(uuid);
}
示例14: main
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的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());
}
示例15: joinServer
import com.mojang.authlib.exceptions.AuthenticationException; //导入依赖的package包/类
public void joinServer(GameProfile profile, String authenticationToken, String serverId) throws AuthenticationException {
JoinMinecraftServerRequest request = new JoinMinecraftServerRequest();
request.accessToken = authenticationToken;
request.selectedProfile = profile.getId();
request.serverId = serverId;
this.getAuthenticationService().makeRequest(JOIN_URL, request, Response.class);
}