Package org.alfresco.repo.remoteticket
Class RemoteAlfrescoTicketServiceImpl
- java.lang.Object
-
- org.alfresco.repo.remoteticket.RemoteAlfrescoTicketServiceImpl
-
- All Implemented Interfaces:
RemoteAlfrescoTicketService
public class RemoteAlfrescoTicketServiceImpl extends Object implements RemoteAlfrescoTicketService
Service for working with a Remote Alfresco instance, which holds user credentials for the remote system via theRemoteCredentialsService, and handles ticket negotiation for you. Note - this service will be moved to the Repository Core once it has stabilised (likely after OAuth support is added) TODO OAuth support- Since:
- 4.0.2
- Author:
- Nick Burch
-
-
Constructor Summary
Constructors Constructor Description RemoteAlfrescoTicketServiceImpl()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleandeleteRemoteCredentials(String remoteSystemId)Deletes the remote credentials (if any) for the current userprotected PasswordCredentialsInfoensureCredentialsFound(String remoteSystemId, BaseCredentialsInfo credentails)protected voidensureRemoteSystemKnown(String remoteSystemId)RemoteAlfrescoTicketInfogetAlfrescoTicket(String remoteSystemId)Returns the current Alfresco Ticket for the current user on the remote system, fetching if it isn't already cached.BaseCredentialsInfogetRemoteCredentials(String remoteSystemId)Retrieves the remote credentials (if any) for the current userRemoteAlfrescoTicketInforefetchAlfrescoTicket(String remoteSystemId)Forces a re-fetch of the Alfresco Ticket for the current user, if possible, and marks the credentials as failing if not.protected RemoteAlfrescoTicketInforefreshTicket(String remoteSystemId, PasswordCredentialsInfo credentials)Fetches a new ticket for the given user, and caches itvoidregisterRemoteSystem(String remoteSystemId, String baseUrl, Map<String,String> requestHeaders)Registers the details of a new Remote System with the service.voidsetRemoteConnectorService(RemoteConnectorService remoteConnectorService)Sets the Remote Connector Service to use to talk to remote systems withvoidsetRemoteCredentialsService(RemoteCredentialsService remoteCredentialsService)Sets the Remote Credentials Service to use to store and retrieve credentialsvoidsetRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper)Sets the Retrying Transaction Helper, used to write changes to Credentials which turn out to be invalidvoidsetTicketsCache(SimpleCache<String,String> ticketsCache)Sets the SimpleCache to be used to cache remote tickets inBaseCredentialsInfostoreRemoteCredentials(String remoteSystemId, String username, String password)Validates and stores the remote credentials for the current userprotected StringtoCacheKey(String remoteSystemId, BaseCredentialsInfo credentials)
-
-
-
Method Detail
-
setRemoteCredentialsService
public void setRemoteCredentialsService(RemoteCredentialsService remoteCredentialsService)
Sets the Remote Credentials Service to use to store and retrieve credentials
-
setRemoteConnectorService
public void setRemoteConnectorService(RemoteConnectorService remoteConnectorService)
Sets the Remote Connector Service to use to talk to remote systems with
-
setTicketsCache
public void setTicketsCache(SimpleCache<String,String> ticketsCache)
Sets the SimpleCache to be used to cache remote tickets in
-
setRetryingTransactionHelper
public void setRetryingTransactionHelper(RetryingTransactionHelper retryingTransactionHelper)
Sets the Retrying Transaction Helper, used to write changes to Credentials which turn out to be invalid
-
registerRemoteSystem
public void registerRemoteSystem(String remoteSystemId, String baseUrl, Map<String,String> requestHeaders)
Registers the details of a new Remote System with the service. Any previous details for the system will be overridden- Specified by:
registerRemoteSystemin interfaceRemoteAlfrescoTicketService- Parameters:
remoteSystemId- The ID to be used to identify the systembaseUrl- The base URL of Alfresco Services on the remote system, eg http://localhost:8080/alfresco/service/requestHeaders- Any HTTP headers that must be sent with the request when talking to the server
-
ensureRemoteSystemKnown
protected void ensureRemoteSystemKnown(String remoteSystemId) throws NoSuchSystemException
- Throws:
NoSuchSystemException
-
ensureCredentialsFound
protected PasswordCredentialsInfo ensureCredentialsFound(String remoteSystemId, BaseCredentialsInfo credentails)
-
toCacheKey
protected String toCacheKey(String remoteSystemId, BaseCredentialsInfo credentials)
-
storeRemoteCredentials
public BaseCredentialsInfo storeRemoteCredentials(String remoteSystemId, String username, String password) throws AuthenticationException, RemoteSystemUnavailableException, NoSuchSystemException
Validates and stores the remote credentials for the current user- Specified by:
storeRemoteCredentialsin interfaceRemoteAlfrescoTicketService- Parameters:
remoteSystemId- The ID of the remote system, as registered with the service- Throws:
AuthenticationException- If the credentials are invalidRemoteSystemUnavailableException- If the remote system is unavailableNoSuchSystemException- If no system has been registered with the given ID
-
getRemoteCredentials
public BaseCredentialsInfo getRemoteCredentials(String remoteSystemId) throws NoSuchSystemException
Retrieves the remote credentials (if any) for the current user- Specified by:
getRemoteCredentialsin interfaceRemoteAlfrescoTicketService- Parameters:
remoteSystemId- The ID of the remote system, as registered with the service- Returns:
- The current user's remote credentials, or null if they don't have any
- Throws:
NoSuchSystemException- If no system has been registered with the given ID
-
deleteRemoteCredentials
public boolean deleteRemoteCredentials(String remoteSystemId) throws NoSuchSystemException
Deletes the remote credentials (if any) for the current user- Specified by:
deleteRemoteCredentialsin interfaceRemoteAlfrescoTicketService- Parameters:
remoteSystemId- The ID of the remote system, as registered with the service- Returns:
- Whether credentials were found to delete
- Throws:
NoSuchSystemException- If no system has been registered with the given ID
-
getAlfrescoTicket
public RemoteAlfrescoTicketInfo getAlfrescoTicket(String remoteSystemId) throws AuthenticationException, NoCredentialsFoundException, NoSuchSystemException, RemoteSystemUnavailableException
Returns the current Alfresco Ticket for the current user on the remote system, fetching if it isn't already cached.- Specified by:
getAlfrescoTicketin interfaceRemoteAlfrescoTicketService- Parameters:
remoteSystemId- The ID of the remote system, as registered with the service- Returns:
- The Alfresco Ticket for the current user on the remote system
- Throws:
AuthenticationException- If the stored remote credentials are now invalidNoCredentialsFoundException- If the user has no stored credentials for the remote systemNoSuchSystemException- If no system has been registered with the given IDRemoteSystemUnavailableException- If it was not possible to talk to the remote system
-
refetchAlfrescoTicket
public RemoteAlfrescoTicketInfo refetchAlfrescoTicket(String remoteSystemId) throws AuthenticationException, NoCredentialsFoundException, NoSuchSystemException, RemoteSystemUnavailableException
Forces a re-fetch of the Alfresco Ticket for the current user, if possible, and marks the credentials as failing if not.- Specified by:
refetchAlfrescoTicketin interfaceRemoteAlfrescoTicketService- Parameters:
remoteSystemId- The ID of the remote system, as registered with the service- Returns:
- The Alfresco Ticket for the current user on the remote system
- Throws:
AuthenticationException- If the stored remote credentials are now invalidNoCredentialsFoundException- If the user has no stored credentials for the remote systemNoSuchSystemException- If no system has been registered with the given IDRemoteSystemUnavailableException- If it was not possible to talk to the remote system
-
refreshTicket
protected RemoteAlfrescoTicketInfo refreshTicket(String remoteSystemId, PasswordCredentialsInfo credentials) throws AuthenticationException, NoSuchSystemException, RemoteSystemUnavailableException
Fetches a new ticket for the given user, and caches it
-
-