Merged BRANCHES/DEV/V4.0-BUG-FIX to HEAD:

35637: RemoteCredentialsService and RemoteAlfrescoTicketService, with tests


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@35639 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Nick Burch
2012-04-24 16:12:47 +00:00
parent e542141b84
commit d0fdeafa2c
36 changed files with 4692 additions and 0 deletions

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remoteconnector;
import java.io.InputStream;
import org.apache.commons.httpclient.Header;
import org.apache.commons.httpclient.methods.RequestEntity;
/**
* Helper wrapper around a Remote Request, to be performed by the
* {@link RemoteConnectorService}.
* To have one of these created for you, use
* {@link RemoteConnectorService#buildRequest(String, String)}
*
* @author Nick Burch
* @since 4.0.2
*/
public interface RemoteConnectorRequest
{
/**
* @return the URL this request is for
*/
String getURL();
/**
* @return the HTTP Method this request will execute (eg POST, GET)
*/
String getMethod();
/**
* @return The Content Type of the request
*/
String getContentType();
/**
* Sets the Content Type to send for the request
*/
void setContentType(String contentType);
/**
* Returns the Request Body, for use by the {@link RemoteConnectorService}
* which created this
*/
Object getRequestBody();
void setRequestBody(String body);
void setRequestBody(byte[] body);
void setRequestBody(InputStream body);
void setRequestBody(RequestEntity body);
Header[] getRequestHeaders();
void addRequestHeader(String name, String value);
void addRequestHeader(Header header);
void addRequestHeaders(Header[] headers);
}

View File

@@ -0,0 +1,70 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remoteconnector;
import java.io.IOException;
import java.io.InputStream;
import org.apache.commons.httpclient.Header;
/**
* Helper wrapper around a Remote Response, for a request that
* was executed by {@link RemoteConnectorService}.
*
* @author Nick Burch
* @since 4.0.2
*/
public interface RemoteConnectorResponse
{
/**
* @return The request that generated this response
*/
RemoteConnectorRequest getRequest();
/**
* @return The raw response content type, if available
*/
String getRawContentType();
/**
* @return The mimetype of the response content, if available
*/
String getContentType();
/**
* @return The charset of the response content, if available
*/
String getCharset();
/**
* @return All of the response headers
*/
Header[] getResponseHeaders();
/**
* @return The response data, as a stream
*/
InputStream getResponseBodyAsStream() throws IOException;
/**
* @return The response data, as a byte array
*/
byte[] getResponseBodyAsBytes() throws IOException;
/**
* @return The response as a string, based on the response content type charset
*/
String getResponseBodyAsString() throws IOException;
}

View File

@@ -0,0 +1,58 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remoteconnector;
import java.io.IOException;
import org.alfresco.repo.security.authentication.AuthenticationException;
import org.json.simple.JSONObject;
import org.json.simple.parser.ParseException;
/**
* Helper Service for performing remote web requests from within
* the repository tier.
*
* The default implementation of the service works with HttpClient
* internally, but other implementations (such as testing loopback)
* can be used.
*
* @author Nick Burch
* @since 4.0.2
*/
public interface RemoteConnectorService
{
/**
* Builds a new Request object, to talk to the given URL
* with the supplied method
*/
RemoteConnectorRequest buildRequest(String url, String method);
/**
* Executes the specified request, and return the response
*/
RemoteConnectorResponse executeRequest(RemoteConnectorRequest request) throws IOException, AuthenticationException;
/**
* Executes the given request, requesting a JSON response, and
* returns the parsed JSON received back
*
* @throws ParseException If the response is not valid JSON
*/
JSONObject executeJSONRequest(RemoteConnectorRequest request) throws IOException, AuthenticationException, ParseException;
}

View File

@@ -0,0 +1,64 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remotecredentials;
import java.io.Serializable;
import org.alfresco.repo.security.permissions.PermissionCheckValue;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.namespace.QName;
/**
* This class is the parent of a set of Remote Credentials
*
* @author Nick Burch
* @since 4.0.2
*/
public interface BaseCredentialsInfo extends Serializable, PermissionCheckValue
{
/**
* @return the NodeRef of the underlying credentials
*/
NodeRef getNodeRef();
/**
* @return the Type of the underlying credentials
*/
QName getCredentialsType();
/**
* @return the Remote System Name the credentials belong to
*/
String getRemoteSystemName();
/**
* @return the NodeRef of the container for the Remote System
*/
NodeRef getRemoteSystemContainerNodeRef();
/**
* @return the Remote Username
*/
String getRemoteUsername();
/**
* @return whether the last authentication attempt succeeded
*/
boolean getLastAuthenticationSucceeded();
}

View File

@@ -0,0 +1,38 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remotecredentials;
/**
* This class represents an OAuth 1.0 based set of credentials
*
* @author Nick Burch
* @since 4.0.2
*/
public interface OAuth1CredentialsInfo extends BaseCredentialsInfo
{
/**
* @return the OAuth Token Identifier
*/
String getOAuthToken();
/**
* @return the OAuth Token Secret
*/
String getOAuthSecret();
}

View File

@@ -0,0 +1,50 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remotecredentials;
import java.util.Date;
/**
* This class represents an OAuth 2.0 based set of credentials
*
* @author Nick Burch
* @since 4.0.2
*/
public interface OAuth2CredentialsInfo extends BaseCredentialsInfo
{
/**
* @return the OAuth Access Token
*/
String getOAuthAccessToken();
/**
* @return the OAuth Refresh
*/
String getOAuthRefreshToken();
/**
* @return When the Access Token was Issued
*/
Date getOAuthTicketIssuedAt();
/**
* @return When the Access Token will Expire
*/
Date getOAuthTicketExpiresAt();
}

View File

@@ -0,0 +1,34 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remotecredentials;
/**
* This class represents a password based set of credentials
*
* @author Nick Burch
* @since 4.0.2
*/
public interface PasswordCredentialsInfo extends BaseCredentialsInfo
{
/**
* @return the Remote Password
*/
String getRemotePassword();
}

View File

@@ -0,0 +1,129 @@
/*
* Copyright (C) 2005-2011 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remotecredentials;
import org.alfresco.query.PagingRequest;
import org.alfresco.query.PagingResults;
import org.alfresco.service.namespace.QName;
/**
* The core Remote Credentials service.
*
* This provides low level support for storing, retrieving
* and finding remote credentials. Most users will want
* something built on top of this, eg to do the OAuth Dance.
*
* The "Remote System" name chosen by systems built on top of
* this need to be unique, to avoid clashes. Where there is
* only one thing that is talked to (eg Twitter, Flickr,
* Alfresco Cloud), then the "Remote System Name" should be
* the name of the system. Where one service can talk to
* multiple systems, the system hostname should be used as
* a suffix, such as "OpenID-livejournal.com" and
* "OpenID-stackexchange.net", so they can be differentiated.
*
* @author Nick Burch
* @since 4.0.2
*/
public interface RemoteCredentialsService
{
/**
* Stores a new {@link BaseCredentialsInfo} for the current user
*/
BaseCredentialsInfo createPersonCredentials(String remoteSystem, BaseCredentialsInfo credentials);
/**
* Stores a new {@link BaseCredentialsInfo} for shared use.
* Permissions should then be set to control access to these.
*/
BaseCredentialsInfo createSharedCredentials(String remoteSystem, BaseCredentialsInfo credentials);
/**
* Updates an existing {@link BaseCredentialsInfo}. The type
* must not change.
*/
BaseCredentialsInfo updateCredentials(BaseCredentialsInfo credentials);
/**
* Records if the most recent Authentication attempt with a given
* set of credentials worked or not.
*/
BaseCredentialsInfo updateCredentialsAuthenticationSucceeded(boolean succeeded, BaseCredentialsInfo credentialsInfo);
/**
* Deletes an existing {@link BaseCredentialsInfo} from the repository
*/
void deleteCredentials(BaseCredentialsInfo credentialsInfo);
/**
* Lists all Remote Systems for which credentials are
* stored for the current user
*/
PagingResults<String> listPersonRemoteSystems(PagingRequest paging);
/**
* Lists all Remote Systems for which the user has access
* to shared credentials
*/
PagingResults<String> listSharedRemoteSystems(PagingRequest paging);
/**
* Lists all the Remote Systems for which the user has credentials,
* either personal ones or shared ones
*/
PagingResults<String> listAllRemoteSystems(PagingRequest paging);
/**
* Fetches the credentials for the current user for the specified
* System. If multiple credentials exist, the first is returned, so
* this should only be used for systems where a user is restricted
* to only one set of credentials per system.
* @return The Credentials, or Null if none exist for the current user
*/
BaseCredentialsInfo getPersonCredentials(String remoteSystem);
/**
* Lists all Credentials for the current user for the given Remote System
*
* @param remoteSystem The Remote System to return credentials for
* @param credentialsType Optional type (including child subtypes) of the credentials to filter by
*/
PagingResults<? extends BaseCredentialsInfo> listPersonCredentials(String remoteSystem, QName credentialsType, PagingRequest paging);
/**
* Lists all Credentials that are shared with the current user for
* the given Remote System
*
* @param remoteSystem The Remote System to return credentials for
* @param credentialsType Optional type (including child subtypes) of the credentials to filter by
*/
PagingResults<? extends BaseCredentialsInfo> listSharedCredentials(String remoteSystem, QName credentialsType, PagingRequest paging);
/**
* Lists all Credentials that the user has access to
* for the given Remote System
*
* @param remoteSystem The Remote System to return credentials for
* @param credentialsType Optional type (including child subtypes) of the credentials to filter by
*/
PagingResults<? extends BaseCredentialsInfo> listAllCredentials(String remoteSystem, QName credentialsType, PagingRequest paging);
}

View File

@@ -0,0 +1,45 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remoteticket;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
/**
* Exception thrown if no credentials could be found when
* attempting to perform an authentication request to
* a remote system.
*
* @author Nick Burch
* @since 4.0.2
*/
public class NoCredentialsFoundException extends AlfrescoRuntimeException
{
private static final long serialVersionUID = -1167368337984937185L;
public NoCredentialsFoundException()
{
super("No Credentials Found");
}
public NoCredentialsFoundException(String remoteSystemId)
{
super("No Credentials Found for " + AuthenticationUtil.getRunAsUser() + " for Remote System '" + remoteSystemId + "'");
}
}

View File

@@ -0,0 +1,46 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remoteticket;
import org.alfresco.error.AlfrescoRuntimeException;
/**
* Exception thrown if a request is made, to work on
* authentication for a Remote System, where the
* System is not known to the service.
*
* @author Nick Burch
* @since 4.0.2
*/
public class NoSuchSystemException extends AlfrescoRuntimeException
{
private static final long serialVersionUID = 282472917033620185L;
private String system;
public NoSuchSystemException(String system)
{
super("No Remote System defined with ID '" + system + "'");
this.system = system;
}
public String getSystem()
{
return system;
}
}

View File

@@ -0,0 +1,63 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remoteticket;
import org.alfresco.util.Pair;
/**
* Holds details on a Ticket from a Remote Alfresco System,
* and provides ways to get it into different forms
* suitable for sending back to the Remote System.
*
* Currently, only regular Tickets are supported, but this
* is designed to handle things like OAuth later
*
* @author Nick Burch
* @since 4.0.2
*/
public interface RemoteAlfrescoTicketInfo
{
/**
* Returns the Ticket as a URL Parameter fragment, such as
* "ticket=123&sig=13". No escaping is done
*/
String getAsUrlParameters();
/**
* Returns the Ticket as a URL Escaped Parameter fragment, such as
* "ticket=12%20xx&sig=2". Special characters in the URL are escaped
* suitable for using as full URL, but any ampersands are not escaped
* (it's not HTML escaped)
*/
String getAsEscapedUrlParameters();
/**
* Returns the Ticket in the form used for HTTP Basic Authentication.
* This should be added as the value to a HTTP Request Header with
* key Authorization
*/
String getAsHTTPAuthorization();
/**
* Returns the Ticket in the form of a pseudo username and password.
* The Username is normally a special ticket identifier, and the password
* is the ticket in a suitably encoded form.
*/
Pair<String,String> getAsUsernameAndPassword();
}

View File

@@ -0,0 +1,126 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remoteticket;
import java.util.Map;
import org.alfresco.repo.security.authentication.AuthenticationException;
import org.alfresco.service.cmr.remotecredentials.BaseCredentialsInfo;
import org.alfresco.service.cmr.remotecredentials.RemoteCredentialsService;
/**
* Service for working with a Remote Alfresco instance, which
* holds user credentials for the remote system via the
* {@link RemoteCredentialsService}, and handles ticket
* negotiation for you.
*
* Currently only Username+Password credentials, exchanged for a
* regular alf_ticket Alfresco Ticket are supported, but
* things like OAuth should be supportable too later.
*
* All Remote Systems must be registered with this service before
* use, supplying details of where to find the remote Alfresco
* for a given Remote System ID. The Remote System names should
* follow the system naming convention from {@link RemoteCredentialsService}
*
* TODO OAuth support
*
* @author Nick Burch
* @since 4.0.2
*/
public interface RemoteAlfrescoTicketService
{
/**
* Validates and stores the remote credentials for the current user
*
* @param remoteSystemId The ID of the remote system, as registered with the service
*
* @throws AuthenticationException If the credentials are invalid
* @throws RemoteSystemUnavailableException If the remote system is unavailable
* @throws NoSuchSystemException If no system has been registered with the given ID
*/
BaseCredentialsInfo storeRemoteCredentials(String remoteSystemId, String username, String password)
throws AuthenticationException, RemoteSystemUnavailableException, NoSuchSystemException;
/**
* Retrieves the remote credentials (if any) for the current user
*
* @param remoteSystemId The ID of the remote system, as registered with the service
* @return 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
*/
BaseCredentialsInfo getRemoteCredentials(String remoteSystemId) throws NoSuchSystemException;
/**
* Deletes the remote credentials (if any) for the current user
*
* @param remoteSystemId The ID of the remote system, as registered with the service
* @return Whether credentials were found to delete
* @throws NoSuchSystemException If no system has been registered with the given ID
*/
boolean deleteRemoteCredentials(String remoteSystemId) throws NoSuchSystemException;
/**
* Returns the current Alfresco Ticket for the current user on
* the remote system, fetching if it isn't already cached.
*
* Note that because tickets are cached, it is possible that a
* ticket has become invalid (due to timeout or server restart).
* If the ticket is rejected by the remote server, you should
* call {@link #refetchAlfrescoTicket(String)} to ensure you have
* the latest ticket, and re-try the request.
*
* @param remoteSystemId The ID of the remote system, as registered with the service
* @return The Alfresco Ticket for the current user on the remote system
*
* @throws AuthenticationException If the stored remote credentials are now invalid
* @throws NoCredentialsFoundException If the user has no stored credentials for the remote system
* @throws NoSuchSystemException If no system has been registered with the given ID
* @throws RemoteSystemUnavailableException If it was not possible to talk to the remote system
*/
RemoteAlfrescoTicketInfo getAlfrescoTicket(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.
*
* Normally {@link #getAlfrescoTicket(String)} should be used initially, with
* this only used if the ticket received is rejected by the remote server.
*
* @param remoteSystemId The ID of the remote system, as registered with the service
* @return The Alfresco Ticket for the current user on the remote system
*
* @throws AuthenticationException If the stored remote credentials are now invalid
* @throws NoCredentialsFoundException If the user has no stored credentials for the remote system
* @throws NoSuchSystemException If no system has been registered with the given ID
* @throws RemoteSystemUnavailableException If it was not possible to talk to the remote system
*/
RemoteAlfrescoTicketInfo refetchAlfrescoTicket(String remoteSystemId)
throws AuthenticationException, NoCredentialsFoundException, NoSuchSystemException, RemoteSystemUnavailableException;
/**
* Registers the details of a new Remote System with the service.
*
* @param remoteSystemId The ID to be used to identify the system
* @param baseUrl The base URL of Alfresco Services on the remote system, eg http://localhost:8080/alfresco/service/
* @param requestHeaders Any HTTP headers that must be sent with the request when talking to the server
*/
void registerRemoteSystem(String remoteSystemId, String baseUrl, Map<String,String> requestHeaders);
}

View File

@@ -0,0 +1,43 @@
/*
* Copyright (C) 2005-2012 Alfresco Software Limited.
*
* This file is part of Alfresco
*
* Alfresco is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Alfresco is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with Alfresco. If not, see <http://www.gnu.org/licenses/>.
*/
package org.alfresco.service.cmr.remoteticket;
import org.alfresco.error.AlfrescoRuntimeException;
/**
* Exception thrown if an error was received when attempting
* to talk with a remote system, meaning that it is unavailable.
*
* @author Nick Burch
* @since 4.0.2
*/
public class RemoteSystemUnavailableException extends AlfrescoRuntimeException
{
private static final long serialVersionUID = 5346482391129538502L;
public RemoteSystemUnavailableException(String message)
{
super(message);
}
public RemoteSystemUnavailableException(String message, Throwable source)
{
super(message, source);
}
}