You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
871 B
38 lines
871 B
package dev.garrettmills.starship.hyperlink.util;
|
|
|
|
/**
|
|
* Token format:
|
|
* "hyperlink|https://hyperlink.url|token"
|
|
*/
|
|
public class LoginToken {
|
|
public static boolean isValidLoginToken(String token) {
|
|
try {
|
|
new LoginToken(token);
|
|
return true;
|
|
} catch (InvalidLoginTokenException e) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
private String _server;
|
|
private String _token;
|
|
|
|
public LoginToken(String token) throws InvalidLoginTokenException {
|
|
String[] parts = token.split("\\|");
|
|
if ( parts.length != 3 || !parts[0].equals("hyperlink")) {
|
|
throw new InvalidLoginTokenException();
|
|
}
|
|
|
|
this._server = parts[1];
|
|
this._token = parts[2];
|
|
}
|
|
|
|
public String getServer() {
|
|
return _server;
|
|
}
|
|
|
|
public String getToken() {
|
|
return _token;
|
|
}
|
|
}
|