public class AuthenticatingConnector extends Object implements 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.
| Modifier and Type | Field and Description |
|---|---|
protected Authenticator |
authenticator |
protected Connector |
connector |
protected static org.apache.commons.logging.Log |
logger |
| Constructor and Description |
|---|
AuthenticatingConnector(Connector connector,
Authenticator authenticator)
Instantiates a new authenticating connector.
|
| Modifier and Type | Method and Description |
|---|---|
Response |
call(String uri)
Invokes a URI on a remote service.
|
Response |
call(String uri,
ConnectorContext context)
Invokes a URI on a remote service.
|
Response |
call(String uri,
ConnectorContext context,
javax.servlet.http.HttpServletRequest req,
javax.servlet.http.HttpServletResponse res)
Invokes a URI on a remote service and streams back results to the
provided response object.
|
Response |
call(String uri,
ConnectorContext context,
InputStream in)
Invokes a URI on a remote service, passing the input as supplied via
a POST/PUT.
|
Response |
call(String uri,
ConnectorContext context,
InputStream in,
OutputStream out)
Invokes a URI on a remote service.
|
ConnectorSession |
getConnectorSession()
Returns the connector session
|
Credentials |
getCredentials()
Returns the credents for this connector.
|
String |
getEndpoint()
Returns the endpoint to which this connector connects.
|
boolean |
handshake()
Performs the authentication handshake.
|
protected boolean |
isAuthenticated()
Returns whether the current session is authenticated already.
|
void |
setConnectorSession(ConnectorSession connectorSession)
Sets the connector session
|
void |
setCredentials(Credentials credentials)
Binds Credentials to this connector.
|
void |
setEndpoint(String endpoint)
Sets the endpoint.
|
String |
toString() |
protected static org.apache.commons.logging.Log logger
protected Connector connector
protected Authenticator authenticator
public AuthenticatingConnector(Connector connector, Authenticator authenticator)
connector - the connectorauthenticator - the authenticatorpublic Response call(String uri)
Connectorpublic Response call(String uri, ConnectorContext context)
Connectorpublic Response call(String uri, ConnectorContext context, InputStream in)
Connectorpublic Response call(String uri, ConnectorContext context, InputStream in, OutputStream out)
Connectorpublic Response call(String uri, ConnectorContext context, javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
Connectorpublic void setCredentials(Credentials credentials)
ConnectorsetCredentials in interface Connectorcredentials - the new credentialspublic Credentials getCredentials()
ConnectorgetCredentials in interface Connectorpublic void setEndpoint(String endpoint)
ConnectorsetEndpoint in interface Connectorendpoint - the new endpointpublic String getEndpoint()
ConnectorgetEndpoint in interface Connectorpublic void setConnectorSession(ConnectorSession connectorSession)
ConnectorsetConnectorSession in interface ConnectorconnectorSession - ConnectorSessionpublic ConnectorSession getConnectorSession()
ConnectorgetConnectorSession in interface Connectorprotected boolean isAuthenticated()
public final boolean handshake()
Copyright © 2005–2019 Alfresco Software. All rights reserved.