Return-Path: X-Original-To: apmail-manifoldcf-commits-archive@www.apache.org Delivered-To: apmail-manifoldcf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 3530F182B6 for ; Tue, 30 Jun 2015 13:19:45 +0000 (UTC) Received: (qmail 82370 invoked by uid 500); 30 Jun 2015 13:19:44 -0000 Delivered-To: apmail-manifoldcf-commits-archive@manifoldcf.apache.org Received: (qmail 82317 invoked by uid 500); 30 Jun 2015 13:19:44 -0000 Mailing-List: contact commits-help@manifoldcf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@manifoldcf.apache.org Delivered-To: mailing list commits@manifoldcf.apache.org Received: (qmail 82268 invoked by uid 99); 30 Jun 2015 13:19:44 -0000 Received: from eris.apache.org (HELO hades.apache.org) (140.211.11.105) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 30 Jun 2015 13:19:44 +0000 Received: from hades.apache.org (localhost [127.0.0.1]) by hades.apache.org (ASF Mail Server at hades.apache.org) with ESMTP id 4FF06AC0337 for ; Tue, 30 Jun 2015 13:19:44 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1688447 - in /manifoldcf/branches/CONNECTORS-1131/framework: api-servlet/src/main/java/org/apache/manifoldcf/apiservlet/APIServlet.java pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java Date: Tue, 30 Jun 2015 13:19:44 -0000 To: commits@manifoldcf.apache.org From: kwright@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20150630131944.4FF06AC0337@hades.apache.org> Author: kwright Date: Tue Jun 30 13:19:43 2015 New Revision: 1688447 URL: http://svn.apache.org/r1688447 Log: Add plumbing for authority checking throughout API Modified: manifoldcf/branches/CONNECTORS-1131/framework/api-servlet/src/main/java/org/apache/manifoldcf/apiservlet/APIServlet.java manifoldcf/branches/CONNECTORS-1131/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java Modified: manifoldcf/branches/CONNECTORS-1131/framework/api-servlet/src/main/java/org/apache/manifoldcf/apiservlet/APIServlet.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1131/framework/api-servlet/src/main/java/org/apache/manifoldcf/apiservlet/APIServlet.java?rev=1688447&r1=1688446&r2=1688447&view=diff ============================================================================== --- manifoldcf/branches/CONNECTORS-1131/framework/api-servlet/src/main/java/org/apache/manifoldcf/apiservlet/APIServlet.java (original) +++ manifoldcf/branches/CONNECTORS-1131/framework/api-servlet/src/main/java/org/apache/manifoldcf/apiservlet/APIServlet.java Tue Jun 30 13:19:43 2015 @@ -319,6 +319,8 @@ public class APIServlet extends HttpServ if (readResult == ManifoldCF.READRESULT_NOTFOUND) response.setStatus(response.SC_NOT_FOUND); + else if (readResult == ManifoldCF.READRESULT_NOTALLOWED) + response.setStatus(response.SC_UNAUTHORIZED); byte[] responseValue = outputText.getBytes(StandardCharsets.UTF_8); @@ -440,6 +442,8 @@ public class APIServlet extends HttpServ response.setStatus(response.SC_CREATED); else if (writeResult == ManifoldCF.WRITERESULT_NOTFOUND) response.setStatus(response.SC_NOT_FOUND); + else if (writeResult == ManifoldCF.WRITERESULT_NOTALLOWED) + response.setStatus(response.SC_UNAUTHORIZED); byte[] responseValue = outputText.getBytes(StandardCharsets.UTF_8); @@ -603,7 +607,9 @@ public class APIServlet extends HttpServ response.setStatus(response.SC_CREATED); else if (writeResult == ManifoldCF.POSTRESULT_NOTFOUND) response.setStatus(response.SC_NOT_FOUND); - + else if (writeResult == ManifoldCF.POSTRESULT_NOTALLOWED) + response.setStatus(response.SC_UNAUTHORIZED); + byte[] responseValue = outputText.getBytes(StandardCharsets.UTF_8); // Set response mime type @@ -686,6 +692,9 @@ public class APIServlet extends HttpServ if (result == ManifoldCF.DELETERESULT_NOTFOUND) response.setStatus(response.SC_NOT_FOUND); + else if (result == ManifoldCF.DELETERESULT_NOTALLOWED) + response.setStatus(response.SC_UNAUTHORIZED); + byte[] responseValue = outputText.getBytes(StandardCharsets.UTF_8); Modified: manifoldcf/branches/CONNECTORS-1131/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java URL: http://svn.apache.org/viewvc/manifoldcf/branches/CONNECTORS-1131/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java?rev=1688447&r1=1688446&r2=1688447&view=diff ============================================================================== --- manifoldcf/branches/CONNECTORS-1131/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java (original) +++ manifoldcf/branches/CONNECTORS-1131/framework/pull-agent/src/main/java/org/apache/manifoldcf/crawler/system/ManifoldCF.java Tue Jun 30 13:19:43 2015 @@ -1376,9 +1376,10 @@ public class ManifoldCF extends org.apac // Read result codes public static final int READRESULT_NOTFOUND = 0; public static final int READRESULT_FOUND = 1; - + public static final int READRESULT_NOTALLOWED = 2; + /** Read jobs */ - protected static int apiReadJobs(IThreadContext tc, Configuration output) + protected static int apiReadJobs(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1401,7 +1402,7 @@ public class ManifoldCF extends org.apac } /** Read a job */ - protected static int apiReadJob(IThreadContext tc, Configuration output, Long jobID) + protected static int apiReadJob(IThreadContext tc, Configuration output, Long jobID, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1429,7 +1430,7 @@ public class ManifoldCF extends org.apac } /** Read an output connection status */ - protected static int apiReadOutputConnectionStatus(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadOutputConnectionStatus(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1471,7 +1472,7 @@ public class ManifoldCF extends org.apac } /** Read a transformation connection status */ - protected static int apiReadTransformationConnectionStatus(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadTransformationConnectionStatus(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1513,7 +1514,7 @@ public class ManifoldCF extends org.apac } /** Read an authority connection status */ - protected static int apiReadAuthorityConnectionStatus(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadAuthorityConnectionStatus(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1555,7 +1556,7 @@ public class ManifoldCF extends org.apac } /** Read a mapping connection status */ - protected static int apiReadMappingConnectionStatus(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadMappingConnectionStatus(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1597,7 +1598,7 @@ public class ManifoldCF extends org.apac } /** Read a repository connection status */ - protected static int apiReadRepositoryConnectionStatus(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadRepositoryConnectionStatus(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1639,7 +1640,7 @@ public class ManifoldCF extends org.apac } /** Read a notification connection status */ - protected static int apiReadNotificationConnectionStatus(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadNotificationConnectionStatus(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1681,7 +1682,7 @@ public class ManifoldCF extends org.apac } /** Read an output connection's info */ - protected static int apiReadOutputConnectionInfo(IThreadContext tc, Configuration output, String connectionName, String command) + protected static int apiReadOutputConnectionInfo(IThreadContext tc, Configuration output, String connectionName, String command, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1714,7 +1715,7 @@ public class ManifoldCF extends org.apac } /** Read a transformation connection's info */ - protected static int apiReadTransformationConnectionInfo(IThreadContext tc, Configuration output, String connectionName, String command) + protected static int apiReadTransformationConnectionInfo(IThreadContext tc, Configuration output, String connectionName, String command, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1747,7 +1748,7 @@ public class ManifoldCF extends org.apac } /** Read a repository connection's info */ - protected static int apiReadRepositoryConnectionInfo(IThreadContext tc, Configuration output, String connectionName, String command) + protected static int apiReadRepositoryConnectionInfo(IThreadContext tc, Configuration output, String connectionName, String command, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1780,7 +1781,7 @@ public class ManifoldCF extends org.apac } /** Read a notification connection's info */ - protected static int apiReadNotificationConnectionInfo(IThreadContext tc, Configuration output, String connectionName, String command) + protected static int apiReadNotificationConnectionInfo(IThreadContext tc, Configuration output, String connectionName, String command, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1813,7 +1814,7 @@ public class ManifoldCF extends org.apac } /** Get api job statuses */ - protected static int apiReadJobStatuses(IThreadContext tc, Configuration output, Map> queryParameters) + protected static int apiReadJobStatuses(IThreadContext tc, Configuration output, Map> queryParameters, IAuthorizer authorizer) throws ManifoldCFException { if (queryParameters == null) @@ -1847,7 +1848,7 @@ public class ManifoldCF extends org.apac } /** Get api job statuses */ - protected static int apiReadJobStatusesNoCounts(IThreadContext tc, Configuration output) + protected static int apiReadJobStatusesNoCounts(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1870,7 +1871,7 @@ public class ManifoldCF extends org.apac } /** Get api job status */ - protected static int apiReadJobStatus(IThreadContext tc, Configuration output, Long jobID, Map> queryParameters) + protected static int apiReadJobStatus(IThreadContext tc, Configuration output, Long jobID, Map> queryParameters, IAuthorizer authorizer) throws ManifoldCFException { if (queryParameters == null) @@ -1903,7 +1904,7 @@ public class ManifoldCF extends org.apac } /** Get api job status with no counts */ - protected static int apiReadJobStatusNoCounts(IThreadContext tc, Configuration output, Long jobID) + protected static int apiReadJobStatusNoCounts(IThreadContext tc, Configuration output, Long jobID, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1925,7 +1926,7 @@ public class ManifoldCF extends org.apac } /** Get authority groups */ - protected static int apiReadAuthorityGroups(IThreadContext tc, Configuration output) + protected static int apiReadAuthorityGroups(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1948,7 +1949,7 @@ public class ManifoldCF extends org.apac } /** Read authority group */ - protected static int apiReadAuthorityGroup(IThreadContext tc, Configuration output, String groupName) + protected static int apiReadAuthorityGroup(IThreadContext tc, Configuration output, String groupName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1976,7 +1977,7 @@ public class ManifoldCF extends org.apac } /** Get output connections */ - protected static int apiReadOutputConnections(IThreadContext tc, Configuration output) + protected static int apiReadOutputConnections(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { try @@ -1999,7 +2000,7 @@ public class ManifoldCF extends org.apac } /** Read output connection */ - protected static int apiReadOutputConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadOutputConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -2027,7 +2028,7 @@ public class ManifoldCF extends org.apac } /** Get transformation connections */ - protected static int apiReadTransformationConnections(IThreadContext tc, Configuration output) + protected static int apiReadTransformationConnections(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { try @@ -2050,7 +2051,7 @@ public class ManifoldCF extends org.apac } /** Read transformation connection */ - protected static int apiReadTransformationConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadTransformationConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -2078,7 +2079,7 @@ public class ManifoldCF extends org.apac } /** Get authority connections */ - protected static int apiReadAuthorityConnections(IThreadContext tc, Configuration output) + protected static int apiReadAuthorityConnections(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { try @@ -2101,7 +2102,7 @@ public class ManifoldCF extends org.apac } /** Get mapping connections */ - protected static int apiReadMappingConnections(IThreadContext tc, Configuration output) + protected static int apiReadMappingConnections(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { try @@ -2124,7 +2125,7 @@ public class ManifoldCF extends org.apac } /** Read authority connection */ - protected static int apiReadAuthorityConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadAuthorityConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -2152,7 +2153,7 @@ public class ManifoldCF extends org.apac } /** Read mapping connection */ - protected static int apiReadMappingConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadMappingConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -2180,7 +2181,7 @@ public class ManifoldCF extends org.apac } /** Get repository connections */ - protected static int apiReadRepositoryConnections(IThreadContext tc, Configuration output) + protected static int apiReadRepositoryConnections(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { try @@ -2203,7 +2204,7 @@ public class ManifoldCF extends org.apac } /** Read repository connection */ - protected static int apiReadRepositoryConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadRepositoryConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -2231,7 +2232,7 @@ public class ManifoldCF extends org.apac } /** Get notification connections */ - protected static int apiReadNotificationConnections(IThreadContext tc, Configuration output) + protected static int apiReadNotificationConnections(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { try @@ -2254,7 +2255,7 @@ public class ManifoldCF extends org.apac } /** Read notification connection */ - protected static int apiReadNotificationConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadNotificationConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -2282,7 +2283,7 @@ public class ManifoldCF extends org.apac } /** List output connectors */ - protected static int apiReadOutputConnectors(IThreadContext tc, Configuration output) + protected static int apiReadOutputConnectors(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { // List registered output connectors @@ -2319,7 +2320,7 @@ public class ManifoldCF extends org.apac } /** List transformation connectors */ - protected static int apiReadTransformationConnectors(IThreadContext tc, Configuration output) + protected static int apiReadTransformationConnectors(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { // List registered transformation connectors @@ -2356,7 +2357,7 @@ public class ManifoldCF extends org.apac } /** List authority connectors */ - protected static int apiReadAuthorityConnectors(IThreadContext tc, Configuration output) + protected static int apiReadAuthorityConnectors(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { // List registered authority connectors @@ -2393,7 +2394,7 @@ public class ManifoldCF extends org.apac } /** List mapping connectors */ - protected static int apiReadMappingConnectors(IThreadContext tc, Configuration output) + protected static int apiReadMappingConnectors(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { // List registered authority connectors @@ -2430,7 +2431,7 @@ public class ManifoldCF extends org.apac } /** List authorization domains */ - protected static int apiReadAuthorizationDomains(IThreadContext tc, Configuration output) + protected static int apiReadAuthorizationDomains(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { // List registered authorization domains @@ -2468,7 +2469,7 @@ public class ManifoldCF extends org.apac } /** List repository connectors */ - protected static int apiReadRepositoryConnectors(IThreadContext tc, Configuration output) + protected static int apiReadRepositoryConnectors(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { // List registered repository connectors @@ -2505,7 +2506,7 @@ public class ManifoldCF extends org.apac } /** List notification connectors */ - protected static int apiReadNotificationConnectors(IThreadContext tc, Configuration output) + protected static int apiReadNotificationConnectors(IThreadContext tc, Configuration output, IAuthorizer authorizer) throws ManifoldCFException { // List registered notification connectors @@ -2568,7 +2569,7 @@ public class ManifoldCF extends org.apac /** Queue reports */ protected static int apiReadRepositoryConnectionQueue(IThreadContext tc, Configuration output, - String connectionName, Map> queryParameters) throws ManifoldCFException + String connectionName, Map> queryParameters, IAuthorizer authorizer) throws ManifoldCFException { if (queryParameters == null) queryParameters = new HashMap>(); @@ -2765,7 +2766,7 @@ public class ManifoldCF extends org.apac /** Get jobs for connection */ protected static int apiReadRepositoryConnectionJobs(IThreadContext tc, Configuration output, - String connectionName) throws ManifoldCFException + String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try { @@ -2793,7 +2794,7 @@ public class ManifoldCF extends org.apac /** History reports */ protected static int apiReadRepositoryConnectionHistory(IThreadContext tc, Configuration output, - String connectionName, Map> queryParameters) throws ManifoldCFException + String connectionName, Map> queryParameters, IAuthorizer authorizer) throws ManifoldCFException { if (queryParameters == null) queryParameters = new HashMap>(); @@ -3129,7 +3130,7 @@ public class ManifoldCF extends org.apac } /** Read the activity list for a given connection name. */ - protected static int apiReadRepositoryConnectionActivities(IThreadContext tc, Configuration output, String connectionName) + protected static int apiReadRepositoryConnectionActivities(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -3165,36 +3166,36 @@ public class ManifoldCF extends org.apac { if (path.equals("jobs")) { - return apiReadJobs(tc,output); + return apiReadJobs(tc,output,authorizer); } else if (path.startsWith("jobs/")) { Long jobID = new Long(path.substring("jobs/".length())); - return apiReadJob(tc,output,jobID); + return apiReadJob(tc,output,jobID,authorizer); } else if (path.startsWith("repositoryconnectionactivities/")) { int firstSeparator = "repositoryconnectionactivities/".length(); String connectionName = decodeAPIPathElement(path.substring(firstSeparator)); - return apiReadRepositoryConnectionActivities(tc,output,connectionName); + return apiReadRepositoryConnectionActivities(tc,output,connectionName,authorizer); } else if (path.startsWith("repositoryconnectionhistory/")) { int firstSeparator = "repositoryconnectionhistory/".length(); String connectionName = decodeAPIPathElement(path.substring(firstSeparator)); - return apiReadRepositoryConnectionHistory(tc,output,connectionName,queryParameters); + return apiReadRepositoryConnectionHistory(tc,output,connectionName,queryParameters,authorizer); } else if (path.startsWith("repositoryconnectionqueue/")) { int firstSeparator = "repositoryconnectionqueue/".length(); String connectionName = decodeAPIPathElement(path.substring(firstSeparator)); - return apiReadRepositoryConnectionQueue(tc,output,connectionName,queryParameters); + return apiReadRepositoryConnectionQueue(tc,output,connectionName,queryParameters,authorizer); } else if (path.startsWith("repositoryconnectionjobs/")) { int firstSeparator = "repositoryconnectionjobs/".length(); String connectionName = decodeAPIPathElement(path.substring(firstSeparator)); - return apiReadRepositoryConnectionJobs(tc,output,connectionName); + return apiReadRepositoryConnectionJobs(tc,output,connectionName,authorizer); } else if (path.startsWith("status/")) { @@ -3211,27 +3212,27 @@ public class ManifoldCF extends org.apac if (connectionType.equals("outputconnections")) { - return apiReadOutputConnectionStatus(tc,output,connectionName); + return apiReadOutputConnectionStatus(tc,output,connectionName,authorizer); } else if (connectionType.equals("transformationconnections")) { - return apiReadTransformationConnectionStatus(tc,output,connectionName); + return apiReadTransformationConnectionStatus(tc,output,connectionName,authorizer); } else if (connectionType.equals("mappingconnections")) { - return apiReadMappingConnectionStatus(tc,output,connectionName); + return apiReadMappingConnectionStatus(tc,output,connectionName,authorizer); } else if (connectionType.equals("authorityconnections")) { - return apiReadAuthorityConnectionStatus(tc,output,connectionName); + return apiReadAuthorityConnectionStatus(tc,output,connectionName,authorizer); } else if (connectionType.equals("repositoryconnections")) { - return apiReadRepositoryConnectionStatus(tc,output,connectionName); + return apiReadRepositoryConnectionStatus(tc,output,connectionName,authorizer); } else if (connectionType.equals("notificationconnections")) { - return apiReadNotificationConnectionStatus(tc,output,connectionName); + return apiReadNotificationConnectionStatus(tc,output,connectionName,authorizer); } else { @@ -3262,19 +3263,19 @@ public class ManifoldCF extends org.apac if (connectionType.equals("outputconnections")) { - return apiReadOutputConnectionInfo(tc,output,connectionName,command); + return apiReadOutputConnectionInfo(tc,output,connectionName,command,authorizer); } else if (connectionType.equals("transformationconnections")) { - return apiReadTransformationConnectionInfo(tc,output,connectionName,command); + return apiReadTransformationConnectionInfo(tc,output,connectionName,command,authorizer); } else if (connectionType.equals("repositoryconnections")) { - return apiReadRepositoryConnectionInfo(tc,output,connectionName,command); + return apiReadRepositoryConnectionInfo(tc,output,connectionName,command,authorizer); } else if (connectionType.equals("notificationconnections")) { - return apiReadNotificationConnectionInfo(tc,output,connectionName,command); + return apiReadNotificationConnectionInfo(tc,output,connectionName,command,authorizer); } else { @@ -3284,112 +3285,112 @@ public class ManifoldCF extends org.apac } else if (path.equals("jobstatuses")) { - return apiReadJobStatuses(tc,output,queryParameters); + return apiReadJobStatuses(tc,output,queryParameters,authorizer); } else if (path.startsWith("jobstatuses/")) { Long jobID = new Long(path.substring("jobstatuses/".length())); - return apiReadJobStatus(tc,output,jobID,queryParameters); + return apiReadJobStatus(tc,output,jobID,queryParameters,authorizer); } else if (path.equals("jobstatusesnocounts")) { - return apiReadJobStatusesNoCounts(tc,output); + return apiReadJobStatusesNoCounts(tc,output,authorizer); } else if (path.startsWith("jobstatusesnocounts/")) { Long jobID = new Long(path.substring("jobstatusesnocounts/".length())); - return apiReadJobStatusNoCounts(tc,output,jobID); + return apiReadJobStatusNoCounts(tc,output,jobID,authorizer); } else if (path.equals("authoritygroups")) { - return apiReadAuthorityGroups(tc,output); + return apiReadAuthorityGroups(tc,output,authorizer); } else if (path.startsWith("authoritygroups/")) { String groupName = decodeAPIPathElement(path.substring("authoritygroups/".length())); - return apiReadAuthorityGroup(tc,output,groupName); + return apiReadAuthorityGroup(tc,output,groupName,authorizer); } else if (path.equals("outputconnections")) { - return apiReadOutputConnections(tc,output); + return apiReadOutputConnections(tc,output,authorizer); } else if (path.startsWith("outputconnections/")) { String connectionName = decodeAPIPathElement(path.substring("outputconnections/".length())); - return apiReadOutputConnection(tc,output,connectionName); + return apiReadOutputConnection(tc,output,connectionName,authorizer); } else if (path.equals("transformationconnections")) { - return apiReadTransformationConnections(tc,output); + return apiReadTransformationConnections(tc,output,authorizer); } else if (path.startsWith("transformationconnections/")) { String connectionName = decodeAPIPathElement(path.substring("transformationconnections/".length())); - return apiReadTransformationConnection(tc,output,connectionName); + return apiReadTransformationConnection(tc,output,connectionName,authorizer); } else if (path.equals("mappingconnections")) { - return apiReadMappingConnections(tc,output); + return apiReadMappingConnections(tc,output,authorizer); } else if (path.startsWith("mappingconnections/")) { String connectionName = decodeAPIPathElement(path.substring("mappingconnections/".length())); - return apiReadMappingConnection(tc,output,connectionName); + return apiReadMappingConnection(tc,output,connectionName,authorizer); } else if (path.equals("authorityconnections")) { - return apiReadAuthorityConnections(tc,output); + return apiReadAuthorityConnections(tc,output,authorizer); } else if (path.startsWith("authorityconnections/")) { String connectionName = decodeAPIPathElement(path.substring("authorityconnections/".length())); - return apiReadAuthorityConnection(tc,output,connectionName); + return apiReadAuthorityConnection(tc,output,connectionName,authorizer); } else if (path.equals("repositoryconnections")) { - return apiReadRepositoryConnections(tc,output); + return apiReadRepositoryConnections(tc,output,authorizer); } else if (path.startsWith("repositoryconnections/")) { String connectionName = decodeAPIPathElement(path.substring("repositoryconnections/".length())); - return apiReadRepositoryConnection(tc,output,connectionName); + return apiReadRepositoryConnection(tc,output,connectionName,authorizer); } else if (path.equals("notificationconnections")) { - return apiReadNotificationConnections(tc,output); + return apiReadNotificationConnections(tc,output,authorizer); } else if (path.startsWith("notificationconnections/")) { String connectionName = decodeAPIPathElement(path.substring("notificationconnections/".length())); - return apiReadNotificationConnection(tc,output,connectionName); + return apiReadNotificationConnection(tc,output,connectionName,authorizer); } else if (path.equals("outputconnectors")) { - return apiReadOutputConnectors(tc,output); + return apiReadOutputConnectors(tc,output,authorizer); } else if (path.equals("transformationconnectors")) { - return apiReadTransformationConnectors(tc,output); + return apiReadTransformationConnectors(tc,output,authorizer); } else if (path.equals("mappingconnectors")) { - return apiReadMappingConnectors(tc,output); + return apiReadMappingConnectors(tc,output,authorizer); } else if (path.equals("authorityconnectors")) { - return apiReadAuthorityConnectors(tc,output); + return apiReadAuthorityConnectors(tc,output,authorizer); } else if (path.equals("repositoryconnectors")) { - return apiReadRepositoryConnectors(tc,output); + return apiReadRepositoryConnectors(tc,output,authorizer); } else if (path.equals("notificationconnectors")) { - return apiReadNotificationConnectors(tc,output); + return apiReadNotificationConnectors(tc,output,authorizer); } else if (path.equals("authorizationdomains")) { - return apiReadAuthorizationDomains(tc,output); + return apiReadAuthorizationDomains(tc,output,authorizer); } else { @@ -3402,10 +3403,11 @@ public class ManifoldCF extends org.apac public static final int POSTRESULT_NOTFOUND = 0; public static final int POSTRESULT_FOUND = 1; public static final int POSTRESULT_CREATED = 2; + public static final int POSTRESULT_NOTALLOWED = 3; /** Post job. */ - protected static int apiPostJob(IThreadContext tc, Configuration output, Configuration input) + protected static int apiPostJob(IThreadContext tc, Configuration output, Configuration input, IAuthorizer authorizer) throws ManifoldCFException { ConfigurationNode jobNode = findConfigurationNode(input,API_JOBNODE); @@ -3454,7 +3456,7 @@ public class ManifoldCF extends org.apac { if (path.equals("jobs")) { - return apiPostJob(tc,output,input); + return apiPostJob(tc,output,input,authorizer); } else { @@ -3467,10 +3469,11 @@ public class ManifoldCF extends org.apac public static final int WRITERESULT_NOTFOUND = 0; public static final int WRITERESULT_FOUND = 1; public static final int WRITERESULT_CREATED = 2; + public static final int WRITERESULT_NOTALLOWED = 3; /** Start a job. */ - protected static int apiWriteStartJob(IThreadContext tc, Configuration output, Long jobID, boolean requestMinimum) + protected static int apiWriteStartJob(IThreadContext tc, Configuration output, Long jobID, boolean requestMinimum, IAuthorizer authorizer) throws ManifoldCFException { try @@ -3488,7 +3491,7 @@ public class ManifoldCF extends org.apac /** Abort a job. */ - protected static int apiWriteAbortJob(IThreadContext tc, Configuration output, Long jobID) + protected static int apiWriteAbortJob(IThreadContext tc, Configuration output, Long jobID, IAuthorizer authorizer) throws ManifoldCFException { try @@ -3506,7 +3509,7 @@ public class ManifoldCF extends org.apac /** Restart a job. */ - protected static int apiWriteRestartJob(IThreadContext tc, Configuration output, Long jobID, boolean requestMinimum) + protected static int apiWriteRestartJob(IThreadContext tc, Configuration output, Long jobID, boolean requestMinimum, IAuthorizer authorizer) throws ManifoldCFException { try @@ -3524,7 +3527,7 @@ public class ManifoldCF extends org.apac /** Pause a job. */ - protected static int apiWritePauseJob(IThreadContext tc, Configuration output, Long jobID) + protected static int apiWritePauseJob(IThreadContext tc, Configuration output, Long jobID, IAuthorizer authorizer) throws ManifoldCFException { try @@ -3542,7 +3545,7 @@ public class ManifoldCF extends org.apac /** Resume a job. */ - protected static int apiWriteResumeJob(IThreadContext tc, Configuration output, Long jobID) + protected static int apiWriteResumeJob(IThreadContext tc, Configuration output, Long jobID, IAuthorizer authorizer) throws ManifoldCFException { try @@ -3560,7 +3563,7 @@ public class ManifoldCF extends org.apac /** Reset incremental seeding for a job. */ - protected static int apiWriteReseedJob(IThreadContext tc, Configuration output, Long jobID) + protected static int apiWriteReseedJob(IThreadContext tc, Configuration output, Long jobID, IAuthorizer authorizer) throws ManifoldCFException { try @@ -3578,7 +3581,7 @@ public class ManifoldCF extends org.apac /** Write job. */ - protected static int apiWriteJob(IThreadContext tc, Configuration output, Configuration input, Long jobID) + protected static int apiWriteJob(IThreadContext tc, Configuration output, Configuration input, Long jobID, IAuthorizer authorizer) throws ManifoldCFException { ConfigurationNode jobNode = findConfigurationNode(input,API_JOBNODE); @@ -3616,7 +3619,7 @@ public class ManifoldCF extends org.apac /** Write authority group. */ - protected static int apiWriteAuthorityGroup(IThreadContext tc, Configuration output, Configuration input, String groupName) + protected static int apiWriteAuthorityGroup(IThreadContext tc, Configuration output, Configuration input, String groupName, IAuthorizer authorizer) throws ManifoldCFException { ConfigurationNode groupNode = findConfigurationNode(input,API_AUTHORITYGROUPNODE); @@ -3651,7 +3654,7 @@ public class ManifoldCF extends org.apac /** Write output connection. */ - protected static int apiWriteOutputConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName) + protected static int apiWriteOutputConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { ConfigurationNode connectionNode = findConfigurationNode(input,API_OUTPUTCONNECTIONNODE); @@ -3686,7 +3689,7 @@ public class ManifoldCF extends org.apac /** Write transformation connection. */ - protected static int apiWriteTransformationConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName) + protected static int apiWriteTransformationConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { ConfigurationNode connectionNode = findConfigurationNode(input,API_TRANSFORMATIONCONNECTIONNODE); @@ -3721,7 +3724,7 @@ public class ManifoldCF extends org.apac /** Write authority connection. */ - protected static int apiWriteAuthorityConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName) + protected static int apiWriteAuthorityConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { ConfigurationNode connectionNode = findConfigurationNode(input,API_AUTHORITYCONNECTIONNODE); @@ -3756,7 +3759,7 @@ public class ManifoldCF extends org.apac /** Write mapping connection. */ - protected static int apiWriteMappingConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName) + protected static int apiWriteMappingConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { ConfigurationNode connectionNode = findConfigurationNode(input,API_MAPPINGCONNECTIONNODE); @@ -3791,7 +3794,7 @@ public class ManifoldCF extends org.apac /** Write repository connection. */ - protected static int apiWriteRepositoryConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName) + protected static int apiWriteRepositoryConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { ConfigurationNode connectionNode = findConfigurationNode(input,API_REPOSITORYCONNECTIONNODE); @@ -3826,7 +3829,7 @@ public class ManifoldCF extends org.apac /** Clear repository connection history. */ - protected static int apiWriteClearHistoryRepositoryConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiWriteClearHistoryRepositoryConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -3844,7 +3847,7 @@ public class ManifoldCF extends org.apac /** Write notification connection. */ - protected static int apiWriteNotificationConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName) + protected static int apiWriteNotificationConnection(IThreadContext tc, Configuration output, Configuration input, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { ConfigurationNode connectionNode = findConfigurationNode(input,API_NOTIFICATIONCONNECTIONNODE); @@ -3879,7 +3882,7 @@ public class ManifoldCF extends org.apac /** Reset output connection (reset version of all recorded documents). */ - protected static int apiWriteClearVersionsOutputConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiWriteClearVersionsOutputConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -3896,7 +3899,7 @@ public class ManifoldCF extends org.apac /** Clear output connection (remove all recorded documents). */ - protected static int apiWriteClearOutputConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiWriteClearOutputConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -3924,88 +3927,88 @@ public class ManifoldCF extends org.apac if (path.startsWith("start/")) { Long jobID = new Long(path.substring("start/".length())); - return apiWriteStartJob(tc,output,jobID,false); + return apiWriteStartJob(tc,output,jobID,false,authorizer); } else if (path.startsWith("startminimal/")) { Long jobID = new Long(path.substring("startminimal/".length())); - return apiWriteStartJob(tc,output,jobID,true); + return apiWriteStartJob(tc,output,jobID,true,authorizer); } else if (path.startsWith("abort/")) { Long jobID = new Long(path.substring("abort/".length())); - return apiWriteAbortJob(tc,output,jobID); + return apiWriteAbortJob(tc,output,jobID,authorizer); } else if (path.startsWith("restart/")) { Long jobID = new Long(path.substring("restart/".length())); - return apiWriteRestartJob(tc,output,jobID,false); + return apiWriteRestartJob(tc,output,jobID,false,authorizer); } else if (path.startsWith("restartminimal/")) { Long jobID = new Long(path.substring("restartminimal/".length())); - return apiWriteRestartJob(tc,output,jobID,true); + return apiWriteRestartJob(tc,output,jobID,true,authorizer); } else if (path.startsWith("pause/")) { Long jobID = new Long(path.substring("pause/".length())); - return apiWritePauseJob(tc,output,jobID); + return apiWritePauseJob(tc,output,jobID,authorizer); } else if (path.startsWith("resume/")) { Long jobID = new Long(path.substring("resume/".length())); - return apiWriteResumeJob(tc,output,jobID); + return apiWriteResumeJob(tc,output,jobID,authorizer); } else if (path.startsWith("reseed/")) { Long jobID = new Long(path.substring("reseed/".length())); - return apiWriteReseedJob(tc,output,jobID); + return apiWriteReseedJob(tc,output,jobID,authorizer); } else if (path.startsWith("jobs/")) { Long jobID = new Long(path.substring("jobs/".length())); - return apiWriteJob(tc,output,input,jobID); + return apiWriteJob(tc,output,input,jobID,authorizer); } else if (path.startsWith("authoritygroups/")) { String groupName = decodeAPIPathElement(path.substring("authoritygroups/".length())); - return apiWriteAuthorityGroup(tc,output,input,groupName); + return apiWriteAuthorityGroup(tc,output,input,groupName,authorizer); } else if (path.startsWith("outputconnections/")) { String connectionName = decodeAPIPathElement(path.substring("outputconnections/".length())); - return apiWriteOutputConnection(tc,output,input,connectionName); + return apiWriteOutputConnection(tc,output,input,connectionName,authorizer); } else if (path.startsWith("transformationconnections/")) { String connectionName = decodeAPIPathElement(path.substring("transformationconnections/".length())); - return apiWriteTransformationConnection(tc,output,input,connectionName); + return apiWriteTransformationConnection(tc,output,input,connectionName,authorizer); } else if (path.startsWith("mappingconnections/")) { String connectionName = decodeAPIPathElement(path.substring("mappingconnections/".length())); - return apiWriteMappingConnection(tc,output,input,connectionName); + return apiWriteMappingConnection(tc,output,input,connectionName,authorizer); } else if (path.startsWith("authorityconnections/")) { String connectionName = decodeAPIPathElement(path.substring("authorityconnections/".length())); - return apiWriteAuthorityConnection(tc,output,input,connectionName); + return apiWriteAuthorityConnection(tc,output,input,connectionName,authorizer); } else if (path.startsWith("repositoryconnections/")) { String connectionName = decodeAPIPathElement(path.substring("repositoryconnections/".length())); - return apiWriteRepositoryConnection(tc,output,input,connectionName); + return apiWriteRepositoryConnection(tc,output,input,connectionName,authorizer); } else if (path.startsWith("notificationconnections/")) { String connectionName = decodeAPIPathElement(path.substring("notificationconnections/".length())); - return apiWriteNotificationConnection(tc,output,input,connectionName); + return apiWriteNotificationConnection(tc,output,input,connectionName,authorizer); } else if (path.startsWith("clearhistory/")) { int firstSeparator = "clearhistory/".length(); String connectionName = decodeAPIPathElement(path.substring(firstSeparator)); - return apiWriteClearHistoryRepositoryConnection(tc,output,connectionName); + return apiWriteClearHistoryRepositoryConnection(tc,output,connectionName,authorizer); } else if (path.startsWith("reset/")) { @@ -4023,7 +4026,7 @@ public class ManifoldCF extends org.apac if (connectionType.equals("outputconnections")) { - return apiWriteClearVersionsOutputConnection(tc,output,connectionName); + return apiWriteClearVersionsOutputConnection(tc,output,connectionName,authorizer); } else { @@ -4035,13 +4038,13 @@ public class ManifoldCF extends org.apac { int firstSeparator = "clearversions/".length(); String connectionName = decodeAPIPathElement(path.substring(firstSeparator)); - return apiWriteClearVersionsOutputConnection(tc,output,connectionName); + return apiWriteClearVersionsOutputConnection(tc,output,connectionName,authorizer); } else if (path.startsWith("clearrecords/")) { int firstSeparator = "clearrecords/".length(); String connectionName = decodeAPIPathElement(path.substring(firstSeparator)); - return apiWriteClearOutputConnection(tc,output,connectionName); + return apiWriteClearOutputConnection(tc,output,connectionName,authorizer); } else { @@ -4053,10 +4056,11 @@ public class ManifoldCF extends org.apac // Delete result codes public static final int DELETERESULT_NOTFOUND = 0; public static final int DELETERESULT_FOUND = 1; - + public static final int DELETERESULT_NOTALLOWED = 2; + /** Delete a job. */ - protected static int apiDeleteJob(IThreadContext tc, Configuration output, Long jobID) + protected static int apiDeleteJob(IThreadContext tc, Configuration output, Long jobID, IAuthorizer authorizer) throws ManifoldCFException { try @@ -4073,7 +4077,7 @@ public class ManifoldCF extends org.apac /** Delete authority group. */ - protected static int apiDeleteAuthorityGroup(IThreadContext tc, Configuration output, String groupName) + protected static int apiDeleteAuthorityGroup(IThreadContext tc, Configuration output, String groupName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -4090,7 +4094,7 @@ public class ManifoldCF extends org.apac /** Delete output connection. */ - protected static int apiDeleteOutputConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiDeleteOutputConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -4107,7 +4111,7 @@ public class ManifoldCF extends org.apac /** Delete authority connection. */ - protected static int apiDeleteAuthorityConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiDeleteAuthorityConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -4124,7 +4128,7 @@ public class ManifoldCF extends org.apac /** Delete repository connection. */ - protected static int apiDeleteRepositoryConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiDeleteRepositoryConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -4141,7 +4145,7 @@ public class ManifoldCF extends org.apac /** Delete notification connection. */ - protected static int apiDeleteNotificationConnection(IThreadContext tc, Configuration output, String connectionName) + protected static int apiDeleteNotificationConnection(IThreadContext tc, Configuration output, String connectionName, IAuthorizer authorizer) throws ManifoldCFException { try @@ -4168,32 +4172,32 @@ public class ManifoldCF extends org.apac if (path.startsWith("jobs/")) { Long jobID = new Long(path.substring("jobs/".length())); - return apiDeleteJob(tc,output,jobID); + return apiDeleteJob(tc,output,jobID,authorizer); } else if (path.startsWith("authoritygroups/")) { String groupName = decodeAPIPathElement(path.substring("authoritygroups/".length())); - return apiDeleteAuthorityGroup(tc,output,groupName); + return apiDeleteAuthorityGroup(tc,output,groupName,authorizer); } else if (path.startsWith("outputconnections/")) { String connectionName = decodeAPIPathElement(path.substring("outputconnections/".length())); - return apiDeleteOutputConnection(tc,output,connectionName); + return apiDeleteOutputConnection(tc,output,connectionName,authorizer); } else if (path.startsWith("authorityconnections/")) { String connectionName = decodeAPIPathElement(path.substring("authorityconnections/".length())); - return apiDeleteAuthorityConnection(tc,output,connectionName); + return apiDeleteAuthorityConnection(tc,output,connectionName,authorizer); } else if (path.startsWith("repositoryconnections/")) { String connectionName = decodeAPIPathElement(path.substring("repositoryconnections/".length())); - return apiDeleteRepositoryConnection(tc,output,connectionName); + return apiDeleteRepositoryConnection(tc,output,connectionName,authorizer); } else if (path.startsWith("notificationconnections/")) { String connectionName = decodeAPIPathElement(path.substring("notificationconnections/".length())); - return apiDeleteNotificationConnection(tc,output,connectionName); + return apiDeleteNotificationConnection(tc,output,connectionName,authorizer); } else {