Java Code Examples for org.eclipse.jetty.util.Fields#add()

The following examples show how to use org.eclipse.jetty.util.Fields#add() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OAuthConnector.java    From openhab-core with Eclipse Public License 2.0 6 votes vote down vote up
private void setAuthentication(@Nullable String clientId, @Nullable String clientSecret, Request request,
        Fields fields, boolean supportsBasicAuth) {
    logger.debug("Setting authentication for clientId {}. Using basic auth {}", clientId, supportsBasicAuth);
    if (supportsBasicAuth && clientSecret != null) {
        String authString = clientId + ":" + clientSecret;
        request.header(HttpHeader.AUTHORIZATION,
                "Basic " + Base64.getEncoder().encodeToString(authString.getBytes(StandardCharsets.UTF_8)));
    } else {
        if (clientId != null) {
            fields.add(CLIENT_ID, clientId);
        }
        if (clientSecret != null) {
            fields.add(CLIENT_SECRET, clientSecret);
        }
    }
}
 
Example 2
Source File: OAuthConnector.java    From smarthome with Eclipse Public License 2.0 6 votes vote down vote up
private void setAuthentication(@Nullable String clientId, @Nullable String clientSecret, Request request,
        Fields fields, boolean supportsBasicAuth) {
    logger.debug("Setting authentication for clientId {}. Using basic auth {}", clientId, supportsBasicAuth);
    if (supportsBasicAuth && clientSecret != null) {
        String authString = clientId + ":" + clientSecret;
        request.header(HttpHeader.AUTHORIZATION,
                "Basic " + Base64.getEncoder().encodeToString(authString.getBytes(StandardCharsets.UTF_8)));
    } else {
        if (clientId != null) {
            fields.add(CLIENT_ID, clientId);
        }
        if (clientSecret != null) {
            fields.add(CLIENT_SECRET, clientSecret);
        }
    }
}
 
Example 3
Source File: RestClient.java    From app-runner with MIT License 5 votes vote down vote up
public ContentResponse createApp(String gitUrl, String appName) throws Exception {
    Fields fields = new Fields();
    fields.add("gitUrl", gitUrl);
    if (appName != null) {
        fields.add("appName", appName);
    }
    return client.POST(appRunnerUrl + "/api/v1/apps")
        .content(new FormContentProvider(fields)).send();
}
 
Example 4
Source File: RestClient.java    From app-runner with MIT License 5 votes vote down vote up
public ContentResponse updateApp(String gitUrl, String appName) throws Exception {
    Fields fields = new Fields();
    fields.add("gitUrl", gitUrl);
    return client.newRequest(appRunnerUrl + "/api/v1/apps/" + appName)
        .method("PUT")
        .content(new FormContentProvider(fields)).send();
}
 
Example 5
Source File: OAuthConnector.java    From openhab-core with Eclipse Public License 2.0 5 votes vote down vote up
private Fields initFields(String... parameters) {
    Fields fields = new Fields();

    for (int i = 0; i < parameters.length; i += 2) {
        if (i + 1 < parameters.length && parameters[i] != null && parameters[i + 1] != null) {
            logger.debug("Oauth request parameter {}, value {}", parameters[i], parameters[i + 1]);
            fields.add(parameters[i], parameters[i + 1]);
        }
    }
    return fields;
}
 
Example 6
Source File: OAuthConnector.java    From smarthome with Eclipse Public License 2.0 5 votes vote down vote up
private Fields initFields(String... parameters) {
    Fields fields = new Fields();

    for (int i = 0; i < parameters.length; i += 2) {
        if (i + 1 < parameters.length && parameters[i] != null && parameters[i + 1] != null) {
            logger.debug("Oauth request parameter {}, value {}", parameters[i], parameters[i + 1]);
            fields.add(parameters[i], parameters[i + 1]);
        }
    }
    return fields;
}