public class ApiBuilder extends Object
Api
object. Instead of using a long
list of constructor arguments, most of then with value null
, this can be used with a fluent style, for
example:
Api api = new ApiBuilder() .url("https://ovirt.example.com/ovirt-engine/api") .user("admin@internal") .password("******") .debug(true) .build();
Constructor and Description |
---|
ApiBuilder() |
Modifier and Type | Method and Description |
---|---|
Api |
build()
Creates an API entry point object.
|
ApiBuilder |
debug(Boolean debug)
Enables or disables debug output.
|
ApiBuilder |
filter(Boolean filter)
If set to
true enables the user mode API, where users will only see the objects that they have
permissions for. |
ApiBuilder |
kerberos(Boolean kerberos)
Enables or disables Kerberos authentication.
|
ApiBuilder |
keyStorePassword(String keyStorePassword)
Sets the password used to decrypt the key store file indicated by the
keyStorePath method. |
ApiBuilder |
keyStorePath(String keyStorePath)
Sets the location of the file containing the CA certificates used to verify the certificate presented by the
server.
|
ApiBuilder |
noHostVerification(Boolean noHostVerification)
Enables or disables verification of the host name inside the SSL certificate presented by the server.
|
ApiBuilder |
password(String password)
Sets the password that will be used to authenticate to the server.
|
ApiBuilder |
persistentAuth(Boolean persistentAuth)
Enables or disables persistent authentication using cookies.
|
ApiBuilder |
requestTimeout(Integer requestTimeout)
Sets the timeout (in seconds) using when waiting for responses from the server.
|
ApiBuilder |
sessionId(String sessionId)
Sets the session identifier that will be used when sending requests to the server.
|
ApiBuilder |
sessionTimeout(Integer sessionTimeout)
Sets the timeout (in minutes) of the session with the server.
|
ApiBuilder |
url(String url)
Sets the URL that will be used to build the API object, for example
https://ovirt.example.com/ovirt-engine/api . |
ApiBuilder |
user(String user)
Sets the name of the user that will be used to authenticate to the server, for example
admin@internal . |
public ApiBuilder url(String url)
https://ovirt.example.com/ovirt-engine/api
.public ApiBuilder user(String user)
admin@internal
.
This should usually be used together with the password(String)
method, as most authentication methods
require both an user name and a password.public ApiBuilder password(String password)
public ApiBuilder sessionId(String sessionId)
public ApiBuilder requestTimeout(Integer requestTimeout)
public ApiBuilder sessionTimeout(Integer sessionTimeout)
public ApiBuilder persistentAuth(Boolean persistentAuth)
public ApiBuilder noHostVerification(Boolean noHostVerification)
true
to this method.public ApiBuilder keyStorePath(String keyStorePath)
keyStorePassword(String)
method.public ApiBuilder keyStorePassword(String keyStorePassword)
keyStorePath
method.public ApiBuilder filter(Boolean filter)
true
enables the user mode API, where users will only see the objects that they have
permissions for. By default this is false
, which means that users will see all objects.public ApiBuilder debug(Boolean debug)
public ApiBuilder kerberos(Boolean kerberos)
true
to this method. In addition, the environment needs to be configured correctly, doing the following:
com.sun.security.jgss.login { com.sun.security.auth.module.Krb5LoginModule required client=true useTicketCache=true; }; com.sun.security.jgss.initiate { com.sun.security.auth.module.Krb5LoginModule required client=TRUE useTicketCache=true; }; com.sun.security.jgss.accept { com.sun.security.auth.module.Krb5LoginModule required client=TRUE useTicketCache=true; };
java
command or using the System.setProperty(String, String)
method:
-Djava.security.auth.login.config=<location of the JAAS configuration file> -Djava.security.krb5.conf=<location of the Kerberos configuration file> -Djavax.security.auth.useSubjectCredsOnly=false
kinit
command. The SDK will then take your credentials from
that cache and use them to authenticate to the server.
Note also that the Kerberos implementation in the JVM only supports the traditional file based credentials
cache, so make sure that if you have either don't default_ccache_name
parameter in your Kerberos
configuration file or its value starts with FILE
, as this is the only type of credential cache
currently supported by the JVM.
If you have problems with this configuration it is very useful to add the debug
parameter to all the
entries in the JAAS configuration file:
com.sun.security.jgss.login { com.sun.security.auth.module.Krb5LoginModule ... debug=true; };It is also useful to enable debug output of the Kerberos implementation of the JVM:
-Dsun.security.krb5.debug=true
public Api build() throws ServerException, UnsecuredConnectionAttemptError, IOException
ServerException
- Signals that an API error has occurredIOException
- Signals that an I/O exception of some sort has occurredUnsecuredConnectionAttemptError
- Signals that attempt of connecting to SSL secured site using HTTP
protocol has occurredCopyright ? 2010 Red Hat, Inc - released under the Apache License Version 2.0