mirror of https://github.com/apache/archiva.git
reduce security informations returned by this public service
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1428920 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
f42e8368e7
commit
4a9e3f90a7
|
@ -18,10 +18,14 @@ package org.apache.archiva.web.api;
|
||||||
* under the License.
|
* under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
|
||||||
|
import org.apache.archiva.redback.configuration.UserConfigurationKeys;
|
||||||
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
import org.apache.archiva.rest.api.services.ArchivaRestServiceException;
|
||||||
import org.apache.archiva.rest.api.services.RedbackRuntimeConfigurationService;
|
import org.apache.archiva.rest.api.services.RedbackRuntimeConfigurationService;
|
||||||
|
import org.apache.archiva.web.model.CookieInformation;
|
||||||
import org.apache.archiva.web.runtime.ArchivaRuntimeInfo;
|
import org.apache.archiva.web.runtime.ArchivaRuntimeInfo;
|
||||||
import org.apache.archiva.web.model.ApplicationRuntimeInfo;
|
import org.apache.archiva.web.model.ApplicationRuntimeInfo;
|
||||||
|
import org.apache.commons.lang.BooleanUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
@ -71,8 +75,24 @@ public class DefaultRuntimeInfoService
|
||||||
new Locale( StringUtils.isEmpty( locale ) ? "en" : locale ) );
|
new Locale( StringUtils.isEmpty( locale ) ? "en" : locale ) );
|
||||||
applicationRuntimeInfo.setTimestampStr( sfd.format( new Date( archivaRuntimeInfo.getTimestamp() ) ) );
|
applicationRuntimeInfo.setTimestampStr( sfd.format( new Date( archivaRuntimeInfo.getTimestamp() ) ) );
|
||||||
|
|
||||||
applicationRuntimeInfo.setRedbackRuntimeConfiguration(
|
CookieInformation cookieInformation = new CookieInformation();
|
||||||
redbackRuntimeConfigurationService.getRedbackRuntimeConfiguration() );
|
|
||||||
|
RedbackRuntimeConfiguration redbackRuntimeConfiguration =
|
||||||
|
redbackRuntimeConfigurationService.getRedbackRuntimeConfiguration();
|
||||||
|
|
||||||
|
cookieInformation.setDomain(
|
||||||
|
redbackRuntimeConfiguration.getConfigurationProperties().get( UserConfigurationKeys.REMEMBER_ME_DOMAIN ) );
|
||||||
|
cookieInformation.setPath(
|
||||||
|
redbackRuntimeConfiguration.getConfigurationProperties().get( UserConfigurationKeys.REMEMBER_ME_PATH ) );
|
||||||
|
cookieInformation.setSecure(
|
||||||
|
redbackRuntimeConfiguration.getConfigurationProperties().get( UserConfigurationKeys.REMEMBER_ME_SECURE ) );
|
||||||
|
cookieInformation.setTimeout(
|
||||||
|
redbackRuntimeConfiguration.getConfigurationProperties().get( UserConfigurationKeys.REMEMBER_ME_TIMEOUT ) );
|
||||||
|
cookieInformation.setRememberMeEnabled( BooleanUtils.toBoolean(
|
||||||
|
redbackRuntimeConfiguration.getConfigurationProperties().get(
|
||||||
|
UserConfigurationKeys.REMEMBER_ME_ENABLED ) ) );
|
||||||
|
|
||||||
|
applicationRuntimeInfo.setCookieInformation( cookieInformation );
|
||||||
|
|
||||||
return applicationRuntimeInfo;
|
return applicationRuntimeInfo;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,7 @@ package org.apache.archiva.web.model;
|
||||||
import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
|
import org.apache.archiva.admin.model.beans.RedbackRuntimeConfiguration;
|
||||||
|
|
||||||
import javax.xml.bind.annotation.XmlRootElement;
|
import javax.xml.bind.annotation.XmlRootElement;
|
||||||
|
import java.io.Serializable;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -29,6 +30,7 @@ import java.util.Calendar;
|
||||||
*/
|
*/
|
||||||
@XmlRootElement(name = "applicationRuntimeInfo")
|
@XmlRootElement(name = "applicationRuntimeInfo")
|
||||||
public class ApplicationRuntimeInfo
|
public class ApplicationRuntimeInfo
|
||||||
|
implements Serializable
|
||||||
{
|
{
|
||||||
private boolean devMode = false;
|
private boolean devMode = false;
|
||||||
|
|
||||||
|
@ -48,7 +50,7 @@ public class ApplicationRuntimeInfo
|
||||||
|
|
||||||
private String timestampStr;
|
private String timestampStr;
|
||||||
|
|
||||||
private RedbackRuntimeConfiguration redbackRuntimeConfiguration;
|
private CookieInformation cookieInformation;
|
||||||
|
|
||||||
public ApplicationRuntimeInfo()
|
public ApplicationRuntimeInfo()
|
||||||
{
|
{
|
||||||
|
@ -151,14 +153,14 @@ public class ApplicationRuntimeInfo
|
||||||
this.timestampStr = timestampStr;
|
this.timestampStr = timestampStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public RedbackRuntimeConfiguration getRedbackRuntimeConfiguration()
|
public CookieInformation getCookieInformation()
|
||||||
{
|
{
|
||||||
return redbackRuntimeConfiguration;
|
return cookieInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRedbackRuntimeConfiguration( RedbackRuntimeConfiguration redbackRuntimeConfiguration )
|
public void setCookieInformation( CookieInformation cookieInformation )
|
||||||
{
|
{
|
||||||
this.redbackRuntimeConfiguration = redbackRuntimeConfiguration;
|
this.cookieInformation = cookieInformation;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -175,7 +177,7 @@ public class ApplicationRuntimeInfo
|
||||||
sb.append( ", logMissingI18n=" ).append( logMissingI18n );
|
sb.append( ", logMissingI18n=" ).append( logMissingI18n );
|
||||||
sb.append( ", baseUrl='" ).append( baseUrl ).append( '\'' );
|
sb.append( ", baseUrl='" ).append( baseUrl ).append( '\'' );
|
||||||
sb.append( ", timestampStr='" ).append( timestampStr ).append( '\'' );
|
sb.append( ", timestampStr='" ).append( timestampStr ).append( '\'' );
|
||||||
sb.append( ", redbackRuntimeConfiguration=" ).append( redbackRuntimeConfiguration );
|
sb.append( ", cookieInformation=" ).append( cookieInformation );
|
||||||
sb.append( '}' );
|
sb.append( '}' );
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,9 +110,7 @@ $.ajax({
|
||||||
window.archivaJavascriptLog=data.javascriptLog;
|
window.archivaJavascriptLog=data.javascriptLog;
|
||||||
window.archivaRuntimeInfo=data;
|
window.archivaRuntimeInfo=data;
|
||||||
|
|
||||||
window.redbackRuntimeConfiguration=mapRedbackRuntimeConfiguration(data.redbackRuntimeConfiguration);
|
window.cookieInformation=mapCookieInformation(data.cookieInformation);
|
||||||
|
|
||||||
$.log("security.rememberme.enabled key value:"+ window.redbackRuntimeConfiguration.findPropertyValue('security.rememberme.enabled'));
|
|
||||||
|
|
||||||
require(['sammy','jquery','i18n','jquery.tmpl','archiva.main','utils','domReady!'],function () {
|
require(['sammy','jquery','i18n','jquery.tmpl','archiva.main','utils','domReady!'],function () {
|
||||||
startArchivaApplication();
|
startArchivaApplication();
|
||||||
|
|
|
@ -1612,7 +1612,6 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
type: "GET",
|
type: "GET",
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
// TODO use window.redbackRuntimeConfiguration ?
|
|
||||||
var redbackRuntimeConfiguration = mapRedbackRuntimeConfiguration(data);
|
var redbackRuntimeConfiguration = mapRedbackRuntimeConfiguration(data);
|
||||||
var redbackRuntimeConfigurationViewModel =
|
var redbackRuntimeConfigurationViewModel =
|
||||||
new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations);
|
new RedbackRuntimeConfigurationViewModel(redbackRuntimeConfiguration,userManagerImplementationInformations);
|
||||||
|
@ -1653,4 +1652,28 @@ define("archiva.general-admin",["jquery","i18n","utils","jquery.tmpl","knockout"
|
||||||
return new CacheConfiguration(data.timeToIdleSeconds,data.timeToLiveSeconds,data.maxElementsInMemory,data.maxElementsOnDisk);
|
return new CacheConfiguration(data.timeToIdleSeconds,data.timeToLiveSeconds,data.maxElementsInMemory,data.maxElementsOnDisk);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CookieInformation=function(path,domain,secure,timeout,rememberMeEnabled){
|
||||||
|
//private String path;
|
||||||
|
this.path=path;
|
||||||
|
|
||||||
|
//private String domain;
|
||||||
|
this.domain=domain;
|
||||||
|
|
||||||
|
//private String secure;
|
||||||
|
this.secure=secure;
|
||||||
|
|
||||||
|
//private String timeout;
|
||||||
|
this.timeout=timeout;
|
||||||
|
|
||||||
|
//private boolean rememberMeEnabled;
|
||||||
|
this.rememberMeEnabled=rememberMeEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
mapCookieInformation=function(data){
|
||||||
|
if(!data){
|
||||||
|
return new CookieInformation();
|
||||||
|
}
|
||||||
|
return new CookieInformation(data.path,data.domain,data.secure,data.timeout,data.rememberMeEnabled);
|
||||||
|
}
|
||||||
|
|
||||||
});
|
});
|
|
@ -29,13 +29,13 @@ function(jquery,ui,sammy,tmpl,i18n,jqueryCookie,bootstrap,archivaSearch,jqueryVa
|
||||||
*/
|
*/
|
||||||
reccordLoginCookie=function(user) {
|
reccordLoginCookie=function(user) {
|
||||||
|
|
||||||
var path = window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.path");
|
var path = window.cookieInformation.path;
|
||||||
path = path ? path : "/";
|
path = path ? path : "/";
|
||||||
|
|
||||||
var domain = window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.domain");
|
var domain = window.cookieInformation.domain;
|
||||||
var secure = window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.secure");
|
var secure = window.cookieInformation.secure;
|
||||||
|
|
||||||
var expires= Number(window.redbackRuntimeConfiguration.findPropertyValue("security.rememberme.timeout"));
|
var expires= Number(window.cookieInformation.timeout);
|
||||||
|
|
||||||
var userJson=ko.toJSON(user);
|
var userJson=ko.toJSON(user);
|
||||||
|
|
||||||
|
|
|
@ -366,9 +366,9 @@ function(jquery,utils,i18n,jqueryValidate,ko,koSimpleGrid,purl) {
|
||||||
$.log("user not in cookie");
|
$.log("user not in cookie");
|
||||||
}
|
}
|
||||||
|
|
||||||
var rememberMe=window.redbackRuntimeConfiguration.findPropertyValue('security.rememberme.enabled');
|
var rememberMe=window.cookieInformation.rememberMeEnabled;
|
||||||
$.log("rememberMe:"+rememberMe);
|
$.log("rememberMe:"+rememberMe);
|
||||||
if (rememberMe=='false'){
|
if (rememberMe=='true'){
|
||||||
$("#user-login-form-rememberme-label" ).hide();
|
$("#user-login-form-rememberme-label" ).hide();
|
||||||
$("#user-login-form-rememberme" ).attr("disabled","true");
|
$("#user-login-form-rememberme" ).attr("disabled","true");
|
||||||
if($("#user-login-form-rememberme" ).get(0 ).checked){
|
if($("#user-login-form-rememberme" ).get(0 ).checked){
|
||||||
|
|
Loading…
Reference in New Issue