[GitHub] [nifi] ferencerdei commented on a diff in pull request #6877: NIFI-11087 Add VerifyContentMAC Processor

2023-01-27 Thread via GitHub


ferencerdei commented on code in PR #6877:
URL: https://github.com/apache/nifi/pull/6877#discussion_r1088690475


##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"Encryption", "Signing", "MAC", "HMAC"})
+@CapabilityDescription("Calculates MAC using the provided Secret Key and 
compares it with the provided MAC parameter")
+@EventDriven
+@WritesAttributes({
+@WritesAttribute(attribute = VerifyContentMAC.MAC_CALCULATED_ATTRIBUTE, 
description = "The calculated MAC value"),
+@WritesAttribute(attribute = VerifyContentMAC.MAC_ALGORITHM_ATTRIBUTE, 
description = "The MAC algorithm")})
+public class VerifyContentMAC extends AbstractProcessor {
+
+protected static final String HMAC_SHA256 = "HmacSHA256";
+protected static final String HMAC_SHA512 = "HmacSHA512";
+
+protected static final PropertyDescriptor MAC_ALGORITHM = new 
PropertyDescriptor.Builder()
+.name("MAC_ALGORITHM")
+.displayName("MAC Algorithm")
+.description("Cryptographic Hash Function")
+.allowableValues(HMAC_SHA256, HMAC_SHA512)
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.build();
+
+protected static final PropertyDescriptor SECRET_KEY = new 
PropertyDescriptor.Builder()
+.name("SECRET_KEY")
+.displayName("Secret key")
+.description("Cryptographic key to calculate the hash")
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.sensitive(true)
+.build();
+
+protected static final PropertyDescriptor MAC = new 
PropertyDescriptor.Builder()
+.name("MAC")
+.displayName("Message Authentication Code")
+.description("The MAC to compare with the calculated value")
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+.build();
+
+protected static final Relationship FAILURE = new Relationship.Builder()
+.name("failure")
+.description("Signature Verification Failed")
+.build();
+
+protected static final Relationship SUCCESS = new Relationship.Builder()
+.name("success")
+.description("Signature Verification Succeeded")
+.build();
+
+private static final List PROPERTIES = 
Collections.unmodifiableList(Arrays.asList(MAC_ALGORITHM, SECRET_KEY, MAC));
+private static final Set RELATIONSHIPS = 
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(SUCCESS, 

[GitHub] [nifi] ferencerdei commented on a diff in pull request #6877: NIFI-11087 Add VerifyContentMAC Processor

2023-01-27 Thread via GitHub


ferencerdei commented on code in PR #6877:
URL: https://github.com/apache/nifi/pull/6877#discussion_r1088690187


##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"Encryption", "Signing", "MAC", "HMAC"})

Review Comment:
   done



##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org

[GitHub] [nifi] ferencerdei commented on a diff in pull request #6877: NIFI-11087 Add VerifyContentMAC Processor

2023-01-27 Thread via GitHub


ferencerdei commented on code in PR #6877:
URL: https://github.com/apache/nifi/pull/6877#discussion_r1088690017


##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"Encryption", "Signing", "MAC", "HMAC"})
+@CapabilityDescription("Calculates MAC using the provided Secret Key and 
compares it with the provided MAC parameter")
+@EventDriven
+@WritesAttributes({
+@WritesAttribute(attribute = VerifyContentMAC.MAC_CALCULATED_ATTRIBUTE, 
description = "The calculated MAC value"),

Review Comment:
   done



##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.Exp

[GitHub] [nifi] ferencerdei commented on a diff in pull request #6877: NIFI-11087 Add VerifyContentMAC Processor

2023-01-27 Thread via GitHub


ferencerdei commented on code in PR #6877:
URL: https://github.com/apache/nifi/pull/6877#discussion_r1088689594


##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"Encryption", "Signing", "MAC", "HMAC"})
+@CapabilityDescription("Calculates MAC using the provided Secret Key and 
compares it with the provided MAC parameter")
+@EventDriven
+@WritesAttributes({
+@WritesAttribute(attribute = VerifyContentMAC.MAC_CALCULATED_ATTRIBUTE, 
description = "The calculated MAC value"),
+@WritesAttribute(attribute = VerifyContentMAC.MAC_ALGORITHM_ATTRIBUTE, 
description = "The MAC algorithm")})
+public class VerifyContentMAC extends AbstractProcessor {
+
+protected static final String HMAC_SHA256 = "HmacSHA256";
+protected static final String HMAC_SHA512 = "HmacSHA512";
+
+protected static final PropertyDescriptor MAC_ALGORITHM = new 
PropertyDescriptor.Builder()
+.name("MAC_ALGORITHM")
+.displayName("MAC Algorithm")
+.description("Cryptographic Hash Function")
+.allowableValues(HMAC_SHA256, HMAC_SHA512)
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.build();
+
+protected static final PropertyDescriptor SECRET_KEY = new 
PropertyDescriptor.Builder()
+.name("SECRET_KEY")
+.displayName("Secret key")
+.description("Cryptographic key to calculate the hash")
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.sensitive(true)
+.build();
+
+protected static final PropertyDescriptor MAC = new 
PropertyDescriptor.Builder()
+.name("MAC")
+.displayName("Message Authentication Code")
+.description("The MAC to compare with the calculated value")
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+.build();
+
+protected static final Relationship FAILURE = new Relationship.Builder()
+.name("failure")
+.description("Signature Verification Failed")
+.build();
+
+protected static final Relationship SUCCESS = new Relationship.Builder()
+.name("success")
+.description("Signature Verification Succeeded")
+.build();
+
+private static final List PROPERTIES = 
Collections.unmodifiableList(Arrays.asList(MAC_ALGORITHM, SECRET_KEY, MAC));
+private static final Set RELATIONSHIPS = 
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(SUCCESS, 

[GitHub] [nifi] ferencerdei commented on a diff in pull request #6877: NIFI-11087 Add VerifyContentMAC Processor

2023-01-27 Thread via GitHub


ferencerdei commented on code in PR #6877:
URL: https://github.com/apache/nifi/pull/6877#discussion_r1088689378


##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"Encryption", "Signing", "MAC", "HMAC"})
+@CapabilityDescription("Calculates MAC using the provided Secret Key and 
compares it with the provided MAC parameter")
+@EventDriven
+@WritesAttributes({
+@WritesAttribute(attribute = VerifyContentMAC.MAC_CALCULATED_ATTRIBUTE, 
description = "The calculated MAC value"),
+@WritesAttribute(attribute = VerifyContentMAC.MAC_ALGORITHM_ATTRIBUTE, 
description = "The MAC algorithm")})
+public class VerifyContentMAC extends AbstractProcessor {
+
+protected static final String HMAC_SHA256 = "HmacSHA256";
+protected static final String HMAC_SHA512 = "HmacSHA512";
+
+protected static final PropertyDescriptor MAC_ALGORITHM = new 
PropertyDescriptor.Builder()
+.name("MAC_ALGORITHM")
+.displayName("MAC Algorithm")
+.description("Cryptographic Hash Function")
+.allowableValues(HMAC_SHA256, HMAC_SHA512)
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.build();
+
+protected static final PropertyDescriptor SECRET_KEY = new 
PropertyDescriptor.Builder()
+.name("SECRET_KEY")
+.displayName("Secret key")
+.description("Cryptographic key to calculate the hash")
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.sensitive(true)
+.build();
+
+protected static final PropertyDescriptor MAC = new 
PropertyDescriptor.Builder()
+.name("MAC")
+.displayName("Message Authentication Code")
+.description("The MAC to compare with the calculated value")
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+.build();
+
+protected static final Relationship FAILURE = new Relationship.Builder()
+.name("failure")
+.description("Signature Verification Failed")
+.build();
+
+protected static final Relationship SUCCESS = new Relationship.Builder()
+.name("success")
+.description("Signature Verification Succeeded")
+.build();
+
+private static final List PROPERTIES = 
Collections.unmodifiableList(Arrays.asList(MAC_ALGORITHM, SECRET_KEY, MAC));
+private static final Set RELATIONSHIPS = 
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(SUCCESS, 

[GitHub] [nifi] ferencerdei commented on a diff in pull request #6877: NIFI-11087 Add VerifyContentMAC Processor

2023-01-27 Thread via GitHub


ferencerdei commented on code in PR #6877:
URL: https://github.com/apache/nifi/pull/6877#discussion_r1088689103


##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"Encryption", "Signing", "MAC", "HMAC"})
+@CapabilityDescription("Calculates MAC using the provided Secret Key and 
compares it with the provided MAC parameter")
+@EventDriven
+@WritesAttributes({
+@WritesAttribute(attribute = VerifyContentMAC.MAC_CALCULATED_ATTRIBUTE, 
description = "The calculated MAC value"),
+@WritesAttribute(attribute = VerifyContentMAC.MAC_ALGORITHM_ATTRIBUTE, 
description = "The MAC algorithm")})
+public class VerifyContentMAC extends AbstractProcessor {
+
+protected static final String HMAC_SHA256 = "HmacSHA256";
+protected static final String HMAC_SHA512 = "HmacSHA512";
+
+protected static final PropertyDescriptor MAC_ALGORITHM = new 
PropertyDescriptor.Builder()
+.name("MAC_ALGORITHM")
+.displayName("MAC Algorithm")
+.description("Cryptographic Hash Function")
+.allowableValues(HMAC_SHA256, HMAC_SHA512)
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.build();
+
+protected static final PropertyDescriptor SECRET_KEY = new 
PropertyDescriptor.Builder()
+.name("SECRET_KEY")
+.displayName("Secret key")
+.description("Cryptographic key to calculate the hash")
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.sensitive(true)
+.build();
+
+protected static final PropertyDescriptor MAC = new 
PropertyDescriptor.Builder()
+.name("MAC")

Review Comment:
   done



##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.
+ *

[GitHub] [nifi] ferencerdei commented on a diff in pull request #6877: NIFI-11087 Add VerifyContentMAC Processor

2023-01-27 Thread via GitHub


ferencerdei commented on code in PR #6877:
URL: https://github.com/apache/nifi/pull/6877#discussion_r1088688817


##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"Encryption", "Signing", "MAC", "HMAC"})
+@CapabilityDescription("Calculates MAC using the provided Secret Key and 
compares it with the provided MAC parameter")
+@EventDriven
+@WritesAttributes({
+@WritesAttribute(attribute = VerifyContentMAC.MAC_CALCULATED_ATTRIBUTE, 
description = "The calculated MAC value"),
+@WritesAttribute(attribute = VerifyContentMAC.MAC_ALGORITHM_ATTRIBUTE, 
description = "The MAC algorithm")})
+public class VerifyContentMAC extends AbstractProcessor {
+
+protected static final String HMAC_SHA256 = "HmacSHA256";
+protected static final String HMAC_SHA512 = "HmacSHA512";
+
+protected static final PropertyDescriptor MAC_ALGORITHM = new 
PropertyDescriptor.Builder()
+.name("MAC_ALGORITHM")
+.displayName("MAC Algorithm")
+.description("Cryptographic Hash Function")
+.allowableValues(HMAC_SHA256, HMAC_SHA512)
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.build();
+
+protected static final PropertyDescriptor SECRET_KEY = new 
PropertyDescriptor.Builder()
+.name("SECRET_KEY")

Review Comment:
   done



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: issues-unsubscr...@nifi.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org



[GitHub] [nifi] ferencerdei commented on a diff in pull request #6877: NIFI-11087 Add VerifyContentMAC Processor

2023-01-27 Thread via GitHub


ferencerdei commented on code in PR #6877:
URL: https://github.com/apache/nifi/pull/6877#discussion_r1088688552


##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"Encryption", "Signing", "MAC", "HMAC"})
+@CapabilityDescription("Calculates MAC using the provided Secret Key and 
compares it with the provided MAC parameter")
+@EventDriven
+@WritesAttributes({
+@WritesAttribute(attribute = VerifyContentMAC.MAC_CALCULATED_ATTRIBUTE, 
description = "The calculated MAC value"),
+@WritesAttribute(attribute = VerifyContentMAC.MAC_ALGORITHM_ATTRIBUTE, 
description = "The MAC algorithm")})
+public class VerifyContentMAC extends AbstractProcessor {
+
+protected static final String HMAC_SHA256 = "HmacSHA256";
+protected static final String HMAC_SHA512 = "HmacSHA512";
+
+protected static final PropertyDescriptor MAC_ALGORITHM = new 
PropertyDescriptor.Builder()
+.name("MAC_ALGORITHM")
+.displayName("MAC Algorithm")
+.description("Cryptographic Hash Function")
+.allowableValues(HMAC_SHA256, HMAC_SHA512)
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.build();
+
+protected static final PropertyDescriptor SECRET_KEY = new 
PropertyDescriptor.Builder()
+.name("SECRET_KEY")
+.displayName("Secret key")

Review Comment:
   done



##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.se

[GitHub] [nifi] ferencerdei commented on a diff in pull request #6877: NIFI-11087 Add VerifyContentMAC Processor

2023-01-27 Thread via GitHub


ferencerdei commented on code in PR #6877:
URL: https://github.com/apache/nifi/pull/6877#discussion_r1088688192


##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"Encryption", "Signing", "MAC", "HMAC"})
+@CapabilityDescription("Calculates MAC using the provided Secret Key and 
compares it with the provided MAC parameter")
+@EventDriven
+@WritesAttributes({
+@WritesAttribute(attribute = VerifyContentMAC.MAC_CALCULATED_ATTRIBUTE, 
description = "The calculated MAC value"),
+@WritesAttribute(attribute = VerifyContentMAC.MAC_ALGORITHM_ATTRIBUTE, 
description = "The MAC algorithm")})
+public class VerifyContentMAC extends AbstractProcessor {
+
+protected static final String HMAC_SHA256 = "HmacSHA256";
+protected static final String HMAC_SHA512 = "HmacSHA512";
+
+protected static final PropertyDescriptor MAC_ALGORITHM = new 
PropertyDescriptor.Builder()
+.name("MAC_ALGORITHM")
+.displayName("MAC Algorithm")
+.description("Cryptographic Hash Function")
+.allowableValues(HMAC_SHA256, HMAC_SHA512)
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.build();
+
+protected static final PropertyDescriptor SECRET_KEY = new 
PropertyDescriptor.Builder()
+.name("SECRET_KEY")
+.displayName("Secret key")
+.description("Cryptographic key to calculate the hash")
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.sensitive(true)
+.build();
+
+protected static final PropertyDescriptor MAC = new 
PropertyDescriptor.Builder()
+.name("MAC")
+.displayName("Message Authentication Code")
+.description("The MAC to compare with the calculated value")

Review Comment:
   added the mac encoding property



##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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

[GitHub] [nifi] ferencerdei commented on a diff in pull request #6877: NIFI-11087 Add VerifyContentMAC Processor

2023-01-25 Thread via GitHub


ferencerdei commented on code in PR #6877:
URL: https://github.com/apache/nifi/pull/6877#discussion_r1086476629


##
nifi-nar-bundles/nifi-standard-bundle/nifi-standard-processors/src/main/java/org/apache/nifi/processors/standard/VerifyContentMAC.java:
##
@@ -0,0 +1,187 @@
+/*
+ * 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.processors.standard;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
+import java.security.InvalidKeyException;
+import java.security.NoSuchAlgorithmException;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import javax.crypto.Mac;
+import javax.crypto.spec.SecretKeySpec;
+import org.apache.nifi.annotation.behavior.EventDriven;
+import org.apache.nifi.annotation.behavior.InputRequirement;
+import org.apache.nifi.annotation.behavior.WritesAttribute;
+import org.apache.nifi.annotation.behavior.WritesAttributes;
+import org.apache.nifi.annotation.documentation.CapabilityDescription;
+import org.apache.nifi.annotation.documentation.Tags;
+import org.apache.nifi.annotation.lifecycle.OnScheduled;
+import org.apache.nifi.components.PropertyDescriptor;
+import org.apache.nifi.expression.ExpressionLanguageScope;
+import org.apache.nifi.flowfile.FlowFile;
+import org.apache.nifi.processor.AbstractProcessor;
+import org.apache.nifi.processor.ProcessContext;
+import org.apache.nifi.processor.ProcessSession;
+import org.apache.nifi.processor.Relationship;
+import org.apache.nifi.processor.exception.ProcessException;
+import org.apache.nifi.processor.util.StandardValidators;
+
+@InputRequirement(InputRequirement.Requirement.INPUT_REQUIRED)
+@Tags({"Encryption", "Signing", "MAC", "HMAC"})
+@CapabilityDescription("Calculates MAC using the provided Secret Key and 
compares it with the provided MAC parameter")
+@EventDriven
+@WritesAttributes({
+@WritesAttribute(attribute = VerifyContentMAC.MAC_CALCULATED_ATTRIBUTE, 
description = "The calculated MAC value"),
+@WritesAttribute(attribute = VerifyContentMAC.MAC_ALGORITHM_ATTRIBUTE, 
description = "The MAC algorithm")})
+public class VerifyContentMAC extends AbstractProcessor {
+
+protected static final String HMAC_SHA256 = "HmacSHA256";
+protected static final String HMAC_SHA512 = "HmacSHA512";
+
+protected static final PropertyDescriptor MAC_ALGORITHM = new 
PropertyDescriptor.Builder()
+.name("MAC_ALGORITHM")
+.displayName("MAC Algorithm")
+.description("Cryptographic Hash Function")
+.allowableValues(HMAC_SHA256, HMAC_SHA512)
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.build();
+
+protected static final PropertyDescriptor SECRET_KEY = new 
PropertyDescriptor.Builder()
+.name("SECRET_KEY")
+.displayName("Secret key")
+.description("Cryptographic key to calculate the hash")
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+.sensitive(true)
+.build();
+
+protected static final PropertyDescriptor MAC = new 
PropertyDescriptor.Builder()
+.name("MAC")
+.displayName("Message Authentication Code")
+.description("The MAC to compare with the calculated value")
+.required(true)
+.addValidator(StandardValidators.NON_EMPTY_VALIDATOR)
+
.expressionLanguageSupported(ExpressionLanguageScope.FLOWFILE_ATTRIBUTES)
+.build();
+
+protected static final Relationship FAILURE = new Relationship.Builder()
+.name("failure")
+.description("Signature Verification Failed")
+.build();
+
+protected static final Relationship SUCCESS = new Relationship.Builder()
+.name("success")
+.description("Signature Verification Succeeded")
+.build();
+
+private static final List PROPERTIES = 
Collections.unmodifiableList(Arrays.asList(MAC_ALGORITHM, SECRET_KEY, MAC));
+private static final Set RELATIONSHIPS = 
Collections.unmodifiableSet(new HashSet<>(Arrays.asList(SUCCESS,