Search in sources :

Example 16 with Escaper

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);
}
Also used : Escaper(com.google.common.escape.Escaper)

Example 17 with Escaper

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;
}
Also used : Map(java.util.Map) Escaper(com.google.common.escape.Escaper)

Aggregations

Escaper (com.google.common.escape.Escaper)17 Map (java.util.Map)2 TextMatching (annis.model.QueryNode.TextMatching)1 IndentedLinesBuilder (com.google.template.soy.base.internal.IndentedLinesBuilder)1 SoyMsg (com.google.template.soy.msgs.restricted.SoyMsg)1 SoyMsgPart (com.google.template.soy.msgs.restricted.SoyMsgPart)1 SoyMsgPlaceholderPart (com.google.template.soy.msgs.restricted.SoyMsgPlaceholderPart)1 SoyMsgRawTextPart (com.google.template.soy.msgs.restricted.SoyMsgRawTextPart)1 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)1 Task (com.intellij.openapi.progress.Task)1 Project (com.intellij.openapi.project.Project)1 CharacterEscapeHandler (com.sun.xml.bind.marshaller.CharacterEscapeHandler)1 IOException (java.io.IOException)1 Writer (java.io.Writer)1 CancellationException (java.util.concurrent.CancellationException)1 CompletionException (java.util.concurrent.CompletionException)1 JAXBContext (javax.xml.bind.JAXBContext)1 JAXBException (javax.xml.bind.JAXBException)1 Marshaller (javax.xml.bind.Marshaller)1 Test (org.junit.Test)1