mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
ACE-3195 "Master key removal leads to Document Library and Dashboards errors"
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@89115 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -614,9 +614,56 @@ public abstract class AbstractContentDataDAOImpl implements ContentDataDAO
|
||||
* @return Returns the number of rows deleted
|
||||
*/
|
||||
protected abstract int deleteContentDataEntity(Long id);
|
||||
|
||||
protected abstract int deleteContentUrlEntity(long id);
|
||||
protected abstract int updateContentUrlEntity(ContentUrlEntity existing, ContentUrlEntity entity);
|
||||
|
||||
@Override
|
||||
public boolean updateContentUrlKey(String contentUrl, ContentUrlKeyEntity contentUrlKey)
|
||||
{
|
||||
boolean success = true;
|
||||
|
||||
ContentUrlEntity existing = getContentUrl(contentUrl);
|
||||
if(existing != null)
|
||||
{
|
||||
ContentUrlEntity entity = ContentUrlEntity.setContentUrlKey(existing, contentUrlKey);
|
||||
updateContentUrl(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("No content url, not updating symmetric key");
|
||||
}
|
||||
success = false;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateContentUrlKey(long contentUrlId, ContentUrlKeyEntity contentUrlKey)
|
||||
{
|
||||
boolean success = true;
|
||||
|
||||
ContentUrlEntity existing = getContentUrl(contentUrlId);
|
||||
if(existing != null)
|
||||
{
|
||||
ContentUrlEntity entity = ContentUrlEntity.setContentUrlKey(existing, contentUrlKey);
|
||||
updateContentUrl(entity);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (logger.isDebugEnabled())
|
||||
{
|
||||
logger.debug("No content url, not updating symmetric key");
|
||||
}
|
||||
success = false;
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Transactional listener that deletes unreferenced <b>content_url</b> entities.
|
||||
*
|
||||
|
@@ -147,6 +147,24 @@ public interface ContentDataDAO
|
||||
*/
|
||||
void updateContentUrl(ContentUrlEntity contentUrlEntity);
|
||||
|
||||
/**
|
||||
* Updates the content key for the given content url
|
||||
*
|
||||
* @since 5.0
|
||||
* @param contentUrl
|
||||
* @param contentUrlKeyEntity
|
||||
*/
|
||||
boolean updateContentUrlKey(String contentUrl, ContentUrlKeyEntity contentUrlKeyEntity);
|
||||
|
||||
/**
|
||||
* Updates the content key for the given content url
|
||||
*
|
||||
* @since 5.0
|
||||
* @param contentUrlId
|
||||
* @param contentUrlKeyEntity
|
||||
*/
|
||||
boolean updateContentUrlKey(long contentUrlId, ContentUrlKeyEntity contentUrlKey);
|
||||
|
||||
/**
|
||||
* Get symmetric keys entities for symmetric keys that have been encrypted using the given
|
||||
* master key, starting from 'fromId' and returning at most 'maxResults' entities.
|
||||
|
@@ -72,7 +72,8 @@ public class ContentUrlEntity implements Serializable
|
||||
else if (obj instanceof ContentUrlEntity)
|
||||
{
|
||||
ContentUrlEntity that = (ContentUrlEntity) obj;
|
||||
return EqualsHelper.nullSafeEquals(this.contentUrl, that.contentUrl);
|
||||
return EqualsHelper.nullSafeEquals(this.contentUrl, that.contentUrl)
|
||||
&& EqualsHelper.nullSafeEquals(contentUrlKey, that.getContentUrlKey());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -79,15 +79,34 @@ public class ContentUrlKeyEntity implements Serializable
|
||||
return encryptedKeyAsBytes;
|
||||
}
|
||||
|
||||
public void updateEncryptedKey(EncryptedKey encryptedKey)
|
||||
public void setEncryptedKey(EncryptedKey encryptedKey)
|
||||
{
|
||||
byte[] encryptedKeyAsBytes = new byte[encryptedKey.getByteBuffer().remaining()];
|
||||
encryptedKey.getByteBuffer().get(encryptedKeyAsBytes);
|
||||
|
||||
this.encryptedKeyAsBytes = encryptedKeyAsBytes;
|
||||
setKeySize(encryptedKeyAsBytes.length*8);
|
||||
setAlgorithm(encryptedKey.getAlgorithm());
|
||||
setMasterKeyAlias(encryptedKey.getMasterKeyAlias());
|
||||
setMasterKeystoreId(encryptedKey.getMasterKeystoreId());
|
||||
this.keySize = encryptedKeyAsBytes.length*8;
|
||||
this.algorithm = encryptedKey.getAlgorithm();
|
||||
this.masterKeyAlias = encryptedKey.getMasterKeyAlias();
|
||||
this.masterKeystoreId = encryptedKey.getMasterKeystoreId();
|
||||
}
|
||||
|
||||
public static ContentUrlKeyEntity setEncryptedKey(ContentUrlKeyEntity existing, EncryptedKey encryptedKey)
|
||||
{
|
||||
ContentUrlKeyEntity newContentUrlKeyEntity = new ContentUrlKeyEntity();
|
||||
|
||||
byte[] encryptedKeyAsBytes = new byte[encryptedKey.getByteBuffer().remaining()];
|
||||
encryptedKey.getByteBuffer().get(encryptedKeyAsBytes);
|
||||
newContentUrlKeyEntity.setEncryptedKeyAsBytes(encryptedKeyAsBytes);
|
||||
newContentUrlKeyEntity.setKeySize(encryptedKeyAsBytes.length*8);
|
||||
newContentUrlKeyEntity.setAlgorithm(encryptedKey.getAlgorithm());
|
||||
newContentUrlKeyEntity.setMasterKeyAlias(encryptedKey.getMasterKeyAlias());
|
||||
newContentUrlKeyEntity.setMasterKeystoreId(encryptedKey.getMasterKeystoreId());
|
||||
newContentUrlKeyEntity.setContentUrlId(existing.getContentUrlId());
|
||||
newContentUrlKeyEntity.setUnencryptedFileSize(existing.getUnencryptedFileSize());
|
||||
newContentUrlKeyEntity.setId(existing.getId());
|
||||
|
||||
return newContentUrlKeyEntity;
|
||||
}
|
||||
|
||||
public Long getId()
|
||||
@@ -157,6 +176,55 @@ public class ContentUrlKeyEntity implements Serializable
|
||||
this.masterKeyAlias = masterKeyAlias;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode()
|
||||
{
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result
|
||||
+ ((algorithm == null) ? 0 : algorithm.hashCode());
|
||||
result = prime * result + ((id == null) ? 0 : id.hashCode());
|
||||
result = prime * result
|
||||
+ ((masterKeyAlias == null) ? 0 : masterKeyAlias.hashCode());
|
||||
result = prime
|
||||
* result
|
||||
+ ((masterKeystoreId == null) ? 0 : masterKeystoreId.hashCode());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj)
|
||||
{
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
ContentUrlKeyEntity other = (ContentUrlKeyEntity) obj;
|
||||
if (algorithm == null) {
|
||||
if (other.algorithm != null)
|
||||
return false;
|
||||
} else if (!algorithm.equals(other.algorithm))
|
||||
return false;
|
||||
if (id == null) {
|
||||
if (other.id != null)
|
||||
return false;
|
||||
} else if (!id.equals(other.id))
|
||||
return false;
|
||||
if (masterKeyAlias == null) {
|
||||
if (other.masterKeyAlias != null)
|
||||
return false;
|
||||
} else if (!masterKeyAlias.equals(other.masterKeyAlias))
|
||||
return false;
|
||||
if (masterKeystoreId == null) {
|
||||
if (other.masterKeystoreId != null)
|
||||
return false;
|
||||
} else if (!masterKeystoreId.equals(other.masterKeystoreId))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString()
|
||||
{
|
||||
|
Reference in New Issue
Block a user