Project

General

Profile

1 4100 daigle
<%@ page language="java"%>
2 8529 tao
<%@ page import="java.util.Set,java.util.Map,java.util.Vector,edu.ucsb.nceas.utilities.*, edu.ucsb.nceas.metacat.properties.PropertyService" %>
3 4080 daigle
<%
4
	/**
5
 *  '$RCSfile$'
6
 *    Copyright: 2008 Regents of the University of California and the
7
 *               National Center for Ecological Analysis and Synthesis
8
 *  For Details: http://www.nceas.ucsb.edu/
9
 *
10
 *   '$Author$'
11
 *     '$Date$'
12
 * '$Revision$'
13
 *
14
 * This program is free software; you can redistribute it and/or modify
15
 * it under the terms of the GNU General Public License as published by
16
 * the Free Software Foundation; either version 2 of the License, or
17
 * (at your option) any later version.
18
 *
19
 * This program is distributed in the hope that it will be useful,
20
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 * GNU General Public License for more details.
23
 *
24
 * You should have received a copy of the GNU General Public License
25
 * along with this program; if not, write to the Free Software
26
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27
 */
28
%>
29
30
<html>
31
<head>
32
33 4583 daigle
<title>Authentication Configuration</title>
34 8240 walker
<%@ include file="./head-section.jsp"%>
35 4080 daigle
36 4753 daigle
<SCRIPT LANGUAGE="JavaScript" TYPE="TEXT/JAVASCRIPT">
37
<!--
38
	createExclusionList();
39
//-->
40
</SCRIPT>
41
42
43 4080 daigle
</head>
44
<body>
45 4557 daigle
<%@ include file="./header-section.jsp"%>
46
47 8222 walker
<div class="document">
48
		<h2>Authentication Configuration</h2>
49
		<p>Enter authentication service properties here.</p>
50
51
		<br class="auth-header">
52
53
		<%@ include file="./page-message-section.jsp"%>
54
55
56
		<form method="POST" name="configuration_form" action="<%= request.getContextPath() %>/admin"
57
		                                        onsubmit="return validateAndSubmitForm(this);">
58
		<%
59
			// metadata holds all group and properties metadata
60
		    PropertiesMetaData metadata = (PropertiesMetaData)request.getAttribute("metadata");
61
			if (metadata != null) {
62
				// each group describes a section of properties
63
				Map<Integer, MetaDataGroup> groupMap = metadata.getGroups();
64
				Set<Integer> groupIdSet = groupMap.keySet();
65
				for (Integer groupId : groupIdSet) {
66
					if (groupId == 0) {
67
						continue;
68 4258 daigle
					}
69 8222 walker
					// for this group, display the header (group name)
70
					MetaDataGroup metaDataGroup = (MetaDataGroup)groupMap.get(groupId);
71
		%>
72
				<h3><%= metaDataGroup.getName()  %></h3>
73
				<p><%= metaDataGroup.getDescription()  %></p>
74
		<%
75
					// get all the properties in this group
76
					Map<Integer, MetaDataProperty> propertyMap =
77
						metadata.getPropertiesInGroup(metaDataGroup.getIndex());
78
					Set<Integer> propertyIndexes = propertyMap.keySet();
79
					// iterate through each property and display appropriately
80
					for (Integer propertyIndex : propertyIndexes) {
81
						MetaDataProperty metaDataProperty = propertyMap.get(propertyIndex);
82
		    			String fieldType = metaDataProperty.getFieldType();
83
		    			if (metaDataProperty.getIsRequired()) {
84
		%>
85
						<SCRIPT LANGUAGE="JavaScript" TYPE="TEXT/JAVASCRIPT">
86
						<!--
87
							addExclusion("<%= metaDataProperty.getKey() %>");
88
						//-->
89
						</SCRIPT>
90
		<%
91
		    			}
92
		    			if (fieldType.equals("select")) {
93
		%>
94
						<div class="form-row">
95
		     				<div class="textinput-label"><label for="<%= metaDataProperty.getKey() %>"><%= metaDataProperty.getLabel() %></label></div>
96
							<select class="textinput" name="<%= metaDataProperty.getKey() %>">
97
		<%
98 8518 tao
		                    String storedValue = (String)request.getAttribute(metaDataProperty.getKey());
99 8222 walker
							Vector<String> fieldOptionValues = metaDataProperty.getFieldOptionValues();
100
							Vector<String> fieldOptionNames = metaDataProperty.getFieldOptionNames();
101
							for (int i = 0; i < fieldOptionNames.size(); i++) {
102 8518 tao
							     boolean foundStoredValue = false;
103
							     if(storedValue != null && !storedValue.equals("") && storedValue.equals(fieldOptionNames.elementAt(i))) {
104
							         foundStoredValue = true;
105
							     }
106
                             if(foundStoredValue) {
107
        %>
108
                                <option value="<%= fieldOptionValues.elementAt(i) %>" selected="selected"><%= fieldOptionNames.elementAt(i) %></option>
109
        <%
110
                              } else {
111
        %>
112
								<option value="<%= fieldOptionValues.elementAt(i) %>"><%= fieldOptionNames.elementAt(i) %></option>
113 8222 walker
		<%
114 8518 tao
		                      }
115 8222 walker
							}
116
		%>
117 8518 tao
118 8222 walker
							</select>
119
							<i class="icon-question-sign" onClick="helpWindow('<%= request.getContextPath() %>','<%= metaDataProperty.getHelpFile() %>')"></i>
120
121
						</div>
122
		<%
123
							if (metaDataProperty.getDescription() != null) {
124
		%>
125
								<div class="textinput-description">[<%= metaDataProperty.getDescription() %>]</div>
126
		<%
127
							}
128
						} else if (fieldType.equals("password")) {
129
		%>
130
						<div class="form-row">
131
							<div class="textinput-label"><label for="<%= metaDataProperty.getKey() %>"><%= metaDataProperty.getLabel() %></label></div>
132
							<input class="textinput" id="<%= metaDataProperty.getKey() %>" name="<%= metaDataProperty.getKey() %>"
133
			           		    	value="<%= request.getAttribute(metaDataProperty.getKey()) %>"
134
			           		    	type="<%= fieldType %>"/>
135
							<i class="icon-question-sign" onClick="helpWindow('<%= request.getContextPath() %>','<%= metaDataProperty.getHelpFile() %>')"></i>
136
						</div>
137
		<%
138
							if (metaDataProperty.getDescription() != null) {
139
		%>
140
								<div class="textinput-description">[<%= metaDataProperty.getDescription() %>]</div>
141
		<%
142
							}
143
						} else {
144
		%>
145
						<div class="form-row">
146 8529 tao
							<div class="textinput-label"><label for="<%= metaDataProperty.getKey() %>"><%= metaDataProperty.getLabel() %></label></div>
147
		<%
148
							if(metaDataProperty.getKey().equals("auth.userManagementUrl")) {
149
							     //System.out.println("getURL   ==== "+request.getRequestURL().toString());
150
							     //System.out.println("getURI   ==== "+request.getRequestURI());
151
							     //System.out.println("getServletpath   ==== "+request.getServletPath());
152
153
							     //System.out.println("getScheme   ==== "+request.getScheme());
154
							     //System.out.println("getServer name   ==== "+request.getServerName());
155
							     //System.out.println("getServer port   ==== "+request.getServerPort());
156
							     //System.out.println("getServer context ==== "+request.getContextPath());
157
                                 String userManagementUrl = (String)request.getAttribute(metaDataProperty.getKey());
158
                                 if(userManagementUrl == null || userManagementUrl.equals("")) {
159
                                    userManagementUrl = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath()+PropertyService.getProperty("auth.defaultUserManagementPage");
160
                                 }
161
        %>
162
                                 <input class="textinput" id="<%= metaDataProperty.getKey() %>" name="<%= metaDataProperty.getKey() %>"
163
                                    value="<%= userManagementUrl%>"
164
                                    type="<%= fieldType %>"/>
165
        <%
166
                             } else {
167
        %>
168
                                 <input class="textinput" id="<%= metaDataProperty.getKey() %>" name="<%= metaDataProperty.getKey() %>"
169
                                    value="<%= request.getAttribute(metaDataProperty.getKey()) %>"
170
                                    type="<%= fieldType %>  "/>
171
        <%
172
                             }
173
        %>
174
175 8222 walker
							<i class="icon-question-sign" onClick="helpWindow('<%= request.getContextPath() %>','<%= metaDataProperty.getHelpFile() %>')"></i>
176
									</div>
177
		<%
178
							if (metaDataProperty.getDescription() != null) {
179
		%>
180
								<div class="textinput-description">[<%= metaDataProperty.getDescription() %>]</div>
181
		<%
182
							}
183
						}
184 4258 daigle
					}
185 4159 daigle
				}
186
			}
187 8222 walker
		%>
188
189
		  <div class="buttons-wrapper">
190
		  	<input type="hidden" name="configureType" value="auth"/>
191
		  	<input type="hidden" name="processForm" value="true"/>
192
		  	<input class="button" type="submit" value="Save"/>
193
		  	<input class="button" type="button" value="Cancel" onClick="forward('./admin')">
194
		 </div>
195
		</form>
196
</div>
197 4557 daigle
<%@ include file="./footer-section.jsp"%>
198
199 4080 daigle
</body>
200
</html>