diff --git a/designer/src/eu.aniketos.securebpmn.validation.bpmn20/META-INF/MANIFEST.MF b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/META-INF/MANIFEST.MF new file mode 100644 index 0000000..1d14a5c --- /dev/null +++ b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/META-INF/MANIFEST.MF @@ -0,0 +1,23 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Activiti Designer - SecureBPMN: Validation +Bundle-SymbolicName: eu.aniketos.securebpmn.validation.bpmn20;singleton:=true +Bundle-Version: 5.8.0 +Bundle-Activator: eu.aniketos.securebpmn.validation.bpmn20.bundle.Activator +Bundle-Vendor: SAP SE +Require-Bundle: org.eclipse.core.runtime, + org.eclipse.emf, + org.eclipse.core.resources, + org.eclipse.graphiti.mm, + org.activiti.designer.eclipse, + org.activiti.designer.model +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-ActivationPolicy: lazy +Bundle-ClassPath: ., + xalan-2.7.1.jar, + serializer-2.7.1.jar, + xml-apis-1.3.04.jar, + com.sun.xacml-0.1.jar, + jdi.jar, + jdimodel.jar, + junit.jar diff --git a/designer/src/eu.aniketos.securebpmn.validation.bpmn20/build.properties b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/build.properties new file mode 100644 index 0000000..936c481 --- /dev/null +++ b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/build.properties @@ -0,0 +1,5 @@ +source.. = src/main/java/ +output.. = target/ +bin.includes = META-INF/,\ + plugin.xml,\ + . \ No newline at end of file diff --git a/designer/src/eu.aniketos.securebpmn.validation.bpmn20/plugin.xml b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/plugin.xml new file mode 100644 index 0000000..6c744e1 --- /dev/null +++ b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/plugin.xml @@ -0,0 +1,10 @@ + + + + + + + + diff --git a/designer/src/eu.aniketos.securebpmn.validation.bpmn20/pom.xml b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/pom.xml new file mode 100644 index 0000000..e2b3ff6 --- /dev/null +++ b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/pom.xml @@ -0,0 +1,13 @@ + + + 4.0.0 + + org.activiti.designer + org.activiti.designer.parent + 5.8.0 + ../org.activiti.designer.parent/pom.xml + + eu.aniketos.securebpmn.validation.bpmn20 + eclipse-plugin + Activiti Designer - SecureBPMN: Validation + diff --git a/designer/src/eu.aniketos.securebpmn.validation.bpmn20/src/main/java/eu/aniketos/securebpmn/validation/bpmn20/bundle/Activator.java b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/src/main/java/eu/aniketos/securebpmn/validation/bpmn20/bundle/Activator.java new file mode 100644 index 0000000..f35d100 --- /dev/null +++ b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/src/main/java/eu/aniketos/securebpmn/validation/bpmn20/bundle/Activator.java @@ -0,0 +1,58 @@ +/* Copyright 2012-2015 SAP SE + * + * Licensed 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 eu.aniketos.securebpmn.validation.bpmn20.bundle; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + * + * + */ +public class Activator implements BundleActivator { + + // The plug-in ID + public static final String PLUGIN_ID = "eu.aniketos.securebpmn.validation.bpmn20"; //$NON-NLS-1$ + + private static BundleContext context; + + static BundleContext getContext() { + return context; + } + + /* + * (non-Javadoc) + * + * @see + * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext + * ) + */ + public void start(BundleContext bundleContext) throws Exception { + Activator.context = bundleContext; + } + + /* + * (non-Javadoc) + * + * @see + * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext bundleContext) throws Exception { + Activator.context = null; + } + +} diff --git a/designer/src/eu.aniketos.securebpmn.validation.bpmn20/src/main/java/eu/aniketos/securebpmn/validation/bpmn20/validation/BPMN20ProcessValidator.java b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/src/main/java/eu/aniketos/securebpmn/validation/bpmn20/validation/BPMN20ProcessValidator.java new file mode 100644 index 0000000..fb49bc5 --- /dev/null +++ b/designer/src/eu.aniketos.securebpmn.validation.bpmn20/src/main/java/eu/aniketos/securebpmn/validation/bpmn20/validation/BPMN20ProcessValidator.java @@ -0,0 +1,165 @@ +/* Copyright 2012-2015 SAP SE + * + * Licensed 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 eu.aniketos.securebpmn.validation.bpmn20.validation; + +import java.util.List; +import java.util.Map; + +import org.activiti.designer.eclipse.common.ActivitiBPMNDiagramConstants; +import org.activiti.designer.eclipse.extension.validation.AbstractProcessValidator; +import org.eclipse.bpmn2.UserTask; +import org.eclipse.bpmn2.impl.UserTaskImpl; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.graphiti.mm.pictograms.Diagram; +import org.eclipse.securebpmn2.ActivityAction; + +/** + * Checks if every UserTask has a SecureBPMN Action of the type assign, claim + * and execute, i.e., if the UserTask can be properly executed. + * + * + */ +public class BPMN20ProcessValidator extends AbstractProcessValidator { + + private boolean overallResult; + + public BPMN20ProcessValidator() { + } + + /* + * (non-Javadoc) + * + * @see org.activiti.designer.eclipse.extension.validation.ProcessValidator# + * getValidatorId() + */ + @Override + public String getValidatorId() { + return ActivitiBPMNDiagramConstants.ASLAN_VALIDATOR_ID; + } + + /* + * (non-Javadoc) + * + * @see org.activiti.designer.eclipse.extension.validation.ProcessValidator# + * getValidatorName() + */ + @Override + public String getValidatorName() { + return ActivitiBPMNDiagramConstants.ASLAN_VALIDATOR_NAME; + } + + /* + * (non-Javadoc) + * + * @see org.activiti.designer.eclipse.extension.validation.ProcessValidator# + * getFormatName() + */ + @Override + public String getFormatName() { + return "SecureBPMN: ASLan"; + } + + /* + * (non-Javadoc) + * + * @see org.activiti.designer.eclipse.extension.validation.ProcessValidator# + * validateDiagram(org.eclipse.graphiti.mm.pictograms.Diagram, + * org.eclipse.core.runtime.IProgressMonitor) + */ + @Override + public boolean validateDiagram(Diagram diagram, IProgressMonitor monitor) { + + this.overallResult = true; + + monitor.beginTask("Validating Diagram for ASLan export", 5); + + // Clear problems for this diagram first + clearMarkers(getResource(diagram.eResource().getURI())); + + final Map> processNodes = extractProcessConstructs( + getResourceForDiagram(diagram).getContents(), + new SubProgressMonitor(monitor, 2)); + + final List userTasks = processNodes.get(UserTaskImpl.class + .getCanonicalName()); + + for (EObject object : userTasks) { + + UserTask userTask = (UserTask) object; + + boolean assignNotSet = true; + boolean claimNotSet = true; + boolean completeNotSet = true; + + for (ActivityAction a : userTask.getActivityActions()) { + if (a.getActionName() != null) { + if (a.getActionName().equals("Assign")) { + assignNotSet = false; + } else if (a.getActionName().equals("Claim")) { + claimNotSet = false; + } else if (a.getActionName().equals("Complete")) { + completeNotSet = false; + } else if (a.getActionName().equals("Full Access")) { + assignNotSet = false; + claimNotSet = false; + completeNotSet = false; + } + } + } + + if (assignNotSet) { + addProblemToDiagram(diagram, + "[SCVM-VAL-001] Missing Assign Action on UserTask \"" + + userTask.getId() + "\".", userTask.getId()); + } + + if (claimNotSet) { + addProblemToDiagram(diagram, + "[SCVM-VAL-002] Missing Claim Action on UserTask \"" + + userTask.getId() + "\".", userTask.getId()); + } + + if (completeNotSet) { + addProblemToDiagram(diagram, + "[SCVM-VAL-003] Missing Complete Action on UserTask \"" + + userTask.getId() + "\".", userTask.getId()); + } + + } + + monitor.worked(3); + + monitor.done(); + return overallResult; + } + + /* + * (non-Javadoc) + * + * @see org.activiti.designer.eclipse.extension.AbstractDiagramWorker# + * addProblemToDiagram(org.eclipse.graphiti.mm.pictograms.Diagram, + * java.lang.String, java.lang.String) + */ + @Override + protected void addProblemToDiagram(Diagram diagram, String message, + String nodeId) { + super.addProblemToDiagram(diagram, message, nodeId); + overallResult = false; + } + +}