1 package org.apache.archiva.rest.services.v2;/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
11 * Unless required by applicable law or agreed to in writing,
12 * software distributed under the License is distributed on an
13 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 * KIND, either express or implied. See the License for the
15 * specific language governing permissions and limitations
19 import org.apache.archiva.admin.model.RepositoryAdminException;
20 import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
21 import org.apache.archiva.admin.model.runtime.RedbackRuntimeConfigurationAdmin;
22 import org.apache.archiva.components.rest.model.PagedResult;
23 import org.apache.archiva.components.rest.model.PropertyEntry;
24 import org.apache.archiva.components.rest.util.QueryHelper;
25 import org.apache.archiva.redback.authentication.Authenticator;
26 import org.apache.archiva.redback.common.ldap.connection.LdapConnection;
27 import org.apache.archiva.redback.common.ldap.connection.LdapConnectionConfiguration;
28 import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
29 import org.apache.archiva.redback.common.ldap.connection.LdapException;
30 import org.apache.archiva.redback.common.ldap.user.LdapUserMapper;
31 import org.apache.archiva.redback.policy.CookieSettings;
32 import org.apache.archiva.redback.policy.PasswordRule;
33 import org.apache.archiva.redback.rbac.RBACManager;
34 import org.apache.archiva.redback.role.RoleManager;
35 import org.apache.archiva.redback.users.UserManager;
36 import org.apache.archiva.rest.api.model.v2.BeanInformation;
37 import org.apache.archiva.rest.api.model.v2.CacheConfiguration;
38 import org.apache.archiva.rest.api.model.v2.LdapConfiguration;
39 import org.apache.archiva.rest.api.model.v2.SecurityConfiguration;
40 import org.apache.archiva.rest.api.services.v2.ArchivaRestServiceException;
41 import org.apache.archiva.rest.api.services.v2.ErrorMessage;
42 import org.apache.archiva.rest.api.services.v2.SecurityConfigurationService;
43 import org.apache.commons.collections4.CollectionUtils;
44 import org.apache.commons.lang3.StringUtils;
45 import org.slf4j.Logger;
46 import org.slf4j.LoggerFactory;
47 import org.springframework.context.ApplicationContext;
48 import org.springframework.stereotype.Service;
50 import javax.annotation.PostConstruct;
51 import javax.inject.Inject;
52 import javax.inject.Named;
53 import javax.naming.AuthenticationException;
54 import javax.naming.AuthenticationNotSupportedException;
55 import javax.naming.CommunicationException;
56 import javax.naming.InvalidNameException;
57 import javax.naming.NamingException;
58 import javax.naming.NoPermissionException;
59 import javax.naming.ServiceUnavailableException;
60 import javax.ws.rs.core.Response;
61 import java.util.ArrayList;
62 import java.util.Collection;
63 import java.util.Collections;
64 import java.util.Comparator;
65 import java.util.List;
67 import java.util.Properties;
68 import java.util.ResourceBundle;
69 import java.util.function.Predicate;
70 import java.util.stream.Collectors;
72 import static org.apache.archiva.rest.services.v2.ErrorKeys.INVALID_RESULT_SET_ERROR;
73 import static org.apache.archiva.rest.services.v2.ErrorKeys.REPOSITORY_ADMIN_ERROR;
76 * @author Martin Stockhammer <martin_s@apache.org>
78 @Service( "v2.defaultSecurityConfigurationService" )
79 public class DefaultSecurityConfigurationService implements SecurityConfigurationService
81 private static final Logger log = LoggerFactory.getLogger( DefaultSecurityConfigurationService.class );
83 private static final String[] KNOWN_LDAP_CONTEXT_PROVIDERS = {"com.sun.jndi.ldap.LdapCtxFactory","com.ibm.jndi.LDAPCtxFactory"};
84 private final List<String> availableContextProviders = new ArrayList<>( );
86 private static final QueryHelper<PropertyEntry> PROP_QUERY_HELPER = new QueryHelper<>( new String[]{"key"} );
90 PROP_QUERY_HELPER.addStringFilter( "key", PropertyEntry::getKey );
91 PROP_QUERY_HELPER.addStringFilter( "value", PropertyEntry::getValue );
92 PROP_QUERY_HELPER.addNullsafeFieldComparator( "key", PropertyEntry::getKey );
93 PROP_QUERY_HELPER.addNullsafeFieldComparator( "value", PropertyEntry::getValue );
97 private ResourceBundle bundle;
101 private RedbackRuntimeConfigurationAdmin redbackRuntimeConfigurationAdmin;
104 private ApplicationContext applicationContext;
107 @Named( value = "userManager#default" )
108 private UserManager userManager;
111 @Named( value = "rbacManager#default" )
112 private RBACManager rbacManager;
115 private RoleManager roleManager;
118 @Named( value = "ldapConnectionFactory#configurable" )
119 private LdapConnectionFactory ldapConnectionFactory;
122 private LdapUserMapper ldapUserMapper;
128 bundle = ResourceBundle.getBundle( "org.apache.archiva.rest.RestBundle" );
129 for (String ldapClass : KNOWN_LDAP_CONTEXT_PROVIDERS) {
130 if (isContextFactoryAvailable( ldapClass )) {
131 availableContextProviders.add( ldapClass );
137 public SecurityConfiguration getConfiguration( ) throws ArchivaRestServiceException
141 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
142 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
144 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
146 return SecurityConfiguration.ofRedbackConfiguration( redbackRuntimeConfiguration );
148 catch ( RepositoryAdminException e )
150 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
154 private void updateConfig( SecurityConfiguration newConfig, RedbackRuntimeConfiguration rbConfig )
156 rbConfig.setUserManagerImpls( newConfig.getActiveUserManagers( ) );
157 rbConfig.setRbacManagerImpls( newConfig.getActiveRbacManagers( ) );
158 rbConfig.setUseUsersCache( newConfig.isUserCacheEnabled( ) );
159 Map<String, String> props = rbConfig.getConfigurationProperties( );
160 for ( Map.Entry<String, String> newProp : newConfig.getProperties( ).entrySet( ) )
162 props.put( newProp.getKey( ), newProp.getValue( ) );
166 private void updateConfig( LdapConfiguration newConfig, RedbackRuntimeConfiguration rbConfig )
168 org.apache.archiva.admin.model.beans.LdapConfiguration ldapConfig = rbConfig.getLdapConfiguration( );
169 ldapConfig.setBaseDn( newConfig.getBaseDn( ) );
170 ldapConfig.setAuthenticationMethod( newConfig.getAuthenticationMethod( ) );
171 ldapConfig.setBindAuthenticatorEnabled( newConfig.isBindAuthenticatorEnabled( ) );
172 ldapConfig.setBindDn( newConfig.getBindDn( ) );
173 ldapConfig.setSsl( newConfig.isSslEnabled( ) );
174 ldapConfig.setBaseGroupsDn( newConfig.getGroupsBaseDn( ) );
175 ldapConfig.setHostName( newConfig.getHostName( ) );
176 ldapConfig.setPort( newConfig.getPort( ) );
177 ldapConfig.setPassword( newConfig.getBindPassword( ) );
178 ldapConfig.setUseRoleNameAsGroup( newConfig.isUseRoleNameAsGroup( ) );
179 ldapConfig.setWritable( newConfig.isWritable( ) );
180 ldapConfig.setContextFactory( newConfig.getContextFactory( ) );
182 Map<String, String> props = ldapConfig.getExtraProperties( );
183 for ( Map.Entry<String, String> newProp : newConfig.getProperties( ).entrySet( ) )
185 props.put( newProp.getKey( ), newProp.getValue( ) );
189 private void updateConfig( CacheConfiguration newConfig, RedbackRuntimeConfiguration rbConfig )
191 org.apache.archiva.admin.model.beans.CacheConfiguration cacheConfig = rbConfig.getUsersCacheConfiguration( );
192 cacheConfig.setMaxElementsInMemory( newConfig.getMaxEntriesInMemory( ) );
193 cacheConfig.setMaxElementsOnDisk( newConfig.getMaxEntriesOnDisk( ) );
194 cacheConfig.setTimeToLiveSeconds( newConfig.getTimeToLiveSeconds( ) );
195 cacheConfig.setTimeToIdleSeconds( newConfig.getTimeToIdleSeconds( ) );
199 public SecurityConfiguration updateConfiguration( SecurityConfiguration newConfiguration ) throws ArchivaRestServiceException
201 if ( newConfiguration == null )
203 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.MISSING_DATA ), 400 );
207 RedbackRuntimeConfiguration conf = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
208 boolean userManagerChanged = !CollectionUtils.isEqualCollection( newConfiguration.getActiveUserManagers( ), conf.getUserManagerImpls( ) );
209 boolean rbacManagerChanged = !CollectionUtils.isEqualCollection( newConfiguration.getActiveRbacManagers( ), conf.getRbacManagerImpls( ) );
211 boolean ldapConfigured = newConfiguration.getActiveUserManagers( ).stream( ).anyMatch( um -> um.contains( "ldap" ) );
212 if ( !ldapConfigured )
214 ldapConfigured= newConfiguration.getActiveRbacManagers( ).stream( ).anyMatch( um -> um.contains( "ldap" ) );
217 updateConfig( newConfiguration, conf );
218 redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( conf );
220 if ( userManagerChanged )
222 log.info( "user managerImpls changed to {} so reload it",
223 newConfiguration.getActiveUserManagers( ) );
224 userManager.initialize( );
227 if ( rbacManagerChanged )
229 log.info( "rbac manager changed to {} so reload it",
230 newConfiguration.getActiveRbacManagers( ) );
231 rbacManager.initialize( );
232 roleManager.initialize( );
235 if ( ldapConfigured )
239 ldapConnectionFactory.initialize( );
241 catch ( Exception e )
243 log.error( "Could not initialize LDAP connection factory: {}", e.getMessage( ) );
244 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_CF_INIT_FAILED, e.getMessage( ) ) );
247 Collection<PasswordRule> passwordRules = applicationContext.getBeansOfType( PasswordRule.class ).values( );
249 for ( PasswordRule passwordRule : passwordRules )
251 passwordRule.initialize( );
254 Collection<CookieSettings> cookieSettingsList =
255 applicationContext.getBeansOfType( CookieSettings.class ).values( );
257 for ( CookieSettings cookieSettings : cookieSettingsList )
259 cookieSettings.initialize( );
262 Collection<Authenticator> authenticators =
263 applicationContext.getBeansOfType( Authenticator.class ).values( );
265 for ( Authenticator authenticator : authenticators )
269 log.debug( "Initializing authenticatior " + authenticator.getId( ) );
270 authenticator.initialize( );
272 catch ( Exception e )
274 log.error( "Initialization of authenticator failed " + authenticator.getId( ), e );
278 if ( ldapConfigured )
282 ldapUserMapper.initialize( );
284 catch ( Exception e )
286 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_USER_MAPPER_INIT_FAILED, e.getMessage( ) ) );
290 catch ( RepositoryAdminException e )
292 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
296 return SecurityConfiguration.ofRedbackConfiguration( redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( ) );
298 catch ( RepositoryAdminException e )
300 log.error( "Error while retrieve updated configuration: {}", e.getMessage( ) );
301 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
306 public PagedResult<PropertyEntry> getConfigurationProperties( String searchTerm, Integer offset, Integer limit, List<String> orderBy, String order ) throws ArchivaRestServiceException
310 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
311 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
313 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
315 boolean ascending = PROP_QUERY_HELPER.isAscending( order );
316 Predicate<PropertyEntry> filter = PROP_QUERY_HELPER.getQueryFilter( searchTerm );
317 Comparator<PropertyEntry> comparator = PROP_QUERY_HELPER.getComparator( orderBy, ascending );
318 Map<String, String> props = redbackRuntimeConfiguration.getConfigurationProperties( );
319 int totalCount = Math.toIntExact( props.entrySet( ).stream( ).map(
320 entry -> new PropertyEntry( entry.getKey( ), entry.getValue( ) )
321 ).filter( filter ).count( ) );
322 List<PropertyEntry> result = props.entrySet( ).stream( ).map(
323 entry -> new PropertyEntry( entry.getKey( ), entry.getValue( ) )
325 .sorted( comparator )
326 .skip( offset ).limit( limit )
327 .collect( Collectors.toList( ) );
328 return new PagedResult<>( totalCount, offset, limit, result );
329 } catch (ArithmeticException e) {
330 log.error( "The total count of the result properties is higher than max integer value!" );
331 throw new ArchivaRestServiceException( ErrorMessage.of( INVALID_RESULT_SET_ERROR ) );
333 catch ( RepositoryAdminException e )
335 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
340 public PropertyEntry getConfigurationProperty( String propertyName ) throws ArchivaRestServiceException
344 RedbackRuntimeConfiguration conf = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
345 if ( conf.getConfigurationProperties( ).containsKey( propertyName ) )
347 String value = conf.getConfigurationProperties( ).get( propertyName );
348 return new PropertyEntry( propertyName, value );
352 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.PROPERTY_NOT_FOUND ), 404 );
356 catch ( RepositoryAdminException e )
358 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
364 public Response updateConfigurationProperty( String propertyName, PropertyEntry propertyValue ) throws ArchivaRestServiceException
366 if ( propertyValue == null )
368 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.MISSING_DATA ), 400 );
372 RedbackRuntimeConfiguration conf = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
373 if ( conf.getConfigurationProperties( ).containsKey( propertyName ) )
375 conf.getConfigurationProperties( ).put( propertyName, propertyValue.getValue( ) );
376 redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( conf );
377 return Response.ok( ).build( );
381 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.PROPERTY_NOT_FOUND ), 404 );
385 catch ( RepositoryAdminException e )
387 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
392 public LdapConfiguration getLdapConfiguration( ) throws ArchivaRestServiceException
396 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
397 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
399 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
401 LdapConfiguration ldapConfig = LdapConfiguration.of( redbackRuntimeConfiguration.getLdapConfiguration( ) );
402 ldapConfig.setAvailableContextFactories( availableContextProviders );
405 catch ( RepositoryAdminException e )
407 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
413 public LdapConfiguration updateLdapConfiguration( LdapConfiguration configuration ) throws ArchivaRestServiceException
417 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
418 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
420 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
422 updateConfig( configuration, redbackRuntimeConfiguration );
424 redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
425 ldapConnectionFactory.initialize( );
427 catch ( RepositoryAdminException e )
429 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
434 return LdapConfiguration.of( redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( ).getLdapConfiguration() );
436 catch ( RepositoryAdminException e )
438 log.error( "Error while retrieve updated configuration: {}", e.getMessage( ) );
439 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
444 static Properties toProperties( Map<String, String> values )
446 Properties result = new Properties( );
447 for ( Map.Entry<String, String> entry : values.entrySet( ) )
449 result.setProperty( entry.getKey( ), entry.getValue( ) );
454 private static boolean isContextFactoryAvailable( final String factoryClass)
458 return Thread.currentThread().getContextClassLoader().loadClass( factoryClass )
461 catch ( ClassNotFoundException e )
469 public Response verifyLdapConfiguration( LdapConfiguration ldapConfiguration ) throws ArchivaRestServiceException
471 LdapConnection ldapConnection = null;
474 LdapConnectionConfiguration ldapConnectionConfiguration =
475 new LdapConnectionConfiguration( ldapConfiguration.getHostName( ), ldapConfiguration.getPort( ),
476 ldapConfiguration.getBaseDn( ), ldapConfiguration.getContextFactory( ),
477 ldapConfiguration.getBindDn( ), ldapConfiguration.getBindPassword( ),
478 ldapConfiguration.getAuthenticationMethod( ),
479 toProperties( ldapConfiguration.getProperties( ) ) );
480 ldapConnectionConfiguration.setSsl( ldapConfiguration.isSslEnabled( ) );
482 ldapConnection = ldapConnectionFactory.getConnection( ldapConnectionConfiguration );
484 catch ( InvalidNameException e )
486 log.warn( "LDAP connection check failed with invalid name : {}", e.getMessage( ), e );
487 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_INVALID_NAME, e.getMessage( ) ), 400 );
489 catch ( LdapException e )
491 handleLdapException( e );
495 if ( ldapConnection != null )
499 ldapConnection.close( );
501 catch ( NamingException e )
503 log.error( "Could not close connection: {}", e.getMessage( ) );
506 ldapConnection = null;
511 // verify groups dn value too
513 LdapConnectionConfiguration ldapConnectionConfiguration = new LdapConnectionConfiguration( ldapConfiguration.getHostName( ), ldapConfiguration.getPort( ),
514 ldapConfiguration.getGroupsBaseDn( ),
515 ldapConfiguration.getContextFactory( ), ldapConfiguration.getBindDn( ),
516 ldapConfiguration.getBindPassword( ),
517 ldapConfiguration.getAuthenticationMethod( ),
518 toProperties( ldapConfiguration.getProperties( ) ) );
520 ldapConnectionConfiguration.setSsl( ldapConfiguration.isSslEnabled( ) );
522 ldapConnection = ldapConnectionFactory.getConnection( ldapConnectionConfiguration );
524 catch ( InvalidNameException e )
526 log.warn( "LDAP connection check failed with invalid name : {}", e.getMessage( ), e );
527 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_INVALID_NAME, e.getMessage( ) ), 400 );
529 catch ( LdapException e )
531 handleLdapException( e );
535 if ( ldapConnection != null )
539 ldapConnection.close( );
541 catch ( NamingException e )
543 log.error( "Could not close connection: {}", e.getMessage( ), e );
548 return Response.ok( ).build( );
551 private void handleLdapException( LdapException e ) throws ArchivaRestServiceException
553 Throwable rootCause = e.getRootCause( );
554 if ( rootCause instanceof CommunicationException )
556 log.warn( "LDAP connection check failed with CommunicationException: {}", e.getMessage( ), e );
557 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_COMMUNICATION_ERROR, e.getMessage( ) ), 400 );
558 } else if (rootCause instanceof ServiceUnavailableException ) {
559 log.warn( "LDAP connection check failed with ServiceUnavailableException: {}", e.getMessage( ), e );
560 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_SERVICE_UNAVAILABLE, e.getMessage( ) ), 400 );
561 } else if (rootCause instanceof AuthenticationException ) {
562 log.warn( "LDAP connection check failed with AuthenticationException: {}", e.getMessage( ), e );
563 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_SERVICE_AUTHENTICATION_FAILED, e.getMessage( ) ), 400 );
564 } else if (rootCause instanceof AuthenticationNotSupportedException ) {
565 log.warn( "LDAP connection check failed with AuthenticationNotSupportedException: {}", e.getMessage( ), e );
566 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_SERVICE_AUTHENTICATION_NOT_SUPPORTED, e.getMessage( ) ), 400 );
567 } else if (rootCause instanceof NoPermissionException ) {
568 log.warn( "LDAP connection check failed with NoPermissionException: {}", e.getMessage( ), e );
569 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_SERVICE_NO_PERMISSION, e.getMessage( ) ), 400 );
571 log.warn( "LDAP connection check failed: {} - {}", e.getClass().getName(), e.getMessage( ), e );
572 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_GENERIC_ERROR, e.getMessage( ) ), 400 );
576 public CacheConfiguration getCacheConfiguration( ) throws ArchivaRestServiceException
580 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
581 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
583 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
585 return CacheConfiguration.of( redbackRuntimeConfiguration.getUsersCacheConfiguration( ) );
587 catch ( RepositoryAdminException e )
589 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
595 public CacheConfiguration updateCacheConfiguration( CacheConfiguration cacheConfiguration ) throws ArchivaRestServiceException
597 if ( cacheConfiguration == null )
599 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.MISSING_DATA ), 400 );
603 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
604 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
606 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
607 updateConfig( cacheConfiguration, redbackRuntimeConfiguration );
608 redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
609 return getCacheConfiguration( );
611 catch ( RepositoryAdminException e )
613 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
618 public List<BeanInformation> getAvailableUserManagers( )
620 Map<String, UserManager> beans = applicationContext.getBeansOfType( UserManager.class );
622 if ( beans.isEmpty( ) )
624 return Collections.emptyList( );
627 return beans.entrySet( ).stream( )
628 .filter( entry -> entry.getValue( ).isFinalImplementation( ) )
629 .map( ( Map.Entry<String, UserManager> entry ) -> {
630 UserManager um = entry.getValue( );
631 String id = StringUtils.substringAfter( entry.getKey( ), "#" );
632 String displayName = bundle.getString( "user_manager." + id + ".display_name" );
633 String description = bundle.getString( "user_manager." + id + ".description" );
634 return new BeanInformation( StringUtils.substringAfter( entry.getKey( ), "#" ), displayName, um.getDescriptionKey( ), description, um.isReadOnly( ) );
635 } ).collect( Collectors.toList( ) );
639 public List<BeanInformation> getAvailableRbacManagers( )
641 Map<String, RBACManager> beans = applicationContext.getBeansOfType( RBACManager.class );
643 if ( beans.isEmpty( ) )
645 return Collections.emptyList( );
648 return beans.entrySet( ).stream( )
649 .filter( entry -> entry.getValue( ).isFinalImplementation( ) )
650 .map( ( Map.Entry<String, RBACManager> entry ) -> {
651 RBACManager rm = entry.getValue( );
652 String id = StringUtils.substringAfter( entry.getKey( ), "#" );
653 String displayName = bundle.getString( "rbac_manager." + id + ".display_name" );
654 String description = bundle.getString( "rbac_manager." + id + ".description" );
655 return new BeanInformation( StringUtils.substringAfter( entry.getKey( ), "#" ), displayName, rm.getDescriptionKey( ), description, rm.isReadOnly( ) );
656 } ).collect( Collectors.toList( ) );