NIFI-1554: - Addressing access controls for the Controller resource. - Addressing access controls for RAW site to site clients. - Addressing access controls for downloading content (from provenance and queue). - Addressing access controls for accessing queues. - Addressing access controls for cluster endpoints. - Addressing access controls for counter endpoints. - Removing redundant authorization calls. NIFI-2044: - Requiring revision when creating components. - Requiring component creation over POST requests. NIFI-1901 - Continuing to restore access control tests. - Converting access control tests to itegration tests. - Restoring contrib check to travis build. - This closes #567
Project: http://git-wip-us.apache.org/repos/asf/nifi/repo Commit: http://git-wip-us.apache.org/repos/asf/nifi/commit/f0811ca4 Tree: http://git-wip-us.apache.org/repos/asf/nifi/tree/f0811ca4 Diff: http://git-wip-us.apache.org/repos/asf/nifi/diff/f0811ca4 Branch: refs/heads/master Commit: f0811ca45adf15edf02f0f2d5f1d2d6929edd329 Parents: f0662a2 Author: Matt Gilman <[email protected]> Authored: Thu Jun 23 15:55:18 2016 -0400 Committer: Matt Gilman <[email protected]> Committed: Thu Jun 23 17:09:54 2016 -0400 ---------------------------------------------------------------------- .travis.yml | 2 +- .../main/java/org/apache/nifi/web/Revision.java | 27 +- .../java/org/apache/nifi/web/TestRevision.java | 61 + .../nifi-framework/nifi-authorizer/pom.xml | 4 + .../web/api/dto/ControllerConfigurationDTO.java | 54 +- .../nifi/web/api/dto/FlowConfigurationDTO.java | 80 ++ .../apache/nifi/web/api/dto/RevisionDTO.java | 3 +- .../entity/ControllerConfigurationEntity.java | 29 +- .../web/api/entity/FlowConfigurationEntity.java | 48 + .../authorization/resource/Authorizable.java | 26 +- .../authorization/resource/ResourceFactory.java | 44 + .../authorization/resource/ResourceType.java | 1 + .../nifi/authorization/user/NiFiUser.java | 4 - .../endpoints/ReportingTasksEndpointMerger.java | 2 +- .../nifi/web/revision/UpdateRevisionTask.java | 32 - .../controller/StandardFlowServiceTest.java | 22 +- .../scheduling/TestProcessorLifecycle.java | 42 +- .../nifi/remote/StandardRootGroupPort.java | 28 +- .../HttpServletConfigurationRequestContext.java | 6 +- .../nifi-web/nifi-web-api/pom.xml | 2 +- .../org/apache/nifi/web/AuthorizableLookup.java | 7 + .../org/apache/nifi/web/NiFiServiceFacade.java | 70 +- .../nifi/web/StandardAuthorizableLookup.java | 5 + .../nifi/web/StandardNiFiServiceFacade.java | 467 +++---- .../StandardNiFiWebConfigurationContext.java | 12 +- .../java/org/apache/nifi/web/UpdateResult.java | 40 - .../nifi/web/api/AccessPolicyResource.java | 20 +- .../apache/nifi/web/api/ClusterResource.java | 357 ----- .../apache/nifi/web/api/ConnectionResource.java | 17 +- .../apache/nifi/web/api/ControllerResource.java | 651 ++++++--- .../nifi/web/api/ControllerServiceResource.java | 23 +- .../apache/nifi/web/api/CountersResource.java | 252 ++++ .../nifi/web/api/FlowFileQueueResource.java | 69 +- .../org/apache/nifi/web/api/FlowResource.java | 386 ++++- .../org/apache/nifi/web/api/FunnelResource.java | 17 +- .../apache/nifi/web/api/HistoryResource.java | 525 ------- .../apache/nifi/web/api/InputPortResource.java | 53 +- .../org/apache/nifi/web/api/LabelResource.java | 51 +- .../org/apache/nifi/web/api/NodeResource.java | 219 --- .../apache/nifi/web/api/OutputPortResource.java | 53 +- .../nifi/web/api/ProcessGroupResource.java | 151 +- .../apache/nifi/web/api/ProcessorResource.java | 17 +- .../web/api/RemoteProcessGroupResource.java | 15 +- .../nifi/web/api/ReportingTaskResource.java | 23 +- .../apache/nifi/web/api/SiteToSiteResource.java | 21 +- .../apache/nifi/web/api/UserGroupsResource.java | 16 +- .../org/apache/nifi/web/api/UsersResource.java | 16 +- .../org/apache/nifi/web/api/dto/DtoFactory.java | 7 +- .../apache/nifi/web/api/dto/EntityFactory.java | 9 +- .../nifi/web/controller/ControllerFacade.java | 107 +- .../web/dao/impl/StandardConnectionDAO.java | 33 +- .../dao/impl/StandardControllerServiceDAO.java | 7 +- .../src/main/resources/nifi-web-api-context.xml | 19 +- .../web/StandardNiFiServiceFacadeSpec.groovy | 224 ++- .../apache/nifi/integration/NiFiWebApiTest.java | 6 +- .../accesscontrol/AccessControlHelper.java | 31 + .../accesscontrol/AccessTokenEndpointTest.java | 274 ---- .../accesscontrol/AdminAccessControlTest.java | 1010 ------------- .../ConnectionAccessControlTest.java | 427 ------ .../accesscontrol/DfmAccessControlTest.java | 1322 ------------------ .../accesscontrol/FunnelAccessControlTest.java | 361 ----- .../accesscontrol/ITAccessTokenEndpoint.java | 274 ++++ .../ITConnectionAccessControl.java | 427 ++++++ .../accesscontrol/ITCountersAccessControl.java | 86 ++ .../accesscontrol/ITFlowAccessControl.java | 245 ++++ .../accesscontrol/ITFunnelAccessControl.java | 361 +++++ .../accesscontrol/ITInputPortAccessControl.java | 405 ++++++ .../accesscontrol/ITLabelAccessControl.java | 402 ++++++ .../ITOutputPortAccessControl.java | 405 ++++++ .../ITProcessGroupAccessControl.java | 405 ++++++ .../accesscontrol/ITProcessorAccessControl.java | 489 +++++++ .../InputPortAccessControlTest.java | 405 ------ .../accesscontrol/LabelAccessControlTest.java | 402 ------ .../OutputPortAccessControlTest.java | 405 ------ .../ProcessGroupAccessControlTest.java | 405 ------ .../ProcessorAccessControlTest.java | 489 ------- .../ReadOnlyAccessControlTest.java | 983 ------------- .../util/NiFiFlowTestAuthorizer.java | 87 ++ .../integration/util/NiFiTestAuthorizer.java | 4 +- .../nifi/integration/util/NiFiTestUser.java | 16 +- .../nifi/web/api/TestSiteToSiteResource.java | 4 +- .../org.apache.nifi.authorization.Authorizer | 3 +- .../resources/access-control/authorizers.xml | 4 + .../propertytable/jquery.propertytable.js | 5 + .../header/components/nf-ng-funnel-component.js | 5 + .../header/components/nf-ng-group-component.js | 5 + .../components/nf-ng-input-port-component.js | 5 + .../header/components/nf-ng-label-component.js | 5 + .../components/nf-ng-output-port-component.js | 5 + .../components/nf-ng-processor-component.js | 5 + .../nf-ng-remote-process-group-component.js | 5 + .../src/main/webapp/js/nf/canvas/nf-canvas.js | 8 +- .../js/nf/canvas/nf-connection-configuration.js | 5 + .../js/nf/canvas/nf-controller-service.js | 4 +- .../js/nf/canvas/nf-controller-services.js | 5 + .../js/nf/canvas/nf-processor-configuration.js | 2 +- .../webapp/js/nf/canvas/nf-reporting-task.js | 4 +- .../src/main/webapp/js/nf/canvas/nf-settings.js | 17 +- .../webapp/js/nf/cluster/nf-cluster-table.js | 2 +- .../webapp/js/nf/counters/nf-counters-table.js | 2 +- .../webapp/js/nf/history/nf-history-model.js | 2 +- .../webapp/js/nf/history/nf-history-table.js | 2 +- .../main/webapp/js/nf/nf-processor-details.js | 2 +- .../js/nf/provenance/nf-provenance-table.js | 2 +- .../webapp/js/nf/provenance/nf-provenance.js | 2 +- .../webapp/js/nf/summary/nf-cluster-search.js | 2 +- .../webapp/js/nf/summary/nf-summary-table.js | 6 +- .../src/main/webapp/js/nf/summary/nf-summary.js | 2 +- .../processors/standard/TestGetJMSQueue.java | 33 +- .../nifi/controller/MonitorMemoryTest.java | 14 +- .../update/attributes/api/RuleResource.java | 2 +- 111 files changed, 5951 insertions(+), 8820 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/.travis.yml ---------------------------------------------------------------------- diff --git a/.travis.yml b/.travis.yml index db579ce..811a4c2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -14,4 +14,4 @@ before_install: - sed -e "s/^\\(127\\.0\\.0\\.1.*\\)/\\1 $(hostname | cut -c1-63)/" /etc/hosts | sudo tee /etc/hosts - sed -i.bak -e 's|https://nexus.codehaus.org/snapshots/|https://oss.sonatype.org/content/repositories/codehaus-snapshots/|g' ~/.m2/settings.xml -script: mvn clean install -T4 +script: mvn clean install -Pcontrib-check http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-api/src/main/java/org/apache/nifi/web/Revision.java ---------------------------------------------------------------------- diff --git a/nifi-api/src/main/java/org/apache/nifi/web/Revision.java b/nifi-api/src/main/java/org/apache/nifi/web/Revision.java index 1308e1b..d768faa 100644 --- a/nifi-api/src/main/java/org/apache/nifi/web/Revision.java +++ b/nifi-api/src/main/java/org/apache/nifi/web/Revision.java @@ -17,7 +17,6 @@ package org.apache.nifi.web; import java.io.Serializable; -import java.util.Objects; /** * A model object representing a revision. Equality is defined as matching @@ -46,15 +45,17 @@ public class Revision implements Serializable { */ private final String componentId; - @Deprecated - public Revision(Long revision, String clientId) { - this(revision, clientId, "root"); // TODO: remove this constructor. This is to bridge the gap right now - } + public Revision(Long version, String clientId, String componentId) { + if (version == null) { + throw new IllegalArgumentException("The revision must be specified."); + } + if (componentId == null) { + throw new IllegalArgumentException("The componentId must be specified."); + } - public Revision(Long revision, String clientId, String componentId) { - this.version = revision; + this.version = version; this.clientId = clientId; - this.componentId = Objects.requireNonNull(componentId); + this.componentId = componentId; } public String getClientId() { @@ -69,6 +70,16 @@ public class Revision implements Serializable { return componentId; } + /** + * Returns a new Revision that has the same Client ID and Component ID as this one + * but with a larger version + * + * @return the updated Revision + */ + public Revision incrementRevision(final String clientId) { + return new Revision(version + 1, clientId, componentId); + } + @Override public boolean equals(final Object obj) { if (obj == null) { http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-api/src/test/java/org/apache/nifi/web/TestRevision.java ---------------------------------------------------------------------- diff --git a/nifi-api/src/test/java/org/apache/nifi/web/TestRevision.java b/nifi-api/src/test/java/org/apache/nifi/web/TestRevision.java new file mode 100644 index 0000000..6d513fd --- /dev/null +++ b/nifi-api/src/test/java/org/apache/nifi/web/TestRevision.java @@ -0,0 +1,61 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.web; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +/** + * + */ +public class TestRevision { + + @Test(expected = IllegalArgumentException.class) + public void testNullVersion() throws Exception { + new Revision(null, "client-id", "component-id"); + } + + @Test(expected = IllegalArgumentException.class) + public void testNullComponentId() throws Exception { + new Revision(0l, "client-id", null); + } + + @Test + public void testIncrementRevision() throws Exception { + final String clientId = "client-id"; + final String componentId = "component-id"; + final Revision revision = new Revision(0l, clientId, componentId); + final Revision updatedRevision = revision.incrementRevision(clientId); + assertEquals(1, updatedRevision.getVersion().longValue()); + assertEquals(clientId, updatedRevision.getClientId()); + assertEquals(componentId, updatedRevision.getComponentId()); + } + + @Test + public void testIncrementRevisionNewClient() throws Exception { + final String clientId = "client-id"; + final String newClientId = "new-client-id"; + final String componentId = "component-id"; + final Revision revision = new Revision(0l, clientId, componentId); + final Revision updatedRevision = revision.incrementRevision(newClientId); + assertEquals(1, updatedRevision.getVersion().longValue()); + assertEquals(newClientId, updatedRevision.getClientId()); + assertEquals(componentId, updatedRevision.getComponentId()); + } + +} http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/pom.xml index b8e1652..ee9f85a 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/pom.xml +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-authorizer/pom.xml @@ -69,6 +69,10 @@ <groupId>org.apache.nifi</groupId> <artifactId>nifi-nar-utils</artifactId> </dependency> + <dependency> + <groupId>org.apache.nifi</groupId> + <artifactId>nifi-properties</artifactId> + </dependency> </dependencies> </project> \ No newline at end of file http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java index 2c7edf7..aee65b4 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/ControllerConfigurationDTO.java @@ -17,26 +17,18 @@ package org.apache.nifi.web.api.dto; import com.wordnik.swagger.annotations.ApiModelProperty; -import org.apache.nifi.web.api.dto.util.TimeAdapter; import javax.xml.bind.annotation.XmlType; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; -import java.util.Date; /** * Details for the controller configuration. */ -@XmlType(name = "config") +@XmlType(name = "controllerConfiguration") public class ControllerConfigurationDTO { private Integer maxTimerDrivenThreadCount; private Integer maxEventDrivenThreadCount; - private Long autoRefreshIntervalSeconds; - - private Date currentTime; - private Integer timeOffset; - /** * @return maximum number of timer driven threads this NiFi has available */ @@ -64,48 +56,4 @@ public class ControllerConfigurationDTO { public void setMaxEventDrivenThreadCount(Integer maxEventDrivenThreadCount) { this.maxEventDrivenThreadCount = maxEventDrivenThreadCount; } - - /** - * @return interval in seconds between the automatic NiFi refresh requests. This value is read only - */ - @ApiModelProperty( - value = "The interval in seconds between the automatic NiFi refresh requests.", - readOnly = true - ) - public Long getAutoRefreshIntervalSeconds() { - return autoRefreshIntervalSeconds; - } - - public void setAutoRefreshIntervalSeconds(Long autoRefreshIntervalSeconds) { - this.autoRefreshIntervalSeconds = autoRefreshIntervalSeconds; - } - - /** - * @return current time on the server - */ - @XmlJavaTypeAdapter(TimeAdapter.class) - @ApiModelProperty( - value = "The current time on the system." - ) - public Date getCurrentTime() { - return currentTime; - } - - public void setCurrentTime(Date currentTime) { - this.currentTime = currentTime; - } - - /** - * @return time offset of the server - */ - @ApiModelProperty( - value = "The time offset of the system." - ) - public Integer getTimeOffset() { - return timeOffset; - } - - public void setTimeOffset(Integer timeOffset) { - this.timeOffset = timeOffset; - } } http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java new file mode 100644 index 0000000..d5028d2 --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/FlowConfigurationDTO.java @@ -0,0 +1,80 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.web.api.dto; + +import com.wordnik.swagger.annotations.ApiModelProperty; +import org.apache.nifi.web.api.dto.util.TimeAdapter; + +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import java.util.Date; + +/** + * Details for the controller configuration. + */ +@XmlType(name = "flowConfiguration") +public class FlowConfigurationDTO { + + private Long autoRefreshIntervalSeconds; + + private Date currentTime; + private Integer timeOffset; + + /** + * @return interval in seconds between the automatic NiFi refresh requests. This value is read only + */ + @ApiModelProperty( + value = "The interval in seconds between the automatic NiFi refresh requests.", + readOnly = true + ) + public Long getAutoRefreshIntervalSeconds() { + return autoRefreshIntervalSeconds; + } + + public void setAutoRefreshIntervalSeconds(Long autoRefreshIntervalSeconds) { + this.autoRefreshIntervalSeconds = autoRefreshIntervalSeconds; + } + + /** + * @return current time on the server + */ + @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The current time on the system." + ) + public Date getCurrentTime() { + return currentTime; + } + + public void setCurrentTime(Date currentTime) { + this.currentTime = currentTime; + } + + /** + * @return time offset of the server + */ + @ApiModelProperty( + value = "The time offset of the system." + ) + public Integer getTimeOffset() { + return timeOffset; + } + + public void setTimeOffset(Integer timeOffset) { + this.timeOffset = timeOffset; + } +} http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java index 0e673f8..e50e6e1 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/dto/RevisionDTO.java @@ -70,7 +70,8 @@ public class RevisionDTO { * @return The user that last modified the flow */ @ApiModelProperty( - value = "The user that last modified the flow." + value = "The user that last modified the flow.", + readOnly = true ) public String getLastModifier() { return lastModifier; http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerConfigurationEntity.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerConfigurationEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerConfigurationEntity.java index 4b1188c..066950e 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerConfigurationEntity.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/ControllerConfigurationEntity.java @@ -20,8 +20,11 @@ import com.wordnik.swagger.annotations.ApiModelProperty; import org.apache.nifi.web.api.dto.AccessPolicyDTO; import org.apache.nifi.web.api.dto.ControllerConfigurationDTO; import org.apache.nifi.web.api.dto.RevisionDTO; +import org.apache.nifi.web.api.dto.util.TimeAdapter; import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import java.util.Date; /** * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a ControllerConfigurationDTO. @@ -29,7 +32,8 @@ import javax.xml.bind.annotation.XmlRootElement; @XmlRootElement(name = "controllerConfigurationEntity") public class ControllerConfigurationEntity extends Entity { - private ControllerConfigurationDTO config; + private Date currentTime; + private ControllerConfigurationDTO controllerConfiguration; private RevisionDTO revision; private AccessPolicyDTO accessPolicy; @@ -59,12 +63,12 @@ public class ControllerConfigurationEntity extends Entity { @ApiModelProperty( value = "The controller configuration." ) - public ControllerConfigurationDTO getConfig() { - return config; + public ControllerConfigurationDTO getControllerConfiguration() { + return controllerConfiguration; } - public void setConfig(ControllerConfigurationDTO config) { - this.config = config; + public void setControllerConfiguration(ControllerConfigurationDTO controllerConfiguration) { + this.controllerConfiguration = controllerConfiguration; } /** @@ -82,4 +86,19 @@ public class ControllerConfigurationEntity extends Entity { public void setAccessPolicy(AccessPolicyDTO accessPolicy) { this.accessPolicy = accessPolicy; } + + /** + * @return current time on the server + */ + @XmlJavaTypeAdapter(TimeAdapter.class) + @ApiModelProperty( + value = "The current time on the system." + ) + public Date getCurrentTime() { + return currentTime; + } + + public void setCurrentTime(Date currentTime) { + this.currentTime = currentTime; + } } http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FlowConfigurationEntity.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FlowConfigurationEntity.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FlowConfigurationEntity.java new file mode 100644 index 0000000..54af4d4 --- /dev/null +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-client-dto/src/main/java/org/apache/nifi/web/api/entity/FlowConfigurationEntity.java @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.web.api.entity; + +import com.wordnik.swagger.annotations.ApiModelProperty; +import org.apache.nifi.web.api.dto.FlowConfigurationDTO; + +import javax.xml.bind.annotation.XmlRootElement; + +/** + * A serialized representation of this class can be placed in the entity body of a request or response to or from the API. This particular entity holds a reference to a FlowConfigurationDTO. + */ +@XmlRootElement(name = "flowConfigurationEntity") +public class FlowConfigurationEntity extends Entity { + + private FlowConfigurationDTO flowConfiguration; + + /** + * The FlowConfigurationDTO that is being serialized. + * + * @return The FlowConfigurationDTO object + */ + @ApiModelProperty( + value = "The controller configuration." + ) + public FlowConfigurationDTO getFlowConfiguration() { + return flowConfiguration; + } + + public void setFlowConfiguration(FlowConfigurationDTO flowConfiguration) { + this.flowConfiguration = flowConfiguration; + } + +} http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java index c897be2..50f7288 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/Authorizable.java @@ -65,18 +65,30 @@ public interface Authorizable { * @return is authorized */ default AuthorizationResult checkAuthorization(Authorizer authorizer, RequestAction action) { - final NiFiUser user = NiFiUserUtils.getNiFiUser(); + return checkAuthorization(authorizer, action, NiFiUserUtils.getNiFiUser()); + } + /** + * Returns the result of an authorization request for the specified user for the specified action on the specified + * resource. This method does not imply the user is directly attempting to access the specified resource. If the user is + * attempting a direct access use Authorizable.authorize(). + * + * @param authorizer authorizer + * @param action action + * @param user user + * @return is authorized + */ + default AuthorizationResult checkAuthorization(Authorizer authorizer, RequestAction action, NiFiUser user) { // TODO - include user details context // build the request final AuthorizationRequest request = new AuthorizationRequest.Builder() - .identity(user.getIdentity()) - .anonymous(user.isAnonymous()) - .accessAttempt(false) - .action(action) - .resource(getResource()) - .build(); + .identity(user.getIdentity()) + .anonymous(user.isAnonymous()) + .accessAttempt(false) + .action(action) + .resource(getResource()) + .build(); // perform the authorization final AuthorizationResult result = authorizer.authorize(request); http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java index 92d8e33..0454ad7 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceFactory.java @@ -169,6 +169,18 @@ public final class ResourceFactory { } }; + private final static Resource COUNTERS_RESOURCE = new Resource() { + @Override + public String getIdentifier() { + return ResourceType.Counters.getValue(); + } + + @Override + public String getName() { + return "Counters"; + } + }; + private final static Resource PROVENANCE_RESOURCE = new Resource() { @Override public String getIdentifier() { @@ -437,6 +449,15 @@ public final class ResourceFactory { } /** + * Gets the Resource for accessing the Counters.. + * + * @return The resource for accessing the Controller + */ + public static Resource getCountersResource() { + return COUNTERS_RESOURCE; + } + + /** * Gets the Resource for accessing provenance. Access to this Resource allows the user to access data provenance. However, additional authorization * is required based on the component that generated the event and the attributes of the event. * @@ -529,6 +550,29 @@ public final class ResourceFactory { } /** + * Gets a Resource for performing site to site on a port. + * + * @param identifier The identifier of the component being accessed + * @param name The name of the component being accessed + * @return The resource + */ + public static Resource getSiteToSiteResource(final String identifier, final String name) { + Objects.requireNonNull(identifier, "The component identifier must be specified."); + + return new Resource() { + @Override + public String getIdentifier() { + return String.format("%s/%s", ResourceType.SiteToSite.getValue(), identifier); + } + + @Override + public String getName() { + return name; + } + }; + } + + /** * Gets the {@link Resource} for accessing {@link AccessPolicy}s. * @return The policies resource */ http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceType.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceType.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceType.java index 784af6d..94b6118 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceType.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/resource/ResourceType.java @@ -38,6 +38,7 @@ public enum ResourceType { System("/system"), Template("/templates"), Token("/token"), + Counters("/counters"), User("/users"); final String value; http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java index 80e7406..f560cd7 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-authorization/src/main/java/org/apache/nifi/authorization/user/NiFiUser.java @@ -35,10 +35,6 @@ public class NiFiUser implements Serializable { this(identity, identity, null); } - public NiFiUser(String identity, String userName) { - this(identity, userName, null); - } - public NiFiUser(String identity, NiFiUser chain) { this(identity, identity, chain); } http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ReportingTasksEndpointMerger.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ReportingTasksEndpointMerger.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ReportingTasksEndpointMerger.java index a5390e8..8771722 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ReportingTasksEndpointMerger.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-cluster/src/main/java/org/apache/nifi/cluster/coordination/http/endpoints/ReportingTasksEndpointMerger.java @@ -30,7 +30,7 @@ import java.util.Map; import java.util.Set; public class ReportingTasksEndpointMerger implements EndpointResponseMerger { - public static final String REPORTING_TASKS_URI = "/nifi-api/controller/reporting-tasks"; + public static final String REPORTING_TASKS_URI = "/nifi-api/flow/reporting-tasks"; @Override public boolean canHandle(URI uri, String method) { http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/web/revision/UpdateRevisionTask.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/web/revision/UpdateRevisionTask.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/web/revision/UpdateRevisionTask.java index f2f7914..bcf68b5 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/web/revision/UpdateRevisionTask.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core-api/src/main/java/org/apache/nifi/web/revision/UpdateRevisionTask.java @@ -17,12 +17,6 @@ package org.apache.nifi.web.revision; -import java.util.ArrayList; -import java.util.Collection; -import java.util.List; - -import org.apache.nifi.web.Revision; - /** * <p> * A task that is responsible for updating some component(s). @@ -35,30 +29,4 @@ public interface UpdateRevisionTask<T> { * @return the updated revisions for the components */ RevisionUpdate<T> update(); - - /** - * Returns a new Revision that has the same Client ID and Component ID as the given one - * but with a larger version - * - * @param revision the revision to update - * @return the updated Revision - */ - default Revision incrementRevision(Revision revision) { - return new Revision(revision.getVersion() + 1, revision.getClientId(), revision.getComponentId()); - } - - /** - * Returns a Collection of Revisions that contains an updated version of all Revisions passed in - * - * @param revisions the Revisions to update - * @return a Collection of all Revisions that are passed in - */ - default Collection<Revision> incrementRevisions(Revision... revisions) { - final List<Revision> updated = new ArrayList<>(revisions.length); - for (final Revision revision : revisions) { - updated.add(incrementRevision(revision)); - } - - return updated; - } } http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardFlowServiceTest.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardFlowServiceTest.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardFlowServiceTest.java index b2d920a..9dd9762 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardFlowServiceTest.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/StandardFlowServiceTest.java @@ -16,14 +16,7 @@ */ package org.apache.nifi.controller; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; - -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - +import org.apache.commons.io.IOUtils; import org.apache.nifi.admin.service.AuditService; import org.apache.nifi.authorization.Authorizer; import org.apache.nifi.cluster.protocol.StandardDataFlow; @@ -31,6 +24,8 @@ import org.apache.nifi.controller.repository.FlowFileEventRepository; import org.apache.nifi.controller.serialization.FlowSerializationException; import org.apache.nifi.controller.serialization.FlowSerializer; import org.apache.nifi.controller.serialization.StandardFlowSerializer; +import org.apache.nifi.encrypt.StringEncryptor; +import org.apache.nifi.events.VolatileBulletinRepository; import org.apache.nifi.util.NiFiProperties; import org.apache.nifi.web.api.dto.ConnectableDTO; import org.apache.nifi.web.api.dto.ConnectionDTO; @@ -41,15 +36,20 @@ import org.apache.nifi.web.api.dto.ProcessGroupDTO; import org.apache.nifi.web.api.dto.ProcessorConfigDTO; import org.apache.nifi.web.api.dto.ProcessorDTO; import org.apache.nifi.web.revision.RevisionManager; -import org.apache.commons.io.IOUtils; -import org.apache.nifi.encrypt.StringEncryptor; -import org.apache.nifi.events.VolatileBulletinRepository; import org.junit.Assert; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Ignore; import org.junit.Test; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; + /** */ @Ignore http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestProcessorLifecycle.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestProcessorLifecycle.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestProcessorLifecycle.java index 16f4784..0933013 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestProcessorLifecycle.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-framework-core/src/test/java/org/apache/nifi/controller/scheduling/TestProcessorLifecycle.java @@ -16,27 +16,6 @@ */ package org.apache.nifi.controller.scheduling; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.mockito.Mockito.mock; - -import java.io.File; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.LinkedList; -import java.util.List; -import java.util.Random; -import java.util.UUID; -import java.util.concurrent.CountDownLatch; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.TimeUnit; -import java.util.concurrent.locks.LockSupport; - import org.apache.commons.io.FileUtils; import org.apache.nifi.admin.service.AuditService; import org.apache.nifi.annotation.lifecycle.OnScheduled; @@ -71,6 +50,27 @@ import org.junit.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.File; +import java.lang.reflect.Method; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.Collections; +import java.util.LinkedList; +import java.util.List; +import java.util.Random; +import java.util.UUID; +import java.util.concurrent.CountDownLatch; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.locks.LockSupport; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import static org.mockito.Mockito.mock; + /** * Validate Processor's life-cycle operation within the context of * {@link FlowController} and {@link StandardProcessScheduler} http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/StandardRootGroupPort.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/StandardRootGroupPort.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/StandardRootGroupPort.java index cd10d5c..9ad9987 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/StandardRootGroupPort.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-site-to-site/src/main/java/org/apache/nifi/remote/StandardRootGroupPort.java @@ -16,7 +16,14 @@ */ package org.apache.nifi.remote; +import org.apache.nifi.authorization.AuthorizationResult; +import org.apache.nifi.authorization.AuthorizationResult.Result; import org.apache.nifi.authorization.Authorizer; +import org.apache.nifi.authorization.RequestAction; +import org.apache.nifi.authorization.Resource; +import org.apache.nifi.authorization.resource.Authorizable; +import org.apache.nifi.authorization.resource.ResourceFactory; +import org.apache.nifi.authorization.user.NiFiUser; import org.apache.nifi.components.ValidationResult; import org.apache.nifi.connectable.ConnectableType; import org.apache.nifi.controller.AbstractPort; @@ -72,6 +79,7 @@ public class StandardRootGroupPort extends AbstractPort implements RootGroupPort private final ProcessScheduler processScheduler; private final boolean secure; private final Authorizer authorizer; + @SuppressWarnings("unused") private final BulletinRepository bulletinRepository; private final EventReporter eventReporter; @@ -337,6 +345,16 @@ public class StandardRootGroupPort extends AbstractPort implements RootGroupPort } @Override + public Authorizable getParentAuthorizable() { + return null; + } + + @Override + public Resource getResource() { + return ResourceFactory.getSiteToSiteResource(getIdentifier(), getName()); + } + + @Override public PortAuthorizationResult checkUserAuthorization(final String dn) { if (!secure) { return new StandardPortAuthorizationResult(true, "Site-to-Site is not Secure"); @@ -349,7 +367,15 @@ public class StandardRootGroupPort extends AbstractPort implements RootGroupPort return new StandardPortAuthorizationResult(false, "User DN is not known"); } - // TODO - Replace with call to Authorizer to authorize site to site data transfer + // attempt to authorize the specified user + final AuthorizationResult result = checkAuthorization(authorizer, RequestAction.WRITE, new NiFiUser(dn)); + if (!Result.Approved.equals(result.getResult())) { + final String message = String.format("%s authorization failed for user %s because %s", this, dn, result.getExplanation()); + logger.warn(message); + eventReporter.reportEvent(Severity.WARNING, CATEGORY, message); + return new StandardPortAuthorizationResult(false, message); + } + return new StandardPortAuthorizationResult(true, "User is Authorized"); } http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-custom-ui-utilities/src/main/java/org/apache/nifi/web/HttpServletConfigurationRequestContext.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-custom-ui-utilities/src/main/java/org/apache/nifi/web/HttpServletConfigurationRequestContext.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-custom-ui-utilities/src/main/java/org/apache/nifi/web/HttpServletConfigurationRequestContext.java index 986ce4c..7c4131f 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-custom-ui-utilities/src/main/java/org/apache/nifi/web/HttpServletConfigurationRequestContext.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-custom-ui-utilities/src/main/java/org/apache/nifi/web/HttpServletConfigurationRequestContext.java @@ -24,6 +24,7 @@ import javax.servlet.http.HttpServletRequest; */ public class HttpServletConfigurationRequestContext extends HttpServletRequestContext implements NiFiWebConfigurationRequestContext { + private static final String ID_PARAM = "id"; private static final String CLIENT_ID_PARAM = "clientId"; private static final String REVISION_PARAM = "revision"; @@ -36,7 +37,7 @@ public class HttpServletConfigurationRequestContext extends HttpServletRequestCo /** * @return the revision retrieved from the request parameters with keys - * equal to "clientId" and "revision". + * equal to "clientId", "revision", and "id". */ @Override public Revision getRevision() { @@ -49,8 +50,9 @@ public class HttpServletConfigurationRequestContext extends HttpServletRequestCo } final String clientId = request.getParameter(CLIENT_ID_PARAM); + final String componentId = request.getParameter(ID_PARAM); - return new Revision(revision, clientId); + return new Revision(revision, clientId, componentId); } } http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml index 9882486..38ce1a6 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/pom.xml @@ -49,7 +49,7 @@ </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> - <artifactId>maven-surefire-plugin</artifactId> + <artifactId>maven-failsafe-plugin</artifactId> <configuration> <argLine>-Xms512m -Xmx512m</argLine> <forkCount>1</forkCount> http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/AuthorizableLookup.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/AuthorizableLookup.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/AuthorizableLookup.java index e032718..f988780 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/AuthorizableLookup.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/AuthorizableLookup.java @@ -25,6 +25,13 @@ import org.apache.nifi.controller.Snippet; public interface AuthorizableLookup { /** + * Get the authorizable Controller. + * + * @return authorizable + */ + Authorizable getController(); + + /** * Get the authorizable Processor. * * @param id processor id http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java index f9a91cf..1c08f75 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/NiFiServiceFacade.java @@ -73,6 +73,7 @@ import org.apache.nifi.web.api.entity.ConnectionEntity; import org.apache.nifi.web.api.entity.ControllerConfigurationEntity; import org.apache.nifi.web.api.entity.ControllerServiceEntity; import org.apache.nifi.web.api.entity.ControllerServiceReferencingComponentsEntity; +import org.apache.nifi.web.api.entity.FlowConfigurationEntity; import org.apache.nifi.web.api.entity.FlowEntity; import org.apache.nifi.web.api.entity.FunnelEntity; import org.apache.nifi.web.api.entity.LabelEntity; @@ -290,6 +291,13 @@ public interface NiFiServiceFacade { ControllerConfigurationEntity getControllerConfiguration(); /** + * Gets the configuration for the flow. + * + * @return Flow configuration transfer object + */ + FlowConfigurationEntity getFlowConfiguration(); + + /** * Updates the configuration for this controller. * * @param revision Revision to compare with current base revision @@ -447,11 +455,12 @@ public interface NiFiServiceFacade { /** * Creates a new Processor. * + * @param revision revision * @param groupId Group id * @param processorDTO The processor DTO * @return The new processor DTO */ - ProcessorEntity createProcessor(String groupId, ProcessorDTO processorDTO); + ProcessorEntity createProcessor(Revision revision, String groupId, ProcessorDTO processorDTO); /** * Gets the Processor transfer object for the specified id. @@ -508,7 +517,7 @@ public interface NiFiServiceFacade { * @param processorDTO The processorDTO * @return The updated processor */ - UpdateResult<ProcessorEntity> updateProcessor(Revision revision, ProcessorDTO processorDTO); + ProcessorEntity updateProcessor(Revision revision, ProcessorDTO processorDTO); /** * Verifies the specified processor can be removed. @@ -565,11 +574,12 @@ public interface NiFiServiceFacade { /** * Creates a new Relationship target. * + * @param revision revision * @param groupId group * @param connectionDTO The Connection DTO * @return The Connection DTO */ - ConnectionEntity createConnection(String groupId, ConnectionDTO connectionDTO); + ConnectionEntity createConnection(Revision revision, String groupId, ConnectionDTO connectionDTO); /** * Determines if this connection can be listed. @@ -600,7 +610,7 @@ public interface NiFiServiceFacade { * @param connectionDTO The Connection DTO * @return The Connection DTO */ - UpdateResult<ConnectionEntity> updateConnection(Revision revision, ConnectionDTO connectionDTO); + ConnectionEntity updateConnection(Revision revision, ConnectionDTO connectionDTO); /** * Determines if this connection can be removed. @@ -690,11 +700,12 @@ public interface NiFiServiceFacade { /** * Creates a new input port. * + * @param revision revision * @param groupId The id of the group this port should be create in * @param inputPortDTO The input PortDTO * @return snapshot */ - PortEntity createInputPort(String groupId, PortDTO inputPortDTO); + PortEntity createInputPort(Revision revision, String groupId, PortDTO inputPortDTO); /** * Gets an input port. @@ -732,9 +743,9 @@ public interface NiFiServiceFacade { * * @param revision Revision to compare with current base revision * @param inputPortDTO The input PortDTO - * @return snapshort + * @return snapshot */ - UpdateResult<PortEntity> updateInputPort(Revision revision, PortDTO inputPortDTO); + PortEntity updateInputPort(Revision revision, PortDTO inputPortDTO); /** * Determines if the input port could be deleted. @@ -758,11 +769,12 @@ public interface NiFiServiceFacade { /** * Creates a new output port. * + * @param revision revision * @param groupId The id of the group this port should be create in * @param outputPortDTO The output PortDTO * @return snapshot */ - PortEntity createOutputPort( String groupId, PortDTO outputPortDTO); + PortEntity createOutputPort(Revision revision, String groupId, PortDTO outputPortDTO); /** * Gets an output port. @@ -802,7 +814,7 @@ public interface NiFiServiceFacade { * @param outputPortDTO The output PortDTO * @return snapshot */ - UpdateResult<PortEntity> updateOutputPort(Revision revision, PortDTO outputPortDTO); + PortEntity updateOutputPort(Revision revision, PortDTO outputPortDTO); /** * Determines if the output port could be deleted. @@ -838,11 +850,12 @@ public interface NiFiServiceFacade { /** * Creates a new process group. * + * @param revision revision * @param parentGroupId The id of the parent group * @param processGroupDTO The ProcessGroupDTO * @return snapshot */ - ProcessGroupEntity createProcessGroup(String parentGroupId, ProcessGroupDTO processGroupDTO); + ProcessGroupEntity createProcessGroup(Revision revision, String parentGroupId, ProcessGroupDTO processGroupDTO); /** * Returns the process group. @@ -886,7 +899,7 @@ public interface NiFiServiceFacade { * @param processGroupDTO The ProcessGroupDTO * @return snapshot */ - UpdateResult<ProcessGroupEntity> updateProcessGroup(Revision revision, ProcessGroupDTO processGroupDTO); + ProcessGroupEntity updateProcessGroup(Revision revision, ProcessGroupDTO processGroupDTO); /** * Verifies the specified process group can be removed. @@ -910,11 +923,12 @@ public interface NiFiServiceFacade { /** * Creates a new remote process group. * + * @param revision revision * @param groupId The id of the parent group * @param remoteProcessGroupDTO The RemoteProcessGroupDTO * @return snapshot */ - RemoteProcessGroupEntity createRemoteProcessGroup(String groupId, RemoteProcessGroupDTO remoteProcessGroupDTO); + RemoteProcessGroupEntity createRemoteProcessGroup(Revision revision, String groupId, RemoteProcessGroupDTO remoteProcessGroupDTO); /** * Gets a remote process group. @@ -978,7 +992,7 @@ public interface NiFiServiceFacade { * @param remoteProcessGroupDTO The RemoteProcessGroupDTO * @return snapshot */ - UpdateResult<RemoteProcessGroupEntity> updateRemoteProcessGroup(Revision revision, RemoteProcessGroupDTO remoteProcessGroupDTO); + RemoteProcessGroupEntity updateRemoteProcessGroup(Revision revision, RemoteProcessGroupDTO remoteProcessGroupDTO); /** * Updates the specified remote process groups input port. @@ -1022,11 +1036,12 @@ public interface NiFiServiceFacade { /** * Creates a funnel. * + * @param revision revision * @param groupId group * @param funnelDTO funnel * @return The funnel DTO */ - FunnelEntity createFunnel(String groupId, FunnelDTO funnelDTO); + FunnelEntity createFunnel(Revision revision, String groupId, FunnelDTO funnelDTO); /** * Gets the specified funnel. @@ -1045,13 +1060,13 @@ public interface NiFiServiceFacade { Set<FunnelEntity> getFunnels(String groupId); /** - * Updates the specified label. + * Updates the specified funnel. * * @param revision Revision to compare with current base revision * @param funnelDTO The funnel DTO * @return The funnel DTO */ - UpdateResult<FunnelEntity> updateFunnel(Revision revision, FunnelDTO funnelDTO); + FunnelEntity updateFunnel(Revision revision, FunnelDTO funnelDTO); /** * Verifies the specified funnel can be deleted. @@ -1145,11 +1160,12 @@ public interface NiFiServiceFacade { /** * Creates a label. * + * @param revision revision * @param groupId group * @param labelDTO The label DTO * @return The label DTO */ - LabelEntity createLabel(String groupId, LabelDTO labelDTO); + LabelEntity createLabel(Revision revision, String groupId, LabelDTO labelDTO); /** * Gets the specified label. @@ -1174,7 +1190,7 @@ public interface NiFiServiceFacade { * @param labelDTO The label DTO * @return The label DTO */ - UpdateResult<LabelEntity> updateLabel(Revision revision, LabelDTO labelDTO); + LabelEntity updateLabel(Revision revision, LabelDTO labelDTO); /** * Deletes the specified label. @@ -1210,7 +1226,7 @@ public interface NiFiServiceFacade { * @param userDTO The user DTO * @return The user transfer object */ - UpdateResult<UserEntity> updateUser(Revision revision, UserDTO userDTO); + UserEntity updateUser(Revision revision, UserDTO userDTO); /** * Deletes the specified user. @@ -1245,7 +1261,7 @@ public interface NiFiServiceFacade { * @param userGroupDTO The user group DTO * @return The user group transfer object */ - UpdateResult<UserGroupEntity> updateUserGroup(Revision revision, UserGroupDTO userGroupDTO); + UserGroupEntity updateUserGroup(Revision revision, UserGroupDTO userGroupDTO); /** * Deletes the specified user group. @@ -1279,7 +1295,7 @@ public interface NiFiServiceFacade { * @param accessPolicyDTO The access policy DTO * @return The access policy transfer object */ - UpdateResult<AccessPolicyEntity> updateAccessPolicy(Revision revision, AccessPolicyDTO accessPolicyDTO); + AccessPolicyEntity updateAccessPolicy(Revision revision, AccessPolicyDTO accessPolicyDTO); /** * Deletes the specified access policy. @@ -1295,11 +1311,12 @@ public interface NiFiServiceFacade { /** * Creates a controller service. * + * @param revision revision * @param groupId the ID of the Process Group to add the Controller Service to * @param controllerServiceDTO The controller service DTO * @return The controller service DTO */ - ControllerServiceEntity createControllerService(String groupId, ControllerServiceDTO controllerServiceDTO); + ControllerServiceEntity createControllerService(Revision revision, String groupId, ControllerServiceDTO controllerServiceDTO); /** * Gets all controller services that belong to the given group and its parent/ancestor groups @@ -1347,13 +1364,13 @@ public interface NiFiServiceFacade { Map<String, Revision> referenceRevisions, String controllerServiceId, ScheduledState scheduledState, ControllerServiceState controllerServiceState); /** - * Updates the specified label. + * Updates the specified controller service. * * @param revision Revision to compare with current base revision * @param controllerServiceDTO The controller service DTO * @return The controller service DTO */ - UpdateResult<ControllerServiceEntity> updateControllerService(Revision revision, ControllerServiceDTO controllerServiceDTO); + ControllerServiceEntity updateControllerService(Revision revision, ControllerServiceDTO controllerServiceDTO); /** * Deletes the specified label. @@ -1393,10 +1410,11 @@ public interface NiFiServiceFacade { /** * Creates a reporting task. * + * @param revision revision * @param reportingTaskDTO The reporting task DTO * @return The reporting task DTO */ - ReportingTaskEntity createReportingTask(ReportingTaskDTO reportingTaskDTO); + ReportingTaskEntity createReportingTask(Revision revision, ReportingTaskDTO reportingTaskDTO); /** * Gets all reporting tasks. @@ -1429,7 +1447,7 @@ public interface NiFiServiceFacade { * @param reportingTaskDTO The reporting task DTO * @return The reporting task DTO */ - UpdateResult<ReportingTaskEntity> updateReportingTask(Revision revision, ReportingTaskDTO reportingTaskDTO); + ReportingTaskEntity updateReportingTask(Revision revision, ReportingTaskDTO reportingTaskDTO); /** * Deletes the specified reporting task. http://git-wip-us.apache.org/repos/asf/nifi/blob/f0811ca4/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardAuthorizableLookup.java ---------------------------------------------------------------------- diff --git a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardAuthorizableLookup.java b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardAuthorizableLookup.java index aef2798..f702ffc 100644 --- a/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardAuthorizableLookup.java +++ b/nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/StandardAuthorizableLookup.java @@ -67,6 +67,11 @@ class StandardAuthorizableLookup implements AuthorizableLookup { private AccessPolicyDAO accessPolicyDAO; @Override + public Authorizable getController() { + return controllerFacade; + } + + @Override public Authorizable getProcessor(final String id) { return processorDAO.getProcessor(id); }
