mirror of https://github.com/apache/archiva.git
[MRM-1732] dynamic configuration of users cache
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1425052 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
88979e943a
commit
738de86c70
|
@ -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.LdapConnectionConfiguration;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
import org.apache.archiva.redback.common.ldap.connection.LdapConnectionFactory;
|
||||||
import org.apache.archiva.redback.common.ldap.connection.LdapException;
|
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.CookieSettings;
|
||||||
import org.apache.archiva.redback.policy.PasswordRule;
|
import org.apache.archiva.redback.policy.PasswordRule;
|
||||||
import org.apache.archiva.redback.users.UserManager;
|
import org.apache.archiva.redback.users.UserManager;
|
||||||
|
@ -71,6 +72,10 @@ public class DefaultRedbackRuntimeConfigurationService
|
||||||
@Named(value = "ldapConnectionFactory#configurable")
|
@Named(value = "ldapConnectionFactory#configurable")
|
||||||
private LdapConnectionFactory ldapConnectionFactory;
|
private LdapConnectionFactory ldapConnectionFactory;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
@Named( value = "cache#users" )
|
||||||
|
private Cache usersCache;
|
||||||
|
|
||||||
public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
|
public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
|
||||||
throws ArchivaRestServiceException
|
throws ArchivaRestServiceException
|
||||||
{
|
{
|
||||||
|
@ -131,6 +136,10 @@ public class DefaultRedbackRuntimeConfigurationService
|
||||||
authenticator.initialize();
|
authenticator.initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// users cache
|
||||||
|
usersCache.setTimeToIdleSeconds( redbackRuntimeConfiguration.getUseUsersCacheTimeToIdleSeconds() );
|
||||||
|
usersCache.setTimeToLiveSeconds( redbackRuntimeConfiguration.getUseUsersCacheTimeToLiveSeconds() );
|
||||||
|
|
||||||
return Boolean.TRUE;
|
return Boolean.TRUE;
|
||||||
}
|
}
|
||||||
catch ( AuthenticationException e )
|
catch ( AuthenticationException e )
|
||||||
|
|
|
@ -261,6 +261,10 @@ public class ArchivaConfigurableUsersManager
|
||||||
user = userManager.getGuestUser();
|
user = userManager.getGuestUser();
|
||||||
if ( user != null )
|
if ( user != null )
|
||||||
{
|
{
|
||||||
|
if ( useUsersCache() )
|
||||||
|
{
|
||||||
|
usersCache.put( user.getUsername(), user );
|
||||||
|
}
|
||||||
return user;
|
return user;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1152,7 +1152,7 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
|
|
||||||
|
|
||||||
RedbackRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries
|
RedbackRuntimeConfiguration=function(userManagerImpls,ldapConfiguration,migratedFromRedbackConfiguration,configurationPropertiesEntries
|
||||||
,useUsersCache){
|
,useUsersCache,useUsersCacheTimeToIdleSeconds,useUsersCacheTimeToLiveSeconds){
|
||||||
$.log("new RedbackRuntimeConfiguration");
|
$.log("new RedbackRuntimeConfiguration");
|
||||||
var self=this;
|
var self=this;
|
||||||
this.modified=ko.observable(false);
|
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=ko.observable(useUsersCache);
|
||||||
this.useUsersCache.subscribe(function(newValue){self.modified(true)});
|
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){
|
mapRedbackRuntimeConfiguration=function(data){
|
||||||
|
@ -1196,7 +1203,8 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
$.log("mapLdapConfiguration done for ");
|
$.log("mapLdapConfiguration done for ");
|
||||||
|
|
||||||
var redbackRuntimeConfiguration =
|
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");
|
$.log("mapRedbackRuntimeConfiguration done");
|
||||||
var configurationPropertiesEntries = data.configurationPropertiesEntries == null ? []: $.each(data.configurationPropertiesEntries,function(item){
|
var configurationPropertiesEntries = data.configurationPropertiesEntries == null ? []: $.each(data.configurationPropertiesEntries,function(item){
|
||||||
|
|
|
@ -899,25 +899,12 @@
|
||||||
<li class="active" id="redback-runtime-general-li"><a href="#redback-runtime-general-content" data-toggle="tab">${$.i18n.prop('redback.runtime.general.title')}</a></li>
|
<li class="active" id="redback-runtime-general-li"><a href="#redback-runtime-general-content" data-toggle="tab">${$.i18n.prop('redback.runtime.general.title')}</a></li>
|
||||||
<li id="redback-runtime-ldap-li"><a href="#redback-runtime-ldap-content" data-toggle="tab">${$.i18n.prop('redback.runtime.ldap.title')}</a></li>
|
<li id="redback-runtime-ldap-li"><a href="#redback-runtime-ldap-content" data-toggle="tab">${$.i18n.prop('redback.runtime.ldap.title')}</a></li>
|
||||||
<li id="redback-runtime-properties-li"><a href="#redback-runtime-properties-content" data-toggle="tab">${$.i18n.prop('redback.runtime.properties.title')}</a></li>
|
<li id="redback-runtime-properties-li"><a href="#redback-runtime-properties-content" data-toggle="tab">${$.i18n.prop('redback.runtime.properties.title')}</a></li>
|
||||||
|
<li id="redback-runtime-users-cache-li"><a href="#redback-runtime-users-cache-content" data-toggle="tab">${$.i18n.prop('redback.runtime.users.cache.title')}</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
<div class="tab-content">
|
<div class="tab-content">
|
||||||
<div class="tab-pane active" id="redback-runtime-general-content">
|
<div class="tab-pane active" id="redback-runtime-general-content">
|
||||||
<div class="well">
|
<div class="well">
|
||||||
<div class="row-fluid">
|
|
||||||
<form class="form-horizontal" id="redback-runtime-general-form-id">
|
|
||||||
<div class="control-group">
|
|
||||||
<label for="redback-runtime-useUsersCache" class="control-label">
|
|
||||||
${$.i18n.prop('redback.runtime.useUsersCache.label')}
|
|
||||||
</label>
|
|
||||||
<div class="controls">
|
|
||||||
<input type="checkbox" id="redback-runtime-useUsersCache" name="redback-runtime-useUsersCache"
|
|
||||||
data-bind="checked: redbackRuntimeConfiguration().useUsersCache"/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</form>
|
|
||||||
</div>
|
|
||||||
<hr/>
|
|
||||||
<div class="row-fluid">
|
<div class="row-fluid">
|
||||||
<div class="span4 dotted">
|
<div class="span4 dotted">
|
||||||
<h5>${$.i18n.prop('redback.runtime.user-managers.impls.choosed')}</h5>
|
<h5>${$.i18n.prop('redback.runtime.user-managers.impls.choosed')}</h5>
|
||||||
|
@ -1034,7 +1021,43 @@
|
||||||
</table>
|
</table>
|
||||||
<div id="properties-grid-pagination"></div>
|
<div id="properties-grid-pagination"></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="tab-pane" id="redback-runtime-users-cache-content">
|
||||||
|
|
||||||
|
<div class="well">
|
||||||
|
|
||||||
|
|
||||||
|
<form class="form-horizontal" id="redback-runtime-general-form-id">
|
||||||
|
<div class="control-group">
|
||||||
|
<label for="redback-runtime-useUsersCache" class="control-label">${$.i18n.prop('redback.runtime.useUsersCache.label')}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="checkbox" id="redback-runtime-useUsersCache" name="redback-runtime-useUsersCache"
|
||||||
|
data-bind="checked: redbackRuntimeConfiguration().useUsersCache"/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="useUsersCacheTimeToLiveSeconds">${$.i18n.prop('redback.runtime.useUsersCacheTimeToLiveSeconds.label')}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" class="xlarge required numeric" data-bind="value: redbackRuntimeConfiguration().useUsersCacheTimeToLiveSeconds"
|
||||||
|
id="useUsersCacheTimeToLiveSeconds" name="useUsersCacheTimeToLiveSeconds" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="control-group">
|
||||||
|
<label class="control-label" for="useUsersCacheTimeToIdleSeconds">${$.i18n.prop('redback.runtime.useUsersCacheTimeToIdleSeconds.label')}</label>
|
||||||
|
<div class="controls">
|
||||||
|
<input type="text" class="xlarge required numeric" data-bind="value: redbackRuntimeConfiguration().useUsersCacheTimeToIdleSeconds"
|
||||||
|
id="useUsersCacheTimeToIdleSeconds" name="useUsersCacheTimeToIdleSeconds" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
</form>
|
||||||
|
|
||||||
|
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<button data-bind="click: saveRedbackRuntimeConfiguration,css:{ 'btn-warning': redbackRuntimeConfiguration().modified() | redbackRuntimeConfiguration().ldapConfiguration().modified() }"
|
<button data-bind="click: saveRedbackRuntimeConfiguration,css:{ 'btn-warning': redbackRuntimeConfiguration().modified() | redbackRuntimeConfiguration().ldapConfiguration().modified() }"
|
||||||
|
|
Loading…
Reference in New Issue