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.redback.components.cache.Cache;
32 import org.apache.archiva.redback.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.lang.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 redbackRuntimeConfiguration.getUserManagerImpls().add( impl );
108 redbackRuntimeConfiguration.getUserManagerImpls().add( DEFAULT_USER_MANAGER_IMPL );
111 String rbacManagerImpls =
112 userConfiguration.getConcatenatedList( UserConfigurationKeys.RBAC_MANAGER_IMPL, //
113 DEFAULT_RBAC_MANAGER_IMPL );
115 if ( StringUtils.isNotEmpty( rbacManagerImpls ) )
117 String[] impls = StringUtils.split( rbacManagerImpls, ',' );
118 for ( String impl : impls )
120 redbackRuntimeConfiguration.getRbacManagerImpls().add( impl );
125 redbackRuntimeConfiguration.getRbacManagerImpls().add( DEFAULT_RBAC_MANAGER_IMPL );
130 LdapConfiguration ldapConfiguration = redbackRuntimeConfiguration.getLdapConfiguration();
131 if ( ldapConfiguration == null )
133 ldapConfiguration = new LdapConfiguration();
134 redbackRuntimeConfiguration.setLdapConfiguration( ldapConfiguration );
137 ldapConfiguration.setHostName(
138 userConfiguration.getString( UserConfigurationKeys.LDAP_HOSTNAME, null ) );
139 ldapConfiguration.setPort( userConfiguration.getInt( UserConfigurationKeys.LDAP_PORT, -1 ) );
140 ldapConfiguration.setSsl( userConfiguration.getBoolean( UserConfigurationKeys.LDAP_SSL, false ) );
141 ldapConfiguration.setBaseDn(
142 userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_BASEDN, null ) );
144 ldapConfiguration.setBaseGroupsDn(
145 userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_GROUPS_BASEDN,
146 ldapConfiguration.getBaseDn() ) );
148 ldapConfiguration.setContextFactory(
149 userConfiguration.getString( UserConfigurationKeys.LDAP_CONTEX_FACTORY,
150 isSunContextFactoryAvailable()
151 ? "com.sun.jndi.ldap.LdapCtxFactory"
153 ldapConfiguration.setBindDn(
154 userConfiguration.getConcatenatedList( UserConfigurationKeys.LDAP_BINDDN, null ) );
155 ldapConfiguration.setPassword(
156 userConfiguration.getString( UserConfigurationKeys.LDAP_PASSWORD, null ) );
157 ldapConfiguration.setAuthenticationMethod(
158 userConfiguration.getString( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD, null ) );
160 ldapConfiguration.setWritable(
161 userConfiguration.getBoolean( UserConfigurationKeys.LDAP_WRITABLE, false ) );
163 ldapConfiguration.setUseRoleNameAsGroup(
164 userConfiguration.getBoolean( UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME, false ) );
166 boolean ldapBindAuthenticatorEnabled =
167 userConfiguration.getBoolean( UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED, false );
168 ldapConfiguration.setBindAuthenticatorEnabled( ldapBindAuthenticatorEnabled );
170 // LDAP groups mapping reading !!
171 // UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY
172 // userConfiguration.getKeys()
174 Collection<String> keys = userConfiguration.getKeys();
176 List<LdapGroupMapping> ldapGroupMappings = new ArrayList<>();
178 for ( String key : keys )
180 if ( key.startsWith( UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
183 StringUtils.substringAfter( key, UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY );
184 String val = userConfiguration.getConcatenatedList( key, "" );
185 if ( !StringUtils.isEmpty( val ) )
187 String[] roles = StringUtils.split( val, ',' );
188 ldapGroupMappings.add( new LdapGroupMapping( group, roles ) );
193 redbackRuntimeConfiguration.setLdapGroupMappings( ldapGroupMappings );
195 redbackRuntimeConfiguration.setMigratedFromRedbackConfiguration( true );
197 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
200 // we must ensure userManagerImpls list is not empty if so put at least jdo one !
201 if ( redbackRuntimeConfiguration.getUserManagerImpls().isEmpty() )
204 "redbackRuntimeConfiguration with empty userManagerImpls so force at least jdo implementation !" );
205 redbackRuntimeConfiguration.getUserManagerImpls().add( "jdo" );
206 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
210 log.info( "using userManagerImpls: {}", redbackRuntimeConfiguration.getUserManagerImpls() );
213 // we ensure rbacManagerImpls is not empty if so put at least cached
214 if ( redbackRuntimeConfiguration.getRbacManagerImpls().isEmpty() )
217 "redbackRuntimeConfiguration with empty rbacManagerImpls so force at least cached implementation !" );
218 redbackRuntimeConfiguration.getRbacManagerImpls().add( "cached" );
219 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
223 log.info( "using rbacManagerImpls: {}", redbackRuntimeConfiguration.getRbacManagerImpls() );
226 boolean save = false;
229 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null )
231 redbackRuntimeConfiguration.setUsersCacheConfiguration( new CacheConfiguration() );
233 // if -1 it means non initialized to take values from the spring bean
234 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToIdleSeconds() < 0 )
236 redbackRuntimeConfiguration.getUsersCacheConfiguration().setTimeToIdleSeconds(
237 usersCache.getTimeToIdleSeconds() );
241 usersCache.setTimeToIdleSeconds(
242 redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToIdleSeconds() );
244 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToLiveSeconds() < 0 )
246 redbackRuntimeConfiguration.getUsersCacheConfiguration().setTimeToLiveSeconds(
247 usersCache.getTimeToLiveSeconds() );
251 usersCache.setTimeToLiveSeconds(
252 redbackRuntimeConfiguration.getUsersCacheConfiguration().getTimeToLiveSeconds() );
254 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsInMemory() < 0 )
256 redbackRuntimeConfiguration.getUsersCacheConfiguration().setMaxElementsInMemory(
257 usersCache.getMaxElementsInMemory() );
260 usersCache.setMaxElementsInMemory(
261 redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsInMemory() );
263 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsOnDisk() < 0 )
265 redbackRuntimeConfiguration.getUsersCacheConfiguration().setMaxElementsOnDisk(
266 usersCache.getMaxElementsOnDisk() );
269 usersCache.setMaxElementsOnDisk(
270 redbackRuntimeConfiguration.getUsersCacheConfiguration().getMaxElementsOnDisk() );
274 updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
278 catch ( RepositoryAdminException e )
280 throw new UserConfigurationException( e.getMessage(), e );
284 private boolean isSunContextFactoryAvailable()
288 return Thread.currentThread().getContextClassLoader().loadClass( "com.sun.jndi.ldap.LdapCtxFactory" )
291 catch ( ClassNotFoundException e )
298 public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
300 return build( archivaConfiguration.getConfiguration().getRedbackRuntimeConfiguration() );
304 public void updateRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
305 throws RepositoryAdminException
307 org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration =
308 build( redbackRuntimeConfiguration );
309 Configuration configuration = archivaConfiguration.getConfiguration();
310 configuration.setRedbackRuntimeConfiguration( runtimeConfiguration );
313 archivaConfiguration.save( configuration );
315 catch ( RegistryException e )
317 throw new RepositoryAdminException( e.getMessage(), e );
319 catch ( IndeterminateConfigurationException e )
321 throw new RepositoryAdminException( e.getMessage(), e );
325 private RedbackRuntimeConfiguration build(
326 org.apache.archiva.configuration.RedbackRuntimeConfiguration runtimeConfiguration )
328 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
329 getModelMapper().map( runtimeConfiguration, RedbackRuntimeConfiguration.class );
331 if ( runtimeConfiguration.getLdapConfiguration() != null )
333 redbackRuntimeConfiguration.setLdapConfiguration(
334 getModelMapper().map( runtimeConfiguration.getLdapConfiguration(), LdapConfiguration.class ) );
337 if ( runtimeConfiguration.getUsersCacheConfiguration() != null )
339 redbackRuntimeConfiguration.setUsersCacheConfiguration(
340 getModelMapper().map( runtimeConfiguration.getUsersCacheConfiguration(), CacheConfiguration.class ) );
343 if ( redbackRuntimeConfiguration.getLdapConfiguration() == null )
346 redbackRuntimeConfiguration.setLdapConfiguration( new LdapConfiguration() );
349 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null )
351 redbackRuntimeConfiguration.setUsersCacheConfiguration( new CacheConfiguration() );
354 List<org.apache.archiva.configuration.LdapGroupMapping> mappings = runtimeConfiguration.getLdapGroupMappings();
356 if ( mappings != null && mappings.size() > 0 )
358 List<LdapGroupMapping> ldapGroupMappings = new ArrayList<>( mappings.size() );
360 for ( org.apache.archiva.configuration.LdapGroupMapping mapping : mappings )
362 ldapGroupMappings.add( new LdapGroupMapping( mapping.getGroup(), mapping.getRoleNames() ) );
365 redbackRuntimeConfiguration.setLdapGroupMappings( ldapGroupMappings );
368 cleanupProperties( redbackRuntimeConfiguration );
370 return redbackRuntimeConfiguration;
374 * cleaning from map properties used directly in archiva configuration fields
376 * @param redbackRuntimeConfiguration
378 private void cleanupProperties( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
380 Map<String, String> properties = redbackRuntimeConfiguration.getConfigurationProperties();
381 properties.remove( UserConfigurationKeys.LDAP_HOSTNAME );
382 properties.remove( UserConfigurationKeys.LDAP_PORT );
383 properties.remove( UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED );
384 properties.remove( UserConfigurationKeys.LDAP_SSL );
385 properties.remove( UserConfigurationKeys.LDAP_BASEDN );
386 properties.remove( UserConfigurationKeys.LDAP_GROUPS_BASEDN );
387 properties.remove( UserConfigurationKeys.LDAP_CONTEX_FACTORY );
388 properties.remove( UserConfigurationKeys.LDAP_BINDDN );
389 properties.remove( UserConfigurationKeys.LDAP_PASSWORD );
390 properties.remove( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD );
391 properties.remove( UserConfigurationKeys.LDAP_WRITABLE );
392 properties.remove( UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME );
394 // cleanup groups <-> role mapping
395 /**for ( Map.Entry<String, String> entry : new HashMap<String, String>( properties ).entrySet() )
397 if ( entry.getKey().startsWith( UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
399 properties.remove( entry.getKey() );
404 private org.apache.archiva.configuration.RedbackRuntimeConfiguration build(
405 RedbackRuntimeConfiguration redbackRuntimeConfiguration )
407 org.apache.archiva.configuration.RedbackRuntimeConfiguration res =
408 getModelMapper().map( redbackRuntimeConfiguration,
409 org.apache.archiva.configuration.RedbackRuntimeConfiguration.class );
411 if ( redbackRuntimeConfiguration.getLdapConfiguration() == null )
413 redbackRuntimeConfiguration.setLdapConfiguration( new LdapConfiguration() );
415 res.setLdapConfiguration( getModelMapper().map( redbackRuntimeConfiguration.getLdapConfiguration(),
416 org.apache.archiva.configuration.LdapConfiguration.class ) );
418 if ( redbackRuntimeConfiguration.getUsersCacheConfiguration() == null )
420 redbackRuntimeConfiguration.setUsersCacheConfiguration( new CacheConfiguration() );
423 res.setUsersCacheConfiguration( getModelMapper().map( redbackRuntimeConfiguration.getUsersCacheConfiguration(),
424 org.apache.archiva.configuration.CacheConfiguration.class ) );
426 List<LdapGroupMapping> ldapGroupMappings = redbackRuntimeConfiguration.getLdapGroupMappings();
428 if ( ldapGroupMappings != null && ldapGroupMappings.size() > 0 )
431 List<org.apache.archiva.configuration.LdapGroupMapping> mappings =
432 new ArrayList<>( ldapGroupMappings.size() );
434 for ( LdapGroupMapping ldapGroupMapping : ldapGroupMappings )
437 org.apache.archiva.configuration.LdapGroupMapping mapping =
438 new org.apache.archiva.configuration.LdapGroupMapping();
439 mapping.setGroup( ldapGroupMapping.getGroup() );
440 mapping.setRoleNames( new ArrayList<>( ldapGroupMapping.getRoleNames() ) );
441 mappings.add( mapping );
444 res.setLdapGroupMappings( mappings );
449 // wrapper for UserConfiguration to intercept values (and store it not yet migrated)
453 public String getString( String key )
455 if ( UserConfigurationKeys.USER_MANAGER_IMPL.equals( key ) )
457 // possible false for others than archiva user manager
458 return getRedbackRuntimeConfiguration().getUserManagerImpls().get( 0 );
461 if ( StringUtils.startsWith( key, UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) )
463 RedbackRuntimeConfiguration redbackRuntimeConfiguration = getRedbackRuntimeConfiguration();
464 int index = redbackRuntimeConfiguration.getLdapGroupMappings().indexOf( new LdapGroupMapping(
465 StringUtils.substringAfter( key, UserConfigurationKeys.LDAP_GROUPS_ROLE_START_KEY ) ) );
468 return StringUtils.join( redbackRuntimeConfiguration.getLdapGroupMappings().get( index ).getRoleNames(),
473 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
475 if ( conf.getConfigurationProperties().containsKey( key ) )
477 return conf.getConfigurationProperties().get( key );
480 String value = userConfiguration.getString( key );
485 conf.getConfigurationProperties().put( key, value );
489 updateRedbackRuntimeConfiguration( conf );
491 catch ( RepositoryAdminException e )
493 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
494 throw new RuntimeException( e.getMessage(), e );
501 public String getString( String key, String defaultValue )
503 if ( UserConfigurationKeys.LDAP_HOSTNAME.equals( key ) )
505 return getRedbackRuntimeConfiguration().getLdapConfiguration().getHostName();
507 if ( UserConfigurationKeys.LDAP_CONTEX_FACTORY.equals( key ) )
509 return getRedbackRuntimeConfiguration().getLdapConfiguration().getContextFactory();
511 if ( UserConfigurationKeys.LDAP_PASSWORD.equals( key ) )
513 return getRedbackRuntimeConfiguration().getLdapConfiguration().getPassword();
515 if ( UserConfigurationKeys.LDAP_AUTHENTICATION_METHOD.equals( key ) )
517 return getRedbackRuntimeConfiguration().getLdapConfiguration().getAuthenticationMethod();
520 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
522 if ( conf.getConfigurationProperties().containsKey( key ) )
524 return conf.getConfigurationProperties().get( key );
527 String value = userConfiguration.getString( key, defaultValue );
534 conf.getConfigurationProperties().put( key, value );
537 updateRedbackRuntimeConfiguration( conf );
539 catch ( RepositoryAdminException e )
541 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
542 throw new RuntimeException( e.getMessage(), e );
549 public int getInt( String key )
551 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
553 if ( conf.getConfigurationProperties().containsKey( key ) )
555 return Integer.valueOf( conf.getConfigurationProperties().get( key ) );
558 int value = userConfiguration.getInt( key );
560 conf.getConfigurationProperties().put( key, Integer.toString( value ) );
563 updateRedbackRuntimeConfiguration( conf );
565 catch ( RepositoryAdminException e )
567 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
568 throw new RuntimeException( e.getMessage(), e );
575 public int getInt( String key, int defaultValue )
577 if ( UserConfigurationKeys.LDAP_PORT.equals( key ) )
579 return getRedbackRuntimeConfiguration().getLdapConfiguration().getPort();
582 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
584 if ( conf.getConfigurationProperties().containsKey( key ) )
586 return Integer.valueOf( conf.getConfigurationProperties().get( key ) );
589 int value = userConfiguration.getInt( key, defaultValue );
591 conf.getConfigurationProperties().put( key, Integer.toString( value ) );
594 updateRedbackRuntimeConfiguration( conf );
596 catch ( RepositoryAdminException e )
598 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
599 throw new RuntimeException( e.getMessage(), e );
606 public boolean getBoolean( String key )
608 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
610 if ( UserConfigurationKeys.LDAP_WRITABLE.equals( key ) )
612 return conf.getLdapConfiguration().isWritable();
615 if ( UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME.equals( key ) )
617 return conf.getLdapConfiguration().isUseRoleNameAsGroup();
620 if ( UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED.equals( key ) )
622 return conf.getLdapConfiguration().isBindAuthenticatorEnabled();
625 if ( conf.getConfigurationProperties().containsKey( key ) )
627 return Boolean.valueOf( conf.getConfigurationProperties().get( key ) );
630 boolean value = userConfiguration.getBoolean( key );
632 conf.getConfigurationProperties().put( key, Boolean.toString( value ) );
635 updateRedbackRuntimeConfiguration( conf );
637 catch ( RepositoryAdminException e )
639 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
640 throw new RuntimeException( e.getMessage(), e );
647 public boolean getBoolean( String key, boolean defaultValue )
649 if ( UserConfigurationKeys.LDAP_SSL.equals( key ) )
651 return getRedbackRuntimeConfiguration().getLdapConfiguration().isSsl();
654 if ( UserConfigurationKeys.LDAP_WRITABLE.equals( key ) )
656 return getRedbackRuntimeConfiguration().getLdapConfiguration().isWritable();
659 if ( UserConfigurationKeys.LDAP_GROUPS_USE_ROLENAME.equals( key ) )
661 return getRedbackRuntimeConfiguration().getLdapConfiguration().isUseRoleNameAsGroup();
664 if ( UserConfigurationKeys.LDAP_BIND_AUTHENTICATOR_ENABLED.equals( key ) )
666 return getRedbackRuntimeConfiguration().getLdapConfiguration().isBindAuthenticatorEnabled();
669 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
671 if ( conf.getConfigurationProperties().containsKey( key ) )
673 return Boolean.valueOf( conf.getConfigurationProperties().get( key ) );
676 boolean value = userConfiguration.getBoolean( key, defaultValue );
678 conf.getConfigurationProperties().put( key, Boolean.toString( value ) );
681 updateRedbackRuntimeConfiguration( conf );
683 catch ( RepositoryAdminException e )
685 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
686 throw new RuntimeException( e.getMessage(), e );
693 public List<String> getList( String key )
695 RedbackRuntimeConfiguration conf = getRedbackRuntimeConfiguration();
696 if (conf.getConfigurationProperties().containsKey(key)) {
697 return Arrays.asList(conf.getConfigurationProperties().get(key).split(","));
700 List<String> value = userConfiguration.getList( key );
702 conf.getConfigurationProperties().put( key, "" );
705 updateRedbackRuntimeConfiguration( conf );
707 catch ( RepositoryAdminException e )
709 log.error( "fail to save RedbackRuntimeConfiguration: {}", e.getMessage(), e );
710 throw new RuntimeException( e.getMessage(), e );
717 public String getConcatenatedList( String key, String defaultValue )
719 if ( UserConfigurationKeys.LDAP_BASEDN.equals( key ) )
721 return getRedbackRuntimeConfiguration().getLdapConfiguration().getBaseDn();
723 if ( UserConfigurationKeys.LDAP_BINDDN.equals( key ) )
725 return getRedbackRuntimeConfiguration().getLdapConfiguration().getBindDn();
727 if ( UserConfigurationKeys.LDAP_GROUPS_BASEDN.equals( key ) )
729 return getRedbackRuntimeConfiguration().getLdapConfiguration().getBaseGroupsDn();
731 return userConfiguration.getConcatenatedList( key, defaultValue );
735 public Collection<String> getKeys()
737 Collection<String> keys = userConfiguration.getKeys();
739 Set<String> keysSet = new HashSet<>( keys );
741 keysSet.addAll( getRedbackRuntimeConfiguration().getConfigurationProperties().keySet() );