This is an automated email from the ASF dual-hosted git repository.
markap14 pushed a commit to branch NIFI-15258
in repository https://gitbox.apache.org/repos/asf/nifi-api.git
The following commit(s) were added to refs/heads/NIFI-15258 by this push:
new 0020d5a NIFI-15356: Introducing the ConnectorWebMethod. (#37)
0020d5a is described below
commit 0020d5a7d36ed17f331a547891a4240cbe95d3d7
Author: Matt Gilman <[email protected]>
AuthorDate: Sun Dec 21 14:31:38 2025 -0500
NIFI-15356: Introducing the ConnectorWebMethod. (#37)
---
.../org/apache/nifi/web/ConnectorWebMethod.java | 77 ++++++++++++++++++++++
1 file changed, 77 insertions(+)
diff --git a/src/main/java/org/apache/nifi/web/ConnectorWebMethod.java
b/src/main/java/org/apache/nifi/web/ConnectorWebMethod.java
new file mode 100644
index 0000000..8a64c34
--- /dev/null
+++ b/src/main/java/org/apache/nifi/web/ConnectorWebMethod.java
@@ -0,0 +1,77 @@
+/*
+ * 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 java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Indicates that a method in a Connector interface requires specific
authorization to be invoked.
+ * This annotation is used by the NiFi framework to enforce access control
when custom UIs interact
+ * with Connector instances.
+ *
+ * <p>Methods without this annotation will be blocked by the framework,
preventing their invocation
+ * through the Connector web context.</p>
+ *
+ * <p>Example Usage:</p>
+ * <pre>
+ * {@code
+ * import static org.apache.nifi.web.ConnectorWebMethod.AccessType;
+ *
+ * public interface MyConnector {
+ * @ConnectorWebMethod(AccessType.READ)
+ * List<String> getAvailableOptions();
+ *
+ * @ConnectorWebMethod(AccessType.WRITE)
+ * void applyConfiguration(Map<String, String> config);
+ *
+ * // This method cannot be called through the web context - throws
IllegalStateException
+ * void internalMethod();
+ * }
+ * }
+ * </pre>
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface ConnectorWebMethod {
+ /**
+ * The type of access required to invoke this method.
+ * READ for read-only operations, WRITE for operations that modify state.
+ * @return the required access type
+ */
+ AccessType value();
+
+ /**
+ * Defines the type of access required for a connector method.
+ */
+ enum AccessType {
+ /**
+ * Indicates the method only reads data and does not modify state.
+ */
+ READ,
+
+ /**
+ * Indicates the method modifies state.
+ */
+ WRITE
+ }
+}
+