Re-added SecureBPMN process validator.

This commit is contained in:
Achim D. Brucker 2015-05-30 16:10:14 +02:00
parent 83f41d285c
commit 444ca8cb38
6 changed files with 274 additions and 0 deletions

View File

@ -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

View File

@ -0,0 +1,5 @@
source.. = src/main/java/
output.. = target/
bin.includes = META-INF/,\
plugin.xml,\
.

View File

@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.6"?>
<plugin>
<extension
point="org.activiti.designer.eclipse.extension.validation.ProcessValidator">
<ProcessValidator
class="eu.aniketos.securebpmn.validation.bpmn20.validation.BPMN20ProcessValidator">
</ProcessValidator>
</extension>
</plugin>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.activiti.designer</groupId>
<artifactId>org.activiti.designer.parent</artifactId>
<version>5.8.0</version>
<relativePath>../org.activiti.designer.parent/pom.xml</relativePath>
</parent>
<artifactId>eu.aniketos.securebpmn.validation.bpmn20</artifactId>
<packaging>eclipse-plugin</packaging>
<name>Activiti Designer - SecureBPMN: Validation</name>
</project>

View File

@ -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;
}
}

View File

@ -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<String, List<EObject>> processNodes = extractProcessConstructs(
getResourceForDiagram(diagram).getContents(),
new SubProgressMonitor(monitor, 2));
final List<EObject> 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;
}
}