diff --git a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java index 362f093d8..eb2e22383 100644 --- a/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java +++ b/archiva-modules/archiva-web/archiva-rest/archiva-rest-services/src/main/java/org/apache/archiva/rest/services/DefaultRedbackRuntimeConfigurationService.java @@ -28,6 +28,7 @@ import org.apache.archiva.redback.common.ldap.connection.LdapConnection; import org.apache.archiva.redback.common.ldap.connection.LdapConnectionConfiguration; import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory; import org.apache.archiva.redback.common.ldap.connection.LdapException; +import org.apache.archiva.redback.components.cache.Cache; import org.apache.archiva.redback.policy.CookieSettings; import org.apache.archiva.redback.policy.PasswordRule; import org.apache.archiva.redback.users.UserManager; @@ -71,6 +72,10 @@ public class DefaultRedbackRuntimeConfigurationService @Named(value = "ldapConnectionFactory#configurable") private LdapConnectionFactory ldapConnectionFactory; + @Inject + @Named( value = "cache#users" ) + private Cache usersCache; + public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration() throws ArchivaRestServiceException { @@ -131,6 +136,10 @@ public class DefaultRedbackRuntimeConfigurationService authenticator.initialize(); } + // users cache + usersCache.setTimeToIdleSeconds( redbackRuntimeConfiguration.getUseUsersCacheTimeToIdleSeconds() ); + usersCache.setTimeToLiveSeconds( redbackRuntimeConfiguration.getUseUsersCacheTimeToLiveSeconds() ); + return Boolean.TRUE; } catch ( AuthenticationException e ) diff --git a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java index f73785d7f..e601643fc 100644 --- a/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java +++ b/archiva-modules/archiva-web/archiva-web-common/src/main/java/org/apache/archiva/web/security/ArchivaConfigurableUsersManager.java @@ -261,6 +261,10 @@ public class ArchivaConfigurableUsersManager user = userManager.getGuestUser(); if ( user != null ) { + if ( useUsersCache() ) + { + usersCache.put( user.getUsername(), user ); + } return user; } } diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js index 9b5fd25eb..aa80ffb3b 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/archiva/general-admin.js @@ -1152,7 +1152,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" RedbackRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries - ,useUsersCache){ + ,useUsersCache,useUsersCacheTimeToIdleSeconds,useUsersCacheTimeToLiveSeconds){ $.log("new RedbackRuntimeConfiguration"); var self=this; this.modified=ko.observable(false); @@ -1188,6 +1188,13 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" this.useUsersCache=ko.observable(useUsersCache); this.useUsersCache.subscribe(function(newValue){self.modified(true)}); + + this.useUsersCacheTimeToIdleSeconds=ko.observable(useUsersCacheTimeToIdleSeconds); + this.useUsersCacheTimeToIdleSeconds.subscribe(function(newValue){self.modified(true)}); + + this.useUsersCacheTimeToLiveSeconds=ko.observable(useUsersCacheTimeToLiveSeconds); + this.useUsersCacheTimeToLiveSeconds.subscribe(function(newValue){self.modified(true)}); + } mapRedbackRuntimeConfiguration=function(data){ @@ -1196,7 +1203,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout" $.log("mapLdapConfiguration done for "); var redbackRuntimeConfiguration = - new RedbackRuntimeConfiguration(data.userManagerImpls,ldapConfiguration,data.migratedFromRedbackConfiguration,[],data.useUsersCache); + new RedbackRuntimeConfiguration(data.userManagerImpls,ldapConfiguration,data.migratedFromRedbackConfiguration,[] + ,data.useUsersCache,data.useUsersCacheTimeToIdleSeconds,data.useUsersCacheTimeToLiveSeconds); $.log("mapRedbackRuntimeConfiguration done"); var configurationPropertiesEntries = data.configurationPropertiesEntries == null ? []: $.each(data.configurationPropertiesEntries,function(item){ diff --git a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html index f49127623..bc6caebd7 100644 --- a/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html +++ b/archiva-modules/archiva-web/archiva-webapp-js/src/main/webapp/js/templates/archiva/general-admin.html @@ -899,25 +899,12 @@