mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Revert "Merge branch 'feature-2.7/RM-7119_ACS527StartUpFix' into 'release/V2.7'"
This reverts commit 594931a1
This commit is contained in:
@@ -33,11 +33,8 @@ import java.util.Map;
|
|||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.slf4j.Logger;
|
|
||||||
import org.slf4j.LoggerFactory;
|
|
||||||
import org.springframework.beans.PropertyValue;
|
import org.springframework.beans.PropertyValue;
|
||||||
import org.springframework.beans.factory.config.BeanDefinition;
|
import org.springframework.beans.factory.config.BeanDefinition;
|
||||||
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
|
||||||
@@ -54,7 +51,7 @@ import org.springframework.beans.factory.config.TypedStringValue;
|
|||||||
*/
|
*/
|
||||||
public class RMMethodSecurityPostProcessor implements BeanFactoryPostProcessor
|
public class RMMethodSecurityPostProcessor implements BeanFactoryPostProcessor
|
||||||
{
|
{
|
||||||
private static final Logger LOGGER = LoggerFactory.getLogger(RMMethodSecurityPostProcessor.class);
|
private static Log logger = LogFactory.getLog(RMMethodSecurityPostProcessor.class);
|
||||||
|
|
||||||
public static final String PROP_OBJECT_DEFINITION_SOURCE = "objectDefinitionSource";
|
public static final String PROP_OBJECT_DEFINITION_SOURCE = "objectDefinitionSource";
|
||||||
public static final String PROPERTY_PREFIX = "rm.methodsecurity.";
|
public static final String PROPERTY_PREFIX = "rm.methodsecurity.";
|
||||||
@@ -97,7 +94,10 @@ public class RMMethodSecurityPostProcessor implements BeanFactoryPostProcessor
|
|||||||
{
|
{
|
||||||
if (beanFactory.containsBeanDefinition(bean))
|
if (beanFactory.containsBeanDefinition(bean))
|
||||||
{
|
{
|
||||||
LOGGER.debug("Adding RM method security definitions for {}", bean);
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Adding RM method security definitions for " + bean);
|
||||||
|
}
|
||||||
|
|
||||||
BeanDefinition beanDef = beanFactory.getBeanDefinition(bean);
|
BeanDefinition beanDef = beanFactory.getBeanDefinition(bean);
|
||||||
PropertyValue beanValue = beanDef.getPropertyValues().getPropertyValue(PROP_OBJECT_DEFINITION_SOURCE);
|
PropertyValue beanValue = beanDef.getPropertyValues().getPropertyValue(PROP_OBJECT_DEFINITION_SOURCE);
|
||||||
@@ -134,7 +134,10 @@ public class RMMethodSecurityPostProcessor implements BeanFactoryPostProcessor
|
|||||||
String securityBeanName = split[index] + SECURITY_BEAN_POSTFIX;
|
String securityBeanName = split[index] + SECURITY_BEAN_POSTFIX;
|
||||||
if (!securityBeanNameCache.contains(securityBeanName) && beanFactory.containsBean(securityBeanName))
|
if (!securityBeanNameCache.contains(securityBeanName) && beanFactory.containsBean(securityBeanName))
|
||||||
{
|
{
|
||||||
LOGGER.debug("Adding {} to list from properties.", securityBeanName);
|
if (logger.isDebugEnabled())
|
||||||
|
{
|
||||||
|
logger.debug("Adding " + securityBeanName + " to list from properties.");
|
||||||
|
}
|
||||||
|
|
||||||
securityBeanNameCache.add(securityBeanName);
|
securityBeanNameCache.add(securityBeanName);
|
||||||
}
|
}
|
||||||
@@ -163,7 +166,10 @@ public class RMMethodSecurityPostProcessor implements BeanFactoryPostProcessor
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LOGGER.warn("Missing RM security definition for method {}", key);
|
if (logger.isWarnEnabled())
|
||||||
|
{
|
||||||
|
logger.warn("Missing RM security definition for method " + key);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -171,28 +177,16 @@ public class RMMethodSecurityPostProcessor implements BeanFactoryPostProcessor
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Convert the lines of a string to a map, separating keys from values by the first "=" sign.
|
* @param stringValue
|
||||||
*
|
* @return
|
||||||
* @param stringValue The multi-line string.
|
|
||||||
* @return The resulting map.
|
|
||||||
* @throws AlfrescoRuntimeException If a non-blank line does not contain an "=" sign.
|
|
||||||
*/
|
*/
|
||||||
protected Map<String, String> convertToMap(String stringValue)
|
private Map<String, String> convertToMap(String stringValue)
|
||||||
{
|
{
|
||||||
String[] values = stringValue.trim().split("\n");
|
String[] values = stringValue.trim().split("\n");
|
||||||
Map<String, String> map = new HashMap<String, String>(values.length);
|
Map<String, String> map = new HashMap<String, String>(values.length);
|
||||||
for (String value : values)
|
for (String value : values)
|
||||||
{
|
{
|
||||||
String trimmed = value.trim();
|
String[] pair = value.trim().split("=");
|
||||||
if (trimmed.isEmpty())
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
String[] pair = trimmed.split("=", 2);
|
|
||||||
if (pair.length != 2)
|
|
||||||
{
|
|
||||||
throw new AlfrescoRuntimeException("Could not convert string to map " + trimmed);
|
|
||||||
}
|
|
||||||
map.put(pair[0], pair[1]);
|
map.put(pair[0], pair[1]);
|
||||||
}
|
}
|
||||||
return map;
|
return map;
|
||||||
|
@@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* #%L
|
|
||||||
* Alfresco Records Management Module
|
|
||||||
* %%
|
|
||||||
* Copyright (C) 2005 - 2020 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.module.org_alfresco_module_rm.security;
|
|
||||||
|
|
||||||
import static java.util.Collections.emptyMap;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableMap;
|
|
||||||
|
|
||||||
import org.alfresco.error.AlfrescoRuntimeException;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unit tests for {@link RMMethodSecurityPostProcessor}.
|
|
||||||
*
|
|
||||||
* See RM-7119.
|
|
||||||
*/
|
|
||||||
public class RMMethodSecurityPostProcessorUnitTest
|
|
||||||
{
|
|
||||||
/** The class under test. */
|
|
||||||
private RMMethodSecurityPostProcessor rmMethodSecurityPostProcessor = new RMMethodSecurityPostProcessor();
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testConvertToMap_emptyString()
|
|
||||||
{
|
|
||||||
Map<String, String> actual = rmMethodSecurityPostProcessor.convertToMap("");
|
|
||||||
assertEquals("Unexpectedly included empty string in output.", emptyMap(), actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testConvertToMap_normalPairs()
|
|
||||||
{
|
|
||||||
Map<String, String> actual = rmMethodSecurityPostProcessor.convertToMap("a=b\nc=d");
|
|
||||||
assertEquals("Failed to handle multiline input string.", ImmutableMap.of("a", "b", "c", "d"), actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testConvertToMap_stripWhitespace()
|
|
||||||
{
|
|
||||||
Map<String, String> actual = rmMethodSecurityPostProcessor.convertToMap(" \n \t a=b \n \t ");
|
|
||||||
assertEquals("Failed to strip whitespace.", ImmutableMap.of("a", "b"), actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testConvertToMap_ignoreBlankLine()
|
|
||||||
{
|
|
||||||
Map<String, String> actual = rmMethodSecurityPostProcessor.convertToMap("a=b\n\nc=d");
|
|
||||||
assertEquals("Failed to ignore blank line.", ImmutableMap.of("a", "b", "c", "d"), actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testConvertToMap_multipleEquals()
|
|
||||||
{
|
|
||||||
Map<String, String> actual = rmMethodSecurityPostProcessor.convertToMap("a=b=c\nd=e=f");
|
|
||||||
assertEquals("Issue with handling of = symbol in value.", ImmutableMap.of("a", "b=c", "d", "e=f"), actual);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Check that if a line is missing an equals sign then we get an exception. */
|
|
||||||
@Test(expected = AlfrescoRuntimeException.class)
|
|
||||||
public void testConvertToMap_missingEquals()
|
|
||||||
{
|
|
||||||
rmMethodSecurityPostProcessor.convertToMap("a=b\ncd");
|
|
||||||
}
|
|
||||||
}
|
|
Reference in New Issue
Block a user