public abstract class ConnectionBuilder extends Object
This class is used to build connections to the API server.
Modifier and Type | Field and Description |
---|---|
protected static String |
BAD_KEY_ERROR |
protected static String |
BAD_PROTOCOL_ERROR |
protected static String |
CERTIFICATE_ERROR |
protected boolean |
compress |
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 and Description |
---|
ConnectionBuilder() |
Modifier and Type | Method and 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 flag
|
static ConnectionBuilder |
connection()
Creates a new connection builder.
|
protected abstract HttpClient |
createHttpClient() |
protected String |
getHost() |
protected int |
getPort() |
protected String |
getProtocol() |
String |
getUrl() |
ConnectionBuilder |
insecure(boolean insecure)
Set insecure flag
|
ConnectionBuilder |
kerberos(boolean kerberos)
Set kerberos flag
|
ConnectionBuilder |
password(String password)
Set password
|
ConnectionBuilder |
ssoRevokeUrl(String ssoRevokeUrl)
Set SSO revoke url
|
ConnectionBuilder |
ssoTokenName(String ssoTokenName)
Set SSO token name
|
ConnectionBuilder |
ssoUrl(String ssoUrl)
Set SSO url
|
ConnectionBuilder |
timeout(int timeout)
Set timeout
|
ConnectionBuilder |
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
|
protected static final String BAD_PROTOCOL_ERROR
protected static final String BAD_KEY_ERROR
protected static final String NO_TLS_ERROR
protected static final String KEY_STORE_ERROR
protected static final String KEY_STORE_FILE_NOT_FOUND_ERROR
protected static final String CERTIFICATE_ERROR
protected static final String IO_ERROR
protected static String HTTP_PROTOCOL
protected static String HTTPS_PROTOCOL
protected String url
protected String user
protected String password
protected String token
protected boolean insecure
protected boolean kerberos
protected int timeout
protected boolean compress
protected String trustStoreFile
protected URL urlobj
protected String trustStorePassword
protected NoCaTrustManager noCaTrustManager
public static ConnectionBuilder connection()
Creates a new connection builder.
public ConnectionBuilder url(String url)
Set a Url of connection.
url
- A string containing the base URL of the server, usually something like
'https://server.example.com/ovirt-engine/api'public ConnectionBuilder user(String user)
Set user
user
- public ConnectionBuilder password(String password)
Set password
password
- The password of the userpublic 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.
public ConnectionBuilder insecure(boolean insecure)
Set insecure flag
insecure
- A boolean flag that indicates if the server TLS certificate and host
name should be checked.public ConnectionBuilder kerberos(boolean kerberos)
Set kerberos flag
kerberos
- A boolean flag indicating if Kerberos authentication should be used
instead of the default basic authentication. Default is false.public ConnectionBuilder timeout(int timeout)
Set timeout
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.public ConnectionBuilder compress(boolean compress)
Set a compress flag
compress
- A flag indicating if the SDK should ask
the server to send compressed responses. The default is false
.
Note that this is a hint for the server, and that it may return
uncompressed data even when this parameter is set to true
.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.
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.
public ConnectionBuilder ssoUrl(String ssoUrl)
Set SSO url
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.public ConnectionBuilder ssoRevokeUrl(String ssoRevokeUrl)
Set SSO revoke url
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.public ConnectionBuilder ssoTokenName(String ssoTokenName)
Set SSO token name
ssoTokenName
- The token name in the JSON SSO response returned from the SSO
server. Default value is access_token
.public Connection build()
Checks the values of the parameters given so far, checks that they are valid, and builds a connection using them.
protected abstract HttpClient createHttpClient()
protected String getHost()
protected String getProtocol()
protected int getPort()
public String getUrl()
Copyright © 2016. All rights reserved.