|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.novell.sentinel.client.http.java.JavaRequestorBase<T>
T
- The type of data interface (e.g., JSONParser
or Parser
) that will be reported
as the result of the HTTP request.public abstract class JavaRequestorBase<T>
Base implementation for synchronous and asynchronous HttpRequestor interfaces.
Nested Class Summary | |
---|---|
static class |
JavaRequestorBase.DefaultHostnameVerifier
Implementation of HostnameVerifier that returns true regardless of the hostname. |
protected static class |
JavaRequestorBase.NcacFault
|
static class |
JavaRequestorBase.TestTrustManager
A TrustManager implementation useful only for testing. |
Field Summary | |
---|---|
static String |
CHAR_ENCODING
The character encoding used by HTTP requests/responses issued/received by this class ("UTF-8"). |
Constructor Summary | |
---|---|
JavaRequestorBase()
|
Method Summary | |
---|---|
void |
authenticate(String username,
String password,
UriConstructor url)
Authenticate to the Sentinel server and obtain a SAML token which will be used for HTTP requests made through this instance. |
void |
deleteToken(String username,
String password,
UriConstructor url)
Delete the SAML token that is contained in this instance. |
HostnameVerifier |
getHostnameVerifier()
Get the HostnameVerifier implementation in use for this instance. |
String |
getLocaleName()
Implementation of HttpRequestor.getLocaleName() . |
protected abstract String |
getMediaType()
Derived classes must return the media type to use for requests/responses. |
protected abstract JavaRequestorBase.NcacFault |
getNcacFault(InputStream source)
Derived classes must attempt to return Ncac fault information found in the passed InputStream. |
protected abstract T |
getParser(InputStream source)
Get a parser (or whatever data source type is being used) that will return data from the passed InputStream. |
String |
getSAMLToken()
Get the Sentinel SAML token in use by this instance, or null if there is none. |
protected SecureRandom |
getSecureRandom()
Supply a SecureRandom object for use in TLS/SSL. |
protected SSLSocketFactory |
getSocketFactory()
Get the SSLSocketFactory to use. |
SSLSocketFactory |
getSSLSocketFactory()
Get the SSLSocketFactory implementation in use by this instance. |
protected abstract String |
getToken(InputStream source)
Derived classes must return the Base64-encoded Sentinel SAML token returned in response to the POST request issued by the authenticate method. |
TrustManager |
getTrustManager()
Get the TrustManager implementation current set in this instance. |
protected byte[] |
issueOctetRequest(HttpRequestMethod.HttpMethod method,
String url,
byte[] data)
Method for derived classes to issue an HTTP request that deals with octet stream data. |
protected T |
issueRequest(HttpRequestMethod.HttpMethod method,
String url,
T parser)
Method for derived classes to issue an HTTP request. |
protected abstract void |
sendData(OutputStream dest,
T parser)
Given the passed data source (parser), serialize the data from the data source to the passed OutputStream. |
void |
setHostnameVerifier(HostnameVerifier verifier)
Set the HostnameVerifier implementation to use in establishing the TLS/SSL connection. |
protected void |
setLanguageHeaders(HttpURLConnection connection)
|
void |
setLocaleName(String localeName)
Implementation of HttpRequestor.setLocaleName(String) . |
protected void |
setMediaTypeHeaders(HttpURLConnection connection)
|
void |
setSAMLToken(String token)
Set the Sentinel SAML token for use by this instance. |
void |
setSSLSocketFactory(SSLSocketFactory socketFactory)
Set the SSLSocketFactory implementation for use by this instance. |
void |
setTrustManager(TrustManager trustManager)
Set the TrustManager implementation to be used for the TLS/SSL connection. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String CHAR_ENCODING
Constructor Detail |
---|
public JavaRequestorBase()
Method Detail |
---|
public void setLocaleName(String localeName)
HttpRequestor.setLocaleName(String)
.
localeName
- Locale name to use in HTTP "Accept-Language" header (may be null).public String getLocaleName()
HttpRequestor.getLocaleName()
.
public void authenticate(String username, String password, UriConstructor url) throws HttpException
username
- The name of the Sentinel user.password
- The password of the Sentinel user.url
- A UriConstructor instance with at least the scheme, host, and port specified. If no URI path is
specified, "SentinelAuthServices/auth/tokens" is appended to the passed information.
HttpException
- If an error occurs.public void deleteToken(String username, String password, UriConstructor url) throws HttpException
username
- The name of the Sentinel user.password
- The password of the Sentinel user.url
- A UriConstructor instance with at least the scheme, host, and port specified. If no URI path is
specified, "SentinelAuthServices/auth/tokens" is appended to the passed information.
HttpException
- If an error occurs.public void setTrustManager(TrustManager trustManager)
If no TrustManager is set, the default TrustManager used by SSLSocketFactory.getDefault() will be used, which will typically disallow connections to the Sentinel server because Sentinel by default uses self-signed certificates.
For testing, an instance of TestTrustManager can be used, but TestTrustManager should not be used in production because no certificate checking is performed at all.
trustManager
- The implementation to use.public TrustManager getTrustManager()
public void setHostnameVerifier(HostnameVerifier verifier)
verifier
- The implementation to use (must not be null).public HostnameVerifier getHostnameVerifier()
public void setSSLSocketFactory(SSLSocketFactory socketFactory)
socketFactory
- public SSLSocketFactory getSSLSocketFactory()
public String getSAMLToken()
public void setSAMLToken(String token)
token
- authenticate(String, String, UriConstructor)
protected T issueRequest(HttpRequestMethod.HttpMethod method, String url, T parser) throws HttpException
method
- The request type (HttpMethod.GET, HttpMethod.PUT, etc.)url
- The URL of the request.parser
- The source from which any request content will be obtained (may be null for requests without content).
HttpException
- if an error occurs making the request.protected byte[] issueOctetRequest(HttpRequestMethod.HttpMethod method, String url, byte[] data) throws HttpException
method
- The request type (HttpMethod.GET, HttpMethod.PUT, etc.)url
- The URL of the request.data
- The request content, if any (may be null).
HttpException
- if an error occurs making the request.protected SSLSocketFactory getSocketFactory()
protected SecureRandom getSecureRandom()
The default implementation returns a default SecureRandom instance (constructed with the default constructor) that is shared among all instances of this class.
protected void setMediaTypeHeaders(HttpURLConnection connection)
protected void setLanguageHeaders(HttpURLConnection connection)
protected abstract String getMediaType()
protected abstract String getToken(InputStream source) throws IOException
source
- The response data from the server.
IOException
- If an error occurs reading the token.protected abstract T getParser(InputStream source)
source
- The InputStream.
protected abstract void sendData(OutputStream dest, T parser) throws IOException
dest
- The OutputStream to which to write the data.parser
- The data source containing the data.
IOException
- If an error occurs writing the data.protected abstract JavaRequestorBase.NcacFault getNcacFault(InputStream source) throws IOException
source
- The error stream from the Http request.
IOException
- If any error occurs attempting to parse Ncac fault information.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |