Acs 1865 impl configs for da us (#634)

* ACS-1781 Config set up and validation

* ACS-1781 Unit tests for config validation

* ACS-1865 Code tidy up

* ACS-1865 Updates from PR review

* ACS-1865 Updates from review
This commit is contained in:
Sara
2021-08-03 14:16:24 +01:00
committed by GitHub
parent 9626f5ace6
commit e95100e429
13 changed files with 2723 additions and 1607 deletions

View File

@@ -0,0 +1,93 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.rest.api.impl.directurl;
import org.alfresco.repo.content.directurl.AbstractDirectUrlConfig;
import org.alfresco.repo.content.directurl.InvalidDirectAccessUrlConfigException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* REST API direct access URL configuration settings.
*
* @author Sara Aspery
*/
public class RestApiDirectUrlConfig extends AbstractDirectUrlConfig
{
private static final Log logger = LogFactory.getLog(RestApiDirectUrlConfig.class);
/**
* Configuration initialise
*/
public void init()
{
validate();
}
/**
* {@inheritDoc}
*/
@Override
public void validate()
{
// Disable direct access URLs for the REST API if any error found in the REST API direct access URL config
try
{
validateDirectAccessUrlConfig();
}
catch (InvalidDirectAccessUrlConfigException ex)
{
logger.error("Disabling REST API direct access URLs due to configuration error: " + ex.getMessage());
setEnabled(false);
}
}
/* Helper method to validate the REST API direct access url configuration settings */
private void validateDirectAccessUrlConfig() throws InvalidDirectAccessUrlConfigException
{
if (isEnabled())
{
if (getDefaultExpiryTimeInSec() == null)
{
logger.warn(String.format("Default expiry time property is missing: setting to system-wide default [%s].", getSysWideDefaultExpiryTimeInSec()));
setDefaultExpiryTimeInSec(getSysWideDefaultExpiryTimeInSec());
}
if (getDefaultExpiryTimeInSec() < 1)
{
String errorMsg = String.format("REST API direct access URL default expiry time [%s] is invalid.", getDefaultExpiryTimeInSec());
throw new InvalidDirectAccessUrlConfigException(errorMsg);
}
if (getDefaultExpiryTimeInSec() > getSysWideMaxExpiryTimeInSec())
{
String errorMsg = String.format("REST API direct access URL default expiry time [%s] exceeds system-wide maximum expiry time [%s].",
getDefaultExpiryTimeInSec(), getSysWideMaxExpiryTimeInSec());
throw new InvalidDirectAccessUrlConfigException(errorMsg);
}
}
}
}

View File

@@ -2,7 +2,7 @@
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2017 Alfresco Software Limited
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
@@ -76,6 +76,7 @@ import org.junit.runners.Suite;
org.alfresco.repo.web.scripts.site.SurfConfigTest.class,
org.alfresco.repo.web.scripts.node.NodeWebScripTest.class,
org.alfresco.rest.api.impl.CommentsImplUnitTest.class,
org.alfresco.rest.api.impl.RestApiDirectUrlConfigUnitTest.class
})
public class AppContext04TestSuite
{

View File

@@ -0,0 +1,132 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.rest.api.impl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.alfresco.repo.content.directurl.SystemWideDirectUrlConfig;
import org.alfresco.rest.api.impl.directurl.RestApiDirectUrlConfig;
import org.junit.Before;
import org.junit.Test;
/**
* Tests for REST API direct access URL configuration settings.
*
* @author Sara Aspery
*/
public class RestApiDirectUrlConfigUnitTest
{
private static final Boolean ENABLED = Boolean.TRUE;
private static final Boolean DISABLED = Boolean.FALSE;
private static final Long DEFAULT_EXPIRY_TIME_IN_SECS = 20L;
private RestApiDirectUrlConfig restApiDirectUrlConfig;
@Before
public void setup()
{
this.restApiDirectUrlConfig = new RestApiDirectUrlConfig();
SystemWideDirectUrlConfig sysConfig = new SystemWideDirectUrlConfig();
sysConfig.setEnabled(ENABLED);
sysConfig.setDefaultExpiryTimeInSec(30L);
sysConfig.setMaxExpiryTimeInSec(300L);
restApiDirectUrlConfig.setSystemWideDirectUrlConfig(sysConfig);
}
@Test
public void testValidConfig_RemainsEnabled()
{
setupDirectAccessConfig(ENABLED, DEFAULT_EXPIRY_TIME_IN_SECS);
assertTrue("Expected REST API direct URLs to be enabled", restApiDirectUrlConfig.isEnabled());
restApiDirectUrlConfig.validate();
assertTrue("Expected REST API direct URLs to be enabled", restApiDirectUrlConfig.isEnabled());
}
@Test
public void testValidConfig_RemainsDisabled()
{
setupDirectAccessConfig(DISABLED, DEFAULT_EXPIRY_TIME_IN_SECS);
assertFalse("Expected REST API direct URLs to be disabled", restApiDirectUrlConfig.isEnabled());
restApiDirectUrlConfig.validate();
assertFalse("Expected REST API direct URLs to be disabled", restApiDirectUrlConfig.isEnabled());
}
@Test
public void testValidConfig_DefaultExpiryTimeMissing()
{
setupDirectAccessConfig(ENABLED, null);
assertNull("Expected REST API default expiry time to be null", restApiDirectUrlConfig.getDefaultExpiryTimeInSec());
restApiDirectUrlConfig.validate();
Long expectedDefaultExpiryTime = restApiDirectUrlConfig.getSysWideDefaultExpiryTimeInSec();
assertEquals("Expected REST API default expiry time to be set to the system-wide default", expectedDefaultExpiryTime, restApiDirectUrlConfig.getDefaultExpiryTimeInSec());
assertTrue("Expected REST API direct URLs to be enabled", restApiDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_DefaultExpiryTimeZero()
{
setupDirectAccessConfig(ENABLED, 0L);
assertTrue("Expected REST API direct URLs to be enabled", restApiDirectUrlConfig.isEnabled());
restApiDirectUrlConfig.validate();
assertFalse("Expected REST API direct URLs to be disabled", restApiDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_DefaultExpiryTimeNegative()
{
setupDirectAccessConfig(ENABLED, -1L);
assertTrue("Expected REST API direct URLs to be enabled", restApiDirectUrlConfig.isEnabled());
restApiDirectUrlConfig.validate();
assertFalse("Expected REST API direct URLs to be disabled", restApiDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_DefaultExpiryTimeExceedsSystemMax()
{
Long systemMax = restApiDirectUrlConfig.getSysWideMaxExpiryTimeInSec();
setupDirectAccessConfig(ENABLED, systemMax + 1);
assertTrue("Expected REST API direct URLs to be enabled", restApiDirectUrlConfig.isEnabled());
restApiDirectUrlConfig.validate();
assertFalse("Expected REST API direct URLs to be disabled", restApiDirectUrlConfig.isEnabled());
}
/* Helper method to set system-wide direct access url configuration settings */
private void setupDirectAccessConfig(Boolean isEnabled, Long defaultExpiryTime)
{
restApiDirectUrlConfig.setEnabled(isEnabled);
restApiDirectUrlConfig.setDefaultExpiryTimeInSec(defaultExpiryTime);
}
}

View File

@@ -0,0 +1,81 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.repo.content.directurl;
/**
* Direct Access Url configuration settings.
*
* @author Sara Aspery
*/
public abstract class AbstractDirectUrlConfig implements DirectUrlConfig
{
/** System-wide direct access URL configuration */
private SystemWideDirectUrlConfig systemWideDirectUrlConfig;
/** Direct access URL configuration settings */
private Boolean enabled;
private Long defaultExpiryTimeInSec;
public void setSystemWideDirectUrlConfig(SystemWideDirectUrlConfig systemWideDirectUrlConfig)
{
this.systemWideDirectUrlConfig = systemWideDirectUrlConfig;
}
public void setEnabled(Boolean enabled)
{
this.enabled = enabled;
}
public void setDefaultExpiryTimeInSec(Long defaultExpiryTimeInSec)
{
this.defaultExpiryTimeInSec = defaultExpiryTimeInSec;
}
protected Boolean isSysWideEnabled()
{
return systemWideDirectUrlConfig.isEnabled();
}
public Long getSysWideDefaultExpiryTimeInSec()
{
return systemWideDirectUrlConfig.getDefaultExpiryTimeInSec();
}
public Long getSysWideMaxExpiryTimeInSec()
{
return systemWideDirectUrlConfig.getMaxExpiryTimeInSec();
}
public Boolean isEnabled()
{
return enabled;
}
public Long getDefaultExpiryTimeInSec()
{
return defaultExpiryTimeInSec;
}
}

View File

@@ -0,0 +1,134 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.repo.content.directurl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* Content store direct access URL configuration settings.
*
* @author Sara Aspery
*/
public class ContentStoreDirectUrlConfig extends AbstractDirectUrlConfig
{
private static final Log logger = LogFactory.getLog(ContentStoreDirectUrlConfig.class);
private Long maxExpiryTimeInSec;
public void setMaxExpiryTimeInSec(Long maxExpiryTimeInSec)
{
this.maxExpiryTimeInSec = maxExpiryTimeInSec;
}
public Long getMaxExpiryTimeInSec()
{
return maxExpiryTimeInSec;
}
/**
* Configuration initialise
*/
public void init()
{
validate();
}
/**
* {@inheritDoc}
*/
@Override
public void validate()
{
// Disable direct access URLs for the content store if any error found in the content store direct access URL config
try
{
validateDirectAccessUrlConfig();
}
catch (InvalidDirectAccessUrlConfigException ex)
{
logger.error("Disabling content store direct access URLs due to configuration error: " + ex.getMessage());
setEnabled(false);
}
}
/* Helper method to validate the content direct access url configuration settings */
private void validateDirectAccessUrlConfig() throws InvalidDirectAccessUrlConfigException
{
if (isEnabled())
{
if (getMaxExpiryTimeInSec() == null)
{
logger.warn(String.format("Maximum expiry time property is missing: setting to system-wide maximum [%s].", getSysWideMaxExpiryTimeInSec()));
setMaxExpiryTimeInSec(getSysWideMaxExpiryTimeInSec());
}
else if (getMaxExpiryTimeInSec() > getSysWideMaxExpiryTimeInSec())
{
String errorMsg = String.format("Content store direct access URL maximum expiry time [%s] exceeds system-wide maximum expiry time [%s].",
getMaxExpiryTimeInSec(), getSysWideMaxExpiryTimeInSec());
throw new InvalidDirectAccessUrlConfigException(errorMsg);
}
if (getDefaultExpiryTimeInSec() == null)
{
logger.warn(String.format("Default expiry time property is missing: setting to system-wide default [%s].", getSysWideDefaultExpiryTimeInSec()));
setDefaultExpiryTimeInSec(getSysWideDefaultExpiryTimeInSec());
}
else if (getDefaultExpiryTimeInSec() > getMaxExpiryTimeInSec())
{
logger.warn(String.format("Default expiry time property [%s] exceeds maximum expiry time for content store [%s]: setting to system-wide default [%s].",
getDefaultExpiryTimeInSec(), getMaxExpiryTimeInSec(), getSysWideDefaultExpiryTimeInSec()));
setDefaultExpiryTimeInSec(getSysWideDefaultExpiryTimeInSec());
}
else if (getDefaultExpiryTimeInSec() > getSysWideDefaultExpiryTimeInSec())
{
logger.warn(String.format("Default expiry time property [%s] exceeds system-wide default expiry time [%s]: setting to system-wide default.",
getDefaultExpiryTimeInSec(), getSysWideDefaultExpiryTimeInSec()));
setDefaultExpiryTimeInSec(getSysWideDefaultExpiryTimeInSec());
}
if (getDefaultExpiryTimeInSec() < 1)
{
String errorMsg = String.format("Content store direct access URL default expiry time [%s] is invalid.", getDefaultExpiryTimeInSec());
throw new InvalidDirectAccessUrlConfigException(errorMsg);
}
if (getDefaultExpiryTimeInSec() > getSysWideMaxExpiryTimeInSec())
{
String errorMsg = String.format("Content store direct access URL default expiry time [%s] exceeds system-wide maximum expiry time [%s].",
getDefaultExpiryTimeInSec(), getSysWideMaxExpiryTimeInSec());
throw new InvalidDirectAccessUrlConfigException(errorMsg);
}
if (getDefaultExpiryTimeInSec() > getMaxExpiryTimeInSec())
{
String errorMsg = String.format("Content store direct access URL default expiry time [%s] exceeds content store maximum expiry time [%s].",
getDefaultExpiryTimeInSec(), getMaxExpiryTimeInSec());
throw new InvalidDirectAccessUrlConfigException(errorMsg);
}
}
}
}

View File

@@ -0,0 +1,41 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.repo.content.directurl;
import org.alfresco.api.AlfrescoPublicApi;
/**
* Direct Access Url configuration settings interface.
*
* @author Sara Aspery
*/
@AlfrescoPublicApi
public interface DirectUrlConfig
{
Boolean isEnabled();
Long getDefaultExpiryTimeInSec();
void validate();
}

View File

@@ -0,0 +1,44 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.repo.content.directurl;
import org.alfresco.error.AlfrescoRuntimeException;
/**
* Runtime exception thrown when the direct access URL configuration settings are invalid.
*
* @author Sara Aspery
*/
public class InvalidDirectAccessUrlConfigException extends AlfrescoRuntimeException
{
private static final long serialVersionUID = -6318313836484979887L;
public InvalidDirectAccessUrlConfigException(String msg)
{
super(msg);
}
}

View File

@@ -0,0 +1,124 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.repo.content.directurl;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
/**
* System-wide direct access URL configuration settings.
*
* @author Sara Aspery
*/
public class SystemWideDirectUrlConfig implements DirectUrlConfig
{
private static final Log logger = LogFactory.getLog(SystemWideDirectUrlConfig.class);
/** Direct access url configuration settings */
private Boolean enabled;
private Long defaultExpiryTimeInSec;
private Long maxExpiryTimeInSec;
public void setEnabled(Boolean enabled)
{
this.enabled = enabled;
}
public void setDefaultExpiryTimeInSec(Long defaultExpiryTimeInSec)
{
this.defaultExpiryTimeInSec = defaultExpiryTimeInSec;
}
public void setMaxExpiryTimeInSec(Long maxExpiryTimeInSec)
{
this.maxExpiryTimeInSec = maxExpiryTimeInSec;
}
public Boolean isEnabled()
{
return enabled;
}
public Long getDefaultExpiryTimeInSec()
{
return defaultExpiryTimeInSec;
}
public Long getMaxExpiryTimeInSec()
{
return maxExpiryTimeInSec;
}
/**
* Configuration initialise
*/
public void init()
{
validate();
}
/**
* {@inheritDoc}
*/
@Override
public void validate()
{
// Disable direct access URLs system-wide if any error found in the system-wide direct access URL config
try
{
validateSystemDirectAccessUrlConfig();
}
catch (InvalidDirectAccessUrlConfigException ex)
{
logger.error("Disabling system-wide direct access URLs due to configuration error: " + ex.getMessage());
setEnabled(false);
}
}
/* Helper method to validate the system-wide direct access url configuration settings */
private void validateSystemDirectAccessUrlConfig() throws InvalidDirectAccessUrlConfigException
{
if (isEnabled())
{
if (getDefaultExpiryTimeInSec() == null || getDefaultExpiryTimeInSec() < 1)
{
throw new InvalidDirectAccessUrlConfigException("System-wide direct access URL default expiry time is missing or invalid.");
}
if (getMaxExpiryTimeInSec() == null || getMaxExpiryTimeInSec() < 1)
{
throw new InvalidDirectAccessUrlConfigException("System-wide direct access URL maximum expiry time is missing or invalid.");
}
if (getDefaultExpiryTimeInSec() > getMaxExpiryTimeInSec())
{
String errorMsg = String.format("System-wide direct access URL default expiry time [%s] exceeds maximum expiry time [%s].",
getDefaultExpiryTimeInSec(), getMaxExpiryTimeInSec());
throw new InvalidDirectAccessUrlConfigException(errorMsg);
}
}
}
}

View File

@@ -1,359 +1,373 @@
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- ContentStore subsystem that allows switching between different types e.g. unencrypted and encrypted -->
<bean id="ContentStore" class="org.alfresco.repo.management.subsystems.CryptodocSwitchableApplicationContextFactory"
parent="abstractPropertyBackedBean">
<property name="autoStart">
<value>false</value>
</property>
<property name="category">
<value>ContentStore</value>
</property>
<property name="sourceBeanName">
<!-- default subsystem's bean name -->
<value>${filecontentstore.subsystem.name}</value>
</property>
<property name="instancePath">
<list>
<value>manager</value>
</list>
</property>
</bean>
<!-- Default ContentStore subsystem, that does not use encryption -->
<bean id="unencryptedContentStore" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
<property name="autoStart">
<value>true</value>
</property>
<property name="category">
<value>ContentStore</value>
</property>
<property name="typeName">
<value>unencrypted</value>
</property>
<property name="instancePath">
<list>
<value>managed</value>
<value>unencrypted</value>
</list>
</property>
</bean>
<!-- Import the selected ContentStore subsystem's fileContentStore bean for use in the main repository context -->
<bean id="fileContentStore" class="org.alfresco.repo.management.subsystems.CryptodocSubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="ContentStore" />
</property>
<property name="sourceBeanName">
<value>fileContentStore</value>
</property>
<property name="interfaces">
<list>
<value>org.alfresco.repo.content.ContentStore</value>
<value>org.alfresco.repo.content.ContentStoreCaps</value>
</list>
</property>
</bean>
<bean id="defaultFileContentUrlProvider" class="org.alfresco.repo.content.filestore.TimeBasedFileContentUrlProvider">
<property name="bucketsPerMinute" value="${dir.contentstore.bucketsPerMinute}"/>
</bean>
<!-- This content limit provider is used above (and can also be overriden, eg. by modules). -->
<bean id="defaultContentLimitProvider" class="org.alfresco.repo.content.ContentLimitProvider$SimpleFixedLimitProvider">
<property name="sizeLimitString" value="${system.content.maximumFileSizeLimit}"/>
</bean>
<!-- deleted content will get pushed into this store, where it can be cleaned up at will -->
<bean id="deletedContentStore" class="org.alfresco.repo.content.filestore.FileContentStore">
<constructor-arg>
<value>${dir.contentstore.deleted}</value>
</constructor-arg>
</bean>
<!-- bean to move deleted content into the the backup store -->
<bean id="deletedContentBackupListener" class="org.alfresco.repo.content.cleanup.DeletedContentBackupCleanerListener" >
<property name="store">
<ref bean="deletedContentStore" />
</property>
</bean>
<!-- A list of content deletion listeners. This is split out for re-use. -->
<bean id="deletedContentBackupListeners" class="java.util.ArrayList">
<constructor-arg>
<list>
<ref bean="deletedContentBackupListener" />
</list>
</constructor-arg>
</bean>
<!-- Performs the content cleanup -->
<bean id="contentStoreCleaner" class="org.alfresco.repo.content.cleanup.ContentStoreCleaner" init-method="init">
<property name="protectDays" >
<value>${system.content.orphanProtectDays}</value>
</property>
<property name="deletionFailureAction" >
<value>${system.content.deletionFailureAction}</value>
</property>
<property name="eagerContentStoreCleaner" >
<ref bean="eagerContentStoreCleaner" />
</property>
<property name="jobLockService">
<ref bean="jobLockService" />
</property>
<property name="contentDataDAO">
<ref bean="contentDataDAO"/>
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
<property name="contentService" >
<ref bean="contentService" />
</property>
<property name="transactionService" >
<ref bean="transactionService" />
</property>
<property name="batchSize" >
<value>${system.content.cleanerBatchSize}</value>
</property>
</bean>
<bean id="eagerContentStoreCleaner" class="org.alfresco.repo.content.cleanup.EagerContentStoreCleaner" init-method="init">
<property name="eagerOrphanCleanup" >
<value>${system.content.eagerOrphanCleanup}</value>
</property>
<property name="stores" ref="contentStoresToClean" />
<property name="listeners" >
<ref bean="deletedContentBackupListeners" />
</property>
</bean>
<bean id="contentStoresToClean" class="java.util.ArrayList" >
<constructor-arg>
<list>
<ref bean="fileContentStore" />
</list>
</constructor-arg>
</bean>
<!-- Abstract bean definition defining base definition for content service -->
<bean id="baseContentService" class="org.alfresco.repo.content.ContentServiceImpl" abstract="true" init-method="init">
<property name="retryingTransactionHelper">
<ref bean="retryingTransactionHelper"/>
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="policyComponent">
<ref bean="policyComponent" />
</property>
<property name="mimetypeService">
<ref bean="mimetypeService"/>
</property>
<property name="eagerContentStoreCleaner" >
<ref bean="eagerContentStoreCleaner" />
</property>
<property name="ignoreEmptyContent" >
<value>${policy.content.update.ignoreEmpty}</value>
</property>
</bean>
<bean id="contentService" parent="baseContentService">
<property name="store">
<ref bean="fileContentStore" />
</property>
</bean>
<!-- Our common Tika configuration -->
<bean id="tikaConfig" class="org.apache.tika.config.TikaConfig" >
<constructor-arg type="java.io.InputStream" value="classpath:alfresco/tika/tika-config.xml" />
</bean>
<!-- Characterset decoder -->
<bean id="charset.finder" class="org.alfresco.repo.content.encoding.ContentCharsetFinder">
<property name="defaultCharset">
<value>UTF-8</value>
</property>
<property name="mimetypeService">
<ref bean="mimetypeService"/>
</property>
<property name="charactersetFinders">
<list>
<bean class="org.alfresco.encoding.GuessEncodingCharsetFinder" />
<bean class="org.alfresco.encoding.TikaCharsetFinder" />
</list>
</property>
</bean>
<bean id="shutdownIndicator" class="org.alfresco.util.ShutdownIndicator"/>
<bean id="mimetypeConfigService" class="org.springframework.extensions.config.xml.XMLConfigService" init-method="init">
<constructor-arg>
<bean class="org.alfresco.util.ResourceFinderConfigSource">
<property name="resourceFinder">
<ref bean="resourceFinder" />
</property>
<property name="locations">
<list>
<value>classpath:alfresco/mimetype/mimetype-map.xml</value>
<value>classpath:alfresco/mimetype/mimetype-map-openoffice.xml</value>
<value>classpath*:alfresco/module/*/mimetype-map*.xml</value>
<value>classpath*:alfresco/extension/mimetype/*-map.xml</value>
</list>
</property>
</bean>
</constructor-arg>
</bean>
<bean id="mimetypeService" class="org.alfresco.repo.content.MimetypeMap" init-method="init" >
<property name="configService">
<ref bean="mimetypeConfigService" />
</property>
<property name="contentCharsetFinder">
<ref bean="charset.finder"/>
</property>
<property name="tikaConfig">
<ref bean="tikaConfig"/>
</property>
<property name="jsonObjectMapper" ref="mimetypeServiceJsonObjectMapper" />
<property name="mimetypeJsonConfigDir" value="${mimetype.config.dir}" />
<property name="cronExpression" value="${mimetype.config.cronExpression}" />
<property name="initialAndOnErrorCronExpression" value="${mimetype.config.initialAndOnError.cronExpression}" />
<property name="shutdownIndicator" ref="shutdownIndicator" />
</bean>
<bean id="mimetypeServiceJsonObjectMapper" class="com.fasterxml.jackson.databind.ObjectMapper" />
<bean id="contentFilterLanguagesConfigService" class="org.springframework.extensions.config.xml.XMLConfigService" init-method="init">
<constructor-arg>
<bean class="org.springframework.extensions.config.source.UrlConfigSource">
<constructor-arg>
<list>
<value>classpath:alfresco/ml/content-filter-lang.xml</value>
</list>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
<bean id="contentFilterLanguagesService" class="org.alfresco.repo.model.ml.ContentFilterLanguagesMap" init-method="init" >
<property name="configService">
<ref bean="contentFilterLanguagesConfigService" />
</property>
</bean>
<!-- Metadata Extraction Registry -->
<bean id="metadataExtracterRegistry" class="org.alfresco.repo.content.metadata.MetadataExtracterRegistry">
<property name="asyncExtractEnabled" value="${content.metadata.async.extract.enabled}" />
<property name="asyncEmbedEnabled" value="${content.metadata.async.embed.enabled}" />
</bean>
<!-- Abstract bean definition defining base definition for all metadata extracters -->
<bean id="baseMetadataExtracter"
abstract="true"
init-method="register">
<property name="registry">
<ref bean="metadataExtracterRegistry" />
</property>
<property name="mimetypeService">
<ref bean="mimetypeService" />
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
<property name="properties">
<ref bean="global-properties" />
</property>
<property name="supportedDateFormats">
<list>
<value>EEE, d MMM yyyy HH:mm:ss Z</value>
<value>EEE, d MMM yy HH:mm:ss Z</value>
<value>d MMM yyyy HH:mm:ss Z</value>
</list>
</property>
</bean>
<!-- Content Metadata Extractors -->
<!-- The last one listed for any mimetype will be used if available -->
<bean id="extractor.Asynchronous" class="org.alfresco.repo.content.metadata.AsynchronousExtractor" parent="baseMetadataExtracter">
<property name="nodeService" ref="nodeService" />
<property name="namespacePrefixResolver" ref="namespaceService" />
<property name="transformerDebug" ref="transformerDebug" />
<property name="renditionService2" ref="renditionService2" />
<property name="renditionDefinitionRegistry2" ref="renditionDefinitionRegistry2" />
<property name="contentService" ref="ContentService" />
<property name="transactionService" ref="transactionService" />
<property name="transformServiceRegistry" ref="transformServiceRegistry" />
<property name="taggingService" ref="taggingService" />
<property name="metadataExtractorPropertyMappingOverrides">
<list>
<ref bean="extracter.RFC822" /> <!-- The RM AMP overrides this bean, extending the base class -->
</list>
</property>
</bean>
<!-- No longer used as an extractor but still extended by RM to provide additional mappings -->
<bean id="extracter.RFC822" class="org.alfresco.repo.content.metadata.RFC822MetadataExtracter" parent="baseMetadataExtracter" >
<property name="nodeService" ref="nodeService"/>
</bean>
<!-- Transformation Debug -->
<bean id="transformerDebug" class="org.alfresco.repo.content.transform.AdminUiTransformerDebug">
<property name="nodeService" ref="nodeService" />
<property name="mimetypeService" ref="mimetypeService" />
<property name="transformerLog" ref="transformerLog" />
<property name="transformerDebugLog" ref="transformerDebugLog" />
<property name="localTransformServiceRegistry" ref="localTransformServiceRegistry" />
<property name="remoteTransformServiceRegistry" ref="remoteTransformServiceRegistry" />
</bean>
<!-- Transformer JMX bean (in addition to sub system properties) -->
<bean id="transformerConfigMBean" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="Transformers" />
</property>
<property name="interfaces">
<list>
<value>org.alfresco.repo.content.transform.TransformerConfigMBean</value>
</list>
</property>
</bean>
<!-- Logger for transformer debug that may be accessed via JMX -->
<bean id="transformerDebugLog" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="Transformers" />
</property>
<property name="sourceBeanName">
<value>transformerDebugLog</value>
</property>
<property name="interfaces">
<list>
<value>org.apache.commons.logging.Log</value>
</list>
</property>
</bean>
<!-- Logger for transformer log that may be accessed via JMX -->
<bean id="transformerLog" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="Transformers" />
</property>
<property name="sourceBeanName">
<value>transformerLog</value>
</property>
<property name="interfaces">
<list>
<value>org.apache.commons.logging.Log</value>
</list>
</property>
</bean>
</beans>
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd">
<!-- ContentStore subsystem that allows switching between different types e.g. unencrypted and encrypted -->
<bean id="ContentStore" class="org.alfresco.repo.management.subsystems.CryptodocSwitchableApplicationContextFactory"
parent="abstractPropertyBackedBean">
<property name="autoStart">
<value>false</value>
</property>
<property name="category">
<value>ContentStore</value>
</property>
<property name="sourceBeanName">
<!-- default subsystem's bean name -->
<value>${filecontentstore.subsystem.name}</value>
</property>
<property name="instancePath">
<list>
<value>manager</value>
</list>
</property>
</bean>
<!-- Default ContentStore subsystem, that does not use encryption -->
<bean id="unencryptedContentStore" class="org.alfresco.repo.management.subsystems.ChildApplicationContextFactory" parent="abstractPropertyBackedBean">
<property name="autoStart">
<value>true</value>
</property>
<property name="category">
<value>ContentStore</value>
</property>
<property name="typeName">
<value>unencrypted</value>
</property>
<property name="instancePath">
<list>
<value>managed</value>
<value>unencrypted</value>
</list>
</property>
</bean>
<!-- Import the selected ContentStore subsystem's fileContentStore bean for use in the main repository context -->
<bean id="fileContentStore" class="org.alfresco.repo.management.subsystems.CryptodocSubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="ContentStore" />
</property>
<property name="sourceBeanName">
<value>fileContentStore</value>
</property>
<property name="interfaces">
<list>
<value>org.alfresco.repo.content.ContentStore</value>
<value>org.alfresco.repo.content.ContentStoreCaps</value>
</list>
</property>
</bean>
<bean id="defaultFileContentUrlProvider" class="org.alfresco.repo.content.filestore.TimeBasedFileContentUrlProvider">
<property name="bucketsPerMinute" value="${dir.contentstore.bucketsPerMinute}"/>
</bean>
<!-- This content limit provider is used above (and can also be overriden, eg. by modules). -->
<bean id="defaultContentLimitProvider" class="org.alfresco.repo.content.ContentLimitProvider$SimpleFixedLimitProvider">
<property name="sizeLimitString" value="${system.content.maximumFileSizeLimit}"/>
</bean>
<!-- deleted content will get pushed into this store, where it can be cleaned up at will -->
<bean id="deletedContentStore" class="org.alfresco.repo.content.filestore.FileContentStore">
<constructor-arg>
<value>${dir.contentstore.deleted}</value>
</constructor-arg>
</bean>
<!-- bean to move deleted content into the the backup store -->
<bean id="deletedContentBackupListener" class="org.alfresco.repo.content.cleanup.DeletedContentBackupCleanerListener" >
<property name="store">
<ref bean="deletedContentStore" />
</property>
</bean>
<!-- A list of content deletion listeners. This is split out for re-use. -->
<bean id="deletedContentBackupListeners" class="java.util.ArrayList">
<constructor-arg>
<list>
<ref bean="deletedContentBackupListener" />
</list>
</constructor-arg>
</bean>
<!-- Performs the content cleanup -->
<bean id="contentStoreCleaner" class="org.alfresco.repo.content.cleanup.ContentStoreCleaner" init-method="init">
<property name="protectDays" >
<value>${system.content.orphanProtectDays}</value>
</property>
<property name="deletionFailureAction" >
<value>${system.content.deletionFailureAction}</value>
</property>
<property name="eagerContentStoreCleaner" >
<ref bean="eagerContentStoreCleaner" />
</property>
<property name="jobLockService">
<ref bean="jobLockService" />
</property>
<property name="contentDataDAO">
<ref bean="contentDataDAO"/>
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
<property name="contentService" >
<ref bean="contentService" />
</property>
<property name="transactionService" >
<ref bean="transactionService" />
</property>
<property name="batchSize" >
<value>${system.content.cleanerBatchSize}</value>
</property>
</bean>
<bean id="eagerContentStoreCleaner" class="org.alfresco.repo.content.cleanup.EagerContentStoreCleaner" init-method="init">
<property name="eagerOrphanCleanup" >
<value>${system.content.eagerOrphanCleanup}</value>
</property>
<property name="stores" ref="contentStoresToClean" />
<property name="listeners" >
<ref bean="deletedContentBackupListeners" />
</property>
</bean>
<bean id="contentStoresToClean" class="java.util.ArrayList" >
<constructor-arg>
<list>
<ref bean="fileContentStore" />
</list>
</constructor-arg>
</bean>
<!-- Abstract bean definition defining base definition for content service -->
<bean id="baseContentService" class="org.alfresco.repo.content.ContentServiceImpl" abstract="true" init-method="init">
<property name="retryingTransactionHelper">
<ref bean="retryingTransactionHelper"/>
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
<property name="nodeService">
<ref bean="nodeService" />
</property>
<property name="policyComponent">
<ref bean="policyComponent" />
</property>
<property name="mimetypeService">
<ref bean="mimetypeService"/>
</property>
<property name="eagerContentStoreCleaner" >
<ref bean="eagerContentStoreCleaner" />
</property>
<property name="ignoreEmptyContent" >
<value>${policy.content.update.ignoreEmpty}</value>
</property>
</bean>
<bean id="contentService" parent="baseContentService">
<property name="store">
<ref bean="fileContentStore" />
</property>
</bean>
<!-- Our common Tika configuration -->
<bean id="tikaConfig" class="org.apache.tika.config.TikaConfig" >
<constructor-arg type="java.io.InputStream" value="classpath:alfresco/tika/tika-config.xml" />
</bean>
<!-- Characterset decoder -->
<bean id="charset.finder" class="org.alfresco.repo.content.encoding.ContentCharsetFinder">
<property name="defaultCharset">
<value>UTF-8</value>
</property>
<property name="mimetypeService">
<ref bean="mimetypeService"/>
</property>
<property name="charactersetFinders">
<list>
<bean class="org.alfresco.encoding.GuessEncodingCharsetFinder" />
<bean class="org.alfresco.encoding.TikaCharsetFinder" />
</list>
</property>
</bean>
<bean id="shutdownIndicator" class="org.alfresco.util.ShutdownIndicator"/>
<bean id="mimetypeConfigService" class="org.springframework.extensions.config.xml.XMLConfigService" init-method="init">
<constructor-arg>
<bean class="org.alfresco.util.ResourceFinderConfigSource">
<property name="resourceFinder">
<ref bean="resourceFinder" />
</property>
<property name="locations">
<list>
<value>classpath:alfresco/mimetype/mimetype-map.xml</value>
<value>classpath:alfresco/mimetype/mimetype-map-openoffice.xml</value>
<value>classpath*:alfresco/module/*/mimetype-map*.xml</value>
<value>classpath*:alfresco/extension/mimetype/*-map.xml</value>
</list>
</property>
</bean>
</constructor-arg>
</bean>
<bean id="mimetypeService" class="org.alfresco.repo.content.MimetypeMap" init-method="init" >
<property name="configService">
<ref bean="mimetypeConfigService" />
</property>
<property name="contentCharsetFinder">
<ref bean="charset.finder"/>
</property>
<property name="tikaConfig">
<ref bean="tikaConfig"/>
</property>
<property name="jsonObjectMapper" ref="mimetypeServiceJsonObjectMapper" />
<property name="mimetypeJsonConfigDir" value="${mimetype.config.dir}" />
<property name="cronExpression" value="${mimetype.config.cronExpression}" />
<property name="initialAndOnErrorCronExpression" value="${mimetype.config.initialAndOnError.cronExpression}" />
<property name="shutdownIndicator" ref="shutdownIndicator" />
</bean>
<bean id="mimetypeServiceJsonObjectMapper" class="com.fasterxml.jackson.databind.ObjectMapper" />
<bean id="contentFilterLanguagesConfigService" class="org.springframework.extensions.config.xml.XMLConfigService" init-method="init">
<constructor-arg>
<bean class="org.springframework.extensions.config.source.UrlConfigSource">
<constructor-arg>
<list>
<value>classpath:alfresco/ml/content-filter-lang.xml</value>
</list>
</constructor-arg>
</bean>
</constructor-arg>
</bean>
<bean id="contentFilterLanguagesService" class="org.alfresco.repo.model.ml.ContentFilterLanguagesMap" init-method="init" >
<property name="configService">
<ref bean="contentFilterLanguagesConfigService" />
</property>
</bean>
<!-- Metadata Extraction Registry -->
<bean id="metadataExtracterRegistry" class="org.alfresco.repo.content.metadata.MetadataExtracterRegistry">
<property name="asyncExtractEnabled" value="${content.metadata.async.extract.enabled}" />
<property name="asyncEmbedEnabled" value="${content.metadata.async.embed.enabled}" />
</bean>
<!-- Abstract bean definition defining base definition for all metadata extracters -->
<bean id="baseMetadataExtracter"
abstract="true"
init-method="register">
<property name="registry">
<ref bean="metadataExtracterRegistry" />
</property>
<property name="mimetypeService">
<ref bean="mimetypeService" />
</property>
<property name="dictionaryService">
<ref bean="dictionaryService" />
</property>
<property name="properties">
<ref bean="global-properties" />
</property>
<property name="supportedDateFormats">
<list>
<value>EEE, d MMM yyyy HH:mm:ss Z</value>
<value>EEE, d MMM yy HH:mm:ss Z</value>
<value>d MMM yyyy HH:mm:ss Z</value>
</list>
</property>
</bean>
<!-- Content Metadata Extractors -->
<!-- The last one listed for any mimetype will be used if available -->
<bean id="extractor.Asynchronous" class="org.alfresco.repo.content.metadata.AsynchronousExtractor" parent="baseMetadataExtracter">
<property name="nodeService" ref="nodeService" />
<property name="namespacePrefixResolver" ref="namespaceService" />
<property name="transformerDebug" ref="transformerDebug" />
<property name="renditionService2" ref="renditionService2" />
<property name="renditionDefinitionRegistry2" ref="renditionDefinitionRegistry2" />
<property name="contentService" ref="ContentService" />
<property name="transactionService" ref="transactionService" />
<property name="transformServiceRegistry" ref="transformServiceRegistry" />
<property name="taggingService" ref="taggingService" />
<property name="metadataExtractorPropertyMappingOverrides">
<list>
<ref bean="extracter.RFC822" /> <!-- The RM AMP overrides this bean, extending the base class -->
</list>
</property>
</bean>
<!-- No longer used as an extractor but still extended by RM to provide additional mappings -->
<bean id="extracter.RFC822" class="org.alfresco.repo.content.metadata.RFC822MetadataExtracter" parent="baseMetadataExtracter" >
<property name="nodeService" ref="nodeService"/>
</bean>
<!-- Transformation Debug -->
<bean id="transformerDebug" class="org.alfresco.repo.content.transform.AdminUiTransformerDebug">
<property name="nodeService" ref="nodeService" />
<property name="mimetypeService" ref="mimetypeService" />
<property name="transformerLog" ref="transformerLog" />
<property name="transformerDebugLog" ref="transformerDebugLog" />
<property name="localTransformServiceRegistry" ref="localTransformServiceRegistry" />
<property name="remoteTransformServiceRegistry" ref="remoteTransformServiceRegistry" />
</bean>
<!-- Transformer JMX bean (in addition to sub system properties) -->
<bean id="transformerConfigMBean" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="Transformers" />
</property>
<property name="interfaces">
<list>
<value>org.alfresco.repo.content.transform.TransformerConfigMBean</value>
</list>
</property>
</bean>
<!-- Logger for transformer debug that may be accessed via JMX -->
<bean id="transformerDebugLog" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="Transformers" />
</property>
<property name="sourceBeanName">
<value>transformerDebugLog</value>
</property>
<property name="interfaces">
<list>
<value>org.apache.commons.logging.Log</value>
</list>
</property>
</bean>
<!-- Logger for transformer log that may be accessed via JMX -->
<bean id="transformerLog" class="org.alfresco.repo.management.subsystems.SubsystemProxyFactory">
<property name="sourceApplicationContextFactory">
<ref bean="Transformers" />
</property>
<property name="sourceBeanName">
<value>transformerLog</value>
</property>
<property name="interfaces">
<list>
<value>org.apache.commons.logging.Log</value>
</list>
</property>
</bean>
<!-- System direct access URL configuration settings -->
<bean id="systemWideDirectUrlConfig" class="org.alfresco.repo.content.directurl.SystemWideDirectUrlConfig" init-method="init">
<property name="enabled" value="${system.directAccessUrl.enabled}" />
<property name="defaultExpiryTimeInSec" value="${system.directAccessUrl.defaultExpiryTimeInSec}" />
<property name="maxExpiryTimeInSec" value="${system.directAccessUrl.maxExpiryTimeInSec}" />
</bean>
<!-- Abstract Direct Access URL configuration -->
<bean id="abstractDirectUrlConfig" class="org.alfresco.repo.content.directurl.AbstractDirectUrlConfig" abstract="true">
<property name="systemWideDirectUrlConfig" >
<ref bean="systemWideDirectUrlConfig" />
</property>
</bean>
</beans>

File diff suppressed because it is too large Load Diff

View File

@@ -180,6 +180,8 @@ import org.junit.runners.Suite;
org.alfresco.repo.audit.AuditableAnnotationTest.class,
org.alfresco.repo.audit.PropertyAuditFilterTest.class,
org.alfresco.repo.audit.access.NodeChangeTest.class,
org.alfresco.repo.content.directurl.SystemWideDirectUrlConfigUnitTest.class,
org.alfresco.repo.content.directurl.ContentStoreDirectUrlConfigUnitTest.class,
org.alfresco.repo.content.LimitedStreamCopierTest.class,
org.alfresco.repo.content.filestore.FileIOTest.class,
org.alfresco.repo.content.filestore.SpoofedTextContentReaderTest.class,

View File

@@ -0,0 +1,234 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.repo.content.directurl;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
/**
* Tests for content store direct access URL configuration settings.
*
* @author Sara Aspery
*/
public class ContentStoreDirectUrlConfigUnitTest
{
private static final Boolean ENABLED = Boolean.TRUE;
private static final Boolean DISABLED = Boolean.FALSE;
private static final Long DEFAULT_EXPIRY_TIME_IN_SECS = 10L;
private static final Long MAX_EXPIRY_TIME_IN_SECS = 20L;
private static final Long SYS_DEFAULT_EXPIRY_TIME_IN_SECS = 30L;
private static final Long SYS_MAX_EXPIRY_TIME_IN_SECS = 300L;
private ContentStoreDirectUrlConfig contentStoreDirectUrlConfig;
@Before
public void setup()
{
this.contentStoreDirectUrlConfig = new ContentStoreDirectUrlConfig();
setupSystemWideDirectAccessConfig();
}
@Test
public void testValidConfig_RemainsEnabled()
{
setupDirectAccessConfig(ENABLED, DEFAULT_EXPIRY_TIME_IN_SECS, MAX_EXPIRY_TIME_IN_SECS);
assertTrue("Expected content store direct URLs to be enabled", contentStoreDirectUrlConfig.isEnabled());
contentStoreDirectUrlConfig.validate();
assertTrue("Expected REST API direct URLs to be enabled", contentStoreDirectUrlConfig.isEnabled());
}
@Test
public void testValidConfig_RemainsDisabled()
{
setupDirectAccessConfig(DISABLED, DEFAULT_EXPIRY_TIME_IN_SECS, MAX_EXPIRY_TIME_IN_SECS);
assertFalse("Expected content store direct URLs to be disabled", contentStoreDirectUrlConfig.isEnabled());
contentStoreDirectUrlConfig.validate();
assertFalse("Expected content store direct URLs to be disabled", contentStoreDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_DefaultExpiryTimeMissing_ValidReplacement()
{
Long maxExpiryTimeInSecs = SYS_DEFAULT_EXPIRY_TIME_IN_SECS + 1;
setupDirectAccessConfig(ENABLED, null, maxExpiryTimeInSecs);
verifyDirectAccessConfig(ENABLED, null, maxExpiryTimeInSecs);
contentStoreDirectUrlConfig.validate();
verifyDirectAccessConfig(ENABLED, SYS_DEFAULT_EXPIRY_TIME_IN_SECS, maxExpiryTimeInSecs);
}
@Test
public void testInvalidConfig_DefaultExpiryTimeMissing_ReplacementExceedsMax()
{
setupDirectAccessConfig(ENABLED, null, MAX_EXPIRY_TIME_IN_SECS);
verifyDirectAccessConfig(ENABLED, null, MAX_EXPIRY_TIME_IN_SECS);
contentStoreDirectUrlConfig.validate();
verifyDirectAccessConfig(DISABLED, SYS_DEFAULT_EXPIRY_TIME_IN_SECS, MAX_EXPIRY_TIME_IN_SECS);
}
@Test
public void testInvalidConfig_DefaultExpiryTimeZero()
{
setupDirectAccessConfig(ENABLED, 0L, MAX_EXPIRY_TIME_IN_SECS);
assertTrue("Expected content store direct URLs to be enabled", contentStoreDirectUrlConfig.isEnabled());
contentStoreDirectUrlConfig.validate();
assertFalse("Expected content store direct URLs to be disabled", contentStoreDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_DefaultExpiryTimeNegative()
{
setupDirectAccessConfig(ENABLED, -1L, MAX_EXPIRY_TIME_IN_SECS);
assertTrue("Expected content store direct URLs to be enabled", contentStoreDirectUrlConfig.isEnabled());
contentStoreDirectUrlConfig.validate();
assertFalse("Expected content store direct URLs to be disabled", contentStoreDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_DefaultExpiryTimeExceedsSystemMax()
{
Long defaultExpiryTimeInSecs = SYS_MAX_EXPIRY_TIME_IN_SECS + 1;
setupDirectAccessConfig(ENABLED, defaultExpiryTimeInSecs, MAX_EXPIRY_TIME_IN_SECS);
assertTrue("Expected content store direct URLs to be enabled", contentStoreDirectUrlConfig.isEnabled());
contentStoreDirectUrlConfig.validate();
assertFalse("Expected content store direct URLs to be disabled", contentStoreDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_DefaultExpiryTimeExceedsStoreMax_ValidReplacement()
{
Long maxExpiryTimeInSecs = SYS_DEFAULT_EXPIRY_TIME_IN_SECS + 1;
Long defaultExpiryTimeInSecs = maxExpiryTimeInSecs + 1;
setupDirectAccessConfig(ENABLED, defaultExpiryTimeInSecs, maxExpiryTimeInSecs);
verifyDirectAccessConfig(ENABLED, defaultExpiryTimeInSecs, maxExpiryTimeInSecs);
contentStoreDirectUrlConfig.validate();
verifyDirectAccessConfig(ENABLED, SYS_DEFAULT_EXPIRY_TIME_IN_SECS, maxExpiryTimeInSecs);
}
@Test
public void testInvalidConfig_DefaultExpiryTimeExceedsStoreMax_ReplacementExceedsStoreMax()
{
Long defaultExpiryTimeInSecs = MAX_EXPIRY_TIME_IN_SECS + 1;
setupDirectAccessConfig(ENABLED, defaultExpiryTimeInSecs, MAX_EXPIRY_TIME_IN_SECS);
verifyDirectAccessConfig(ENABLED, defaultExpiryTimeInSecs, MAX_EXPIRY_TIME_IN_SECS);
contentStoreDirectUrlConfig.validate();
verifyDirectAccessConfig(DISABLED, SYS_DEFAULT_EXPIRY_TIME_IN_SECS, MAX_EXPIRY_TIME_IN_SECS);
}
@Test
public void testInvalidConfig_DefaultExpiryTimeExceedsSystemDefault_ValidReplacement()
{
Long defaultExpiryTimeInSecs = SYS_DEFAULT_EXPIRY_TIME_IN_SECS + 1;
Long maxExpiryTimeInSecs = SYS_MAX_EXPIRY_TIME_IN_SECS;
setupDirectAccessConfig(ENABLED, defaultExpiryTimeInSecs, maxExpiryTimeInSecs);
verifyDirectAccessConfig(ENABLED, defaultExpiryTimeInSecs, maxExpiryTimeInSecs);
contentStoreDirectUrlConfig.validate();
verifyDirectAccessConfig(ENABLED, SYS_DEFAULT_EXPIRY_TIME_IN_SECS, maxExpiryTimeInSecs);
}
@Test
public void testInvalidConfig_DefaultExpiryTimeExceedsSystemDefault_ReplacementExceedsStoreMax()
{
Long defaultExpiryTimeInSecs = SYS_DEFAULT_EXPIRY_TIME_IN_SECS + 1;
setupDirectAccessConfig(ENABLED, defaultExpiryTimeInSecs, MAX_EXPIRY_TIME_IN_SECS);
verifyDirectAccessConfig(ENABLED, defaultExpiryTimeInSecs, MAX_EXPIRY_TIME_IN_SECS);
contentStoreDirectUrlConfig.validate();
verifyDirectAccessConfig(DISABLED, SYS_DEFAULT_EXPIRY_TIME_IN_SECS, MAX_EXPIRY_TIME_IN_SECS);
}
@Test
public void testInvalidConfig_MaxExpiryTimeZero()
{
setupDirectAccessConfig(ENABLED, DEFAULT_EXPIRY_TIME_IN_SECS, 0L);
assertTrue("Expected content store direct URLs to be enabled", contentStoreDirectUrlConfig.isEnabled());
contentStoreDirectUrlConfig.validate();
assertFalse("Expected content store direct URLs to be disabled", contentStoreDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_MaxExpiryTimeNegative()
{
setupDirectAccessConfig(ENABLED, DEFAULT_EXPIRY_TIME_IN_SECS, -1L);
assertTrue("Expected content store direct URLs to be enabled", contentStoreDirectUrlConfig.isEnabled());
contentStoreDirectUrlConfig.validate();
assertFalse("Expected content store direct URLs to be disabled", contentStoreDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_MaxExpiryTimeExceedsSystemMax()
{
Long maxExpiryTimeInSec = contentStoreDirectUrlConfig.getSysWideMaxExpiryTimeInSec() + 1;
setupDirectAccessConfig(ENABLED, DEFAULT_EXPIRY_TIME_IN_SECS, maxExpiryTimeInSec);
assertTrue("Expected content store direct URLs to be enabled", contentStoreDirectUrlConfig.isEnabled());
contentStoreDirectUrlConfig.validate();
assertFalse("Expected content store direct URLs to be disabled", contentStoreDirectUrlConfig.isEnabled());
}
/* Helper method to set content store direct access url configuration settings */
private void setupDirectAccessConfig(Boolean isEnabled, Long defaultExpiryTime, Long maxExpiryTime)
{
contentStoreDirectUrlConfig.setEnabled(isEnabled);
contentStoreDirectUrlConfig.setDefaultExpiryTimeInSec(defaultExpiryTime);
contentStoreDirectUrlConfig.setMaxExpiryTimeInSec(maxExpiryTime);
}
/* Helper method to verify content store direct access url configuration settings */
private void verifyDirectAccessConfig(Boolean isEnabled, Long defaultExpiryTime, Long maxExpiryTime)
{
assertEquals("Expected content store direct URLs to be enabled = " + isEnabled, isEnabled, contentStoreDirectUrlConfig.isEnabled());
assertEquals("Expected default expiry time to match " + defaultExpiryTime, defaultExpiryTime, contentStoreDirectUrlConfig.getDefaultExpiryTimeInSec());
assertEquals("Expected maximum expiry time to match " + maxExpiryTime, maxExpiryTime, contentStoreDirectUrlConfig.getMaxExpiryTimeInSec());
}
/* Helper method to set system-wide direct access url configuration settings */
private void setupSystemWideDirectAccessConfig()
{
SystemWideDirectUrlConfig sysConfig = new SystemWideDirectUrlConfig();
sysConfig.setEnabled(ENABLED);
sysConfig.setDefaultExpiryTimeInSec(SYS_DEFAULT_EXPIRY_TIME_IN_SECS);
sysConfig.setMaxExpiryTimeInSec(SYS_MAX_EXPIRY_TIME_IN_SECS);
sysConfig.validate();
contentStoreDirectUrlConfig.setSystemWideDirectUrlConfig(sysConfig);
}
}

View File

@@ -0,0 +1,153 @@
/*
* #%L
* Alfresco Repository
* %%
* Copyright (C) 2005 - 2021 Alfresco Software Limited
* %%
* This file is part of the Alfresco software.
* If the software was purchased under a paid Alfresco license, the terms of
* the paid license agreement will prevail. Otherwise, the software is
* provided under the following open source license terms:
*
* 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/>.
* #L%
*/
package org.alfresco.repo.content.directurl;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import org.junit.Before;
import org.junit.Test;
/**
* Tests for system-wide direct access URL configuration settings.
*
* @author Sara Aspery
*/
public class SystemWideDirectUrlConfigUnitTest
{
private static final Boolean ENABLED = Boolean.TRUE;
private static final Boolean DISABLED = Boolean.FALSE;
private static final Long DEFAULT_EXPIRY_TIME_IN_SECS = 30L;
private static final Long MAX_EXPIRY_TIME_IN_SECS = 300L;
private SystemWideDirectUrlConfig systemWideDirectUrlConfig;
@Before
public void setup()
{
this.systemWideDirectUrlConfig = new SystemWideDirectUrlConfig();
}
@Test
public void testValidConfig_RemainsEnabled()
{
setupDirectAccessConfig(ENABLED, DEFAULT_EXPIRY_TIME_IN_SECS, MAX_EXPIRY_TIME_IN_SECS);
assertTrue("Expected system-wide direct URLs to be enabled", systemWideDirectUrlConfig.isEnabled());
systemWideDirectUrlConfig.validate();
assertTrue("Expected system-wide direct URLs to be enabled", systemWideDirectUrlConfig.isEnabled());
}
@Test
public void testValidConfig_RemainsDisabled()
{
setupDirectAccessConfig(DISABLED, DEFAULT_EXPIRY_TIME_IN_SECS, MAX_EXPIRY_TIME_IN_SECS);
assertFalse("Expected system-wide direct URLs to be disabled", systemWideDirectUrlConfig.isEnabled());
systemWideDirectUrlConfig.validate();
assertFalse("Expected system-wide direct URLs to be disabled", systemWideDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_DefaultExpiryTimeMissing()
{
setupDirectAccessConfig(ENABLED, null, MAX_EXPIRY_TIME_IN_SECS);
assertTrue("Expected system-wide direct URLs to be enabled", systemWideDirectUrlConfig.isEnabled());
systemWideDirectUrlConfig.validate();
assertFalse("Expected system-wide direct URLs to be disabled", systemWideDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_DefaultExpiryTimeZero()
{
setupDirectAccessConfig(ENABLED, 0L, MAX_EXPIRY_TIME_IN_SECS);
assertTrue("Expected system-wide direct URLs to be enabled", systemWideDirectUrlConfig.isEnabled());
systemWideDirectUrlConfig.validate();
assertFalse("Expected system-wide direct URLs to be disabled", systemWideDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_DefaultExpiryTimeNegative()
{
setupDirectAccessConfig(ENABLED, -1L, MAX_EXPIRY_TIME_IN_SECS);
assertTrue("Expected system-wide direct URLs to be enabled", systemWideDirectUrlConfig.isEnabled());
systemWideDirectUrlConfig.validate();
assertFalse("Expected system-wide direct URLs to be disabled", systemWideDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_MaxExpiryTimeMissing()
{
setupDirectAccessConfig(ENABLED, DEFAULT_EXPIRY_TIME_IN_SECS, null);
assertTrue("Expected system-wide direct URLs to be enabled", systemWideDirectUrlConfig.isEnabled());
systemWideDirectUrlConfig.validate();
assertFalse("Expected system-wide direct URLs to be disabled", systemWideDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_MaxExpiryTimeZero()
{
setupDirectAccessConfig(ENABLED, DEFAULT_EXPIRY_TIME_IN_SECS, 0L);
assertTrue("Expected system-wide direct URLs to be enabled", systemWideDirectUrlConfig.isEnabled());
systemWideDirectUrlConfig.validate();
assertFalse("Expected system-wide direct URLs to be disabled", systemWideDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_MaxExpiryTimeNegative()
{
setupDirectAccessConfig(ENABLED, DEFAULT_EXPIRY_TIME_IN_SECS, -1L);
assertTrue("Expected system-wide direct URLs to be enabled", systemWideDirectUrlConfig.isEnabled());
systemWideDirectUrlConfig.validate();
assertFalse("Expected system-wide direct URLs to be disabled", systemWideDirectUrlConfig.isEnabled());
}
@Test
public void testInvalidConfig_DefaultExpiryTimeExceedsMax()
{
setupDirectAccessConfig(ENABLED, MAX_EXPIRY_TIME_IN_SECS + 1, MAX_EXPIRY_TIME_IN_SECS);
assertTrue("Expected system-wide direct URLs to be enabled", systemWideDirectUrlConfig.isEnabled());
systemWideDirectUrlConfig.validate();
assertFalse("Expected system-wide direct URLs to be disabled", systemWideDirectUrlConfig.isEnabled());
}
/* Helper method to set system-wide direct access url configuration settings */
private void setupDirectAccessConfig(Boolean isEnabled, Long defaultExpiryTime, Long maxExpiryTime)
{
systemWideDirectUrlConfig.setEnabled(isEnabled);
systemWideDirectUrlConfig.setDefaultExpiryTimeInSec(defaultExpiryTime);
systemWideDirectUrlConfig.setMaxExpiryTimeInSec(maxExpiryTime);
}
}