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.redback.configuration.UserConfiguration;
34 import org.apache.archiva.redback.configuration.UserConfigurationException;
35 import org.apache.archiva.redback.configuration.UserConfigurationKeys;
36 import org.apache.commons.lang3.StringUtils;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
39 import org.springframework.stereotype.Service;
41 import javax.annotation.PostConstruct;
42 import javax.inject.Inject;
43 import javax.inject.Named;
44 import java.util.ArrayList;
45 import java.util.Arrays;
46 import java.util.Collection;
47 import java.util.HashSet;
48 import java.util.List;
53 * @author Olivier Lamy
56 @Service( "redbackRuntimeConfigurationAdmin#default" )
57 public class DefaultRedbackRuntimeConfigurationAdmin
58 extends AbstractRepositoryAdmin
59 implements RedbackRuntimeConfigurationAdmin, UserConfiguration
62 protected Logger log = LoggerFactory.getLogger( getClass() );
64 private ArchivaConfiguration archivaConfiguration;
66 private UserConfiguration userConfiguration;
68 private Cache usersCache;
71 public DefaultRedbackRuntimeConfigurationAdmin( ArchivaConfiguration archivaConfiguration,//
72 @Named( value = "userConfiguration#redback" ) //
73 UserConfiguration userConfiguration,
74 @Named( value = "cache#users" ) Cache usersCache )
76 this.archivaConfiguration = archivaConfiguration;
77 this.userConfiguration = userConfiguration;
78 this.usersCache = usersCache;
83 public void initialize()
84 throws UserConfigurationException
88 RedbackRuntimeConfiguration redbackRuntimeConfiguration = getRedbackRuntimeConfiguration();
89 // migrate or not data from redback
90 if ( !redbackRuntimeConfiguration.isMigratedFromRedbackConfiguration() )
92 // not migrated so build a new fresh one
93 redbackRuntimeConfiguration = new RedbackRuntimeConfiguration();
94 // so migrate if available
95 String userManagerImpl =
96 userConfiguration.getConcatenatedList( UserConfigurationKeys.USER_MANAGER_IMPL, //
97 DEFAULT_USER_MANAGER_IMPL );
98 if ( StringUtils.isNotEmpty( userManagerImpl ) )
100 String[] impls = StringUtils.split( userManagerImpl, ',' );
101 for ( String impl : impls )
103 if (StringUtils.equalsIgnoreCase( "jdo", impl ))
105 impl = DEFAULT_USER_MANAGER_IMPL;
107 redbackRuntimeConfiguration.getUserManagerImpls().add( impl );
112 redbackRuntimeConfiguration.getUserManagerImpls().add( DEFAULT_USER_MANAGER_IMPL );
115 String rbacManagerImpls =
116 userConfiguration.getConcatenatedList( UserConfigurationKeys.RBAC_MANAGER_IMPL, //
117 DEFAULT_RBAC_MANAGER_IMPL );
119 if ( StringUtils.isNotEmpty( rbacManagerImpls ) )
121 String[] impls = StringUtils.split( rbacManagerImpls, ',' );
122 for ( String impl : impls )
124 if (StringUtils.equalsIgnoreCase( "jdo", impl ))
126 impl = DEFAULT_RBAC_MANAGER_IMPL;
128 redbackRuntimeConfiguration.getRbacManagerImpls().add( impl );
133 redbackRuntimeConfiguration.getRbacManagerImpls().add( DEFAULT_RBAC_MANAGER_IMPL );
138 LdapConfiguration ldapConfiguration = redbackRuntimeConfiguration.getLdapConfiguration();
139 if ( ldapConfiguration == null )
141 ldapConfiguration = new LdapConfiguration();
142 redbackRuntimeConfiguration.setLdapConfiguration( ldapConfiguration );
145 ldapConfiguration.setHostName(
146 userConfiguration.getString( UserConfigurationKeys.LDAP_HOSTNAME, null ) );
147 ldapConfiguration.setPort( userConfiguration.getInt( UserConfigurationKeys.LDAP_PORT, -1 ) );
148 ldapConfiguration.setSsl( userConfiguration.getBoolean( UserConfigurationKeys.LDAP_SSL, false ) );
149 ldapConfiguration.setBaseDn(
150 userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_BASEDN, null ) );
152 ldapConfiguration.setBaseGroupsDn(
153 userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_GROUPS_BASEDN,
154 ldapConfiguration.getBaseDn() ) );
156 ldapConfiguration.setContextFactory(
157 userConfiguration.getString( UserConfigurationKeys.LDAP_CONTEX_FACTORY,
158 isSunContextFactoryAvailable()
159 ? "com.sun.jndi.ldap.LdapCtxFactory"
161 ldapConfiguration.setBindDn(
162 userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_BINDDN, null ) );
163 ldapConfiguration.setPassword(
164 userConfiguration.getString( UserConfigurationKeys.LDAP_PASSWORD, null ) );
165 ldapConfiguration.setAuthenticationMethod(
166 userConfiguration.getString( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD, null ) );
168 ldapConfiguration.setWritable(
169 userConfiguration.getBoolean( UserConfigurationKeys.LDAP_WRITABLE, false ) );
171 ldapConfiguration.setUseRoleNameAsGroup(
172 userConfiguration.getBoolean( UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME, false ) );
174 boolean ldapBindAuthenticatorEnabled =
175 userConfiguration.getBoolean( UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED, false );
176 ldapConfiguration.setBindAuthenticatorEnabled( ldapBindAuthenticatorEnabled );
178 // LDAP groups mapping reading !!
179 // UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY
180 // userConfiguration.getKeys()
182 Collection<String> keys = userConfiguration.getKeys();
184 List<LdapGroupMapping> ldapGroupMappings = new ArrayList<>();
186 for ( String key : keys )
188 if ( key.startsWith( UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
191 StringUtils.substringAfter( key, UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY );
192 String val = userConfiguration.getConcatenatedList( key, "" );
193 if ( !StringUtils.isEmpty( val ) )
195 String[] roles = StringUtils.split( val, ',' );
196 ldapGroupMappings.add( new LdapGroupMapping( group, roles ) );
201 redbackRuntimeConfiguration.setLdapGroupMappings( ldapGroupMappings );
203 redbackRuntimeConfiguration.setMigratedFromRedbackConfiguration( true );
205 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
208 // we must ensure userManagerImpls list is not empty if so put at least jdo one !
209 if ( redbackRuntimeConfiguration.getUserManagerImpls().isEmpty() )
212 "redbackRuntimeConfiguration with empty userManagerImpls so force at least jdo implementation !" );
213 redbackRuntimeConfiguration.getUserManagerImpls().add( "jdo" );
214 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
218 log.info( "using userManagerImpls: {}", redbackRuntimeConfiguration.getUserManagerImpls() );
221 // we ensure rbacManagerImpls is not empty if so put at least cached
222 if ( redbackRuntimeConfiguration.getRbacManagerImpls().isEmpty() )
225 "redbackRuntimeConfiguration with empty rbacManagerImpls so force at least cached implementation !" );
226 redbackRuntimeConfiguration.getRbacManagerImpls().add( "cached" );
227 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
231 log.info( "using rbacManagerImpls: {}", redbackRuntimeConfiguration.getRbacManagerImpls() );
234 boolean save = false;
237 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null )
239 redbackRuntimeConfiguration.setUsersCacheConfiguration( new CacheConfiguration() );
241 // if -1 it means non initialized to take values from the spring bean
242 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToIdleSeconds() < 0 )
244 redbackRuntimeConfiguration.getUsersCacheConfiguration().setTimeToIdleSeconds(
245 usersCache.getTimeToIdleSeconds() );
249 usersCache.setTimeToIdleSeconds(
250 redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToIdleSeconds() );
252 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToLiveSeconds() < 0 )
254 redbackRuntimeConfiguration.getUsersCacheConfiguration().setTimeToLiveSeconds(
255 usersCache.getTimeToLiveSeconds() );
259 usersCache.setTimeToLiveSeconds(
260 redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToLiveSeconds() );
262 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsInMemory() < 0 )
264 redbackRuntimeConfiguration.getUsersCacheConfiguration().setMaxElementsInMemory(
265 usersCache.getMaxElementsInMemory() );
268 usersCache.setMaxElementsInMemory(
269 redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsInMemory() );
271 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsOnDisk() < 0 )
273 redbackRuntimeConfiguration.getUsersCacheConfiguration().setMaxElementsOnDisk(
274 usersCache.getMaxElementsOnDisk() );
277 usersCache.setMaxElementsOnDisk(
278 redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsOnDisk() );
282 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
286 catch ( RepositoryAdminException e )
288 throw new UserConfigurationException( e.getMessage(), e );
292 private boolean isSunContextFactoryAvailable()
296 return Thread.currentThread().getContextClassLoader().loadClass( "com.sun.jndi.ldap.LdapCtxFactory" )
299 catch ( ClassNotFoundException e )
306 public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
308 return build( archivaConfiguration.getConfiguration().getRedbackRuntimeConfiguration() );
312 public void updateRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
313 throws RepositoryAdminException
315 org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration =
316 build( redbackRuntimeConfiguration );
317 Configuration configuration = archivaConfiguration.getConfiguration();
318 configuration.setRedbackRuntimeConfiguration( runtimeConfiguration );
321 archivaConfiguration.save( configuration );
323 catch ( RegistryException e )
325 throw new RepositoryAdminException( e.getMessage(), e );
327 catch ( IndeterminateConfigurationException e )
329 throw new RepositoryAdminException( e.getMessage(), e );
333 private RedbackRuntimeConfiguration build(
334 org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration )
336 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
337 getModelMapper().map( runtimeConfiguration, RedbackRuntimeConfiguration.class );
339 if ( runtimeConfiguration.getLdapConfiguration() != null )
341 redbackRuntimeConfiguration.setLdapConfiguration(
342 getModelMapper().map( runtimeConfiguration.getLdapConfiguration(), LdapConfiguration.class ) );
345 if ( runtimeConfiguration.getUsersCacheConfiguration() != null )
347 redbackRuntimeConfiguration.setUsersCacheConfiguration(
348 getModelMapper().map( runtimeConfiguration.getUsersCacheConfiguration(), CacheConfiguration.class ) );
351 if ( redbackRuntimeConfiguration.getLdapConfiguration() == null )
354 redbackRuntimeConfiguration.setLdapConfiguration( new LdapConfiguration() );
357 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null )
359 redbackRuntimeConfiguration.setUsersCacheConfiguration( new CacheConfiguration() );
362 List<org.apache.archiva.configuration.LdapGroupMapping> mappings = runtimeConfiguration.getLdapGroupMappings();
364 if ( mappings != null && mappings.size() > 0 )
366 List<LdapGroupMapping> ldapGroupMappings = new ArrayList<>( mappings.size() );
368 for ( org.apache.archiva.configuration.LdapGroupMapping mapping : mappings )
370 ldapGroupMappings.add( new LdapGroupMapping( mapping.getGroup(), mapping.getRoleNames() ) );
373 redbackRuntimeConfiguration.setLdapGroupMappings( ldapGroupMappings );
376 cleanupProperties( redbackRuntimeConfiguration );
378 return redbackRuntimeConfiguration;
382 * cleaning from map properties used directly in archiva configuration fields
384 * @param redbackRuntimeConfiguration
386 private void cleanupProperties( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
388 Map<String, String> properties = redbackRuntimeConfiguration.getConfigurationProperties();
389 properties.remove( UserConfigurationKeys.LDAP_HOSTNAME );
390 properties.remove( UserConfigurationKeys.LDAP_PORT );
391 properties.remove( UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED );
392 properties.remove( UserConfigurationKeys.LDAP_SSL );
393 properties.remove( UserConfigurationKeys.LDAP_BASEDN );
394 properties.remove( UserConfigurationKeys.LDAP_GROUPS_BASEDN );
395 properties.remove( UserConfigurationKeys.LDAP_CONTEX_FACTORY );
396 properties.remove( UserConfigurationKeys.LDAP_BINDDN );
397 properties.remove( UserConfigurationKeys.LDAP_PASSWORD );
398 properties.remove( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD );
399 properties.remove( UserConfigurationKeys.LDAP_WRITABLE );
400 properties.remove( UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME );
402 // cleanup groups <-> role mapping
403 /**for ( Map.Entry<String, String> entry : new HashMap<String, String>( properties ).entrySet() )
405 if ( entry.getKey().startsWith( UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
407 properties.remove( entry.getKey() );
412 private org.apache.archiva.configuration.RedbackRuntimeConfiguration build(
413 RedbackRuntimeConfiguration redbackRuntimeConfiguration )
415 org.apache.archiva.configuration.RedbackRuntimeConfiguration res =
416 getModelMapper().map( redbackRuntimeConfiguration,
417 org.apache.archiva.configuration.RedbackRuntimeConfiguration.class );
419 if ( redbackRuntimeConfiguration.getLdapConfiguration() == null )
421 redbackRuntimeConfiguration.setLdapConfiguration( new LdapConfiguration() );
423 res.setLdapConfiguration( getModelMapper().map( redbackRuntimeConfiguration.getLdapConfiguration(),
424 org.apache.archiva.configuration.LdapConfiguration.class ) );
426 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null )
428 redbackRuntimeConfiguration.setUsersCacheConfiguration( new CacheConfiguration() );
431 res.setUsersCacheConfiguration( getModelMapper().map( redbackRuntimeConfiguration.getUsersCacheConfiguration(),
432 org.apache.archiva.configuration.CacheConfiguration.class ) );
434 List<LdapGroupMapping> ldapGroupMappings = redbackRuntimeConfiguration.getLdapGroupMappings();
436 if ( ldapGroupMappings != null && ldapGroupMappings.size() > 0 )
439 List<org.apache.archiva.configuration.LdapGroupMapping> mappings =
440 new ArrayList<>( ldapGroupMappings.size() );
442 for ( LdapGroupMapping ldapGroupMapping : ldapGroupMappings )
445 org.apache.archiva.configuration.LdapGroupMapping mapping =
446 new org.apache.archiva.configuration.LdapGroupMapping();
447 mapping.setGroup( ldapGroupMapping.getGroup() );
448 mapping.setRoleNames( new ArrayList<>( ldapGroupMapping.getRoleNames() ) );
449 mappings.add( mapping );
452 res.setLdapGroupMappings( mappings );
457 // wrapper for UserConfiguration to intercept values (and store it not yet migrated)
461 public String getString( String key )
463 if ( UserConfigurationKeys.USER_MANAGER_IMPL.equals( key ) )
465 // possible false for others than archiva user manager
466 return getRedbackRuntimeConfiguration().getUserManagerImpls().get( 0 );
469 if ( StringUtils.startsWith( key, UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
471 RedbackRuntimeConfiguration redbackRuntimeConfiguration = getRedbackRuntimeConfiguration();
472 int index = redbackRuntimeConfiguration.getLdapGroupMappings().indexOf( new LdapGroupMapping(
473 StringUtils.substringAfter( key, UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) ) );
476 return StringUtils.join( redbackRuntimeConfiguration.getLdapGroupMappings().get( index ).getRoleNames(),
481 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
483 if ( conf.getConfigurationProperties().containsKey( key ) )
485 return conf.getConfigurationProperties().get( key );
488 String value = userConfiguration.getString( key );
493 conf.getConfigurationProperties().put( key, value );
497 updateRedbackRuntimeConfiguration( conf );
499 catch ( RepositoryAdminException e )
501 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
502 throw new RuntimeException( e.getMessage(), e );
509 public String getString( String key, String defaultValue )
511 if ( UserConfigurationKeys.LDAP_HOSTNAME.equals( key ) )
513 return getRedbackRuntimeConfiguration().getLdapConfiguration().getHostName();
515 if ( UserConfigurationKeys.LDAP_CONTEX_FACTORY.equals( key ) )
517 return getRedbackRuntimeConfiguration().getLdapConfiguration().getContextFactory();
519 if ( UserConfigurationKeys.LDAP_PASSWORD.equals( key ) )
521 return getRedbackRuntimeConfiguration().getLdapConfiguration().getPassword();
523 if ( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD.equals( key ) )
525 return getRedbackRuntimeConfiguration().getLdapConfiguration().getAuthenticationMethod();
528 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
530 if ( conf.getConfigurationProperties().containsKey( key ) )
532 return conf.getConfigurationProperties().get( key );
535 String value = userConfiguration.getString( key, defaultValue );
542 conf.getConfigurationProperties().put( key, value );
545 updateRedbackRuntimeConfiguration( conf );
547 catch ( RepositoryAdminException e )
549 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
550 throw new RuntimeException( e.getMessage(), e );
557 public int getInt( String key )
559 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
561 if ( conf.getConfigurationProperties().containsKey( key ) )
563 return Integer.valueOf( conf.getConfigurationProperties().get( key ) );
566 int value = userConfiguration.getInt( key );
568 conf.getConfigurationProperties().put( key, Integer.toString( value ) );
571 updateRedbackRuntimeConfiguration( conf );
573 catch ( RepositoryAdminException e )
575 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
576 throw new RuntimeException( e.getMessage(), e );
583 public int getInt( String key, int defaultValue )
585 if ( UserConfigurationKeys.LDAP_PORT.equals( key ) )
587 return getRedbackRuntimeConfiguration().getLdapConfiguration().getPort();
590 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
592 if ( conf.getConfigurationProperties().containsKey( key ) )
594 return Integer.valueOf( conf.getConfigurationProperties().get( key ) );
597 int value = userConfiguration.getInt( key, defaultValue );
599 conf.getConfigurationProperties().put( key, Integer.toString( value ) );
602 updateRedbackRuntimeConfiguration( conf );
604 catch ( RepositoryAdminException e )
606 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
607 throw new RuntimeException( e.getMessage(), e );
614 public boolean getBoolean( String key )
616 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
618 if ( UserConfigurationKeys.LDAP_WRITABLE.equals( key ) )
620 return conf.getLdapConfiguration().isWritable();
623 if ( UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME.equals( key ) )
625 return conf.getLdapConfiguration().isUseRoleNameAsGroup();
628 if ( UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED.equals( key ) )
630 return conf.getLdapConfiguration().isBindAuthenticatorEnabled();
633 if ( conf.getConfigurationProperties().containsKey( key ) )
635 return Boolean.valueOf( conf.getConfigurationProperties().get( key ) );
638 boolean value = userConfiguration.getBoolean( key );
640 conf.getConfigurationProperties().put( key, Boolean.toString( value ) );
643 updateRedbackRuntimeConfiguration( conf );
645 catch ( RepositoryAdminException e )
647 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
648 throw new RuntimeException( e.getMessage(), e );
655 public boolean getBoolean( String key, boolean defaultValue )
657 if ( UserConfigurationKeys.LDAP_SSL.equals( key ) )
659 return getRedbackRuntimeConfiguration().getLdapConfiguration().isSsl();
662 if ( UserConfigurationKeys.LDAP_WRITABLE.equals( key ) )
664 return getRedbackRuntimeConfiguration().getLdapConfiguration().isWritable();
667 if ( UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME.equals( key ) )
669 return getRedbackRuntimeConfiguration().getLdapConfiguration().isUseRoleNameAsGroup();
672 if ( UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED.equals( key ) )
674 return getRedbackRuntimeConfiguration().getLdapConfiguration().isBindAuthenticatorEnabled();
677 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
679 if ( conf.getConfigurationProperties().containsKey( key ) )
681 return Boolean.valueOf( conf.getConfigurationProperties().get( key ) );
684 boolean value = userConfiguration.getBoolean( key, defaultValue );
686 conf.getConfigurationProperties().put( key, Boolean.toString( value ) );
689 updateRedbackRuntimeConfiguration( conf );
691 catch ( RepositoryAdminException e )
693 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
694 throw new RuntimeException( e.getMessage(), e );
701 public List<String> getList( String key )
703 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
704 if (conf.getConfigurationProperties().containsKey(key)) {
705 return Arrays.asList(conf.getConfigurationProperties().get(key).split(","));
708 List<String> value = userConfiguration.getList( key );
710 conf.getConfigurationProperties().put( key, "" );
713 updateRedbackRuntimeConfiguration( conf );
715 catch ( RepositoryAdminException e )
717 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
718 throw new RuntimeException( e.getMessage(), e );
725 public String getConcatenatedList( String key, String defaultValue )
727 if ( UserConfigurationKeys.LDAP_BASEDN.equals( key ) )
729 return getRedbackRuntimeConfiguration().getLdapConfiguration().getBaseDn();
731 if ( UserConfigurationKeys.LDAP_BINDDN.equals( key ) )
733 return getRedbackRuntimeConfiguration().getLdapConfiguration().getBindDn();
735 if ( UserConfigurationKeys.LDAP_GROUPS_BASEDN.equals( key ) )
737 return getRedbackRuntimeConfiguration().getLdapConfiguration().getBaseGroupsDn();
739 return userConfiguration.getConcatenatedList( key, defaultValue );
743 public Collection<String> getKeys()
745 Collection<String> keys = userConfiguration.getKeys();
747 Set<String> keysSet = new HashSet<>( keys );
749 keysSet.addAll( getRedbackRuntimeConfiguration().getConfigurationProperties().keySet() );