Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"java.configuration.updateBuildConfiguration": "automatic"
}
32 changes: 32 additions & 0 deletions DigitalSigningAlfresco/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
23 changes: 23 additions & 0 deletions DigitalSigningAlfresco/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>digitalSigningAlfresco</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
eclipse.preferences.version=1
encoding//src/main/resources=UTF-8
encoding/<project>=UTF-8
8 changes: 8 additions & 0 deletions DigitalSigningAlfresco/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
org.eclipse.jdt.core.compiler.compliance=1.7
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.7
4 changes: 4 additions & 0 deletions DigitalSigningAlfresco/.settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
7 changes: 4 additions & 3 deletions DigitalSigningAlfresco/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<!-- Alfresco version just for sdk 2.2.0 -->
<!-- <alfresco.version>5.2.d</alfresco.version> -->

<alfresco.sdk.version>3.0.1</alfresco.sdk.version>
<alfresco.platform.version>5.2.f</alfresco.platform.version>
<alfresco.sdk.version>4.0.0</alfresco.sdk.version>
<alfresco.platform.version>6.1.2-ga</alfresco.platform.version>
<!-- To know which resource folder to filter for AMP extension projects -->
<app.amp.folder>src/main/amp</app.amp.folder>
<!-- To know which folder filtered AMP resources should end up in under /target -->
Expand Down Expand Up @@ -66,7 +66,7 @@
-->
<dependency>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco-platform-distribution</artifactId>
<artifactId>alfresco-content-services-community-distribution</artifactId>
<version>${alfresco.platform.version}</version>
<type>pom</type>
<scope>import</scope>
Expand Down Expand Up @@ -233,6 +233,7 @@
<dependency>
<groupId>xml-apis</groupId>
<artifactId>xml-apis</artifactId>
<version>2.0.2</version>
<scope>provided</scope>
</dependency>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
import org.apache.xmpbox.schema.PDFAIdentificationSchema;
import org.apache.xmpbox.type.BadFieldValueException;
import org.apache.xmpbox.xml.XmpSerializer;
import org.bouncycastle.asn1.DERObjectIdentifier;
//import org.bouncycastle.asn1.DERObjectIdentifier; updated for recent package
import org.bouncycastle.asn1.ASN1ObjectIdentifier;
import org.bouncycastle.asn1.cms.AttributeTable;
import org.bouncycastle.asn1.cms.CMSAttributes;
import org.bouncycastle.asn1.cms.CMSObjectIdentifiers;
Expand Down Expand Up @@ -1363,7 +1364,7 @@ protected boolean certVerify(final CMSSignedData cmsSignedData, final CertStore
final AttributeTable signedAttributes = signerInformation.getSignedAttributes();
if (signedAttributes != null) {
@SuppressWarnings("unused")
Date signingTime = Time.getInstance((Object)signedAttributes.get((DERObjectIdentifier)CMSAttributes.signingTime).getAttrValues().getObjectAt(0)).getDate();
Date signingTime = Time.getInstance((Object)signedAttributes.get((ASN1ObjectIdentifier)CMSAttributes.signingTime).getAttrValues().getObjectAt(0)).getDate();
}
Collection<? extends Certificate> certificates = null;
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import org.alfresco.service.cmr.repository.ContentService;
import org.alfresco.service.cmr.repository.NodeRef;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.namespace.QName;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@
</property>
</bean>

<!-- Alert on certificate expiration job definition -->
<!-- Alert on certificate expiration job definition
<bean id="certificateAlertJobDetail" class="org.springframework.scheduling.quartz.JobDetailBean">
<property name="jobClass">
<value>org.alfresco.plugin.digitalSigning.scheduledAction.CertificateAlertJob</value>
Expand All @@ -259,9 +259,10 @@
</entry>
</map>
</property>
</bean>
</bean> -->
<!-- Bean Updated to work with Quartz 2.3.0


<!-- Alert on certificate expiration trigger definition -->
<bean id="certificateAlertTrigger" class="org.alfresco.util.CronTriggerBean">
<property name="jobDetail">
<ref bean="certificateAlertJobDetail" />
Expand All @@ -274,4 +275,29 @@
</property>
</bean>

-->
<!-- Bean Updated to work with Quartz 2.3.0-->
<bean id="certificateAlertAccessor" class="org.alfresco.schedule.AlfrescoSchedulerAccessorBean">
<property name="scheduler" ref="schedulerFactory"/>
<property name="triggers">
<list>
<bean id="certificateAlertTrigger" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
<property name="cronExpression" value="${digitalSigning.alert.cron}"/>
<property name="jobDetail" ref="certificateAlertJobDetail"/>
</bean>
</list>
</property>
</bean>

<bean id="certificateAlertJobDetail" class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
<property name="jobClass" value="org.alfresco.plugin.digitalSigning.scheduledAction.CertificateAlertJob"/>
<property name="jobDataAsMap">
<map>
<entry key="certificateAlert">
<ref bean="certificateAlert" />
</entry>
</map>
</property>
</bean>

</beans>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<webscript>
<shortname>Get image</shortname>
<description>Get image</description>
<url>/api/digitalSigning/image</url>
<format default="">argument</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<webscript>
<shortname>Verify if NodeRef is transformable in PDF or not</shortname>
<description>Verify if NodeRef is transformable in PDF or not</description>
<url>/api/digitalSigning/isPdfTransformable</url>
<format default="">argument</format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<webscript>
<shortname>Get signature information</shortname>
<description>Get signature information</description>
<url>/api/digitalSigning/signatureInformation</url>
<format default="json">argument</format>
<authentication>user</authentication>
<lifecycle>internal</lifecycle>
</webscript>
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<#escape x as jsonUtils.encodeJSONString(x)>
<#if errorNumber??>
{
"errorNumber":"${errorNumber}"
<#if errorMessage??>
,
"errorMessage":"${errorMessage}"
</#if>
}
<#else>
<#if keyInfos??>
{
"key":
{
"alias":"${keyInfos.alias}",
"subject":"${keyInfos.subject}",
"type":"${keyInfos.type}",
"algorithm":"${keyInfos.algorithm}",
"firstDayValidity":"${keyInfos.firstDayValidity?string("dd-MM-yyyy HH:mm:ss")}",
"lastDayValidity":"${keyInfos.lastDayValidity?string("dd-MM-yyyy HH:mm:ss")}",
"alert":"${keyInfos.alert}",
"hasExpired":${keyInfos.hasExpired?string("true","false")}
<#if keyInfos.expire??>
,"expire":"${keyInfos.expire}"
</#if>
},
"hasImage": ${hasImage?string("true","false")}
}
</#if>
</#if>
</#escape>
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<webscript>
<shortname>Search signed documents by filters</shortname>
<description>Search signed documents by filters</description>
<url>/api/digitalSigning/searchDocuments</url>
<format default="json">argument</format>
<authentication>user</authentication>
<lifecycle>internal</lifecycle>
</webscript>
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/evaluator.lib.js">
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/parse-args.lib.js">

var items = [], item;

var filterPerson = args["filterPerson"];
var filterDate = args["filterDate"];
var siteId = args["siteId"];

var query = 'ASPECT:"dgtsgn:signed"';

// Filter on person
if (filterPerson != null) {
if (filterPerson == "mine") {
query += ' AND @dgtsgn\\:signedby:"' + person.properties.userName + '"';
} else if (filterPerson == "others") {
query += ' AND NOT @dgtsgn\\:signedby:"' + person.properties.userName + '"';
}
}

var currentDateWithoutTime = new Date();
currentDateWithoutTime.setHours(23,59,0,0);
var isoCurrentDateWithoutTime = utils.toISO8601(currentDateWithoutTime);

// Filter on date
if (filterDate != null) {
if (filterDate == "today") {
var yesterdayWithoutTime = new Date(currentDateWithoutTime);
yesterdayWithoutTime.setDate(currentDateWithoutTime.getDate()-1);
var isoYesterdayWithoutTime = utils.toISO8601(yesterdayWithoutTime);

query += ' AND @dgtsgn\\:signaturedate:[' + isoYesterdayWithoutTime + ' TO ' + isoCurrentDateWithoutTime + ']';
} else if (filterDate == "7") {
var sevenDayBeforeWithoutTime = new Date(currentDateWithoutTime);
sevenDayBeforeWithoutTime.setDate(currentDateWithoutTime.getDate()-7);
var isoSevenDayBeforeWithoutTime = utils.toISO8601(sevenDayBeforeWithoutTime);

query += ' AND @dgtsgn\\:signaturedate:[' + isoSevenDayBeforeWithoutTime + ' TO ' + isoCurrentDateWithoutTime + ']';
} if (filterDate == "14") {
var forteenDayBeforeWithoutTime = new Date(currentDateWithoutTime);
forteenDayBeforeWithoutTime.setDate(currentDateWithoutTime.getDate()-14);
var isoForteenDayBeforeWithoutTime = utils.toISO8601(forteenDayBeforeWithoutTime);

query += ' AND @dgtsgn\\:signaturedate:[' + isoForteenDayBeforeWithoutTime + ' TO ' + isoCurrentDateWithoutTime + ']';
} if (filterDate == "28") {
var twentyeightDayBeforeWithoutTime = new Date(currentDateWithoutTime);
twentyeightDayBeforeWithoutTime.setDate(currentDateWithoutTime.getDate()-28);
var isoTwentyeightDayBeforeWithoutTime = utils.toISO8601(twentyeightDayBeforeWithoutTime);

query += ' AND @dgtsgn\\:signaturedate:[' + isoTwentyeightDayBeforeWithoutTime + ' TO ' + isoCurrentDateWithoutTime + ']';
}
}

logger.log(query);

//Filter on site and store site information in model
if (siteId != null && siteId != "") {
query += ' AND PATH:"/app:company_home/st:sites//cm:' + siteId + '/cm:documentLibrary//*"';
var siteNode = siteService.getSite(siteId);
model.siteTitle = siteNode.title;
model.siteId = siteId;
}

var nodes = search.luceneSearch(query);

for each (node in nodes) {
// Get evaluated properties.
item = Evaluator.run(node);

if (item !== null) {
locationNode = item.isLink ? item.linkedNode : item.node;
// Ensure we have Read permissions on the destination on the link object
if (!locationNode.hasPermission("Read")) break;
location = Common.getLocation(locationNode, null);
location.parent = {};
if (node.parent != null && node.parent.isContainer && node.parent.hasPermission("Read")) {
location.parent.nodeRef = String(node.parent.nodeRef.toString());
}

// Resolved location
item.location = location;

items.push(item);
}
}

// Array Remove - By John Resig (MIT Licensed)
var fnArrayRemove = function fnArrayRemove(array, from, to) {
var rest = array.slice((to || from) + 1 || array.length);
array.length = from < 0 ? array.length + from : from;
return array.push.apply(array, rest);
};

/**
* De-duplicate orignals for any existing working copies.
* This can't be done in evaluator.lib.js as it has no knowledge of the current filter or UI operation.
* Note: This may result in pages containing less than the configured amount of items (50 by default).
*/
for each (item in items) {
if (item.customObj && item.customObj.isWorkingCopy) {
var workingCopyOriginal = String(item.customObj.workingCopyOriginal);
for (var i = 0, ii = items.length; i < ii; i++) {
if (String(items[i].node.nodeRef) == workingCopyOriginal) {
fnArrayRemove(items, i);
break;
}
}
}
}

model.count = nodes.length;
model.nodes = items;
Loading