Class AuthenticatingConnector
- All Implemented Interfaces:
Connector
The AuthenticatingConnector is a wrapper around a Connector object and an Authenticator object. It appears as a Connector to the outside world but provides additional functionality.
When a call is made, the underlying connector is used to call over to the resource. The underlying connector retrieves cookie state from the connector session (if available) and attempts to access the remote resource.
If this succeeds, then the AuthenticatingConnector returns this response.
On the other hand, if this fails (i.e. it receives a 401 unauthorized response), the AuthenticatingConnector calls into the underlying Authenticator instance to perform an "authentication handshake".
This handshake retrieves the necessary cookies or tokens and places them into the connector session. The connector session is persisted to the session (if it was originally bound to the session).
The AuthenticatingConnector then reattempts the connection using the newly retrieved cookies or tokens. If a 401 is received again, the credentials are assumed to be invalid.
- Author:
- muzquiano, kevinr
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Authenticatorprotected Connectorprotected static org.apache.commons.logging.Log -
Constructor Summary
ConstructorsConstructorDescriptionAuthenticatingConnector(Connector connector, Authenticator authenticator) Instantiates a new authenticating connector. -
Method Summary
Modifier and TypeMethodDescriptionInvokes a URI on a remote service.call(String uri, ConnectorContext context) Invokes a URI on a remote service.call(String uri, ConnectorContext context, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Invokes a URI on a remote service and streams back results to the provided response object.call(String uri, ConnectorContext context, InputStream in) Invokes a URI on a remote service, passing the input as supplied via a POST/PUT.call(String uri, ConnectorContext context, InputStream in, OutputStream out) Invokes a URI on a remote service.Returns the connector sessionReturns the credents for this connector.Returns the endpoint to which this connector connects.final booleanPerforms the authentication handshake.protected booleanReturns whether the current session is authenticated already.voidsetConnectorSession(ConnectorSession connectorSession) Sets the connector sessionvoidsetCredentials(Credentials credentials) Binds Credentials to this connector.voidsetEndpoint(String endpoint) Sets the endpoint.toString()
-
Field Details
-
logger
protected static org.apache.commons.logging.Log logger -
connector
-
authenticator
-
-
Constructor Details
-
AuthenticatingConnector
Instantiates a new authenticating connector.- Parameters:
connector- the connectorauthenticator- the authenticator
-
-
Method Details
-
call
Description copied from interface:ConnectorInvokes a URI on a remote service. The response data is buffered into a data element on the returned object of type Response. -
call
Description copied from interface:ConnectorInvokes a URI on a remote service. If the context is null, then it will not be utilized. The response data is buffered into a data element on the returned object of type Response. -
call
Description copied from interface:ConnectorInvokes a URI on a remote service, passing the input as supplied via a POST/PUT. If the context is null, then it will not be utilized and POST will be assumed. The response data is buffered into a data element on the returned object of type Response. -
call
Description copied from interface:ConnectorInvokes a URI on a remote service. Data is streamed back from the response into the provided output stream. Headers and response state is maintained on the Response object. If the context is null, then it will not be utilized. The response data is not buffered -
call
public Response call(String uri, ConnectorContext context, jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse res) Description copied from interface:ConnectorInvokes a URI on a remote service and streams back results to the provided response object. This method makes sure that the full response is propagated into the servlet response, including headers, exception states and more. If the context is null, then it will not be utilized. The response data is not buffered. -
setCredentials
Description copied from interface:ConnectorBinds Credentials to this connector.- Specified by:
setCredentialsin interfaceConnector- Parameters:
credentials- the new credentials
-
getCredentials
Description copied from interface:ConnectorReturns the credents for this connector.- Specified by:
getCredentialsin interfaceConnector- Returns:
- the credentials
-
setEndpoint
Description copied from interface:ConnectorSets the endpoint.- Specified by:
setEndpointin interfaceConnector- Parameters:
endpoint- the new endpoint
-
getEndpoint
Description copied from interface:ConnectorReturns the endpoint to which this connector connects.- Specified by:
getEndpointin interfaceConnector- Returns:
- endpoint the endpoint
-
setConnectorSession
Description copied from interface:ConnectorSets the connector session- Specified by:
setConnectorSessionin interfaceConnector- Parameters:
connectorSession- ConnectorSession
-
getConnectorSession
Description copied from interface:ConnectorReturns the connector session- Specified by:
getConnectorSessionin interfaceConnector- Returns:
- the connector session
-
isAuthenticated
protected boolean isAuthenticated()Returns whether the current session is authenticated already.- Returns:
- true, if checks if is authenticated
-
handshake
public final boolean handshake()Performs the authentication handshake.- Returns:
- true, if successful
-
toString
-