Project

General

Profile

1
<%@ page language="java"%>
2
<%@ page import="java.util.Set,java.util.Map,java.util.Vector,edu.ucsb.nceas.utilities.*, edu.ucsb.nceas.metacat.properties.PropertyService, edu.ucsb.nceas.metacat.admin.AuthAdmin" %>
3
<%
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: tao $'
11
 *     '$Date: 2014-01-24 16:32:36 -0800 (Fri, 24 Jan 2014) $'
12
 * '$Revision: 8533 $'
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
<title>Authentication Configuration</title>
34
<%@ include file="./head-section.jsp"%>
35
<script language="javascript" type="text/javascript" src="<%= request.getContextPath() %>/style/common/jquery/jquery.js"></script>
36

    
37
<SCRIPT LANGUAGE="JavaScript" TYPE="TEXT/JAVASCRIPT">
38
<!--
39
	createExclusionList();
40
//-->
41
</SCRIPT>
42

    
43

    
44
</head>
45
<body>
46
<%@ include file="./header-section.jsp"%>
47

    
48
<div class="document">
49
		<h2>Authentication Configuration</h2>
50
		<p>Enter authentication service properties here.</p>
51
		 
52
		<br class="auth-header">
53
		
54
		<%@ include file="./page-message-section.jsp"%>
55
		
56
		
57
		<form method="POST" name="configuration_form" action="<%= request.getContextPath() %>/admin" 
58
		                                        onsubmit="return validateAndSubmitForm(this);">
59
		<% 
60
		    
61
			// metadata holds all group and properties metadata
62
		    PropertiesMetaData metadata = (PropertiesMetaData)request.getAttribute("metadata");
63
			if (metadata != null) {
64
				// each group describes a section of properties
65
				Map<Integer, MetaDataGroup> groupMap = metadata.getGroups();
66
				Set<Integer> groupIdSet = groupMap.keySet();
67
				for (Integer groupId : groupIdSet) {
68
					if (groupId == 0) {
69
						continue;
70
					}
71
					// for this group, display the header (group name)
72
					MetaDataGroup metaDataGroup = (MetaDataGroup)groupMap.get(groupId);
73
		%>
74
		    <div id="<%= metaDataGroup.getName().replace(' ','_') %>">
75
				<h3><%= metaDataGroup.getName()  %></h3>
76
				<p><%= metaDataGroup.getDescription()  %></p>
77
		<%
78
					// get all the properties in this group
79
					Map<Integer, MetaDataProperty> propertyMap = 
80
						metadata.getPropertiesInGroup(metaDataGroup.getIndex());
81
					Set<Integer> propertyIndexes = propertyMap.keySet();
82
					// iterate through each property and display appropriately
83
					for (Integer propertyIndex : propertyIndexes) {
84
						MetaDataProperty metaDataProperty = propertyMap.get(propertyIndex);
85
		    			String fieldType = metaDataProperty.getFieldType(); 
86
		    			if (metaDataProperty.getIsRequired()) {
87
		%>
88
						
89
		<% 		
90
		    			}
91
		    			if (fieldType.equals("select")) {
92
		%> 
93
						<div class="form-row">
94
		     				<div class="textinput-label"><label for="<%= metaDataProperty.getKey() %>"><%= metaDataProperty.getLabel() %></label></div>	   	
95
							<select class="textinput" id="<%= metaDataProperty.getKey().replace('.', '_') %>" name="<%= metaDataProperty.getKey() %>">
96
		<%
97
		                    String storedValue = (String)request.getAttribute(metaDataProperty.getKey());
98
							Vector<String> fieldOptionValues = metaDataProperty.getFieldOptionValues();
99
							Vector<String> fieldOptionNames = metaDataProperty.getFieldOptionNames();
100
							for (int i = 0; i < fieldOptionNames.size(); i++) {
101
							     boolean foundStoredValue = false;
102
							     if(storedValue != null && !storedValue.equals("") && storedValue.equals(fieldOptionNames.elementAt(i))) {
103
							         foundStoredValue = true;
104
							     }
105
                             if(foundStoredValue) {
106
        %>
107
                                <option value="<%= fieldOptionValues.elementAt(i) %>" selected="selected"><%= fieldOptionNames.elementAt(i) %></option>
108
        <%
109
                              } else {
110
        %>
111
								<option value="<%= fieldOptionValues.elementAt(i) %>"><%= fieldOptionNames.elementAt(i) %></option>
112
		<%
113
		                      }
114
							}
115
							
116
		%>
117
		
118
							</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
							<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
							<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
					}
185
		%>
186
				  </div>
187
		<%
188
				}
189
			}
190
		%>
191
		
192
		<%
193
		      String FILEGROUPNAME = "File-based_Authentication_Configuration";
194
		      String LDAPGROUPNAME = "LDAP_Authentication_Configuration";
195
		      String AUTHCLASSID = "auth_class";
196
		%>
197
		<script language="javascript" type="text/javascript">
198
		      //this is for the first loading
199
		      taggleLdapFileConfig();
200
		
201
		      //this is for the user to change to different authentication class.
202
		      $('#<%=AUTHCLASSID%>').change(function(){
203
		          taggleLdapFileConfig();
204
		      });
205
		      
206
		      function taggleLdapFileConfig() {
207
		          if($("#<%=AUTHCLASSID%> option:selected" ).text() == '<%=AuthAdmin.LDAPCLASS%>') {
208
                      $('#<%=FILEGROUPNAME%>').css('display', 'none');
209
                      $('#<%=LDAPGROUPNAME%>').css('display', 'block');
210
                  } else if($("#<%=AUTHCLASSID%> option:selected" ).text() == '<%=AuthAdmin.FILECLASS%>') {
211
                      $('#<%=LDAPGROUPNAME%>').css('display', 'none');
212
                      $('#<%=FILEGROUPNAME%>').css('display', 'block');
213
                  }
214
		      }
215
		</script>
216
		
217
		  <div class="buttons-wrapper">
218
		  	<input type="hidden" name="configureType" value="auth"/>
219
		  	<input type="hidden" name="processForm" value="true"/>
220
		  	<input class="button" type="submit" value="Save"/>
221
		  	<input class="button" type="button" value="Cancel" onClick="forward('./admin')"> 
222
		 </div>
223
		</form>
224
</div>
225
<%@ include file="./footer-section.jsp"%>
226

    
227
</body>
228
</html>
(4-4/20)