Package org.alfresco.repo.remoteticket
Class RemoteAlfrescoTicketServiceImpl
- java.lang.Object
-
- org.alfresco.repo.remoteticket.RemoteAlfrescoTicketServiceImpl
-
- All Implemented Interfaces:
RemoteAlfrescoTicketService
public class RemoteAlfrescoTicketServiceImpl extends java.lang.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(java.lang.String remoteSystemId)Deletes the remote credentials (if any) for the current userprotected PasswordCredentialsInfoensureCredentialsFound(java.lang.String remoteSystemId, BaseCredentialsInfo credentails)protected voidensureRemoteSystemKnown(java.lang.String remoteSystemId)RemoteAlfrescoTicketInfogetAlfrescoTicket(java.lang.String remoteSystemId)Returns the current Alfresco Ticket for the current user on the remote system, fetching if it isn't already cached.BaseCredentialsInfogetRemoteCredentials(java.lang.String remoteSystemId)Retrieves the remote credentials (if any) for the current userRemoteAlfrescoTicketInforefetchAlfrescoTicket(java.lang.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(java.lang.String remoteSystemId, PasswordCredentialsInfo credentials)Fetches a new ticket for the given user, and caches itvoidregisterRemoteSystem(java.lang.String remoteSystemId, java.lang.String baseUrl, java.util.Map<java.lang.String,java.lang.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(org.alfresco.repo.cache.SimpleCache<java.lang.String,java.lang.String> ticketsCache)Sets the SimpleCache to be used to cache remote tickets inBaseCredentialsInfostoreRemoteCredentials(java.lang.String remoteSystemId, java.lang.String username, java.lang.String password)Validates and stores the remote credentials for the current userprotected java.lang.StringtoCacheKey(java.lang.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(org.alfresco.repo.cache.SimpleCache<java.lang.String,java.lang.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(java.lang.String remoteSystemId, java.lang.String baseUrl, java.util.Map<java.lang.String,java.lang.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(java.lang.String remoteSystemId) throws NoSuchSystemException- Throws:
NoSuchSystemException
-
ensureCredentialsFound
protected PasswordCredentialsInfo ensureCredentialsFound(java.lang.String remoteSystemId, BaseCredentialsInfo credentails)
-
toCacheKey
protected java.lang.String toCacheKey(java.lang.String remoteSystemId, BaseCredentialsInfo credentials)
-
storeRemoteCredentials
public BaseCredentialsInfo storeRemoteCredentials(java.lang.String remoteSystemId, java.lang.String username, java.lang.String password) throws org.alfresco.repo.security.authentication.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:
org.alfresco.repo.security.authentication.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(java.lang.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(java.lang.String remoteSystemId) throws NoSuchSystemExceptionDeletes 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(java.lang.String remoteSystemId) throws org.alfresco.repo.security.authentication.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:
org.alfresco.repo.security.authentication.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(java.lang.String remoteSystemId) throws org.alfresco.repo.security.authentication.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:
org.alfresco.repo.security.authentication.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(java.lang.String remoteSystemId, PasswordCredentialsInfo credentials) throws org.alfresco.repo.security.authentication.AuthenticationException, NoSuchSystemException, RemoteSystemUnavailableException
Fetches a new ticket for the given user, and caches it- Throws:
org.alfresco.repo.security.authentication.AuthenticationExceptionNoSuchSystemExceptionRemoteSystemUnavailableException
-
-