public abstract class AuthenticatedHttpEventProcessor extends AbstractEventProcessor
A base class used for EventProcessor
s that makes use of HTTP-calls
that should be done when authenticated against Alfresco. Subclasses can just
do the HTTP-call(s) without having to worry about authentication. Use
#executeHttpMethodAuthenticated(HttpRequestBase, String)
instead of
using HttpClient
manually or
#executeHttpMethodAsAdmin(HttpRequestBase)
to run as Alfresco
Administrator.
Supports both BASIC Authentication (default) and Ticket-based authentication. In case ticket-based authentication is used, the ticket value is stored on the user data-provider and a new ticket is fetched transparantly when the ticket is expired.
DEFAULT_CHART, DEFAULT_PROPAGATE_SESSION_ID, DEFAULT_WARN_DELAY, logger
Constructor and Description |
---|
AuthenticatedHttpEventProcessor(org.alfresco.http.HttpClientProvider httpClientProvider,
org.alfresco.http.AuthenticationDetailsProvider authDetailProvider,
String baseUrl) |
Modifier and Type | Method and Description |
---|---|
protected <T> T |
executeHttpMethodAsAdmin(org.apache.http.client.methods.HttpRequestBase request,
org.alfresco.http.HttpRequestCallback<T> callback)
Execute the given method, authenticated as the Alfresco Administrator.
|
protected <T> T |
executeHttpMethodAsUser(org.apache.http.client.methods.HttpRequestBase request,
String username,
org.alfresco.http.HttpRequestCallback<T> callback)
Execute the given method, authenticated as the given user.
|
org.alfresco.http.AuthenticationDetailsProvider |
getAuthDetailProvider() |
String |
getFullUrlForPath(String path) |
org.alfresco.http.HttpClientProvider |
getHttpProvider() |
protected void |
releaseResources(org.apache.http.client.methods.HttpRequestBase request,
org.apache.http.HttpResponse response)
Release resources associated with an HTTP request.
|
void |
setTicketBasedAuthentication(boolean ticketBasedAuthentication)
Enable ticket-based authentication.
|
getWarnDelay, isChart, processEvent, processEvent, propagateSessionId, register, resumeTimer, setBeanName, setChart, setEventName, setEventNames, setPropagateSessionId, setRegistry, setWarnDelay, stopTimer, suspendTimer, toString
public AuthenticatedHttpEventProcessor(org.alfresco.http.HttpClientProvider httpClientProvider, org.alfresco.http.AuthenticationDetailsProvider authDetailProvider, String baseUrl)
httpClientProvider
- provider class for http-clientauthDetailProvider
- provider for authentication detailsbaseUrl
- the URL to append topublic void setTicketBasedAuthentication(boolean ticketBasedAuthentication)
ticketBasedAuthentication
- whether or not to use ticket for
authenticationpublic org.alfresco.http.HttpClientProvider getHttpProvider()
HttpClientProvider
used by this class.public org.alfresco.http.AuthenticationDetailsProvider getAuthDetailProvider()
AuthenticationDetailsProvider
used by this class.public String getFullUrlForPath(String path)
path
- relative path of the URL from alfresco host.protected <T> T executeHttpMethodAsUser(org.apache.http.client.methods.HttpRequestBase request, String username, org.alfresco.http.HttpRequestCallback<T> callback)
HttpRequestCallback
.request
- request to executeusername
- name of user to authenticate ascallback
- called after http-call is executed. When callback
returns, the response stream is closed, so all respose-related
operations should be done in the callback. Can be null.protected <T> T executeHttpMethodAsAdmin(org.apache.http.client.methods.HttpRequestBase request, org.alfresco.http.HttpRequestCallback<T> callback)
request
- request to executecallback
- called after http-call is executed. When callback
returns, the response stream is closed, so all respose-related
operations should be done in the callback. Can be null.protected void releaseResources(org.apache.http.client.methods.HttpRequestBase request, org.apache.http.HttpResponse response)
request
- the HTTP request that might have open resources (null allowed)Copyright © 2014. All rights reserved.