Merged V3.0 to HEAD

12145: Merged V2.2 to V3.0 (AuthenticationUtil)
    12109: AuthenticationUtil and AuthenticationComponent refactor
  12152: Removed Lucene usage from lookup of 'sites' root folder
  12153: Fix InviteServiceTest by cleaning up leaking authentications
  12159: Fix for broken usage pattern of the Threadlocal values in recent AuthenticationUtil refactor.


git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12508 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Jan Vonka
2008-12-19 12:15:59 +00:00
parent 21bb599e20
commit cd09266213
74 changed files with 870 additions and 997 deletions

View File

@@ -35,12 +35,11 @@ import java.util.Locale;
import javax.servlet.http.HttpServletResponse;
import net.sf.acegisecurity.Authentication;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.i18n.I18NUtil;
import org.alfresco.repo.content.AbstractContentReader;
import org.alfresco.repo.security.authentication.AuthenticationUtil;
import org.alfresco.repo.security.authentication.AuthenticationUtil.RunAsWork;
import org.alfresco.repo.transaction.RetryingTransactionHelper.RetryingTransactionCallback;
import org.alfresco.service.cmr.repository.ContentIOException;
import org.alfresco.service.cmr.repository.ContentReader;
@@ -130,16 +129,27 @@ public class HttpAlfrescoContentReader extends AbstractContentReader
}
private void getInfo()
{
RunAsWork<Object> getInfoRunAs = new RunAsWork<Object>()
{
public Object doWork() throws Exception
{
getInfoImpl();
return null;
}
};
AuthenticationUtil.runAs(getInfoRunAs, AuthenticationUtil.SYSTEM_USER_NAME);
}
private void getInfoImpl()
{
String contentUrl = getContentUrl();
// Info will be cached
isInfoCached = true;
// Authenticate as the system user for the call
Authentication authentication = null;
GetMethod method = null;
try
{
authentication = AuthenticationUtil.setCurrentUser(AuthenticationUtil.SYSTEM_USER_NAME);
String ticket = transactionService.getRetryingTransactionHelper().doInTransaction(ticketCallback, false, true);
String url = HttpAlfrescoContentReader.generateURL(baseHttpUrl, contentUrl, ticket, true);
@@ -214,7 +224,6 @@ public class HttpAlfrescoContentReader extends AbstractContentReader
{
try { method.releaseConnection(); } catch (Throwable e) {}
}
AuthenticationUtil.setCurrentAuthentication(authentication);
}
}
@@ -252,17 +261,27 @@ public class HttpAlfrescoContentReader extends AbstractContentReader
@Override
protected ReadableByteChannel getDirectReadableChannel() throws ContentIOException
{
RunAsWork<ReadableByteChannel> getChannelRunAs = new RunAsWork<ReadableByteChannel>()
{
public ReadableByteChannel doWork() throws Exception
{
return getDirectReadableChannelImpl();
}
};
return AuthenticationUtil.runAs(getChannelRunAs, AuthenticationUtil.SYSTEM_USER_NAME);
}
private ReadableByteChannel getDirectReadableChannelImpl() throws ContentIOException
{
String contentUrl = getContentUrl();
Authentication authentication = null;
try
{
if (!exists())
{
throw new IOException("Content doesn't exist");
}
authentication = AuthenticationUtil.setCurrentUser(AuthenticationUtil.SYSTEM_USER_NAME);
String ticket = transactionService.getRetryingTransactionHelper().doInTransaction(ticketCallback, false, true);
String url = HttpAlfrescoContentReader.generateURL(baseHttpUrl, contentUrl, ticket, false);
@@ -298,10 +317,6 @@ public class HttpAlfrescoContentReader extends AbstractContentReader
" Remote server: " + baseHttpUrl,
e);
}
finally
{
AuthenticationUtil.setCurrentAuthentication(authentication);
}
}
/**