Index: lib/workflowscheduler/workflowscheduler.properties
===================================================================
--- lib/workflowscheduler/workflowscheduler.properties	(revision 5056)
+++ lib/workflowscheduler/workflowscheduler.properties	(revision 5057)
@@ -151,6 +151,8 @@
 ######## Workflow engine section              #########################################
 executionEngine.endPointAddress=http://localhost:8080/axis2/services/KeplerWebService
 
+workflowScheduler.authServiceUrl=http://indus.msi.ucsb.edu/knb/services/AuthenticationService
+
 ######## junit test section  ################
 
 test.printdebug=true
Index: lib/style/skins/sanparks/SaeonLogin.jspx
===================================================================
--- lib/style/skins/sanparks/SaeonLogin.jspx	(revision 5056)
+++ lib/style/skins/sanparks/SaeonLogin.jspx	(revision 5057)
@@ -76,6 +76,9 @@
 			clientViewHelper = ClientViewHelper.clientViewHelperInstance(request);
 			clientViewHelper.clientRequest(request, response);
         </jsp:scriptlet>
+		<script type="text/javascript" >		
+				setCookie('JSESSIONID','<jsp:getProperty name="clientViewBean" property="sessionid" />','<jsp:expression>request.getContextPath()</jsp:expression>');
+		</script>
 
 	<table>
 	<tr>
Index: lib/style/skins/sanparks/sanparks.js
===================================================================
--- lib/style/skins/sanparks/sanparks.js	(revision 5056)
+++ lib/style/skins/sanparks/sanparks.js	(revision 5057)
@@ -226,3 +226,9 @@
 function trim(stringToTrim) {
   return stringToTrim.replace(/^\s*/, '').replace(/\s*$/,'');
 }
+
+function setCookie(cookieName, sessionId, context) {
+	if (sessionId != "null") {
+		document.cookie = cookieName + "=" + sessionId + ";path=" + context;
+	}	
+}
Index: workflowscheduler.build.xml
===================================================================
--- workflowscheduler.build.xml	(revision 5056)
+++ workflowscheduler.build.xml	(revision 5057)
@@ -60,6 +60,10 @@
 			</fileset>
 			<fileset dir="lib/lsid_lib">
 				<include name="commons-logging-1.0.4.jar" />
+				<include name="commons-discovery.jar" />
+				<include name="commons-discovery-0.2.jar" />
+				<include name="wsdl4j-1.5.1.jar" />
+				<include name="saaj.jar" />
 				<include name="axis.jar" />
 				<include name="jaxrpc.jar" />
 			</fileset>
@@ -66,6 +70,9 @@
 			<fileset dir="lib/spatial/geoserver/WEB-INF/lib">
 				<include name="commons-httpclient-2.0.jar" />
 			</fileset>
+			<fileset dir="../seek/projects/ecogrid/build/lib">
+				<include name="org.ecoinformatics.ecogrid.AuthenticationService-stub.jar" />
+			</fileset>
 		</path>
 
 		<!-- It is less likely you'll need to make any changes from here down,
@@ -106,6 +113,7 @@
 		<property name="ver.dir.hle"
 			value="${dist.dir.hle}/harvest-list-editor-${release}" />
 		<property name="pkg.dir" value="./package" />
+		<property name="ecogrid.stublib.dir" value="../seek/projects/ecogrid/build/lib" />
 
 		<property name="package.home" value="edu/ucsb/nceas/metacat" />
 
@@ -303,6 +311,10 @@
 			</fileset>
 			<fileset dir="lib/lsid_lib">
 				<include name="commons-logging-1.0.4.jar" />
+				<include name="commons-discovery.jar" />
+				<include name="commons-discovery-0.2.jar" />
+				<include name="wsdl4j-1.5.1.jar" />
+				<include name="saaj.jar" />
 				<include name="axis.jar" />
 				<include name="jaxrpc.jar" />
 			</fileset>
@@ -309,6 +321,9 @@
 			<fileset dir="lib/spatial/geoserver/WEB-INF/lib">
 				<include name="commons-httpclient-2.0.jar" />
 			</fileset>
+			<fileset dir="${ecogrid.stublib.dir}">
+				<include name="org.ecoinformatics.ecogrid.AuthenticationService-stub.jar" />
+			</fileset>
 		</copy>
 
 		<!-- MCD added next - Remove the tomcat5 reference-->
Index: src/edu/ucsb/nceas/workflowscheduler/WorkflowScheduler.java
===================================================================
--- src/edu/ucsb/nceas/workflowscheduler/WorkflowScheduler.java	(revision 5056)
+++ src/edu/ucsb/nceas/workflowscheduler/WorkflowScheduler.java	(revision 5057)
@@ -28,6 +28,7 @@
 
 import java.io.IOException;
 import java.io.PrintWriter;
+import java.io.StringReader;
 import java.util.Calendar;
 import java.util.Hashtable;
 import java.util.HashMap;
@@ -34,19 +35,27 @@
 
 import javax.servlet.http.HttpServletRequest;
 import javax.servlet.http.HttpServletResponse;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
 
 import org.apache.log4j.Logger;
 
+import org.xml.sax.InputSource;
+
+import org.ecoinformatics.ecogrid.client.AuthenticationServiceClient;
+
 import edu.ucsb.nceas.metacat.scheduler.BaseScheduler;
 import edu.ucsb.nceas.metacat.scheduler.ScheduledJobAccess;
 import edu.ucsb.nceas.metacat.scheduler.ScheduledJobDAO;
 import edu.ucsb.nceas.metacat.scheduler.SchedulerService;
 import edu.ucsb.nceas.metacat.scheduler.MetacatSchedulerException;
+import edu.ucsb.nceas.metacat.properties.PropertyService;
 import edu.ucsb.nceas.metacat.shared.AccessException;
 import edu.ucsb.nceas.metacat.shared.ServiceException;
 import edu.ucsb.nceas.metacat.util.ErrorSendingErrorException;
 import edu.ucsb.nceas.metacat.util.ResponseUtil;
 import edu.ucsb.nceas.utilities.DateUtil;
+import edu.ucsb.nceas.utilities.PropertyNotFoundException;
 import edu.ucsb.nceas.utilities.UtilException;
 
 /**
@@ -94,9 +103,9 @@
 	 *            the user's group
 	 */
 	public void scheduleJob(HttpServletRequest request, HttpServletResponse response, 
-			Hashtable<String, String[]> params, String username,
-			String[] groups) throws MetacatSchedulerException {
-		 		
+			Hashtable<String, String[]> params) throws MetacatSchedulerException {
+		 
+		String sessionIds[] = params.get("sessionid");
 		String delays[] = params.get("delay");
 		String startTimes[] = params.get("starttime");
 		String endTimes[] = params.get("endtime");
@@ -103,7 +112,20 @@
 		HashMap<String, String> jobParams = new HashMap<String, String>();
 		Calendar startCal = null;
 		Calendar endCal = null;
-
+		
+		if (sessionIds == null) {
+			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - sessionid field must be populated "
+							+ "in scheduler parameters when scheduling job.");
+		}
+		
+		String sessionStatus = validateRemoteSession(sessionIds[0]);
+		logMetacat.debug("WorkflowScheduler.scheduleJob - session status: " + sessionStatus);
+		
+		if (!sessionStatus.equals("valid")) {
+			throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - session " 
+					+ sessionIds[0] + " is not valid.");
+		}
+		
 		try {
 			SchedulerService schedulerService = SchedulerService.getInstance();
 
@@ -169,7 +191,7 @@
 
 			// Schedule the job
 			String xmlResult = schedulerService.scheduleJob(jobName, startCal, endCal, intervalValue, intervalUnit,
-					WORKFLOW_JOB_CLASS, WORKFLOW_JOB_GROUP, jobParams, username, groups);
+					WORKFLOW_JOB_CLASS, WORKFLOW_JOB_GROUP, jobParams);
 			
 			ResponseUtil.sendSuccessXML(response, xmlResult);
 			
@@ -203,6 +225,22 @@
 			Hashtable<String, String[]> params, String username, String[] groups)
 			throws MetacatSchedulerException {
 		try {
+			String sessionIds[] = params.get("sessionid");
+			
+			// interval value must exist
+			if (sessionIds == null || sessionIds.length == 0) {
+				throw new MetacatSchedulerException("WorkflowScheduler.unscheduleJob - sessionid field must be populated "
+								+ "in scheduler parameters when unscheduling job.");
+			}
+			
+			String sessionStatus = validateRemoteSession(sessionIds[0]);
+			logMetacat.debug("WorkflowScheduler.unscheduleJob - session status: " + sessionStatus);
+			
+			if (!sessionStatus.equals("valid")) {
+				throw new MetacatSchedulerException("WorkflowScheduler.unscheduleJob - session " 
+						+ sessionIds[0] + " is not valid.");
+			}
+			
 			// workflow job id must exist
 			String jobNames[] = params.get("workflowjobname");
 			if (jobNames == null || jobNames.length == 0) {
@@ -245,10 +283,27 @@
 			String[] groups) throws MetacatSchedulerException {
 		 		
 		try {
+			String sessionIds[] = params.get("sessionid");
+			
+			// interval value must exist
+			if (sessionIds == null || sessionIds.length == 0) {
+				throw new MetacatSchedulerException("WorkflowScheduler.rescheduleJob - sessionid field must be populated "
+								+ "in scheduler parameters when rescheduling job.");
+			}
+			
+			String sessionStatus = validateRemoteSession(sessionIds[0]);
+			
+			logMetacat.debug("WorkflowScheduler.rescheduleJob - session status: " + sessionStatus);
+			
+			if (!sessionStatus.equals("valid")) {
+				throw new MetacatSchedulerException("WorkflowScheduler.scheduleJob - session " 
+						+ sessionIds[0] + " is not valid.");
+			}
+			
 			// workflow job id must exist
 			String jobNames[] = params.get("workflowjobname");	
 			if (jobNames == null || jobNames.length == 0) {
-				throw new MetacatSchedulerException("WorkflowScheduler.reScheduleJob - workflowjobname field must be populated "
+				throw new MetacatSchedulerException("WorkflowScheduler.rescheduleJob - workflowjobname field must be populated "
 						+ "in scheduler parameters when rescheduling job.");
 			}			
 			String jobName = jobNames[0];
@@ -263,14 +318,14 @@
 			ResponseUtil.sendSuccessXML(response, result);
 			
 		} catch (AccessException ae) {
-			throw new MetacatSchedulerException("WorkflowScheduler.reScheduleJob - " 
-					+ "DB access issue when scheduling job  : ", ae);
+			throw new MetacatSchedulerException("WorkflowScheduler.rescheduleJob - " 
+					+ "DB access issue when rescheduling job  : ", ae);
 		} catch (ServiceException se) {
-			throw new MetacatSchedulerException("WorkflowScheduler.reScheduleJob - " 
-					+ "Service issue scheduling job", se);
+			throw new MetacatSchedulerException("WorkflowScheduler.rescheduleJob - " 
+					+ "Service issue rescheduling job", se);
 		} catch (ErrorSendingErrorException esee) {
-			throw new MetacatSchedulerException("WorkflowScheduler.reScheduleJob - " 
-					+ "Issue sending erro when scheduling job: " + esee.getMessage());			
+			throw new MetacatSchedulerException("WorkflowScheduler.rescheduleJob - " 
+					+ "Issue sending erro when rescheduling job: " + esee.getMessage());			
 		}
 	}
 	
@@ -280,6 +335,22 @@
 	public void deleteJob(HttpServletRequest request, HttpServletResponse response, 
 			Hashtable<String, String[]> params, String username, String[] groups) throws MetacatSchedulerException {
 		 try {
+			String sessionIds[] = params.get("sessionid");
+				
+			// interval value must exist
+			if (sessionIds == null || sessionIds.length == 0) {
+				throw new MetacatSchedulerException("WorkflowScheduler.deleteJob - sessionid field must be populated "
+								+ "in scheduler parameters when deleting job.");
+			}
+				
+			String sessionStatus = validateRemoteSession(sessionIds[0]);
+			logMetacat.debug("WorkflowScheduler.rescheduleJob - session status: " + sessionStatus);
+				
+			if (!sessionStatus.equals("valid")) {
+				throw new MetacatSchedulerException("WorkflowScheduler.deleteJob - session " 
+						+ sessionIds[0] + " is not valid.");
+			}
+				
 			// workflow job id must exist
 			String jobNames[] = params.get("workflowjobname");
 			if (jobNames == null || jobNames.length == 0) {
@@ -294,7 +365,7 @@
 
 			// delete the job
 			SchedulerService schedulerService = SchedulerService.getInstance();
-			String result = schedulerService.deleteJob(jobDAO, username, groups);
+			String result = schedulerService.deleteJob(jobDAO);
 
 			ResponseUtil.sendSuccessXML(response, result);
 
@@ -356,4 +427,32 @@
 			}
 		}
 	}
+	
+	private String validateRemoteSession(String sessionId) throws MetacatSchedulerException {
+		String sessionStatus = "unknown";
+	    XPath xpath = XPathFactory.newInstance().newXPath();
+		
+		try {
+			String ecogridUrl = PropertyService.getProperty("workflowScheduler.authServiceUrl");
+		
+			AuthenticationServiceClient authServiceClient = 
+					new AuthenticationServiceClient(ecogridUrl);
+			
+			String sessionStatusXML = authServiceClient.validate_session_action(sessionId);
+			
+			sessionStatus = 
+				xpath.evaluate("/validateSession/status",  new InputSource(new StringReader(sessionStatusXML)));
+			
+			
+		} catch (PropertyNotFoundException pnfe) {
+			throw new MetacatSchedulerException("WorkflowScheduler.validateSession - Could not " 
+					+ "find property: " + pnfe.getMessage());
+		} catch (Exception e) {
+			throw new MetacatSchedulerException("WorkflowScheduler.validateSession - " 
+					+ "general error when validating Session: " + e.getMessage());
+		}
+		
+		
+		return sessionStatus;
+	}
 }
Index: src/edu/ucsb/nceas/workflowscheduler/WorkflowSchedulerServlet.java
===================================================================
--- src/edu/ucsb/nceas/workflowscheduler/WorkflowSchedulerServlet.java	(revision 5056)
+++ src/edu/ucsb/nceas/workflowscheduler/WorkflowSchedulerServlet.java	(revision 5057)
@@ -321,7 +321,7 @@
 			if (action.equals("scheduleWorkflow")) {
 				try {
 					WorkflowScheduler.getInstance().scheduleJob(request, response,
-							params, userName, groupNames);
+							params);
 					return;
 				} catch (BaseException be) {
 					logMetacat.error("WorkflowSchedulerServlet.handleGetOrPost - error when scheduling" 
Index: src/edu/ucsb/nceas/metacat/service/SessionService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/service/SessionService.java	(revision 5056)
+++ src/edu/ucsb/nceas/metacat/service/SessionService.java	(revision 5057)
@@ -186,7 +186,7 @@
 		response.setContentType("text/xml");
 		out.println("<?xml version=\"1.0\"?>");
 		out.write("<validateSession><status>");
-		if (sessionId != null && isSessionRegistered(sessionId)) {
+		if (sessionId != null && !sessionId.equals(PUBLIC_SESSION_ID) && isSessionRegistered(sessionId)) {
 			out.write("valid");
 		} else {
 			out.write("invalid");
Index: src/edu/ucsb/nceas/metacat/workflow/WorkflowSchedulerClient.java
===================================================================
--- src/edu/ucsb/nceas/metacat/workflow/WorkflowSchedulerClient.java	(revision 5056)
+++ src/edu/ucsb/nceas/metacat/workflow/WorkflowSchedulerClient.java	(revision 5057)
@@ -94,6 +94,7 @@
 
 		try {
 			params.put("action", new String[] { "scheduleWorkflow" });
+			params.put("sessionid", new String[] { RequestUtil.getSessionData(request).getId() });
 			
 			String schedulerUrl = PropertyService.getProperty("workflowScheduler.url");
 			String result = RequestUtil.get(schedulerUrl, params);
@@ -155,6 +156,7 @@
 			String[] groups) throws MetacatSchedulerException {
 		try {
 			params.put("action", new String[] { "unscheduleWorkflow" });
+			params.put("sessionid", new String[] { RequestUtil.getSessionData(request).getId() });
 			
 			String schedulerUrl = PropertyService.getProperty("workflowScheduler.url");
 			String result = RequestUtil.get(schedulerUrl, params);
@@ -217,6 +219,7 @@
 		 		
 		try {
 			params.put("action", new String[] { "rescheduleWorkflow" });
+			params.put("sessionid", new String[] { RequestUtil.getSessionData(request).getId() });
 			
 			String schedulerUrl = PropertyService.getProperty("workflowScheduler.url");
 			String result = RequestUtil.get(schedulerUrl, params);
@@ -267,6 +270,7 @@
 			String[] groups) throws MetacatSchedulerException {
 		try {
 			params.put("action", new String[] { "deleteScheduledWorkflow" });
+			params.put("sessionid", new String[] { RequestUtil.getSessionData(request).getId() });
 			
 			String schedulerUrl = PropertyService.getProperty("workflowScheduler.url");
 			String result = RequestUtil.get(schedulerUrl, params);
@@ -327,7 +331,6 @@
 			Hashtable<String, String[]> params, String username,
 			String[] groups) throws MetacatSchedulerException {
 		
-//		StringWriter stringWriter = null;
 		try {	
 			params.put("action", new String[] { "getScheduledWorkflow" });
 			
@@ -334,8 +337,6 @@
 			String schedulerUrl = PropertyService.getProperty("workflowScheduler.url");
 			String result = RequestUtil.get(schedulerUrl, params);
 			
-//			stringWriter = new StringWriter();
-			
 			String qformats[] = params.get("qformat");			
 			String qformat = null;
 			if (qformats == null || qformats.length == 0) {
Index: src/edu/ucsb/nceas/metacat/client/MetacatClient.java
===================================================================
--- src/edu/ucsb/nceas/metacat/client/MetacatClient.java	(revision 5056)
+++ src/edu/ucsb/nceas/metacat/client/MetacatClient.java	(revision 5057)
@@ -32,13 +32,9 @@
 import java.io.StringWriter;
 import java.io.Reader;
 import java.net.URL;
-import java.util.HashMap;
 import java.util.Properties;
 import java.util.Vector;
 import javax.servlet.http.HttpServletRequest;
-import javax.xml.xpath.XPath;
-import javax.xml.xpath.XPathFactory;
-import org.w3c.dom.Document;
 
 import org.w3c.dom.Node;
 import org.w3c.dom.NodeList;
@@ -164,6 +160,40 @@
     }
     
     /**
+     *  Method used to log in to a metacat server. Implementations will need
+     *  to cache a cookie value to make the session persistent.  Each time a
+     *  call is made to one of the other methods (e.g., read), the cookie will
+     *  need to be passed back to the metacat server along with the request.
+     *
+     *  @param username   the username of the user, like an LDAP DN
+     *  @param password   the password for that user for authentication
+     *  @return the response string from metacat in XML format
+     *  @throws MetacatAuthException when the username/password could
+     *                    not be authenticated
+     */
+    public String validateSession(String sessionId)
+    		throws MetacatAuthException, MetacatInaccessibleException {
+    	
+        Properties prop = new Properties();
+        prop.put("action", "validatesession");
+        prop.put("sessionid", sessionId);
+        
+        String response = null;
+        try {
+            response = sendDataForString(prop, null, null, 0);
+        } catch (Exception e) {
+            throw new MetacatInaccessibleException(e.getMessage());
+        }
+        
+        if (response.indexOf("<validateSession><status>") == -1) {
+            setSessionId("");
+            throw new MetacatAuthException(response);
+        } 
+        
+        return response;
+    }
+    
+    /**
      * Read an XML document from the metacat server session, accessed by docid,
      * and returned as a Reader.
      *
Index: src/edu/ucsb/nceas/metacat/scheduler/SchedulerService.java
===================================================================
--- src/edu/ucsb/nceas/metacat/scheduler/SchedulerService.java	(revision 5056)
+++ src/edu/ucsb/nceas/metacat/scheduler/SchedulerService.java	(revision 5057)
@@ -166,7 +166,7 @@
         // schedule the job
 		return scheduleJob(jobDAO.getName(), startTimeCal, endTimeCal, jobDAO.getIntervalValue(), 
 				jobDAO.getIntervalUnit(), jobDAO.getClassName(), jobDAO.getGroupName(), 
-				jobParams, username, groups);
+				jobParams);
 	}
 	
 	/**
@@ -195,8 +195,8 @@
 	 * @return a message saying that the job was scheduled
 	 */
 	public String scheduleJob(String jobName, Calendar startCal, Calendar endCal, int intervalValue, 
-			String intervalUnit, String jobClassName, String jobGroup, HashMap<String, String> jobParams, 
-			String username, String[] groups) throws ServiceException {
+			String intervalUnit, String jobClassName, String jobGroup, HashMap<String, String> jobParams) 
+	throws ServiceException {
         
         Class<Job> jobClass = null;
         try {
@@ -219,7 +219,7 @@
 					intervalValue, intervalUnit, jobParams);
 		} catch (AccessException ae) {
 			try {
-				deleteJob(jobName, username, groups);
+				deleteJob(jobName);
 			} catch (Exception e) {
 				// Not much we can do here but log this
 				logMetacat.error("SchedulerService.scheduleJob - An access exception was thrown when writing job: "
@@ -425,8 +425,7 @@
 	 *            the user's group name
 	 * @return a message saying that the job was deleted
 	 */
-	public String deleteJob(String jobName, String username,
-			String[] groups) throws ServiceException {
+	public String deleteJob(String jobName) throws ServiceException {
 		
 		ScheduledJobDAO jobDAO = null;
 		try {	
@@ -437,7 +436,7 @@
 					+ "scheduled job : " + jobDAO.getName() + " because of db access issue: ", ae);
 		}
 		
-		return deleteJob(jobDAO, username, groups);
+		return deleteJob(jobDAO);
 	}
 	
 	/**
@@ -450,8 +449,7 @@
 	 *            the user's group name
 	 * @return a message saying that the job was deleted
 	 */
-	public String deleteJob(ScheduledJobDAO jobDAO, String username,
-			String[] groups) throws ServiceException {
+	public String deleteJob(ScheduledJobDAO jobDAO) throws ServiceException {
 
 		String groupName = "";
 		try {
Index: src/edu/ucsb/nceas/metacat/scheduler/BaseScheduler.java
===================================================================
--- src/edu/ucsb/nceas/metacat/scheduler/BaseScheduler.java	(revision 5056)
+++ src/edu/ucsb/nceas/metacat/scheduler/BaseScheduler.java	(revision 5057)
@@ -36,7 +36,7 @@
 	// Schedule a job by extracting job specific information and registering it with the scheduler 
 	// service.  
 	public abstract void scheduleJob(HttpServletRequest request, HttpServletResponse response, 
-            Hashtable<String, String[]> params, String username, String[] groups) throws MetacatSchedulerException;
+            Hashtable<String, String[]> params) throws MetacatSchedulerException;
 	
 	// Unschedule a job in the scheduler service. 
 	public abstract void unscheduleJob(HttpServletRequest request, HttpServletResponse response, 
