use of com.google.common.escape.Escaper in project AuthMeReloaded by AuthMe.
the class TwoFactor method getQrBarcodeUrl.
/**
* Creates a link to a QR barcode with the provided secret.
*
* @param user the player's name
* @param host the server host
* @param secret the TOTP secret
* @return URL leading to a QR code
*/
public static String getQrBarcodeUrl(String user, String host, String secret) {
String format = "https://www.google.com/chart?chs=130x130&chld=M%%7C0&cht=qr&chl=" + "otpauth://totp/" + "%s@%s%%3Fsecret%%3D%s";
Escaper urlEscaper = UrlEscapers.urlFragmentEscaper();
return String.format(format, urlEscaper.escape(user), urlEscaper.escape(host), secret);
}
use of com.google.common.escape.Escaper in project timbuctoo by HuygensING.
the class HttpRequest method getPathAndQuery.
public String getPathAndQuery() {
String url = this.path;
boolean isFirst = true;
for (Map.Entry<String, String> queryParameter : this.queryParameters.entries()) {
if (isFirst) {
url += "?";
isFirst = false;
} else {
url += "&";
}
Escaper escaper = UrlEscapers.urlFormParameterEscaper();
url += escaper.escape(queryParameter.getKey()) + "=" + escaper.escape(queryParameter.getValue());
}
return url;
}
Aggregations