rem generates several self signed keys <name>.cer, <name>.jks, and <name>.p12 .
rem Truststore is set with name truststore.jks and set password of password12345
rem usage: createKey.bat <user> <password>
rem createKey.bat somebody password123
set NAME=%1%
set PASSWORD=%2%
set STORE_PASSWORD=password12345
echo 'Creating key for ' %NAME% ' using password ' %PASSWORD%
keytool -genkey -alias %NAME% -keyalg RSA -keysize 1024 -dname "CN=NiFi %NAME%, OU=SCC,O=SCC,L=Annapolis,S=Maryland,C=US" -keypass %PASSWORD% -keystore %NAME%.jks -storepass %PASSWORD% -validity 360
keytool -importkeystore -srckeystore %NAME%.jks -destkeystore %NAME%.p12 -srcstoretype JKS -deststoretype PKCS12 -srcstorepass %PASSWORD% -deststorepass %PASSWORD% -srcalias %NAME% -destalias %NAME% -srckeypass %PASSWORD% -destkeypass
%PASSWORD% -noprompt
keytool -export -keystore %NAME%.jks -storepass %PASSWORD% -alias %NAME% -file %NAME%.cer
#keytool -import -trustcacerts -file %NAME%.cer -alias %NAME% -keystore truststore.jks -storepass %STORE_PASSWORD% -noprompt
keytool -import -trustcacerts -file %NAME%.cer -alias %NAME% -keystore truststore.jks -storepass password12345 -noprompt
echo 'Done creating key for ' %NAME%
keytool -list -keystore truststore.jks -storepass password12345 -noprompt
Silver Cloud Computing
.... The ONE silver lining for all of your software needs!
NiFi Lesson 10: java file source code.
package scc.processors.demo;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.components.PropertyValue;
import org.apache.nifi.flowfile.FlowFile;
import org.apache.nifi.processor.*;
import org.apache.nifi.annotation.behavior.ReadsAttribute;
import org.apache.nifi.annotation.behavior.ReadsAttributes;
import org.apache.nifi.annotation.behavior.WritesAttribute;
import org.apache.nifi.annotation.behavior.WritesAttributes;
import org.apache.nifi.annotation.lifecycle.OnScheduled;
import org.apache.nifi.annotation.documentation.CapabilityDescription;
import org.apache.nifi.annotation.documentation.SeeAlso;
import org.apache.nifi.annotation.documentation.Tags;
import org.apache.nifi.processor.exception.ProcessException;
import org.apache.nifi.processor.util.StandardValidators;
import java.util.*;
@Tags({ "example" })
@CapabilityDescription("Provide a description")
@SeeAlso({})
@ReadsAttributes({ @ReadsAttribute(attribute = "", description = "") })
@WritesAttributes({ @WritesAttribute(attribute = "", description = "") })
public class FileSizeFilter extends AbstractProcessor {
private static int MAX_FILE_SIZE = 0;
public static final Relationship SUCCESS_RELATIONSHIP = new Relationship.Builder()
.name("pass the file")
.description("this file will be passed on to success").build();
public static final Relationship FAIL_RELATIONSHIP = new Relationship.Builder()
.name("do NOT pass the file")
.description("this file will NOT be passed on to success").build();
public static final PropertyDescriptor MAX_FILE_SIZE_ATTRIBUTE_PROPERTY = new PropertyDescriptor.Builder()
.name("Max File Size Attribute")
.description(
"This is the name of the attribute that contains the file size")
.required(true).defaultValue("some.file.size")
.addValidator(StandardValidators.NON_EMPTY_VALIDATOR).build();
private List<PropertyDescriptor> descriptors;
private Set<Relationship> relationships;
@Override
protected void init(final ProcessorInitializationContext context) {
final List<PropertyDescriptor> descriptors = new ArrayList<PropertyDescriptor>();
descriptors.add(MAX_FILE_SIZE_ATTRIBUTE_PROPERTY);
this.descriptors = Collections.unmodifiableList(descriptors);
final Set<Relationship> relationships = new HashSet<Relationship>();
relationships.add(FAIL_RELATIONSHIP);
relationships.add(SUCCESS_RELATIONSHIP);
this.relationships = Collections.unmodifiableSet(relationships);
}
@Override
public Set<Relationship> getRelationships() {
return this.relationships;
}
@Override
public final List<PropertyDescriptor> getSupportedPropertyDescriptors() {
return descriptors;
}
@OnScheduled
public void onScheduled(final ProcessContext context) {
}
@Override
public void onTrigger(final ProcessContext context,
final ProcessSession session) throws ProcessException {
FlowFile flowFile = session.get();
if (flowFile == null) {
return;
}
String attributeMax = context.getProperty(
MAX_FILE_SIZE_ATTRIBUTE_PROPERTY).getValue();
getLogger().info("Got a flow file");
if (flowFile.getAttribute(attributeMax) != null) {
MAX_FILE_SIZE = Integer.parseInt(flowFile
.getAttribute(attributeMax));
getLogger().info(
"Reset MAX file size value to " + MAX_FILE_SIZE
+ " Attrib Ref:" + attributeMax);
session.remove(flowFile);
return;
}
if (flowFile.getSize() < MAX_FILE_SIZE) {
getLogger().info(
"File passed, size is less than " + MAX_FILE_SIZE + "("
+ flowFile.getSize() + " )");
session.transfer(flowFile, SUCCESS_RELATIONSHIP);
} else {
getLogger().info(
"File NOT passed, size is more than " + MAX_FILE_SIZE + "("
+ flowFile.getSize() + " )");
session.transfer(flowFile, FAIL_RELATIONSHIP);
}
}
}