[MRM-1722] Use cookie settings from redback for rememberme feature

fix issues on not saved redbackRuntimeConfiguration.properties

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1424183 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2012-12-19 22:37:53 +00:00
parent d54308934c
commit 0ae2aff01e
10 changed files with 209 additions and 124 deletions

View File

@ -18,6 +18,8 @@ package org.apache.archiva.web.api;
* under the License.
*/
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.rest.api.services.ArchivaRuntimeConfigurationService;
import org.apache.archiva.web.runtime.ArchivaRuntimeInfo;
import org.apache.archiva.web.model.ApplicationRuntimeInfo;
import org.apache.commons.lang.StringUtils;
@ -44,6 +46,9 @@ public class DefaultRuntimeInfoService
private ArchivaRuntimeInfo archivaRuntimeInfo;
@Inject
private ArchivaRuntimeConfigurationService archivaRuntimeConfigurationService;
@Context
protected HttpServletRequest httpServletRequest;
@ -54,6 +59,7 @@ public class DefaultRuntimeInfoService
}
public ApplicationRuntimeInfo getApplicationRuntimeInfo( String locale )
throws ArchivaRestServiceException
{
ApplicationRuntimeInfo applicationRuntimeInfo = new ApplicationRuntimeInfo();
applicationRuntimeInfo.setBuildNumber( this.archivaRuntimeInfo.getBuildNumber() );
@ -65,6 +71,9 @@ public class DefaultRuntimeInfoService
new Locale( StringUtils.isEmpty( locale ) ? "en" : locale ) );
applicationRuntimeInfo.setTimestampStr( sfd.format( new Date( archivaRuntimeInfo.getTimestamp() ) ) );
applicationRuntimeInfo.setRedbackRuntimeConfiguration(
archivaRuntimeConfigurationService.getRedbackRuntimeConfigurationAdmin() );
return applicationRuntimeInfo;
}

View File

@ -18,6 +18,7 @@ package org.apache.archiva.web.api;
* under the License.
*/
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
import org.apache.archiva.web.model.ApplicationRuntimeInfo;
import org.apache.archiva.redback.authorization.RedbackAuthorization;
@ -39,7 +40,8 @@ public interface RuntimeInfoService
@GET
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@RedbackAuthorization(noRestriction = true)
ApplicationRuntimeInfo getApplicationRuntimeInfo( @PathParam( "locale" ) String locale );
ApplicationRuntimeInfo getApplicationRuntimeInfo( @PathParam("locale") String locale )
throws ArchivaRestServiceException;
@Path("logMissingI18n")

View File

@ -18,6 +18,8 @@ package org.apache.archiva.web.model;
* under the License.
*/
import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
import javax.xml.bind.annotation.XmlRootElement;
import java.util.Calendar;
@ -46,6 +48,8 @@ public class ApplicationRuntimeInfo
private String timestampStr;
private RedbackRuntimeConfiguration redbackRuntimeConfiguration;
public ApplicationRuntimeInfo()
{
this.devMode = Boolean.getBoolean( "archiva.devMode" );
@ -147,6 +151,16 @@ public class ApplicationRuntimeInfo
this.timestampStr = timestampStr;
}
public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
{
return redbackRuntimeConfiguration;
}
public void setRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
{
this.redbackRuntimeConfiguration = redbackRuntimeConfiguration;
}
@Override
public String toString()
{
@ -161,6 +175,7 @@ public class ApplicationRuntimeInfo
sb.append( ", logMissingI18n=" ).append( logMissingI18n );
sb.append( ", baseUrl='" ).append( baseUrl ).append( '\'' );
sb.append( ", timestampStr='" ).append( timestampStr ).append( '\'' );
sb.append( ", redbackRuntimeConfiguration=" ).append( redbackRuntimeConfiguration );
sb.append( '}' );
return sb.toString();
}

View File

@ -96,11 +96,12 @@ $.ajax({
"archiva.search": "archiva/search",
"archiva.proxy-connectors-rules": "archiva/proxy-connectors-rules",
"archiva.docs": "archiva/docs",
"archiva.main": "archiva/main"
"archiva.main": "archiva/main",
"archiva.knockout.properties": "archiva/knockout-properties"
}
});
requirejs(['jquery','jquery.tmpl','jquery.ui','i18n','sammy','startup','utils','domReady!','archiva.main'], function () {
requirejs(['jquery','jquery.tmpl','jquery.ui','i18n','sammy','startup','utils','domReady!','archiva.main','archiva.general-admin'], function () {
loadi18n(function () {
$.ajax({
url: "restServices/archivaUiServices/runtimeInfoService/archivaRuntimeInfo/"+usedLang(),
@ -110,6 +111,10 @@ $.ajax({
window.archivaJavascriptLog=data.javascriptLog;
window.archivaRuntimeInfo=data;
window.redbackRuntimeConfiguration=mapRedbackRuntimeConfiguration(data.redbackRuntimeConfiguration);
$.log("security.rememberme.enabled key value:"+ window.redbackRuntimeConfiguration.findPropertyValue('security.rememberme.enabled'));
require(['sammy','jquery','i18n','jquery.tmpl','archiva.main','utils','domReady!'],function () {
startArchivaApplication();
$("#loadingDiv").hide();

View File

@ -17,7 +17,7 @@
* under the License.
*/
define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout","knockout.simpleGrid",
"knockout.sortable","jquery.validate","bootstrap"]
"knockout.sortable","jquery.validate","bootstrap","archiva.knockout.properties"]
, function(jquery,i18n,utils,jqueryTmpl,ko) {
//-------------------------
@ -1169,6 +1169,16 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
self.modified(true);
$.log("configurationPropertiesEntries modified")
});
this.findPropertyValue=function(key){
for(var i=0;i<self.configurationPropertiesEntries().length;i++){
if(self.configurationPropertiesEntries()[i].key==key){
var val = self.configurationPropertiesEntries()[i].value;
$.log("findPropertyValue " + key + "->" + val);
return val;
}
}
}
}
mapRedbackRuntimeConfiguration=function(data){
@ -1252,6 +1262,24 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
this.usedUserManagerImpls=ko.observableArray([]);
self.gridViewModel = new ko.simpleGrid.viewModel({
data: self.redbackRuntimeConfiguration().configurationPropertiesEntries,
columns: [
{
headerText: $.i18n.prop('redback.runtime.properties.key.label'),
rowText: "key"
},
{
headerText: $.i18n.prop('redback.runtime.properties.value.label'),
rowText: "value"
}
],
pageSize: 10,//self.redbackRuntimeConfiguration().configurationPropertiesEntries.length,
gridUpdateCallBack: function(){
}
});
findUserManagerImplementationInformation=function(id){
for(var i= 0;i<self.userManagerImplementationInformations().length;i++){
$.log(id+""+self.userManagerImplementationInformations()[i].beanId);
@ -1358,14 +1386,13 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
var userMessages=$("#user-messages");
userMessages.html(mediumSpinnerImg());
self.redbackRuntimeConfiguration().userManagerImpls=ko.observableArray([]);
$.log("length:"+self.usedUserManagerImpls().length);
for(var i=0;i<self.usedUserManagerImpls().length;i++){
var beanId=self.usedUserManagerImpls()[i].beanId;
$.log("beanId:"+beanId);
self.redbackRuntimeConfiguration().userManagerImpls.push(beanId);
}
$.log("length:"+self.redbackRuntimeConfiguration().userManagerImpls().length);
$.log("json:"+ko.toJSON(self.redbackRuntimeConfiguration));
$.log("rememberme enabled:"+self.redbackRuntimeConfiguration().findPropertyValue("security.rememberme.enabled"));
$.ajax("restServices/archivaServices/archivaRuntimeConfigurationService/redbackRuntimeConfiguration",
{
type: "PUT",
@ -1426,11 +1453,12 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
type: "GET",
dataType: 'json',
success: function(data) {
// TODO use window.redbackRuntimeConfiguration ?
var redbackRuntimeConfiguration = mapRedbackRuntimeConfiguration(data);
var redbackRuntimeConfigurationViewModel =
new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations);
mainContent.html( $( "#runtime-configuration-main" ).tmpl() );
ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#runtime-configuration-content" ).get(0));
mainContent.html( $("#redback-runtime-configuration-main" ).tmpl() );
ko.applyBindings(redbackRuntimeConfigurationViewModel,$("#redback-runtime-configuration-content" ).get(0));
activatePopoverDoc();
}
});

View File

@ -359,14 +359,28 @@ require(["jquery","jquery.tmpl","i18n","knockout"], function(jquery,jqueryTmpl,i
*/
Entry=function(key,value,subscribeFn){
var self=this;
this.modified=ko.observable(false);
this.modified.subscribe(function(newValue){
$.log("Entry modified");
});
this.key=ko.observable(key);
this.key.subscribe(function(newValue){
self.modified(true);
if(subscribeFn){
this.key.subscribe(function(newValue){subscribeFn(newValue)});
subscribeFn(newValue)
}
});
this.value=ko.observable(value);
this.value.subscribe(function(newValue){
self.modified(true);
if(subscribeFn){
this.value.subscribe(function(newValue){$.log("value modified");subscribeFn(newValue);});
subscribeFn(newValue)
}
});
}
/**

View File

@ -366,6 +366,16 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
$.log("user not in cookie");
}
var rememberMe=window.redbackRuntimeConfiguration.findPropertyValue('security.rememberme.enabled');
$.log("rememberMe:"+rememberMe);
if (rememberMe!='true'){
$("#user-login-form-rememberme-label" ).hide();
$("#user-login-form-rememberme" ).attr("disabled","true");
if($("#user-login-form-rememberme" ).get(0 ).checked){
$("#user-login-form-rememberme" ).get(0 ).checked=false;
}
}
var userLoginForm = $("#user-login-form");
userLoginForm.validate({

View File

@ -886,11 +886,11 @@
</tbody>
</script>
<script type="text/html" id="runtime-configuration-main">
<script type="text/html" id="redback-runtime-configuration-main">
<div class="page-header">
<h2>${$.i18n.prop('redback-runtime-configuration.title')}</h2>
</div>
<div id="runtime-configuration-content" data-bind='template: {name:"redback-runtime-configuration-content-tmpl"}'>
<div id="redback-runtime-configuration-content" data-bind='template: {name:"redback-runtime-configuration-content-tmpl"}'>
</div>
</script>
@ -1013,8 +1013,23 @@
</div>
<div class="tab-pane" id="redback-runtime-properties-content">
<div class="well">
<table>
<table id="proxyConnectorsTable"
data-bind="simpleGrid: gridViewModel,simpleGridTemplate:'properties-grid',pageLinksId:'properties-grid-pagination'">
</table>
<div id="properties-grid-pagination"></div>
</div>
</div>
<div>
<button data-bind="click: saveRedbackRuntimeConfiguration,css:{ 'btn-warning': redbackRuntimeConfiguration().modified() | redbackRuntimeConfiguration().ldapConfiguration().modified() }"
id="redback-runtime-configuration-save"class="btn">${$.i18n.prop('save')}</button>
</div>
</script>
<script id='properties-grid' type='text/html'>
<thead>
<tr>
<th></th>
@ -1023,35 +1038,22 @@
</tr>
</thead>
<tbody>
{{each(i, property) redbackRuntimeConfiguration().configurationPropertiesEntries}}
{{each(i, row) itemsOnCurrentPage()}}
<tr>
<td>
{{var key = property.key}}
{{var key = row.key}}
<a class="popover-doc"
data-original-title="${$.i18n.prop('redback.runtime.properties.help.title')}"
data-content="${$.i18n.prop(key+'.help.content')}">
<span class="btn btn-info"><i class="icon-question-sign icon-white"></i></span>
</a>
</td>
<td><input type="text" class="input-xxlarge" value="${property.key}"></td>
<td><input type="text" class="input-xlarge" value="${property.value}"></td>
<td>${row.key}</td>
<td><input type="text" class="input-xxlarge" data-bind="value: row.value"></td>
</tr>
{{/each}}
</tbody>
</table>
</div>
</div>
<div>
<button data-bind="click: saveRedbackRuntimeConfiguration,css:{ 'btn-warning': redbackRuntimeConfiguration().modified() | redbackRuntimeConfiguration().ldapConfiguration().modified() }"
id="redback-archiva-runtime-configuration-save"class="btn">${$.i18n.prop('save')}</button>
</div>
</script>
<script id="configurationPropertiesEntries-tmpl" type="text/html">
</script>
<script id="redback-runtime-general-content-usermanagers" type="text/html">

View File

@ -47,7 +47,7 @@
</div>
<div class="modal-footer" id="modal-login-footer">
<div class="pull-left">
<label class="checkbox">
<label class="checkbox" id="user-login-form-rememberme-label">
<input type="checkbox" id="user-login-form-rememberme">${$.i18n.prop('rememberme')}
</label>
</div>