]> source.dussan.org Git - archiva.git/commitdiff
Adding ldap properties
authorMartin Stockhammer <martin_s@apache.org>
Sun, 3 Jan 2021 16:29:03 +0000 (17:29 +0100)
committerMartin Stockhammer <martin_s@apache.org>
Sun, 3 Jan 2021 16:29:03 +0000 (17:29 +0100)
archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/util/ConfigMapper.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java

index 14b9613acf7d34cabe0909843de3d73454d6cc72..f55dbbc66aed49d80dcf54643c3415adc11ef970 100644 (file)
@@ -1,4 +1,5 @@
-package org.apache.archiva.configuration.util;/*
+package org.apache.archiva.configuration.util;
+/*
  * Licensed to the Apache Software Foundation (ASF) under one
  * or more contributor license agreements.  See the NOTICE file
  * distributed with this work for additional information
@@ -76,6 +77,9 @@ public class ConfigMapper<T, K>
         return prefixStringFunctionMap.keySet( ).stream( ).anyMatch( prefix -> attributeName.startsWith( prefix ) );
     }
 
+    public boolean isMapping(String attributeName) {
+        return isStringMapping( attributeName ) || isIntMapping( attributeName ) || isBooleanMapping( attributeName );
+    }
 
     public void addIntMapping( String attributeName, Function<T, Integer> mapping) {
         this.intFunctionMap.put( attributeName, mapping );
index cb4b391f00ea41be9b5e76cd65fe61ec2c02731f..56e3ba1bf629cf8dd3f1b018672de6a5f76cfcce 100644 (file)
@@ -422,16 +422,18 @@ public class DefaultRedbackRuntimeConfigurationAdmin
     private void cleanupProperties( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
     {
         Map<String, String> properties = redbackRuntimeConfiguration.getConfigurationProperties();
+        LdapConfiguration ldapConf = redbackRuntimeConfiguration.getLdapConfiguration( );
         LDAP_MAPPER.getAllAttributes( ).stream( ).forEach( att -> properties.remove( att ) );
-
-        // cleanup groups <-> role mapping
-        /**for ( Map.Entry<String, String> entry : new HashMap<String, String>( properties ).entrySet() )
-         {
-         if ( entry.getKey().startsWith( UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
-         {
-         properties.remove( entry.getKey() );
-         }
-         }*/
+        List<String> prefixRemove = new ArrayList<>( );
+        for ( String key : properties.keySet()) {
+            boolean prefixMapping = LDAP_MAPPER.isPrefixMapping( key );
+            if (prefixMapping) {
+                prefixRemove.add( key );
+            } else if ( key.startsWith( "ldap" ) && !LDAP_MAPPER.isMapping( key ) ) {
+                ldapConf.getExtraProperties( ).put( key, properties.get( key ) );
+            }
+        }
+        prefixRemove.stream( ).forEach( att -> properties.remove( att ) );
     }
 
     private org.apache.archiva.configuration.RedbackRuntimeConfiguration build(