mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-14 17:58:59 +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.model.ContentModel;
|
||||||
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
import org.alfresco.repo.security.authentication.AuthenticationUtil;
|
||||||
import org.alfresco.repo.transaction.AlfrescoTransactionSupport;
|
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.repo.transaction.TransactionListenerAdapter;
|
||||||
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
import org.alfresco.service.cmr.dictionary.DictionaryService;
|
||||||
import org.alfresco.service.cmr.repository.ContentData;
|
import org.alfresco.service.cmr.repository.ContentData;
|
||||||
@@ -208,6 +210,11 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
|||||||
throw new GoogleDocsServiceInitException("No Google Docs credentials found. Please set the Google Docs authentication configuration.");
|
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);
|
service.setUserCredentials(username, password);
|
||||||
serviceTokens.put(serviceName, ((UserToken)service.getAuthTokenFactory().getAuthToken()).getValue());
|
serviceTokens.put(serviceName, ((UserToken)service.getAuthTokenFactory().getAuthToken()).getValue());
|
||||||
}
|
}
|
||||||
@@ -224,7 +231,6 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
|||||||
return service;
|
return service;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param nodeService node service
|
* @param nodeService node service
|
||||||
*/
|
*/
|
||||||
@@ -335,8 +341,7 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
|||||||
public void setUsername(String username)
|
public void setUsername(String username)
|
||||||
{
|
{
|
||||||
this.username = username;
|
this.username = username;
|
||||||
// Reset the token map
|
updatedAuthenticationCredentials();
|
||||||
serviceTokens = new HashMap<String, String>(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -345,8 +350,7 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
|||||||
public void setPassword(String password)
|
public void setPassword(String password)
|
||||||
{
|
{
|
||||||
this.password = password;
|
this.password = password;
|
||||||
// Reset the token map
|
updatedAuthenticationCredentials();
|
||||||
serviceTokens = new HashMap<String, String>(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -364,8 +368,7 @@ public class GoogleDocsServiceImpl extends TransactionListenerAdapter
|
|||||||
public void setEnabled(boolean enabled)
|
public void setEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
this.enabled = enabled;
|
this.enabled = enabled;
|
||||||
// Reset the token map
|
updatedAuthenticationCredentials();
|
||||||
serviceTokens = new HashMap<String, String>(2);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -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