Javascript files for UI functionality loaded from configuration bean

pull/1192/merge
Justin Richer 2017-02-17 17:34:03 -05:00
parent 606dd2633b
commit c79b6da9d9
5 changed files with 138 additions and 9 deletions

View File

@ -0,0 +1,59 @@
/*******************************************************************************
* Copyright 2017 The MITRE Corporation
* and the MIT Internet Trust Consortium
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*******************************************************************************/
package org.mitre.openid.connect.config;
import java.util.Set;
/**
*
* Bean for UI (front-end) configuration to be read at start-up.
*
* @author jricher
*
*/
public class UIConfiguration {
private Set<String> jsFiles;
private Set<String> templateFiles;
/**
* @return the jsFiles
*/
public Set<String> getJsFiles() {
return jsFiles;
}
/**
* @param jsFiles the jsFiles to set
*/
public void setJsFiles(Set<String> jsFiles) {
this.jsFiles = jsFiles;
}
/**
* @return the templateFiles
*/
public Set<String> getTemplateFiles() {
return templateFiles;
}
/**
* @param templateFiles the templateFiles to set
*/
public void setTemplateFiles(Set<String> templateFiles) {
this.templateFiles = templateFiles;
}
}

View File

@ -258,6 +258,9 @@
<!--Import scheduled task configuration -->
<import resource="task-config.xml" />
<!-- Import configuration for front-end (JavaScript) UI components -->
<import resource="ui-config.xml" />
<!-- import application-local configuration information (such as bean definitions) -->
<import resource="local-config.xml" />

View File

@ -15,6 +15,16 @@
<!-- javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script type="text/javascript">
// set up a global variable for UI components to hang extensions off of
var ui = {
templates: [],
routes: []
};
</script>
<script type="text/javascript" src="resources/bootstrap2/js/bootstrap.js"></script>
<script type="text/javascript" src="resources/js/lib/underscore.js"></script>
<script type="text/javascript" src="resources/js/lib/backbone.js"></script>
@ -22,17 +32,12 @@
<script type="text/javascript" src="resources/js/lib/bootstrapx-clickover.js"></script>
<script type="text/javascript" src="resources/js/lib/bootstrap-sheet.js"></script>
<script type="text/javascript" src="resources/js/lib/bootpag.js"></script>
<script type="text/javascript" src="resources/js/lib/retina.js"></script>
<c:if test="${js != null && js != ''}">
<script type="text/javascript" src="resources/js/client.js"></script>
<script type="text/javascript" src="resources/js/grant.js"></script>
<script type="text/javascript" src="resources/js/scope.js"></script>
<script type="text/javascript" src="resources/js/whitelist.js"></script>
<script type="text/javascript" src="resources/js/dynreg.js"></script>
<script type="text/javascript" src="resources/js/rsreg.js"></script>
<script type="text/javascript" src="resources/js/token.js"></script>
<script type="text/javascript" src="resources/js/blacklist.js"></script>
<c:forEach var="file" items="${ ui.jsFiles }">
<script type="text/javascript" src="<c:out value="${ file }" />" ></script>
</c:forEach>
<script type="text/javascript" src="resources/js/admin.js"></script>
</c:if>
<script type="text/javascript" src="resources/js/lib/retina.js"></script>
</body>
</html>

View File

@ -0,0 +1,57 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2017 The MITRE Corporation
and the MIT Internet Trust Consortium
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:security="http://www.springframework.org/schema/security"
xmlns:oauth="http://www.springframework.org/schema/security/oauth2"
xsi:schemaLocation="http://www.springframework.org/schema/security/oauth2 http://www.springframework.org/schema/security/spring-security-oauth2-2.0.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.3.xsd
http://www.springframework.org/schema/security http://www.springframework.org/schema/security/spring-security-4.2.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.3.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd">
<!-- This file allows you to define components to the UI -->
<bean class="org.mitre.openid.connect.config.UIConfiguration" id="uiConfiguration">
<property name="jsFiles">
<set>
<value>resources/js/client.js</value>
<value>resources/js/grant.js</value>
<value>resources/js/scope.js</value>
<value>resources/js/whitelist.js</value>
<value>resources/js/dynreg.js</value>
<value>resources/js/rsreg.js</value>
<value>resources/js/token.js</value>
<value>resources/js/blacklist.js</value>
</set>
</property>
<property name="templateFiles">
<set>
</set>
</property>
</bean>
</beans>

View File

@ -23,6 +23,7 @@ import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.mitre.openid.connect.config.ConfigurationPropertiesBean;
import org.mitre.openid.connect.config.UIConfiguration;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
@ -38,10 +39,14 @@ public class ServerConfigInterceptor extends HandlerInterceptorAdapter {
@Autowired
private ConfigurationPropertiesBean config;
@Autowired
private UIConfiguration ui;
@Override
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
request.setAttribute("config", config);
request.setAttribute("ui", ui);
return true;
}