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.cache.Cache;
23 import org.apache.archiva.components.rest.model.PagedResult;
24 import org.apache.archiva.components.rest.model.PropertyEntry;
25 import org.apache.archiva.components.rest.util.PagingHelper;
26 import org.apache.archiva.components.rest.util.QueryHelper;
27 import org.apache.archiva.redback.authentication.Authenticator;
28 import org.apache.archiva.redback.common.ldap.connection.LdapConnection;
29 import org.apache.archiva.redback.common.ldap.connection.LdapConnectionConfiguration;
30 import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
31 import org.apache.archiva.redback.common.ldap.connection.LdapException;
32 import org.apache.archiva.redback.common.ldap.user.LdapUserMapper;
33 import org.apache.archiva.redback.policy.CookieSettings;
34 import org.apache.archiva.redback.policy.PasswordRule;
35 import org.apache.archiva.redback.rbac.RBACManager;
36 import org.apache.archiva.redback.role.RoleManager;
37 import org.apache.archiva.redback.users.UserManager;
38 import org.apache.archiva.rest.api.model.v2.BeanInformation;
39 import org.apache.archiva.rest.api.model.v2.CacheConfiguration;
40 import org.apache.archiva.rest.api.model.v2.LdapConfiguration;
41 import org.apache.archiva.rest.api.model.v2.SecurityConfiguration;
42 import org.apache.archiva.rest.api.services.v2.ArchivaRestServiceException;
43 import org.apache.archiva.rest.api.services.v2.ErrorMessage;
44 import org.apache.archiva.rest.api.services.v2.SecurityConfigurationService;
45 import org.apache.commons.collections4.CollectionUtils;
46 import org.apache.commons.lang3.StringUtils;
47 import org.slf4j.Logger;
48 import org.slf4j.LoggerFactory;
49 import org.springframework.context.ApplicationContext;
50 import org.springframework.stereotype.Service;
52 import javax.annotation.PostConstruct;
53 import javax.inject.Inject;
54 import javax.inject.Named;
55 import javax.naming.AuthenticationException;
56 import javax.naming.AuthenticationNotSupportedException;
57 import javax.naming.CommunicationException;
58 import javax.naming.InvalidNameException;
59 import javax.naming.NoPermissionException;
60 import javax.naming.ServiceUnavailableException;
61 import javax.ws.rs.core.Response;
62 import java.util.ArrayList;
63 import java.util.Collection;
64 import java.util.Collections;
65 import java.util.Comparator;
66 import java.util.List;
68 import java.util.Properties;
69 import java.util.ResourceBundle;
70 import java.util.function.Predicate;
71 import java.util.stream.Collectors;
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 List<String> availableContextProviders = new ArrayList<>( );
86 private static final QueryHelper<PropertyEntry> PROP_QUERY_HELPER = new QueryHelper( new String[]{"key"} );
87 private static final PagingHelper PROP_PAGING_HELPER = new PagingHelper( );
91 PROP_QUERY_HELPER.addStringFilter( "key", PropertyEntry::getKey );
92 PROP_QUERY_HELPER.addStringFilter( "value", PropertyEntry::getValue );
93 PROP_QUERY_HELPER.addNullsafeFieldComparator( "key", PropertyEntry::getKey );
94 PROP_QUERY_HELPER.addNullsafeFieldComparator( "value", PropertyEntry::getValue );
98 private ResourceBundle bundle;
102 private RedbackRuntimeConfigurationAdmin redbackRuntimeConfigurationAdmin;
105 private ApplicationContext applicationContext;
108 @Named( value = "userManager#default" )
109 private UserManager userManager;
112 @Named( value = "rbacManager#default" )
113 private RBACManager rbacManager;
116 private RoleManager roleManager;
119 @Named( value = "ldapConnectionFactory#configurable" )
120 private LdapConnectionFactory ldapConnectionFactory;
123 private LdapUserMapper ldapUserMapper;
126 @Named( value = "cache#users" )
127 private Cache usersCache;
133 bundle = ResourceBundle.getBundle( "org.apache.archiva.rest.RestBundle" );
134 for (String ldapClass : KNOWN_LDAP_CONTEXT_PROVIDERS) {
135 if (isContextFactoryAvailable( ldapClass )) {
136 availableContextProviders.add( ldapClass );
142 public SecurityConfiguration getConfiguration( ) throws ArchivaRestServiceException
146 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
147 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
149 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
151 return SecurityConfiguration.ofRedbackConfiguration( redbackRuntimeConfiguration );
153 catch ( RepositoryAdminException e )
155 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
159 private void updateConfig( SecurityConfiguration newConfig, RedbackRuntimeConfiguration rbConfig )
161 rbConfig.setUserManagerImpls( newConfig.getActiveUserManagers( ) );
162 rbConfig.setRbacManagerImpls( newConfig.getActiveRbacManagers( ) );
163 rbConfig.setUseUsersCache( newConfig.isUserCacheEnabled( ) );
164 Map<String, String> props = rbConfig.getConfigurationProperties( );
165 for ( Map.Entry<String, String> newProp : newConfig.getProperties( ).entrySet( ) )
167 props.put( newProp.getKey( ), newProp.getValue( ) );
171 private void updateConfig( LdapConfiguration newConfig, RedbackRuntimeConfiguration rbConfig )
173 org.apache.archiva.admin.model.beans.LdapConfiguration ldapConfig = rbConfig.getLdapConfiguration( );
174 ldapConfig.setBaseDn( newConfig.getBaseDn( ) );
175 ldapConfig.setAuthenticationMethod( newConfig.getAuthenticationMethod( ) );
176 ldapConfig.setBindAuthenticatorEnabled( newConfig.isBindAuthenticatorEnabled( ) );
177 ldapConfig.setBindDn( newConfig.getBindDn( ) );
178 ldapConfig.setSsl( newConfig.isSslEnabled( ) );
179 ldapConfig.setBaseGroupsDn( newConfig.getGroupsBaseDn( ) );
180 ldapConfig.setHostName( newConfig.getHostName( ) );
181 ldapConfig.setPort( newConfig.getPort( ) );
182 ldapConfig.setPassword( newConfig.getBindPassword( ) );
183 ldapConfig.setUseRoleNameAsGroup( newConfig.isUseRoleNameAsGroup( ) );
184 ldapConfig.setWritable( newConfig.isWritable( ) );
185 ldapConfig.setContextFactory( newConfig.getContextFactory( ) );
187 Map<String, String> props = ldapConfig.getExtraProperties( );
188 for ( Map.Entry<String, String> newProp : newConfig.getProperties( ).entrySet( ) )
190 props.put( newProp.getKey( ), newProp.getValue( ) );
194 private void updateConfig( CacheConfiguration newConfig, RedbackRuntimeConfiguration rbConfig )
196 org.apache.archiva.admin.model.beans.CacheConfiguration cacheConfig = rbConfig.getUsersCacheConfiguration( );
197 cacheConfig.setMaxElementsInMemory( newConfig.getMaxEntriesInMemory( ) );
198 cacheConfig.setMaxElementsOnDisk( newConfig.getMaxEntriesOnDisk( ) );
199 cacheConfig.setTimeToLiveSeconds( newConfig.getTimeToLiveSeconds( ) );
200 cacheConfig.setTimeToIdleSeconds( newConfig.getTimeToIdleSeconds( ) );
204 public SecurityConfiguration updateConfiguration( SecurityConfiguration newConfiguration ) throws ArchivaRestServiceException
206 if ( newConfiguration == null )
208 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.MISSING_DATA ), 400 );
212 RedbackRuntimeConfiguration conf = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
213 boolean userManagerChanged = !CollectionUtils.isEqualCollection( newConfiguration.getActiveUserManagers( ), conf.getUserManagerImpls( ) );
214 boolean rbacManagerChanged = !CollectionUtils.isEqualCollection( newConfiguration.getActiveRbacManagers( ), conf.getRbacManagerImpls( ) );
216 boolean ldapConfigured = false;
217 for ( String um : newConfiguration.getActiveUserManagers( ) )
219 if ( um.contains( "ldap" ) )
221 ldapConfigured = true;
224 if ( !ldapConfigured )
226 for ( String rbm : newConfiguration.getActiveRbacManagers( ) )
228 if ( rbm.contains( "ldap" ) )
230 ldapConfigured = true;
235 updateConfig( newConfiguration, conf );
236 redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( conf );
238 if ( userManagerChanged )
240 log.info( "user managerImpls changed to {} so reload it",
241 newConfiguration.getActiveUserManagers( ) );
242 userManager.initialize( );
245 if ( rbacManagerChanged )
247 log.info( "rbac manager changed to {} so reload it",
248 newConfiguration.getActiveRbacManagers( ) );
249 rbacManager.initialize( );
250 roleManager.initialize( );
253 if ( ldapConfigured )
257 ldapConnectionFactory.initialize( );
259 catch ( Exception e )
261 log.error( "Could not initialize LDAP connection factory: {}", e.getMessage( ) );
262 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_CF_INIT_FAILED, e.getMessage( ) ) );
265 Collection<PasswordRule> passwordRules = applicationContext.getBeansOfType( PasswordRule.class ).values( );
267 for ( PasswordRule passwordRule : passwordRules )
269 passwordRule.initialize( );
272 Collection<CookieSettings> cookieSettingsList =
273 applicationContext.getBeansOfType( CookieSettings.class ).values( );
275 for ( CookieSettings cookieSettings : cookieSettingsList )
277 cookieSettings.initialize( );
280 Collection<Authenticator> authenticators =
281 applicationContext.getBeansOfType( Authenticator.class ).values( );
283 for ( Authenticator authenticator : authenticators )
287 log.debug( "Initializing authenticatior " + authenticator.getId( ) );
288 authenticator.initialize( );
290 catch ( Exception e )
292 log.error( "Initialization of authenticator failed " + authenticator.getId( ), e );
296 if ( ldapConfigured )
300 ldapUserMapper.initialize( );
302 catch ( Exception e )
304 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_USER_MAPPER_INIT_FAILED, e.getMessage( ) ) );
308 catch ( RepositoryAdminException e )
310 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
314 return SecurityConfiguration.ofRedbackConfiguration( redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( ) );
316 catch ( RepositoryAdminException e )
318 log.error( "Error while retrieve updated configuration: {}", e.getMessage( ) );
319 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
324 public PagedResult<PropertyEntry> getConfigurationProperties( String searchTerm, Integer offset, Integer limit, List<String> orderBy, String order ) throws ArchivaRestServiceException
328 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
329 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
331 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
333 boolean ascending = PROP_QUERY_HELPER.isAscending( order );
334 Predicate<PropertyEntry> filter = PROP_QUERY_HELPER.getQueryFilter( searchTerm );
335 Comparator<PropertyEntry> comparator = PROP_QUERY_HELPER.getComparator( orderBy, ascending );
336 Map<String, String> props = redbackRuntimeConfiguration.getConfigurationProperties( );
337 int totalCount = props.size( );
338 List<PropertyEntry> result = props.entrySet( ).stream( ).map(
339 entry -> new PropertyEntry( entry.getKey( ), entry.getValue( ) )
341 .sorted( comparator )
342 .skip( offset ).limit( limit )
343 .collect( Collectors.toList( ) );
344 return new PagedResult<>( totalCount, offset, limit, result );
346 catch ( RepositoryAdminException e )
348 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
353 public PropertyEntry getConfigurationProperty( String propertyName ) throws ArchivaRestServiceException
357 RedbackRuntimeConfiguration conf = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
358 if ( conf.getConfigurationProperties( ).containsKey( propertyName ) )
360 String value = conf.getConfigurationProperties( ).get( propertyName );
361 return new PropertyEntry( propertyName, value );
365 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.PROPERTY_NOT_FOUND ), 404 );
369 catch ( RepositoryAdminException e )
371 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
377 public Response updateConfigurationProperty( String propertyName, PropertyEntry propertyValue ) throws ArchivaRestServiceException
379 if ( propertyValue == null )
381 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.MISSING_DATA ), 400 );
385 RedbackRuntimeConfiguration conf = redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
386 if ( conf.getConfigurationProperties( ).containsKey( propertyName ) )
388 conf.getConfigurationProperties( ).put( propertyName, propertyValue.getValue( ) );
389 redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( conf );
390 return Response.ok( ).build( );
394 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.PROPERTY_NOT_FOUND ), 404 );
398 catch ( RepositoryAdminException e )
400 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
405 public LdapConfiguration getLdapConfiguration( ) throws ArchivaRestServiceException
409 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
410 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
412 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
414 LdapConfiguration ldapConfig = LdapConfiguration.of( redbackRuntimeConfiguration.getLdapConfiguration( ) );
415 ldapConfig.setAvailableContextFactories( availableContextProviders );
418 catch ( RepositoryAdminException e )
420 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
426 public LdapConfiguration updateLdapConfiguration( LdapConfiguration configuration ) throws ArchivaRestServiceException
430 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
431 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
433 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
435 updateConfig( configuration, redbackRuntimeConfiguration );
437 redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
439 catch ( RepositoryAdminException e )
441 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
446 return LdapConfiguration.of( redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( ).getLdapConfiguration() );
448 catch ( RepositoryAdminException e )
450 log.error( "Error while retrieve updated configuration: {}", e.getMessage( ) );
451 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR, e.getMessage( ) ) );
456 static final Properties toProperties( Map<String, String> values )
458 Properties result = new Properties( );
459 for ( Map.Entry<String, String> entry : values.entrySet( ) )
461 result.setProperty( entry.getKey( ), entry.getValue( ) );
466 private static final boolean isContextFactoryAvailable(final String factoryClass)
470 return Thread.currentThread().getContextClassLoader().loadClass( factoryClass )
473 catch ( ClassNotFoundException e )
481 public Response verifyLdapConfiguration( LdapConfiguration ldapConfiguration ) throws ArchivaRestServiceException
483 LdapConnection ldapConnection = null;
486 LdapConnectionConfiguration ldapConnectionConfiguration =
487 new LdapConnectionConfiguration( ldapConfiguration.getHostName( ), ldapConfiguration.getPort( ),
488 ldapConfiguration.getBaseDn( ), ldapConfiguration.getContextFactory( ),
489 ldapConfiguration.getBindDn( ), ldapConfiguration.getBindPassword( ),
490 ldapConfiguration.getAuthenticationMethod( ),
491 toProperties( ldapConfiguration.getProperties( ) ) );
492 ldapConnectionConfiguration.setSsl( ldapConfiguration.isSslEnabled( ) );
494 ldapConnection = ldapConnectionFactory.getConnection( ldapConnectionConfiguration );
496 catch ( InvalidNameException e )
498 log.warn( "LDAP connection check failed with invalid name : {}", e.getMessage( ), e );
499 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_INVALID_NAME, e.getMessage( ) ), 400 );
501 catch ( LdapException e )
503 handleLdapException( e );
507 if ( ldapConnection != null )
509 ldapConnection.close( );
511 ldapConnection = null;
516 // verify groups dn value too
518 LdapConnectionConfiguration ldapConnectionConfiguration = new LdapConnectionConfiguration( ldapConfiguration.getHostName( ), ldapConfiguration.getPort( ),
519 ldapConfiguration.getGroupsBaseDn( ),
520 ldapConfiguration.getContextFactory( ), ldapConfiguration.getBindDn( ),
521 ldapConfiguration.getBindPassword( ),
522 ldapConfiguration.getAuthenticationMethod( ),
523 toProperties( ldapConfiguration.getProperties( ) ) );
525 ldapConnectionConfiguration.setSsl( ldapConfiguration.isSslEnabled( ) );
527 ldapConnection = ldapConnectionFactory.getConnection( ldapConnectionConfiguration );
529 catch ( InvalidNameException e )
531 log.warn( "LDAP connection check failed with invalid name : {}", e.getMessage( ), e );
532 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_INVALID_NAME, e.getMessage( ) ), 400 );
534 catch ( LdapException e )
536 handleLdapException( e );
540 if ( ldapConnection != null )
542 ldapConnection.close( );
546 return Response.ok( ).build( );
549 private void handleLdapException( LdapException e ) throws ArchivaRestServiceException
551 Throwable rootCause = e.getRootCause( );
552 if ( rootCause instanceof CommunicationException )
554 log.warn( "LDAP connection check failed with CommunicationException: {}", e.getMessage( ), e );
555 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_COMMUNICATION_ERROR, e.getMessage( ) ), 400 );
556 } else if (rootCause instanceof ServiceUnavailableException ) {
557 log.warn( "LDAP connection check failed with ServiceUnavailableException: {}", e.getMessage( ), e );
558 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_SERVICE_UNAVAILABLE, e.getMessage( ) ), 400 );
559 } else if (rootCause instanceof AuthenticationException ) {
560 log.warn( "LDAP connection check failed with AuthenticationException: {}", e.getMessage( ), e );
561 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_SERVICE_AUTHENTICATION_FAILED, e.getMessage( ) ), 400 );
562 } else if (rootCause instanceof AuthenticationNotSupportedException ) {
563 log.warn( "LDAP connection check failed with AuthenticationNotSupportedException: {}", e.getMessage( ), e );
564 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_SERVICE_AUTHENTICATION_NOT_SUPPORTED, e.getMessage( ) ), 400 );
565 } else if (rootCause instanceof NoPermissionException ) {
566 log.warn( "LDAP connection check failed with NoPermissionException: {}", e.getMessage( ), e );
567 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_SERVICE_NO_PERMISSION, e.getMessage( ) ), 400 );
569 log.warn( "LDAP connection check failed: {} - {}", e.getClass().getName(), e.getMessage( ), e );
570 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.LDAP_GENERIC_ERROR, e.getMessage( ) ), 400 );
574 public CacheConfiguration getCacheConfiguration( ) throws ArchivaRestServiceException
578 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
579 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
581 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
583 return CacheConfiguration.of( redbackRuntimeConfiguration.getUsersCacheConfiguration( ) );
585 catch ( RepositoryAdminException e )
587 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
593 public Response updateCacheConfiguration( CacheConfiguration cacheConfiguration ) throws ArchivaRestServiceException
595 if ( cacheConfiguration == null )
597 throw new ArchivaRestServiceException( ErrorMessage.of( ErrorKeys.MISSING_DATA ), 400 );
601 RedbackRuntimeConfiguration redbackRuntimeConfiguration =
602 redbackRuntimeConfigurationAdmin.getRedbackRuntimeConfiguration( );
604 log.debug( "getRedbackRuntimeConfiguration -> {}", redbackRuntimeConfiguration );
605 updateConfig( cacheConfiguration, redbackRuntimeConfiguration );
606 redbackRuntimeConfigurationAdmin.updateRedbackRuntimeConfiguration( redbackRuntimeConfiguration );
607 return Response.ok( ).build( );
609 catch ( RepositoryAdminException e )
611 throw new ArchivaRestServiceException( ErrorMessage.of( REPOSITORY_ADMIN_ERROR ) );
616 public List<BeanInformation> getAvailableUserManagers( ) throws ArchivaRestServiceException
618 Map<String, UserManager> beans = applicationContext.getBeansOfType( UserManager.class );
620 if ( beans.isEmpty( ) )
622 return Collections.emptyList( );
625 return beans.entrySet( ).stream( )
626 .filter( entry -> entry.getValue( ).isFinalImplementation( ) )
627 .map( ( Map.Entry<String, UserManager> entry ) -> {
628 UserManager um = entry.getValue( );
629 String id = StringUtils.substringAfter( entry.getKey( ), "#" );
630 String displayName = bundle.getString( "user_manager." + id + ".display_name" );
631 String description = bundle.getString( "user_manager." + id + ".description" );
632 return new BeanInformation( StringUtils.substringAfter( entry.getKey( ), "#" ), displayName, um.getDescriptionKey( ), description, um.isReadOnly( ) );
633 } ).collect( Collectors.toList( ) );
637 public List<BeanInformation> getAvailableRbacManagers( ) throws ArchivaRestServiceException
639 Map<String, RBACManager> beans = applicationContext.getBeansOfType( RBACManager.class );
641 if ( beans.isEmpty( ) )
643 return Collections.emptyList( );
646 return beans.entrySet( ).stream( )
647 .filter( entry -> entry.getValue( ).isFinalImplementation( ) )
648 .map( ( Map.Entry<String, RBACManager> entry ) -> {
649 RBACManager rm = entry.getValue( );
650 String id = StringUtils.substringAfter( entry.getKey( ), "#" );
651 String displayName = bundle.getString( "rbac_manager." + id + ".display_name" );
652 String description = bundle.getString( "rbac_manager." + id + ".description" );
653 return new BeanInformation( StringUtils.substringAfter( entry.getKey( ), "#" ), displayName, rm.getDescriptionKey( ), description, rm.isReadOnly( ) );
654 } ).collect( Collectors.toList( ) );