From d50e02314093db0ba788a6c79d852e3025d5b939 Mon Sep 17 00:00:00 2001 From: Martin Stockhammer Date: Sun, 3 Jan 2021 17:29:03 +0100 Subject: [PATCH] Adding ldap properties --- .../configuration/util/ConfigMapper.java | 6 +++++- ...faultRedbackRuntimeConfigurationAdmin.java | 20 ++++++++++--------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/util/ConfigMapper.java b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/util/ConfigMapper.java index 14b9613ac..f55dbbc66 100644 --- a/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/util/ConfigMapper.java +++ b/archiva-modules/archiva-base/archiva-configuration/src/main/java/org/apache/archiva/configuration/util/ConfigMapper.java @@ -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 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 mapping) { this.intFunctionMap.put( attributeName, mapping ); diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java index cb4b391f0..56e3ba1bf 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/runtime/DefaultRedbackRuntimeConfigurationAdmin.java @@ -422,16 +422,18 @@ public class DefaultRedbackRuntimeConfigurationAdmin private void cleanupProperties( RedbackRuntimeConfiguration redbackRuntimeConfiguration ) { Map properties = redbackRuntimeConfiguration.getConfigurationProperties(); + LdapConfiguration ldapConf = redbackRuntimeConfiguration.getLdapConfiguration( ); LDAP_MAPPER.getAllAttributes( ).stream( ).forEach( att -> properties.remove( att ) ); - - // cleanup groups <-> role mapping - /**for ( Map.Entry entry : new HashMap( properties ).entrySet() ) - { - if ( entry.getKey().startsWith( UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) ) - { - properties.remove( entry.getKey() ); - } - }*/ + List 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( -- 2.39.5