mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ALF-9006: Can enable Google Docs feature without providing Google account details - breaks functionality when added back in
* Error will be displayed if user name left blank (or password null) * Does not stop the server starting (only stops the values being reset) * TODO investigate possibly related config update issue that was clouding the issue git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@32915 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -33,6 +33,8 @@ import org.alfresco.error.AlfrescoRuntimeException;
|
||||
import org.alfresco.model.ContentModel;
|
||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
||||
import org.alfresco.repo.transaction.RetryingTransactionHelper;
|
||||
import org.alfresco.repo.transaction.TransactionListener;
|
||||
import org.alfresco.repo.transaction.TransactionListenerAdapter;
|
||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||
import org.alfresco.service.cmr.repository.ContentData;
|
||||
@@ -202,11 +204,16 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
||||
if (token == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
{
|
||||
if (username == null ||username.length() == 0 || password == null)
|
||||
{
|
||||
throw new GoogleDocsServiceInitException("No Google Docs credentials found. Please set the Google Docs authentication configuration.");
|
||||
}
|
||||
|
||||
if (logger.isDebugEnabled() == true)
|
||||
{
|
||||
logger.debug("Setting user credentials for GDoc service. (serviceName=" + serviceName + ", userName=" + username + ", password=" + password + ")");
|
||||
}
|
||||
|
||||
service.setUserCredentials(username, password);
|
||||
serviceTokens.put(serviceName, ((UserToken)service.getAuthTokenFactory().getAuthToken()).getValue());
|
||||
@@ -224,7 +231,6 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
||||
return service;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param nodeService node service
|
||||
*/
|
||||
@@ -335,9 +341,8 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
||||
public void setUsername(String username)
|
||||
{
|
||||
this.username = username;
|
||||
// Reset the token map
|
||||
serviceTokens = new HashMap<String, String>(2);
|
||||
}
|
||||
updatedAuthenticationCredentials();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param password google service password
|
||||
@@ -345,8 +350,7 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
||||
public void setPassword(String password)
|
||||
{
|
||||
this.password = password;
|
||||
// Reset the token map
|
||||
serviceTokens = new HashMap<String, String>(2);
|
||||
updatedAuthenticationCredentials();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,8 +368,7 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
||||
public void setEnabled(boolean enabled)
|
||||
{
|
||||
this.enabled = enabled;
|
||||
// Reset the token map
|
||||
serviceTokens = new HashMap<String, String>(2);
|
||||
updatedAuthenticationCredentials();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1291,4 +1294,50 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private TransactionListener validateCredentials = new TransactionListener()
|
||||
{
|
||||
|
||||
@Override
|
||||
public void afterCommit()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterRollback()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCommit(boolean readOnly)
|
||||
{
|
||||
if (enabled == true)
|
||||
{
|
||||
if (username == null || username.length() == 0 || password == null)
|
||||
{
|
||||
throw new GoogleDocsServiceInitException("No Google Docs credentials found. Please set the Google Docs authentication configuration.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeCompletion()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
private void updatedAuthenticationCredentials()
|
||||
{
|
||||
// Reset the token map
|
||||
serviceTokens = new HashMap<String, String>(2);
|
||||
if (RetryingTransactionHelper.getActiveUserTransaction() != null)
|
||||
{
|
||||
AlfrescoTransactionSupport.bindListener(validateCredentials);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user