com.caplin.keymaster.servlet
Class StreamLinkFormatter

java.lang.Object
  extended by com.caplin.keymaster.servlet.StreamLinkFormatter
All Implemented Interfaces:
AdvancedResponseFormatter, ResponseFormatter

public class StreamLinkFormatter
extends Object
implements AdvancedResponseFormatter

This class formats the response passed into it so that the response will be compatible with StreamLink (for Java/C++/Excel etc). This class uses com.caplin.credentials.util.RemoteCredentialsEncoder to return the response in the appropriate format so that a StreamLink based application will be able to understand it.


Constructor Summary
StreamLinkFormatter()
           
 
Method Summary
 String formatErrorResponse(javax.servlet.http.HttpServletRequest request, String errorMessage)
           This method calls com.caplin.credentials.util.RemoteCredentialsEncoder#encodeErrorResponse to format an appropriate error response.
 String formatResponse(javax.servlet.http.HttpServletRequest request, String token)
           This method formats the response for the successful creation of a token.
 String formatResponse(javax.servlet.http.HttpServletRequest request, String token, UserCredentialsProvider provider)
           This method formats the response for the successful creation of a token.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StreamLinkFormatter

public StreamLinkFormatter()
Method Detail

formatErrorResponse

public String formatErrorResponse(javax.servlet.http.HttpServletRequest request,
                                  String errorMessage)

This method calls com.caplin.credentials.util.RemoteCredentialsEncoder#encodeErrorResponse to format an appropriate error response.

Specified by:
formatErrorResponse in interface ResponseFormatter
Parameters:
errorMessage - stating what the problem was.
request - This parameter should be used to retrieve any required information that may be needed to format an error response. This parameter is always passed in from the calling servlet.
Returns:
an encoded error response with the cause of the error.

formatResponse

public String formatResponse(javax.servlet.http.HttpServletRequest request,
                             String token)

This method formats the response for the successful creation of a token. The method retrieves all the required information from the HttpServletRequest object which should contain all the required parameters. The token has been generated by the calling class and represents the password the user should use to access a Liberator source.
The method calls com.caplin.credentials.util.RemoteCredentialsEncoder#encodeOkResponse is called in the RemoteCredentialsEncoder class. This signals that the key was created successfully.
However this method may still return an error if some of the request parameters are missing.

Specified by:
formatResponse in interface ResponseFormatter
Parameters:
request - The request object that has been sent to the servlet calling class. This should contain all the required parameters.
token - The token used to access a Liberator source.
Returns:
a message containing a response (encodeOkResponse/encodeErrorResponse) or an error message.

formatResponse

public String formatResponse(javax.servlet.http.HttpServletRequest request,
                             String token,
                             UserCredentialsProvider provider)

This method formats the response for the successful creation of a token. The method retrieves all the required information from the HttpServletRequest object which should contain all the required parameters. However, should the parameter "username" be missing from the parameters and should the httpUserOverride parameter be equivalent to true then this will not cause a problem provided that a call to HttpServletRequest.getRemoteUser() doesn't return null. If this is the case then it will be the same as if the username parameter were missing.

The token has been generated by the calling class and represents the password the user should use to access a Liberator source.

This method calls com.caplin.credentials.util.RemoteCredentialsEncoder#encodeOkResponse in the RemoteCredentialsEncoder class. This signals that the key was created successfully.
However this method may still return an error if some of the request parameters are missing.

Specified by:
formatResponse in interface AdvancedResponseFormatter
Parameters:
request - The request object that has been sent to the servlet calling class. This should contain all the required parameters.
token - The token used to access a Liberator source.
httpUserOverride - allow the standard HTTP remote user to override any parameter username value. Should the call to HttpServletRequest.getRemoteUser() return null, then an error response will be sent regardless of whether username has been specified as part of the URL request parameters.
Returns:
a message containing a response (encodeOkResponse/encodeErrorResponse) or an error message.


Please send bug reports and comments to Caplin support