Example usage for org.apache.http.client.utils URIBuilder getUserInfo

List of usage examples for org.apache.http.client.utils URIBuilder getUserInfo

Introduction

In this page you can find the example usage for org.apache.http.client.utils URIBuilder getUserInfo.

Prototype

public String getUserInfo() 

Source Link

Usage

From source file:integration.IntegrationTestsConfig.java

public static URI getGlServerURL() throws MalformedURLException, URISyntaxException {
    URIBuilder result = new URIBuilder(GL_BASE_URI);
    if (GL_PORT != null) {
        result.setPort(Integer.parseInt(GL_PORT));
    }//from   w ww.  java 2 s . c  o m

    final String username;
    final String password;
    if (result.getUserInfo() == null) {
        username = GL_ADMIN_USER;
        password = GL_ADMIN_PASSWORD;
    } else {
        final String[] userInfo = result.getUserInfo().split(":");
        username = (GL_ADMIN_USER != null ? GL_ADMIN_USER : userInfo[0]);
        password = (GL_ADMIN_PASSWORD != null ? GL_ADMIN_PASSWORD : userInfo[1]);
    }

    result.setUserInfo(firstNonNull(username, "admin"), firstNonNull(password, "admin"));

    return result.build();
}

From source file:com.thoughtworks.go.util.command.UrlArgument.java

public String replaceSecretInfo(String line) {
    if (StringUtils.isBlank(line)) {
        return line;
    }//from w  ww  .  j av  a2 s. co m

    if (isBlank(this.url)) {
        return line;
    }

    try {
        final URIBuilder uriBuilder = new URIBuilder(this.url).setPath(null).setCustomQuery(null)
                .setFragment(null);
        final UrlUserInfo urlUserInfo = new UrlUserInfo(uriBuilder.getUserInfo());
        if (uriBuilder.getUserInfo() != null) {
            line = line.replace(uriBuilder.getUserInfo(), urlUserInfo.maskedUserInfo());
        }
    } catch (URISyntaxException e) {
        //Ignore as url is not according to URI specs
    }

    return line;
}

From source file:org.eclipse.packagedrone.testing.server.channel.UploadApiV3Test.java

protected CloseableHttpResponse upload(final URIBuilder uri, final File file)
        throws IOException, URISyntaxException {
    final HttpPut http = new HttpPut(uri.build());

    final String encodedAuth = Base64.getEncoder()
            .encodeToString(uri.getUserInfo().getBytes(StandardCharsets.ISO_8859_1));

    http.setHeader(HttpHeaders.AUTHORIZATION, "Basic " + encodedAuth);

    http.setEntity(new FileEntity(file));
    return httpclient.execute(http);
}

From source file:org.blocks4j.reconf.infra.http.layer.SimpleHttpRequest.java

SimpleHttpRequest(String method, String pathBase, String... pathParam) throws URISyntaxException {
    this.httpMethod = method;

    URIBuilder baseBuilder = new URIBuilder(pathBase);
    if (baseBuilder.getScheme() == null) {
        baseBuilder = new URIBuilder("http://" + pathBase);
    }//w w w .j av a  2s .c  o  m

    final StringBuilder pathBuilder = new StringBuilder(baseBuilder.getPath());
    for (String param : pathParam) {
        pathBuilder.append("/").append(param);
    }

    this.setURI(new URI(baseBuilder.getScheme(), baseBuilder.getUserInfo(), baseBuilder.getHost(),
            baseBuilder.getPort(), pathBuilder.toString(), null, null));
}