Package org.ovirt.engine.sdk4
Class ConnectionBuilder
- java.lang.Object
-
- org.ovirt.engine.sdk4.ConnectionBuilder
-
- Direct Known Subclasses:
ConnectionBuilder42
,ConnectionBuilder45
public abstract class ConnectionBuilder extends Object
This class is used to build connections to the API server.
-
-
Field Summary
Fields Modifier and Type Field Description protected static String
BAD_KEY_ERROR
protected static String
BAD_PROTOCOL_ERROR
protected static String
CERTIFICATE_ERROR
protected boolean
compress
protected Map<String,String>
headers
protected static String
HTTP_PROTOCOL
protected static String
HTTPS_PROTOCOL
protected boolean
insecure
protected static String
IO_ERROR
protected boolean
kerberos
protected static String
KEY_STORE_ERROR
protected static String
KEY_STORE_FILE_NOT_FOUND_ERROR
protected static String
NO_TLS_ERROR
protected NoCaTrustManager
noCaTrustManager
protected String
password
protected int
timeout
protected String
token
protected String
trustStoreFile
protected String
trustStorePassword
protected String
url
protected URL
urlobj
protected String
user
-
Constructor Summary
Constructors Constructor Description ConnectionBuilder()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description Connection
build()
Checks the values of the parameters given so far, checks that they are valid, and builds a connection using them.ConnectionBuilder
compress(boolean compress)
Set a compress flagstatic ConnectionBuilder
connection()
Creates a new connection builder.protected abstract HttpClient
createHttpClient()
protected String
getHost()
protected int
getPort()
protected String
getProtocol()
String
getUrl()
ConnectionBuilder
header(String name, String value)
Custom HTTP headers to send with all requests.ConnectionBuilder
insecure(boolean insecure)
Set insecure flagConnectionBuilder
kerberos(boolean kerberos)
Set kerberos flagConnectionBuilder
password(String password)
Set passwordConnectionBuilder
ssoRevokeUrl(String ssoRevokeUrl)
Set SSO revoke urlConnectionBuilder
ssoTokenName(String ssoTokenName)
Set SSO token nameConnectionBuilder
ssoUrl(String ssoUrl)
Set SSO urlConnectionBuilder
timeout(int timeout)
Set timeoutConnectionBuilder
token(String token)
The token to be used to access API.ConnectionBuilder
trustStoreFile(String trustStoreFile)
Set the path of the file containing the trusted CA certificates.ConnectionBuilder
trustStorePassword(String trustStorePassword)
Set the password that is required to open the file containing the CA certificates.ConnectionBuilder
url(String url)
Set a Url of connection.ConnectionBuilder
user(String user)
Set user
-
-
-
Field Detail
-
BAD_PROTOCOL_ERROR
protected static final String BAD_PROTOCOL_ERROR
- See Also:
- Constant Field Values
-
BAD_KEY_ERROR
protected static final String BAD_KEY_ERROR
- See Also:
- Constant Field Values
-
NO_TLS_ERROR
protected static final String NO_TLS_ERROR
- See Also:
- Constant Field Values
-
KEY_STORE_ERROR
protected static final String KEY_STORE_ERROR
- See Also:
- Constant Field Values
-
KEY_STORE_FILE_NOT_FOUND_ERROR
protected static final String KEY_STORE_FILE_NOT_FOUND_ERROR
- See Also:
- Constant Field Values
-
CERTIFICATE_ERROR
protected static final String CERTIFICATE_ERROR
- See Also:
- Constant Field Values
-
IO_ERROR
protected static final String IO_ERROR
- See Also:
- Constant Field Values
-
HTTP_PROTOCOL
protected static String HTTP_PROTOCOL
-
HTTPS_PROTOCOL
protected static String HTTPS_PROTOCOL
-
url
protected String url
-
user
protected String user
-
password
protected String password
-
token
protected String token
-
insecure
protected boolean insecure
-
kerberos
protected boolean kerberos
-
timeout
protected int timeout
-
compress
protected boolean compress
-
trustStoreFile
protected String trustStoreFile
-
urlobj
protected URL urlobj
-
trustStorePassword
protected String trustStorePassword
-
noCaTrustManager
protected NoCaTrustManager noCaTrustManager
-
-
Method Detail
-
connection
public static ConnectionBuilder connection()
Creates a new connection builder.
-
url
public ConnectionBuilder url(String url)
Set a Url of connection.- Parameters:
url
- A string containing the base URL of the server, usually something like 'https://server.example.com/ovirt-engine/api'
-
user
public ConnectionBuilder user(String user)
Set user- Parameters:
user
-
-
password
public ConnectionBuilder password(String password)
Set password- Parameters:
password
- The password of the user
-
token
public ConnectionBuilder token(String token)
The token to be used to access API. Optionally, user can use token, instead of username and password to access API. If user don't specify `token` parameter, SDK will automatically create one.
-
insecure
public ConnectionBuilder insecure(boolean insecure)
Set insecure flag- Parameters:
insecure
- A boolean flag that indicates if the server TLS certificate and host name should be checked.
-
kerberos
public ConnectionBuilder kerberos(boolean kerberos)
Set kerberos flag- Parameters:
kerberos
- A boolean flag indicating if Kerberos authentication should be used instead of the default basic authentication. Default is false.
-
timeout
public ConnectionBuilder timeout(int timeout)
Set timeout- Parameters:
timeout
- The maximum total time to wait for the response, in seconds. A value of zero (the default) means wait for ever. If the timeout expires before the response is received an exception will be raised.
-
compress
public ConnectionBuilder compress(boolean compress)
Set a compress flag- Parameters:
compress
- A flag indicating if the SDK should ask the server to send compressed responses. The default is `true`. Note that this is a hint for the server, and that it may return uncompressed data even when this parameter is set to `true`.
-
trustStorePassword
public ConnectionBuilder trustStorePassword(String trustStorePassword)
Set the password that is required to open the file containing the CA certificates. Note that for Java key store files the password is used only to check the integrity of the file, so it is optional.
-
trustStoreFile
public ConnectionBuilder trustStoreFile(String trustStoreFile)
Set the path of the file containing the trusted CA certificates. This file must be a valid Java key store, using the Java `JKS` format, usually contained within files ending with the `.jks` extension. If `trustStoreFile` parameter is not set, then default Java trust store location is used, which is defined by `javax.net.ssl.trustStore` system property.
-
ssoUrl
public ConnectionBuilder ssoUrl(String ssoUrl)
Set SSO url- Parameters:
ssoUrl
- A string containing the base SSO URL of the server, usually something like `\https://server.example.com/ovirt-engine/sso/oauth/token?` `\grant_type=password&scope=ovirt-app-api` for password authentication or `\https://server.example.com/ovirt-engine/sso/oauth/token-http-auth?` `\grant_type=urn:ovirt:params:oauth:grant-type:http&scope=ovirt-app-api` for kerberos authentication Default SSO url is computed from the `url` if no `sso_url` is provided.
-
ssoRevokeUrl
public ConnectionBuilder ssoRevokeUrl(String ssoRevokeUrl)
Set SSO revoke url- Parameters:
ssoRevokeUrl
- A string containing the base URL of the SSO revoke service. This needs to be specified only when using an external authentication service. By default this URL is automatically calculated from the value of the `url` parameter, so that SSO token revoke will be performed using the SSO service that is part of the engine.
-
ssoTokenName
public ConnectionBuilder ssoTokenName(String ssoTokenName)
Set SSO token name- Parameters:
ssoTokenName
- The token name in the JSON SSO response returned from the SSO server. Default value is `access_token`.
-
header
public ConnectionBuilder header(String name, String value)
Custom HTTP headers to send with all requests. The keys of the map can be strings of symbols, and they will be used as the names of the headers. The values of the map will be used as the names of the headers. If the same header is provided here and in the `headers` parameter of a specific method call, then the `headers` parameter of the specific method call will have precedence.
-
build
public Connection build()
Checks the values of the parameters given so far, checks that they are valid, and builds a connection using them.- Returns:
- the new connection
-
createHttpClient
protected abstract HttpClient createHttpClient()
-
getHost
protected String getHost()
-
getProtocol
protected String getProtocol()
-
getPort
protected int getPort()
-
getUrl
public String getUrl()
- Returns:
- entry point URI
-
-