r4590 - trunk/src/edu/ucsb/nceas/metacat/admin
daigle at ecoinformatics.org
daigle at ecoinformatics.org
Wed Nov 19 15:25:56 PST 2008
Author: daigle
Date: 2008-11-19 15:25:56 -0800 (Wed, 19 Nov 2008)
New Revision: 4590
Added:
trunk/src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java
Removed:
trunk/src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java
trunk/src/edu/ucsb/nceas/metacat/admin/LDAPAdmin.java
Log:
Rename LDAPAdmin to AuthAdmin
Deleted: trunk/src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java
===================================================================
--- trunk/src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java 2008-11-19 23:25:09 UTC (rev 4589)
+++ trunk/src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java 2008-11-19 23:25:56 UTC (rev 4590)
@@ -1,176 +0,0 @@
-/**
- * '$RCSfile$'
- * Purpose: A Class that implements ldap configuration methods
- * Copyright: 2008 Regents of the University of California and the
- * National Center for Ecological Analysis and Synthesis
- * Authors: Michael Daigle
- *
- * '$Author$'
- * '$Date$'
- * '$Revision$'
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-package edu.ucsb.nceas.metacat.admin;
-
-import java.io.IOException;
-import java.util.Vector;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.log4j.Logger;
-
-import edu.ucsb.nceas.metacat.util.LDAPUtil;
-import edu.ucsb.nceas.metacat.util.OrganizationUtil;
-import edu.ucsb.nceas.metacat.util.RequestUtil;
-import edu.ucsb.nceas.metacat.util.UtilException;
-
-/**
- * Control the display of the LDAP configuration page and the processing
- * of the configuration values.
- */
-public class AuthAdmin extends MetaCatAdmin {
-
- private static AuthAdmin authAdmin = null;
- private static Logger logMetacat = Logger.getLogger(AuthAdmin.class);
-
- /**
- * private constructor since this is a singleton
- */
- private AuthAdmin() {}
-
- /**
- * Get the single instance of AuthAdmin.
- *
- * @return the single instance of AuthAdmin
- */
- public static AuthAdmin getInstance() {
- if (authAdmin == null) {
- authAdmin = new AuthAdmin();
- }
- return authAdmin;
- }
-
- /**
- * Handle configuration of the LDAP properties
- *
- * @param request
- * the http request information
- * @param response
- * the http response to be sent back to the client
- */
- public void authenticateUser(HttpServletRequest request,
- HttpServletResponse response) throws AdminException {
-
- String processForm = request.getParameter("processForm");
- String formErrors = (String) request.getAttribute("formErrors");
-
- if (processForm == null || !processForm.equals("true") || formErrors != null) {
- // The servlet configuration parameters have not been set, or there
- // were form errors on the last attempt to configure, so redirect to
- // the web form for configuring metacat
-
- try {
- // Forward the request to the JSP page
- RequestUtil.forwardRequest(request, response,
- "/admin/admin-login.jsp");
- } catch (IOException ioe) {
- throw new AdminException("IO problem while initializing "
- + "user login page:" + ioe.getMessage());
- } catch (ServletException se) {
- throw new AdminException("problem forwarding request while "
- + "initializing user login page: " + se.getMessage());
- }
- } else {
- // The configuration form is being submitted and needs to be
- // processed.
- Vector<String> processingSuccess = new Vector<String>();
- Vector<String> processingErrors = new Vector<String>();
- Vector<String> validationErrors = new Vector<String>();
-
- String loginString = null;
- Boolean isLoggedIn = false;
-
- try {
- String userName = request.getParameter("username");
- String organization = request.getParameter("organization");
- String password = request.getParameter("password");
-
- // Validate that the options provided are legitimate. Note that
- // we've allowed them to persist their entries. As of this point
- // there is no other easy way to go back to the configure form
- // and preserve their entries.
- validationErrors.addAll(validateOptions(request));
-
- if (validationErrors.size() == 0) {
- Vector<String> dnList = OrganizationUtil.getOrgDNs(organization);
- isLoggedIn = LDAPUtil.logUserIn(request, userName, organization, dnList, password);
- loginString = LDAPUtil.createLDAPString(userName, organization, dnList);
- }
-
- if (!isLoggedIn) {
- String errorMessage = "Could not log in as: " + loginString
- + " .Please try again";
- processingErrors.add(errorMessage);
- }
- } catch (UtilException ue) {
- String errorMessage = "Problem in utility while "
- + "processing authentication page: " + ue.getMessage();
- processingErrors.add(errorMessage);
- logMetacat.error(errorMessage);
- }
-
- try {
- if (validationErrors.size() > 0 || processingErrors.size() > 0) {
- RequestUtil.clearRequestMessages(request);
- RequestUtil.setRequestFormErrors(request, validationErrors);
- RequestUtil.setRequestErrors(request, processingErrors);
- RequestUtil.forwardRequest(request, response, "/admin");
- } else {
- // Reload the main metacat configuration page
- processingSuccess.add("User logged in as: " + loginString);
- RequestUtil.clearRequestMessages(request);
- RequestUtil.setUserId(request, loginString);
- RequestUtil.setRequestSuccess(request, processingSuccess);
- RequestUtil.forwardRequest(request, response,
- "/admin?configureType=configure&processForm=false");
- }
- } catch (IOException ioe) {
- throw new AdminException("IO problem while processing LDAP "
- + "properties page: " + ioe.getMessage());
- } catch (ServletException se) {
- throw new AdminException("problem forwarding request while "
- + "processoing LDAP properties page: " + se.getMessage());
- }
- }
- }
-
- /**
- * Validate the most important configuration options submitted by the user.
- *
- * @return a vector holding error message for any fields that fail
- * validation.
- */
- protected Vector<String> validateOptions(HttpServletRequest request) {
- Vector<String> errorVector = new Vector<String>();
-
- //TODO MCD validate options.
-
- return errorVector;
- }
-}
\ No newline at end of file
Copied: trunk/src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java (from rev 4547, trunk/src/edu/ucsb/nceas/metacat/admin/LDAPAdmin.java)
===================================================================
--- trunk/src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java (rev 0)
+++ trunk/src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java 2008-11-19 23:25:56 UTC (rev 4590)
@@ -0,0 +1,268 @@
+/**
+ * '$RCSfile$'
+ * Purpose: A Class that implements ldap configuration methods
+ * Copyright: 2008 Regents of the University of California and the
+ * National Center for Ecological Analysis and Synthesis
+ * Authors: Michael Daigle
+ *
+ * '$Author$'
+ * '$Date$'
+ * '$Revision$'
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package edu.ucsb.nceas.metacat.admin;
+
+import java.io.IOException;
+import java.net.ConnectException;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.Vector;
+
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.log4j.Logger;
+
+import edu.ucsb.nceas.metacat.AuthSession;
+import edu.ucsb.nceas.metacat.service.PropertyService;
+import edu.ucsb.nceas.metacat.util.RequestUtil;
+import edu.ucsb.nceas.utilities.FileUtil;
+import edu.ucsb.nceas.utilities.GeneralPropertyException;
+import edu.ucsb.nceas.utilities.MetaDataProperty;
+import edu.ucsb.nceas.utilities.PropertiesMetaData;
+import edu.ucsb.nceas.utilities.PropertyNotFoundException;
+import edu.ucsb.nceas.utilities.SortedProperties;
+import edu.ucsb.nceas.utilities.StringUtil;
+
+/**
+ * Control the display of the Authentication configuration page and the processing
+ * of the configuration values.
+ */
+public class AuthAdmin extends MetaCatAdmin {
+
+ private static AuthAdmin authAdmin = null;
+ private static Logger logMetacat = Logger.getLogger(AuthAdmin.class);
+
+ /**
+ * private constructor since this is a singleton
+ */
+ private AuthAdmin() {}
+
+ /**
+ * Get the single instance of the MetaCatConfig.
+ *
+ * @return the single instance of MetaCatConfig
+ */
+ public static AuthAdmin getInstance() {
+ if (authAdmin == null) {
+ authAdmin = new AuthAdmin();
+ }
+ return authAdmin;
+ }
+
+ /**
+ * Handle configuration of the Authentication properties
+ *
+ * @param request
+ * the http request information
+ * @param response
+ * the http response to be sent back to the client
+ */
+ public void configureAuth(HttpServletRequest request,
+ HttpServletResponse response) throws AdminException {
+
+ String processForm = request.getParameter("processForm");
+ String formErrors = (String) request.getAttribute("formErrors");
+
+ if (processForm == null || !processForm.equals("true") || formErrors != null) {
+ // The servlet configuration parameters have not been set, or there
+ // were form errors on the last attempt to configure, so redirect to
+ // the web form for configuring metacat
+
+ try {
+ // Load the properties metadata file so that the JSP page can
+ // use the metadata to construct the editing form
+ PropertiesMetaData metadata = PropertyService.getAuthMetaData();
+ request.setAttribute("metadata", metadata);
+ request.setAttribute("groupMap", metadata.getGroups());
+
+ // add the list of auth options and their values to the request
+ Vector<String> propertyNames = PropertyService.getPropertyNamesByGroup("auth");
+ for (String name : propertyNames) {
+ request.setAttribute(name, PropertyService.getProperty(name));
+ }
+
+ // Check for any backup properties and apply them to the request.
+ // These are properties from previous configurations. They keep
+ // the user from having to re-enter all values when upgrading.
+ // If this is a first time install, getBackupProperties will return
+ // null.
+ SortedProperties backupProperties = PropertyService.getAuthBackupProperties();
+ if (backupProperties != null) {
+ Vector<String> backupKeys = backupProperties.getPropertyNames();
+ for (String key : backupKeys) {
+ String value = backupProperties.getProperty(key);
+ if (value != null) {
+ request.setAttribute(key, value);
+ }
+ }
+ }
+ // Forward the request to the JSP page
+ RequestUtil.forwardRequest(request, response,
+ "/admin/auth-configuration.jsp");
+ } catch (PropertyNotFoundException pnfe) {
+ throw new AdminException("Problem getting property while initializing "
+ + "LDAP properties page: " + pnfe.getMessage());
+ } catch (IOException ioe) {
+ throw new AdminException("IO problem while initializing "
+ + "LDAP properties page:" + ioe.getMessage());
+ } catch (ServletException se) {
+ throw new AdminException("problem forwarding request while "
+ + "initializing LDAP properties page: " + se.getMessage());
+ }
+ } else {
+ // The configuration form is being submitted and needs to be
+ // processed.
+ Vector<String> processingSuccess = new Vector<String>();
+ Vector<String> processingErrors = new Vector<String>();
+ Vector<String> validationErrors = new Vector<String>();
+
+ try {
+ // For each property, check if it is changed and save it
+ PropertiesMetaData authMetaData = PropertyService
+ .getAuthMetaData();
+
+ // process the fields for the global options (group 1)
+ SortedMap<Integer, MetaDataProperty> globalPropertyMap = authMetaData
+ .getPropertiesInGroup(1);
+ Set<Integer> globalPropertyIndexes = globalPropertyMap.keySet();
+ for (Integer globalPropertyIndex : globalPropertyIndexes) {
+ String globalPropertyKey = globalPropertyMap.get(
+ globalPropertyIndex).getKey();
+ PropertyService.checkAndSetProperty(request,
+ globalPropertyKey);
+ }
+
+ // we need to write the options from memory to the properties
+ // file
+ PropertyService.persistProperties();
+
+ // Validate that the options provided are legitimate. Note that
+ // we've allowed them to persist their entries. As of this point
+ // there is no other easy way to go back to the configure form
+ // and preserve their entries.
+ validationErrors.addAll(validateOptions(request));
+
+ // Try to create data file and backup directories if
+ // necessary.
+ String backupDir = PropertyService.getBackupDir();
+ try {
+ FileUtil.createDirectory(backupDir);
+ } catch (IOException ioe) {
+ String errorString = "Could not create directory: " + backupDir
+ + " : " + ioe.getMessage();
+ logMetacat.error(errorString);
+ validationErrors.add(errorString);
+ }
+
+ // Write out the configurable properties to a backup file
+ // outside the install directory. Note that we allow them to
+ // do this even if they have validation errors. They will
+ // need to go back and fix the errors before they can run metacat.
+ PropertyService.persistAuthBackupProperties(request.getSession()
+ .getServletContext());
+
+ } catch (GeneralPropertyException gpe) {
+ String errorMessage = "Problem getting or setting property while "
+ + "processing LDAP properties page: " + gpe.getMessage();
+ logMetacat.error(errorMessage);
+ processingErrors.add(errorMessage);
+ }
+
+ try {
+ if (validationErrors.size() > 0 || processingErrors.size() > 0) {
+ RequestUtil.clearRequestMessages(request);
+ RequestUtil.setRequestFormErrors(request, validationErrors);
+ RequestUtil.setRequestErrors(request, processingErrors);
+ RequestUtil.forwardRequest(request, response, "/admin");
+ } else {
+ // Now that the options have been set, change the
+ // 'authConfigured' option to 'true'
+ PropertyService.setProperty("configutil.authConfigured",
+ PropertyService.CONFIGURED);
+
+ // Reload the main metacat configuration page
+ processingSuccess.add("Authentication successfully configured");
+ RequestUtil.clearRequestMessages(request);
+ RequestUtil.setRequestSuccess(request, processingSuccess);
+ RequestUtil.forwardRequest(request, response,
+ "/admin?configureType=configure&processForm=false");
+ }
+ } catch (ServletException se) {
+ throw new AdminException("problem forwarding request while "
+ + "processing LDAP properties page: " + se.getMessage());
+ } catch (IOException ioe) {
+ throw new AdminException("IO problem while processing Authentication "
+ + "properties page: " + ioe.getMessage());
+ } catch (GeneralPropertyException gpe) {
+ String errorMessage = "Problem getting or setting property while "
+ + "processing Authentication properties page: " + gpe.getMessage();
+ logMetacat.error(errorMessage);
+ processingErrors.add(errorMessage);
+ }
+ }
+ }
+
+ /**
+ * Validate the most important configuration options submitted by the user.
+ *
+ * @return a vector holding error message for any fields that fail
+ * validation.
+ */
+ protected Vector<String> validateOptions(HttpServletRequest request) {
+ Vector<String> errorVector = new Vector<String>();
+
+ String adminUsers = request.getParameter("auth.administrators");
+ Vector<String> adminUserList = StringUtil.toVector(adminUsers, ':');
+
+ try {
+ AuthSession authSession = new AuthSession();
+ for (String adminUser : adminUserList) {
+ try {
+ authSession.getAttributes(adminUser);
+ } catch (ConnectException ce) {
+ if (ce.getMessage() != null
+ && ce.getMessage().contains("NameNotFoundException")) {
+ errorVector.add("User : " + adminUser + " is not in LDAP.");
+ } else {
+ errorVector.add("Connection error while verifying Metacat " +
+ "Administrators : " + ce.getMessage());
+ }
+ }
+ }
+ } catch (InstantiationException ie) {
+ errorVector.add("Instantiation error while verifying Metacat Administrators : "
+ + ie.getMessage());
+ } catch (Exception e) {
+ errorVector.add("Error while verifying Metacat Administrators : "
+ + e.getMessage());
+ }
+
+ return errorVector;
+ }
+}
\ No newline at end of file
Property changes on: trunk/src/edu/ucsb/nceas/metacat/admin/AuthAdmin.java
___________________________________________________________________
Name: svn:executable
+ *
Name: svn:keywords
+ Author Date Id Revision
Name: svn:mergeinfo
+
Name: svn:eol-style
+ native
Deleted: trunk/src/edu/ucsb/nceas/metacat/admin/LDAPAdmin.java
===================================================================
--- trunk/src/edu/ucsb/nceas/metacat/admin/LDAPAdmin.java 2008-11-19 23:25:09 UTC (rev 4589)
+++ trunk/src/edu/ucsb/nceas/metacat/admin/LDAPAdmin.java 2008-11-19 23:25:56 UTC (rev 4590)
@@ -1,267 +0,0 @@
-/**
- * '$RCSfile$'
- * Purpose: A Class that implements ldap configuration methods
- * Copyright: 2008 Regents of the University of California and the
- * National Center for Ecological Analysis and Synthesis
- * Authors: Michael Daigle
- *
- * '$Author$'
- * '$Date$'
- * '$Revision$'
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
- */
-
-package edu.ucsb.nceas.metacat.admin;
-
-import java.io.IOException;
-import java.net.ConnectException;
-import java.util.HashMap;
-import java.util.Set;
-import java.util.SortedMap;
-import java.util.Vector;
-
-import javax.servlet.ServletException;
-import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
-
-import org.apache.log4j.Logger;
-
-import edu.ucsb.nceas.metacat.AuthLdap;
-import edu.ucsb.nceas.metacat.service.PropertyService;
-import edu.ucsb.nceas.metacat.util.RequestUtil;
-import edu.ucsb.nceas.utilities.FileUtil;
-import edu.ucsb.nceas.utilities.GeneralPropertyException;
-import edu.ucsb.nceas.utilities.MetaDataProperty;
-import edu.ucsb.nceas.utilities.PropertiesMetaData;
-import edu.ucsb.nceas.utilities.PropertyNotFoundException;
-import edu.ucsb.nceas.utilities.SortedProperties;
-import edu.ucsb.nceas.utilities.StringUtil;
-
-/**
- * Control the display of the LDAP configuration page and the processing
- * of the configuration values.
- */
-public class LDAPAdmin extends MetaCatAdmin {
-
- private static LDAPAdmin ldapAdmin = null;
- private static Logger logMetacat = Logger.getLogger(LDAPAdmin.class);
-
- /**
- * private constructor since this is a singleton
- */
- private LDAPAdmin() {}
-
- /**
- * Get the single instance of the MetaCatConfig.
- *
- * @return the single instance of MetaCatConfig
- */
- public static LDAPAdmin getInstance() {
- if (ldapAdmin == null) {
- ldapAdmin = new LDAPAdmin();
- }
- return ldapAdmin;
- }
-
- /**
- * Handle configuration of the LDAP properties
- *
- * @param request
- * the http request information
- * @param response
- * the http response to be sent back to the client
- */
- public void configureLDAP(HttpServletRequest request,
- HttpServletResponse response) throws AdminException {
-
- String processForm = request.getParameter("processForm");
- String formErrors = (String) request.getAttribute("formErrors");
-
- if (processForm == null || !processForm.equals("true") || formErrors != null) {
- // The servlet configuration parameters have not been set, or there
- // were form errors on the last attempt to configure, so redirect to
- // the web form for configuring metacat
-
- try {
- // Load the properties metadata file so that the JSP page can
- // use the metadata to construct the editing form
- PropertiesMetaData metadata = PropertyService.getLDAPMetaData();
- request.setAttribute("metadata", metadata);
- request.setAttribute("groupMap", metadata.getGroups());
-
- // add the list of ldap options and their values to the request
- Vector<String> propertyNames = PropertyService.getPropertyNamesByGroup("ldap");
- for (String name : propertyNames) {
- request.setAttribute(name, PropertyService.getProperty(name));
- }
-
- // Check for any backup properties and apply them to the request.
- // These are properties from previous configurations. They keep
- // the user from having to re-enter all values when upgrading.
- // If this is a first time install, getBackupProperties will return
- // null.
- SortedProperties backupProperties = PropertyService.getLDAPBackupProperties();
- if (backupProperties != null) {
- Vector<String> backupKeys = backupProperties.getPropertyNames();
- for (String key : backupKeys) {
- String value = backupProperties.getProperty(key);
- if (value != null) {
- request.setAttribute(key, value);
- }
- }
- }
- // Forward the request to the JSP page
- RequestUtil.forwardRequest(request, response,
- "/admin/ldap-configuration.jsp");
- } catch (PropertyNotFoundException pnfe) {
- throw new AdminException("Problem getting property while initializing "
- + "LDAP properties page: " + pnfe.getMessage());
- } catch (IOException ioe) {
- throw new AdminException("IO problem while initializing "
- + "LDAP properties page:" + ioe.getMessage());
- } catch (ServletException se) {
- throw new AdminException("problem forwarding request while "
- + "initializing LDAP properties page: " + se.getMessage());
- }
- } else {
- // The configuration form is being submitted and needs to be
- // processed.
- Vector<String> processingSuccess = new Vector<String>();
- Vector<String> processingErrors = new Vector<String>();
- Vector<String> validationErrors = new Vector<String>();
-
- try {
- // For each property, check if it is changed and save it
- PropertiesMetaData ldapMetaData = PropertyService
- .getLDAPMetaData();
-
- // process the fields for the global options (group 1)
- SortedMap<Integer, MetaDataProperty> globalPropertyMap = ldapMetaData
- .getPropertiesInGroup(1);
- Set<Integer> globalPropertyIndexes = globalPropertyMap.keySet();
- for (Integer globalPropertyIndex : globalPropertyIndexes) {
- String globalPropertyKey = globalPropertyMap.get(
- globalPropertyIndex).getKey();
- PropertyService.checkAndSetProperty(request,
- globalPropertyKey);
- }
-
- // we need to write the options from memory to the properties
- // file
- PropertyService.persistProperties();
-
- // Validate that the options provided are legitimate. Note that
- // we've allowed them to persist their entries. As of this point
- // there is no other easy way to go back to the configure form
- // and preserve their entries.
- validationErrors.addAll(validateOptions(request));
-
- // Try to create data file and backup directories if
- // necessary.
- String backupDir = PropertyService.getBackupDir();
- try {
- FileUtil.createDirectory(backupDir);
- } catch (IOException ioe) {
- String errorString = "Could not create directory: " + backupDir
- + " : " + ioe.getMessage();
- logMetacat.error(errorString);
- validationErrors.add(errorString);
- }
-
- // Write out the configurable properties to a backup file
- // outside the install directory. Note that we allow them to
- // do this even if they have validation errors. They will
- // need to go back and fix the errors before they can run metacat.
- PropertyService.persistLDAPBackupProperties(request.getSession()
- .getServletContext());
-
- } catch (GeneralPropertyException gpe) {
- String errorMessage = "Problem getting or setting property while "
- + "processing LDAP properties page: " + gpe.getMessage();
- logMetacat.error(errorMessage);
- processingErrors.add(errorMessage);
- }
-
- try {
- if (validationErrors.size() > 0 || processingErrors.size() > 0) {
- RequestUtil.clearRequestMessages(request);
- RequestUtil.setRequestFormErrors(request, validationErrors);
- RequestUtil.setRequestErrors(request, processingErrors);
- RequestUtil.forwardRequest(request, response, "/admin");
- } else {
- // Now that the options have been set, change the
- // 'ldapConfigured' option to 'true'
- PropertyService.setProperty("configutil.ldapConfigured",
- PropertyService.CONFIGURED);
-
- // Reload the main metacat configuration page
- processingSuccess.add("LDAP successfully configured");
- RequestUtil.clearRequestMessages(request);
- RequestUtil.setRequestSuccess(request, processingSuccess);
- RequestUtil.forwardRequest(request, response,
- "/admin?configureType=configure&processForm=false");
- }
- } catch (ServletException se) {
- throw new AdminException("problem forwarding request while "
- + "processing LDAP properties page: " + se.getMessage());
- } catch (IOException ioe) {
- throw new AdminException("IO problem while processing LDAP "
- + "properties page: " + ioe.getMessage());
- } catch (GeneralPropertyException gpe) {
- String errorMessage = "Problem getting or setting property while "
- + "processing LDAP properties page: " + gpe.getMessage();
- logMetacat.error(errorMessage);
- processingErrors.add(errorMessage);
- }
- }
- }
-
- /**
- * Validate the most important configuration options submitted by the user.
- *
- * @return a vector holding error message for any fields that fail
- * validation.
- */
- protected Vector<String> validateOptions(HttpServletRequest request) {
- Vector<String> errorVector = new Vector<String>();
-
- String adminUsers = request.getParameter("ldap.administrators");
- Vector<String> adminUserList = StringUtil.toVector(adminUsers, ':');
-
- try {
- AuthLdap authLdap = new AuthLdap();
- for (String adminUser : adminUserList) {
- try {
- authLdap.getAttributes(adminUser);
- } catch (ConnectException ce) {
- if (ce.getMessage() != null
- && ce.getMessage().contains("NameNotFoundException")) {
- errorVector.add("User : " + adminUser + " is not in LDAP.");
- } else {
- errorVector.add("Connection error while verifying Metacat " +
- "Administrators : " + ce.getMessage());
- }
- }
- }
- } catch (InstantiationException ie) {
- errorVector
- .add("Instantiation error while verifying Metacat Administrators : "
- + ie.getMessage());
- }
-
- return errorVector;
- }
-}
\ No newline at end of file
More information about the Metacat-cvs
mailing list