Package org.ovirt.engine.sdk4.internal
Class HttpConnection
- java.lang.Object
-
- org.ovirt.engine.sdk4.internal.HttpConnection
-
- All Implemented Interfaces:
AutoCloseable
,Connection
public class HttpConnection extends Object implements Connection
This class is the HTTP implementation of the connection contract. Refrain from using it directly, as backwards compatibility isn't guaranteed, use theConnectionBuilder
class instead.
-
-
Constructor Summary
Constructors Constructor Description HttpConnection()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
authenticate()
Return token which can be used for authentication instead of credentials.void
close()
void
close(boolean logout)
Releases the resources used by this connection.<TYPE> TYPE
followLink(TYPE object)
Follows the `href` attribute of the given object, retrieves the target object and returns it.HttpClient
getClient()
Map<String,String>
getHeaders()
String
getSsoRevokeUrl()
String
getSsoTokenName()
String
getSsoUrl()
String
getUrl()
boolean
isLink(Object object)
Indicates if the given object is a link.org.apache.http.HttpResponse
send(org.apache.http.client.methods.HttpUriRequest request)
void
setClient(HttpClient client)
void
setHeaders(Map<String,String> headers)
void
setKerberos(boolean kerberos)
void
setPassword(String password)
void
setSsoRevokeUrl(String ssoRevokeUrl)
void
setSsoToken(String ssoToken)
void
setSsoTokenName(String ssoTokenName)
void
setSsoUrl(String ssoUrl)
void
setUrl(String url)
void
setUser(String user)
SystemService
systemService()
Returns a reference to the root of the services tree.boolean
validate()
Validate the connection by making a trivial request and checking that the result is not null
-
-
-
Method Detail
-
getClient
public HttpClient getClient()
-
setClient
public void setClient(HttpClient client)
-
getUrl
public String getUrl()
-
setUrl
public void setUrl(String url)
-
setUser
public void setUser(String user)
-
setPassword
public void setPassword(String password)
-
getSsoUrl
public String getSsoUrl()
-
setSsoUrl
public void setSsoUrl(String ssoUrl)
-
getSsoTokenName
public String getSsoTokenName()
-
setSsoTokenName
public void setSsoTokenName(String ssoTokenName)
-
setKerberos
public void setKerberos(boolean kerberos)
-
getSsoRevokeUrl
public String getSsoRevokeUrl()
-
setSsoRevokeUrl
public void setSsoRevokeUrl(String ssoRevokeUrl)
-
setSsoToken
public void setSsoToken(String ssoToken)
-
systemService
public SystemService systemService()
Description copied from interface:Connection
Returns a reference to the root of the services tree.- Specified by:
systemService
in interfaceConnection
-
isLink
public boolean isLink(Object object)
Description copied from interface:Connection
Indicates if the given object is a link. An object is a link if it has an `href` attribute.- Specified by:
isLink
in interfaceConnection
- Parameters:
object
- the object to check- Returns:
true
iff the object is a link
-
followLink
public <TYPE> TYPE followLink(TYPE object)
Description copied from interface:Connection
Follows the `href` attribute of the given object, retrieves the target object and returns it.- Specified by:
followLink
in interfaceConnection
- Type Parameters:
TYPE
- the type of the target of the link- Parameters:
object
- the object containing the `href` attribute- Returns:
- the object retrieved from the `href`
-
close
public void close() throws Exception
- Specified by:
close
in interfaceAutoCloseable
- Throws:
Exception
-
close
public void close(boolean logout) throws Exception
Description copied from interface:Connection
Releases the resources used by this connection.- Specified by:
close
in interfaceConnection
- Parameters:
logout
- A boolean, which specify if token should be revoked, and so user should be logged out.- Throws:
Exception
-
validate
public boolean validate()
Description copied from interface:Connection
Validate the connection by making a trivial request and checking that the result is not null- Specified by:
validate
in interfaceConnection
- Returns:
- true if the connection is valid, false otherwise
-
send
public org.apache.http.HttpResponse send(org.apache.http.client.methods.HttpUriRequest request)
-
authenticate
public String authenticate()
Description copied from interface:Connection
Return token which can be used for authentication instead of credentials. It will be created, if it not exists, yet. By default the token will be revoked when the connection is closed, unless the `logout` parameter of the `close` method is `false`.- Specified by:
authenticate
in interfaceConnection
-
-