1 package org.apache.archiva.admin.repository.runtime;
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
21 import org.apache.archiva.admin.model.RepositoryAdminException;
22 import org.apache.archiva.admin.model.beans.CacheConfiguration;
23 import org.apache.archiva.admin.model.beans.LdapConfiguration;
24 import org.apache.archiva.admin.model.beans.LdapGroupMapping;
25 import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
26 import org.apache.archiva.admin.model.runtime.RedbackRuntimeConfigurationAdmin;
27 import org.apache.archiva.admin.repository.AbstractRepositoryAdmin;
28 import org.apache.archiva.configuration.ArchivaConfiguration;
29 import org.apache.archiva.configuration.Configuration;
30 import org.apache.archiva.configuration.IndeterminateConfigurationException;
31 import org.apache.archiva.components.cache.Cache;
32 import org.apache.archiva.components.registry.RegistryException;
33 import org.apache.archiva.configuration.util.ConfigMapper;
34 import org.apache.archiva.redback.configuration.UserConfiguration;
35 import org.apache.archiva.redback.configuration.UserConfigurationException;
36 import org.apache.archiva.redback.configuration.UserConfigurationKeys;
37 import org.apache.commons.lang3.StringUtils;
38 import org.slf4j.Logger;
39 import org.slf4j.LoggerFactory;
40 import org.springframework.stereotype.Service;
42 import javax.annotation.PostConstruct;
43 import javax.inject.Inject;
44 import javax.inject.Named;
45 import java.util.ArrayList;
46 import java.util.Arrays;
47 import java.util.Collection;
48 import java.util.HashMap;
49 import java.util.HashSet;
50 import java.util.List;
53 import java.util.function.Function;
55 import static org.apache.archiva.redback.configuration.UserConfigurationKeys.*;
58 * @author Olivier Lamy
61 @Service( "redbackRuntimeConfigurationAdmin#default" )
62 public class DefaultRedbackRuntimeConfigurationAdmin
63 extends AbstractRepositoryAdmin
64 implements RedbackRuntimeConfigurationAdmin, UserConfiguration
67 protected Logger log = LoggerFactory.getLogger( getClass() );
69 private ArchivaConfiguration archivaConfiguration;
71 private UserConfiguration userConfiguration;
73 private static final Map<String, List<String>> LDAP_PROPERTIES = new HashMap<>( );
75 private static final ConfigMapper<LdapConfiguration, List<LdapGroupMapping>> LDAP_MAPPER = new ConfigMapper( );
78 LDAP_MAPPER.addStringMapping( LDAP_HOSTNAME, LdapConfiguration::getHostName );
79 LDAP_MAPPER.addStringMapping( LDAP_CONTEX_FACTORY, LdapConfiguration::getContextFactory );
80 LDAP_MAPPER.addStringMapping( LDAP_PASSWORD, LdapConfiguration::getPassword );
81 LDAP_MAPPER.addStringMapping( LDAP_AUTHENTICATION_METHOD, LdapConfiguration::getAuthenticationMethod );
82 LDAP_MAPPER.addStringMapping( LDAP_BASEDN, LdapConfiguration::getBaseDn );
83 LDAP_MAPPER.addStringMapping( LDAP_GROUPS_BASEDN, LdapConfiguration::getBaseGroupsDn );
84 LDAP_MAPPER.addStringMapping( LDAP_BINDDN, LdapConfiguration::getBindDn );
85 LDAP_MAPPER.addPrefixStringMapping( LDAP_GROUPS_ROLE_START_KEY, (String attributeName, List<LdapGroupMapping> mapping)-> {
86 int index = mapping.indexOf( new LdapGroupMapping(
87 StringUtils.substringAfter( attributeName, LDAP_GROUPS_ROLE_START_KEY ) ) );
90 return StringUtils.join( mapping.get( index ).getRoleNames(),
96 LDAP_MAPPER.addIntMapping( LDAP_PORT, LdapConfiguration::getPort );
97 LDAP_MAPPER.addBooleanMapping( LDAP_SSL, LdapConfiguration::isSsl );
98 LDAP_MAPPER.addBooleanMapping( LDAP_WRITABLE, LdapConfiguration::isWritable );
99 LDAP_MAPPER.addBooleanMapping( LDAP_GROUPS_USE_ROLENAME, LdapConfiguration::isUseRoleNameAsGroup );
100 LDAP_MAPPER.addBooleanMapping( LDAP_BIND_AUTHENTICATOR_ENABLED, LdapConfiguration::isBindAuthenticatorEnabled );
103 private Cache usersCache;
106 public DefaultRedbackRuntimeConfigurationAdmin( ArchivaConfiguration archivaConfiguration,//
107 @Named( value = "userConfiguration#redback" ) //
108 UserConfiguration userConfiguration,
109 @Named( value = "cache#users" ) Cache usersCache )
111 this.archivaConfiguration = archivaConfiguration;
112 this.userConfiguration = userConfiguration;
113 this.usersCache = usersCache;
118 public void initialize()
119 throws UserConfigurationException
123 RedbackRuntimeConfiguration redbackRuntimeConfiguration = getRedbackRuntimeConfiguration();
124 Function<RedbackRuntimeConfiguration, LdapConfiguration> kk = RedbackRuntimeConfiguration::getLdapConfiguration;
125 // migrate or not data from redback
126 if ( !redbackRuntimeConfiguration.isMigratedFromRedbackConfiguration() )
128 // not migrated so build a new fresh one
129 redbackRuntimeConfiguration = new RedbackRuntimeConfiguration();
130 // so migrate if available
131 String userManagerImpl =
132 userConfiguration.getConcatenatedList( USER_MANAGER_IMPL, //
133 DEFAULT_USER_MANAGER_IMPL );
134 if ( StringUtils.isNotEmpty( userManagerImpl ) )
136 String[] impls = StringUtils.split( userManagerImpl, ',' );
137 for ( String impl : impls )
139 if (StringUtils.equalsIgnoreCase( "jdo", impl ))
141 impl = DEFAULT_USER_MANAGER_IMPL;
143 redbackRuntimeConfiguration.getUserManagerImpls().add( impl );
148 redbackRuntimeConfiguration.getUserManagerImpls().add( DEFAULT_USER_MANAGER_IMPL );
151 String rbacManagerImpls =
152 userConfiguration.getConcatenatedList( RBAC_MANAGER_IMPL, //
153 DEFAULT_RBAC_MANAGER_IMPL );
155 if ( StringUtils.isNotEmpty( rbacManagerImpls ) )
157 String[] impls = StringUtils.split( rbacManagerImpls, ',' );
158 for ( String impl : impls )
160 if (StringUtils.equalsIgnoreCase( "jdo", impl ))
162 impl = DEFAULT_RBAC_MANAGER_IMPL;
164 redbackRuntimeConfiguration.getRbacManagerImpls().add( impl );
169 redbackRuntimeConfiguration.getRbacManagerImpls().add( DEFAULT_RBAC_MANAGER_IMPL );
174 LdapConfiguration ldapConfiguration = redbackRuntimeConfiguration.getLdapConfiguration();
175 if ( ldapConfiguration == null )
177 ldapConfiguration = new LdapConfiguration();
178 redbackRuntimeConfiguration.setLdapConfiguration( ldapConfiguration );
181 ldapConfiguration.setHostName(
182 userConfiguration.getString( LDAP_HOSTNAME, null ) );
183 ldapConfiguration.setPort( userConfiguration.getInt( LDAP_PORT, -1 ) );
184 ldapConfiguration.setSsl( userConfiguration.getBoolean( LDAP_SSL, false ) );
185 ldapConfiguration.setBaseDn(
186 userConfiguration.getConcatenatedList( LDAP_BASEDN, null ) );
188 ldapConfiguration.setBaseGroupsDn(
189 userConfiguration.getConcatenatedList( LDAP_GROUPS_BASEDN,
190 ldapConfiguration.getBaseDn() ) );
192 ldapConfiguration.setContextFactory(
193 userConfiguration.getString( LDAP_CONTEX_FACTORY,
194 isSunContextFactoryAvailable()
195 ? "com.sun.jndi.ldap.LdapCtxFactory"
197 ldapConfiguration.setBindDn(
198 userConfiguration.getConcatenatedList( LDAP_BINDDN, null ) );
199 ldapConfiguration.setPassword(
200 userConfiguration.getString( LDAP_PASSWORD, null ) );
201 ldapConfiguration.setAuthenticationMethod(
202 userConfiguration.getString( LDAP_AUTHENTICATION_METHOD, null ) );
204 ldapConfiguration.setWritable(
205 userConfiguration.getBoolean( LDAP_WRITABLE, false ) );
207 ldapConfiguration.setUseRoleNameAsGroup(
208 userConfiguration.getBoolean( LDAP_GROUPS_USE_ROLENAME, false ) );
210 boolean ldapBindAuthenticatorEnabled =
211 userConfiguration.getBoolean( LDAP_BIND_AUTHENTICATOR_ENABLED, false );
212 ldapConfiguration.setBindAuthenticatorEnabled( ldapBindAuthenticatorEnabled );
214 // LDAP groups mapping reading !!
215 // UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY
216 // userConfiguration.getKeys()
218 Collection<String> keys = userConfiguration.getKeys();
220 List<LdapGroupMapping> ldapGroupMappings = new ArrayList<>();
222 for ( String key : keys )
224 if ( key.startsWith( LDAP_GROUPS_ROLE_START_KEY ) )
227 StringUtils.substringAfter( key, LDAP_GROUPS_ROLE_START_KEY );
228 String val = userConfiguration.getConcatenatedList( key, "" );
229 if ( !StringUtils.isEmpty( val ) )
231 String[] roles = StringUtils.split( val, ',' );
232 ldapGroupMappings.add( new LdapGroupMapping( group, roles ) );
237 redbackRuntimeConfiguration.setLdapGroupMappings( ldapGroupMappings );
239 redbackRuntimeConfiguration.setMigratedFromRedbackConfiguration( true );
241 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
244 // we must ensure userManagerImpls list is not empty if so put at least jdo one !
245 if ( redbackRuntimeConfiguration.getUserManagerImpls().isEmpty() )
248 "redbackRuntimeConfiguration with empty userManagerImpls so force at least jdo implementation !" );
249 redbackRuntimeConfiguration.getUserManagerImpls().add( "jdo" );
250 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
254 log.info( "using userManagerImpls: {}", redbackRuntimeConfiguration.getUserManagerImpls() );
257 // we ensure rbacManagerImpls is not empty if so put at least cached
258 if ( redbackRuntimeConfiguration.getRbacManagerImpls().isEmpty() )
261 "redbackRuntimeConfiguration with empty rbacManagerImpls so force at least cached implementation !" );
262 redbackRuntimeConfiguration.getRbacManagerImpls().add( "cached" );
263 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
267 log.info( "using rbacManagerImpls: {}", redbackRuntimeConfiguration.getRbacManagerImpls() );
270 boolean save = false;
273 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null )
275 redbackRuntimeConfiguration.setUsersCacheConfiguration( new CacheConfiguration() );
277 // if -1 it means non initialized to take values from the spring bean
278 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToIdleSeconds() < 0 )
280 redbackRuntimeConfiguration.getUsersCacheConfiguration().setTimeToIdleSeconds(
281 usersCache.getTimeToIdleSeconds() );
285 usersCache.setTimeToIdleSeconds(
286 redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToIdleSeconds() );
288 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToLiveSeconds() < 0 )
290 redbackRuntimeConfiguration.getUsersCacheConfiguration().setTimeToLiveSeconds(
291 usersCache.getTimeToLiveSeconds() );
295 usersCache.setTimeToLiveSeconds(
296 redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToLiveSeconds() );
298 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsInMemory() < 0 )
300 redbackRuntimeConfiguration.getUsersCacheConfiguration().setMaxElementsInMemory(
301 usersCache.getMaxElementsInMemory() );
304 usersCache.setMaxElementsInMemory(
305 redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsInMemory() );
307 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsOnDisk() < 0 )
309 redbackRuntimeConfiguration.getUsersCacheConfiguration().setMaxElementsOnDisk(
310 usersCache.getMaxElementsOnDisk() );
313 usersCache.setMaxElementsOnDisk(
314 redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsOnDisk() );
318 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
322 catch ( RepositoryAdminException e )
324 throw new UserConfigurationException( e.getMessage(), e );
328 private boolean isSunContextFactoryAvailable()
332 return Thread.currentThread().getContextClassLoader().loadClass( "com.sun.jndi.ldap.LdapCtxFactory" )
335 catch ( ClassNotFoundException e )
342 public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
344 return build( archivaConfiguration.getConfiguration().getRedbackRuntimeConfiguration() );
348 public void updateRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
349 throws RepositoryAdminException
351 org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration =
352 build( redbackRuntimeConfiguration );
353 Configuration configuration = archivaConfiguration.getConfiguration();
354 configuration.setRedbackRuntimeConfiguration( runtimeConfiguration );
357 archivaConfiguration.save( configuration );
359 catch ( RegistryException e )
361 throw new RepositoryAdminException( e.getMessage(), e );
363 catch ( IndeterminateConfigurationException e )
365 throw new RepositoryAdminException( e.getMessage(), e );
369 private RedbackRuntimeConfiguration build(
370 org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration )
372 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
373 getModelMapper().map( runtimeConfiguration, RedbackRuntimeConfiguration.class );
375 if ( runtimeConfiguration.getLdapConfiguration() != null )
377 redbackRuntimeConfiguration.setLdapConfiguration(
378 getModelMapper().map( runtimeConfiguration.getLdapConfiguration(), LdapConfiguration.class ) );
381 if ( runtimeConfiguration.getUsersCacheConfiguration() != null )
383 redbackRuntimeConfiguration.setUsersCacheConfiguration(
384 getModelMapper().map( runtimeConfiguration.getUsersCacheConfiguration(), CacheConfiguration.class ) );
387 if ( redbackRuntimeConfiguration.getLdapConfiguration() == null )
390 redbackRuntimeConfiguration.setLdapConfiguration( new LdapConfiguration() );
393 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null )
395 redbackRuntimeConfiguration.setUsersCacheConfiguration( new CacheConfiguration() );
398 List<org.apache.archiva.configuration.LdapGroupMapping> mappings = runtimeConfiguration.getLdapGroupMappings();
400 if ( mappings != null && mappings.size() > 0 )
402 List<LdapGroupMapping> ldapGroupMappings = new ArrayList<>( mappings.size() );
404 for ( org.apache.archiva.configuration.LdapGroupMapping mapping : mappings )
406 ldapGroupMappings.add( new LdapGroupMapping( mapping.getGroup(), mapping.getRoleNames() ) );
409 redbackRuntimeConfiguration.setLdapGroupMappings( ldapGroupMappings );
412 cleanupProperties( redbackRuntimeConfiguration );
414 return redbackRuntimeConfiguration;
418 * cleaning from map properties used directly in archiva configuration fields
420 * @param redbackRuntimeConfiguration
422 private void cleanupProperties( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
424 Map<String, String> properties = redbackRuntimeConfiguration.getConfigurationProperties();
425 LDAP_MAPPER.getAllAttributes( ).stream( ).forEach( att -> properties.remove( att ) );
428 private org.apache.archiva.configuration.RedbackRuntimeConfiguration build(
429 RedbackRuntimeConfiguration redbackRuntimeConfiguration )
431 org.apache.archiva.configuration.RedbackRuntimeConfiguration res =
432 getModelMapper().map( redbackRuntimeConfiguration,
433 org.apache.archiva.configuration.RedbackRuntimeConfiguration.class );
435 if ( redbackRuntimeConfiguration.getLdapConfiguration() == null )
437 redbackRuntimeConfiguration.setLdapConfiguration( new LdapConfiguration() );
439 res.setLdapConfiguration( getModelMapper().map( redbackRuntimeConfiguration.getLdapConfiguration(),
440 org.apache.archiva.configuration.LdapConfiguration.class ) );
442 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null )
444 redbackRuntimeConfiguration.setUsersCacheConfiguration( new CacheConfiguration() );
447 res.setUsersCacheConfiguration( getModelMapper().map( redbackRuntimeConfiguration.getUsersCacheConfiguration(),
448 org.apache.archiva.configuration.CacheConfiguration.class ) );
450 List<LdapGroupMapping> ldapGroupMappings = redbackRuntimeConfiguration.getLdapGroupMappings();
452 if ( ldapGroupMappings != null && ldapGroupMappings.size() > 0 )
455 List<org.apache.archiva.configuration.LdapGroupMapping> mappings =
456 new ArrayList<>( ldapGroupMappings.size() );
458 for ( LdapGroupMapping ldapGroupMapping : ldapGroupMappings )
461 org.apache.archiva.configuration.LdapGroupMapping mapping =
462 new org.apache.archiva.configuration.LdapGroupMapping();
463 mapping.setGroup( ldapGroupMapping.getGroup() );
464 mapping.setRoleNames( new ArrayList<>( ldapGroupMapping.getRoleNames() ) );
465 mappings.add( mapping );
468 res.setLdapGroupMappings( mappings );
473 // wrapper for UserConfiguration to intercept values (and store it not yet migrated)
477 public String getString( String key )
479 final RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
480 if (LDAP_MAPPER.isStringMapping( key )) {
481 final LdapConfiguration ldapConf = conf.getLdapConfiguration( );
482 return LDAP_MAPPER.getString( key, ldapConf );
484 if (LDAP_MAPPER.isPrefixMapping( key )) {
485 return LDAP_MAPPER.getPrefixString( key, conf.getLdapGroupMappings( ) );
487 if (conf.getLdapConfiguration().getExtraProperties().containsKey( key )) {
488 return conf.getLdapConfiguration( ).getExtraProperties( ).get( key );
491 if ( USER_MANAGER_IMPL.equals( key ) )
493 // possible false for others than archiva user manager
494 return conf.getUserManagerImpls().get( 0 );
497 if ( conf.getConfigurationProperties().containsKey( key ) )
499 return conf.getConfigurationProperties().get( key );
502 String value = userConfiguration.getString( key );
507 conf.getConfigurationProperties().put( key, value );
511 updateRedbackRuntimeConfiguration( conf );
513 catch ( RepositoryAdminException e )
515 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
516 throw new RuntimeException( e.getMessage(), e );
523 public String getString( String key, String defaultValue )
525 final RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
526 if (LDAP_MAPPER.isStringMapping( key )) {
527 final LdapConfiguration ldapConf = conf.getLdapConfiguration( );
528 return LDAP_MAPPER.getString( key, ldapConf );
530 if (LDAP_MAPPER.isPrefixMapping( key )) {
531 return LDAP_MAPPER.getPrefixString( key, conf.getLdapGroupMappings( ) );
533 if (conf.getLdapConfiguration().getExtraProperties().containsKey( key )) {
534 return conf.getLdapConfiguration( ).getExtraProperties( ).get( key );
537 if ( conf.getConfigurationProperties().containsKey( key ) )
539 return conf.getConfigurationProperties().get( key );
542 String value = userConfiguration.getString( key, defaultValue );
549 conf.getConfigurationProperties().put( key, value );
552 updateRedbackRuntimeConfiguration( conf );
554 catch ( RepositoryAdminException e )
556 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
557 throw new RuntimeException( e.getMessage(), e );
564 public int getInt( String key )
566 final RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
567 if (LDAP_MAPPER.isIntMapping( key )) {
568 return LDAP_MAPPER.getInt( key, conf.getLdapConfiguration( ) );
571 if ( conf.getConfigurationProperties().containsKey( key ) )
573 return Integer.valueOf( conf.getConfigurationProperties().get( key ) );
576 int value = userConfiguration.getInt( key );
578 conf.getConfigurationProperties().put( key, Integer.toString( value ) );
581 updateRedbackRuntimeConfiguration( conf );
583 catch ( RepositoryAdminException e )
585 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
586 throw new RuntimeException( e.getMessage(), e );
593 public int getInt( String key, int defaultValue )
595 final RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
596 if (LDAP_MAPPER.isIntMapping( key )) {
597 return LDAP_MAPPER.getInt( key, conf.getLdapConfiguration( ) );
600 if ( conf.getConfigurationProperties().containsKey( key ) )
602 return Integer.valueOf( conf.getConfigurationProperties().get( key ) );
605 int value = userConfiguration.getInt( key, defaultValue );
607 conf.getConfigurationProperties().put( key, Integer.toString( value ) );
610 updateRedbackRuntimeConfiguration( conf );
612 catch ( RepositoryAdminException e )
614 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
615 throw new RuntimeException( e.getMessage(), e );
622 public boolean getBoolean( String key )
624 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
625 if (LDAP_MAPPER.isBooleanMapping( key )) {
626 return LDAP_MAPPER.getBoolean( key, conf.getLdapConfiguration( ) );
629 if ( conf.getConfigurationProperties().containsKey( key ) )
631 return Boolean.valueOf( conf.getConfigurationProperties().get( key ) );
634 boolean value = userConfiguration.getBoolean( key );
636 conf.getConfigurationProperties().put( key, Boolean.toString( value ) );
639 updateRedbackRuntimeConfiguration( conf );
641 catch ( RepositoryAdminException e )
643 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
644 throw new RuntimeException( e.getMessage(), e );
651 public boolean getBoolean( String key, boolean defaultValue )
653 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
654 if (LDAP_MAPPER.isBooleanMapping( key )) {
655 return LDAP_MAPPER.getBoolean( key, conf.getLdapConfiguration( ) );
658 if ( conf.getConfigurationProperties().containsKey( key ) )
660 return Boolean.valueOf( conf.getConfigurationProperties().get( key ) );
663 boolean value = userConfiguration.getBoolean( key, defaultValue );
665 conf.getConfigurationProperties().put( key, Boolean.toString( value ) );
668 updateRedbackRuntimeConfiguration( conf );
670 catch ( RepositoryAdminException e )
672 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
673 throw new RuntimeException( e.getMessage(), e );
680 public List<String> getList( String key )
682 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
683 if (conf.getConfigurationProperties().containsKey(key)) {
684 return Arrays.asList(conf.getConfigurationProperties().get(key).split(","));
687 List<String> value = userConfiguration.getList( key );
689 conf.getConfigurationProperties().put( key, "" );
692 updateRedbackRuntimeConfiguration( conf );
694 catch ( RepositoryAdminException e )
696 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
697 throw new RuntimeException( e.getMessage(), e );
704 public String getConcatenatedList( String key, String defaultValue )
706 if (LDAP_MAPPER.isStringMapping( key )) {
707 return LDAP_MAPPER.getString( key, getRedbackRuntimeConfiguration().getLdapConfiguration());
709 return userConfiguration.getConcatenatedList( key, defaultValue );
713 public Collection<String> getKeys()
715 Collection<String> keys = userConfiguration.getKeys();
717 Set<String> keysSet = new HashSet<>( keys );
719 keysSet.addAll( getRedbackRuntimeConfiguration().getConfigurationProperties().keySet() );