Search in sources :

Example 1 with HttpConnection

use of org.ovirt.engine.sdk4.internal.HttpConnection in project ovirt-engine-sdk-java by oVirt.

the class ConnectionBuilder method build.

/**
 * Checks the values of the parameters given so far, checks that they are valid, and builds a connection using
 * them.
 *
 * @return the new connection
 */
public Connection build() {
    try {
        // Check the parameters:
        if (url == null) {
            throw new IllegalArgumentException("The 'url' parameter is mandatory");
        }
        if (trustStoreFile != null && !new File(trustStoreFile).exists()) {
            throw new IllegalArgumentException(String.format("The truststore file '%s' doesn't exist'", trustStoreFile));
        }
        urlobj = new URL(url);
        // If all the checks pass, then create the connection:
        HttpConnection connection = new HttpConnection();
        connection.setClient(createHttpClient());
        connection.setUrl(url);
        connection.setUser(user);
        connection.setPassword(password);
        connection.setSsoToken(token);
        connection.setKerberos(kerberos);
        connection.setSsoUrl(ssoUrl);
        connection.setSsoTokenName(ssoTokenName);
        connection.setSsoRevokeUrl(ssoRevokeUrl);
        connection.setHeaders(headers);
        return connection;
    } catch (Exception e) {
        throw new Error("Failed to build connection", e);
    }
}
Also used : HttpConnection(org.ovirt.engine.sdk4.internal.HttpConnection) File(java.io.File) URL(java.net.URL)

Aggregations

File (java.io.File)1 URL (java.net.URL)1 HttpConnection (org.ovirt.engine.sdk4.internal.HttpConnection)1