This is an automated email from the ASF dual-hosted git repository.
cziegeler pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/felix-dev.git
The following commit(s) were added to refs/heads/master by this push:
new 8e673b065b FELIX-6500 : Apply filtering for post requests
8e673b065b is described below
commit 8e673b065bd18054e9fd2602a70f1e13d67c938e
Author: Carsten Ziegeler <[email protected]>
AuthorDate: Wed May 4 08:47:20 2022 +0200
FELIX-6500 : Apply filtering for post requests
---
.../internal/configuration/ConfigAdminSupport.java | 26 +++++++++++++---------
1 file changed, 15 insertions(+), 11 deletions(-)
diff --git
a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
index 337a42dd10..2840ce34d2 100644
---
a/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
+++
b/webconsole/src/main/java/org/apache/felix/webconsole/internal/configuration/ConfigAdminSupport.java
@@ -21,7 +21,6 @@ package org.apache.felix.webconsole.internal.configuration;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collection;
import java.util.Collections;
import java.util.Dictionary;
import java.util.Enumeration;
@@ -93,6 +92,20 @@ class ConfigAdminSupport {
return null;
}
+ private Map<String, Object> getAllowedValues(final Configuration config,
final Dictionary<String, Object> props) throws IOException {
+ final List<String> allowedProperties =
this.getJsonSupport().getPropertyNamesForForm(config.getFactoryPid(),
config.getPid(), props);
+ final Map<String, Object> allowedValues = new HashMap<>();
+ final Dictionary<String, Object> origProps = config.getProperties();
+ if ( origProps != null ) {
+ for(final String name : Collections.list(origProps.keys())) {
+ if ( !allowedProperties.contains(name) ) {
+ allowedValues.put(name, origProps.get(name));
+ }
+ }
+ }
+ return allowedValues;
+ }
+
/**
* Apply the update to the configuration
* @param request The request
@@ -113,16 +126,7 @@ class ConfigAdminSupport {
props = new Hashtable<>();
}
// filter properties and keep filtered values
- final List<String> allowedProperties =
this.getJsonSupport().getPropertyNamesForForm(config.getFactoryPid(),
config.getPid(), props);
- final Map<String, Object> allowedValues = new HashMap<>();
- final Dictionary<String, Object> origProps = config.getProperties();
- if ( origProps != null ) {
- for(final String name : Collections.list(props.keys())) {
- if ( !allowedProperties.contains(name) ) {
- allowedValues.put(name, origProps.get(name));
- }
- }
- }
+ final Map<String, Object> allowedValues = getAllowedValues(config,
props);
final MetaTypeServiceSupport mtss = getMetaTypeSupport();
final Map<String, MetatypePropertyDescriptor> adMap = ( mtss != null )
? mtss.getAttributeDefinitionMap( config, null ) : new HashMap<>();