Hi , i have signed with CADES signature some pdf file and convert them to p7m file e.g. test.pdf to test.p7m.
For anyone don't know the p7m extension it's just like a zip file where you can extract the single file in it, by using a specific key.
What i want it's to extract the original pdf in the p7m and make it visualize on share like a normal pdf on runtime while using share, so i can use the standard preview and standard thumbnail of the orginal pdf file.
NOTE: by some expert suggestion on a similar question , i need to setup a composite / pipeline transformer for P7M to PNG, since there is likely not going to be an existing one that works with PDF as an intermediary.
In the documentation of alfresco 5.2 the png not support the preview so instead, i'm tring to use the tiff format to show the original signed document of the p7m file (pdf or text o what else).
So in the end i'm tring to make a trasnformer P7M to TIFF:
===============================================================
/src/main/resources/alfresco/extension/mimetype/custom-mimetype-map.xml
===============================================================
<alfresco-config area="mimetype-map">
<config evaluator="string-compare" condition="Mimetype Map">
<mimetypes>
<mimetype mimetype="application/pkcs7-mime" display="P7M">
<extension>p7m</extension>
</mimetype>
</mimetypes>
</config>
</alfresco-config>
=================================================================
/src/main/resources/alfresco/module/webdesktop-amp/alfresco-global.properties
=================================================================
.......
#TRANSFORMER
content.transformer.P7MToTIFF.priority=200
content.transformer.P7MToTIFF.extensions.p7m.tiff.supported=true
................
=================================================================
/src/main/resources/alfresco/module/webdesktop-amp/mimetype-map-custom.xml
=================================================================
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
" rel="nofollow" target="_blank">http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- IS EMPTY -->
</beans>
=================================================================
/src/main/resources/alfresco/module/webdesktop-amp/module-context.xml
=================================================================
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<import resource="classpath:alfresco/module/${project.artifactId}/context/*-context.xml"/>
</beans>
=================================================================
/src/main/resources/alfresco/module/webdesktop-amp/context/transformer-context.xml
=================================================================
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="transformer.P7MToTIFF"
class="org.alfresco.transformers.P7MToTIFFTransformer"
parent="baseContentTransformer" >
</bean>
</beans>
=================================================================
/src/main/java/org/alfresco/transformers/P7MToTIFFTransformer.java
=================================================================
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.net.URLConnection;
import java.nio.charset.StandardCharsets;
import org.alfresco.repo.content.transform.AbstractContentTransformer2;
import org.alfresco.repo.content.transform.UnsupportedTransformationException;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
public class P7MToTIFFTransformer extends AbstractContentTransformer2
{
private static final Log logger = LogFactory.getLog(P7MToTIFFTransformer.class);
/**
* Select only the file to transform
*/
public boolean isTransformable(String sourceMimetype, String targetMimetype, TransformationOptions options)
{
String ext = getExtensionOrAny("application/pkcs7-mime");
if ("application/pkcs7-mime".equalsIgnoreCase(sourceMimetype) || ext.equalsIgnoreCase("p7m")){
logger.debug("P/MToTIFFTransformer IsTranformable '"+ sourceMimetype + "' to '" + targetMimetype+"'");
return true;
}else{
return false;
}
}
/**
* Transofmer a p7m to the tiff image of single file in it
*/
@Override
protected void transformInternal(ContentReader contentReader, ContentWriter contentWriter, TransformationOptions options) throws Exception
{
logger.debug("USE P7MToTIFFTransformer");
BufferedReader reader = null;
Writer out = null;
InputStream inStream = null;
InputStream is = null;
try
{
// Check the transformability
String myMimeType = myStrictMimetypeCheck(contentReader, contentWriter, options);
if(myMimeType !=null && !mimeType.isEmpty())contentWriter.setMimetype(myMimeType);
//The p7m file on share
inStream = contentReader.getContentInputStream();
out = new BufferedWriter(new OutputStreamWriter(contentWriter.getContentOutputStream()));
//Extract Original Signed Document from the p7m file (ignore these line they are work just fine)
byte[] originalFile = Manager.getOriginalDocumentBinaries(inStream);
logger.debug("OriginalFile: " + String.valueOf(originalFile!=null && originalFile.length >0));
is = new BufferedInputStream(Manager.getOriginalDocumentStream(inStream));
//Try to guess the mimetype of the orginal signed document (ignore these line they are work just fine)
String guessMimeType = URLConnection.guessContentTypeFromStream(is);
logger.debug("GuessMimetype: " + guessMimeType); //this is for example "application/pdf"
//Convert the pdf file extract from p7m file to a tiff image because the
//pdf transformer don't work like a intermediary
File fileTiffOriginal = Manager.toTiff(originalFile);
IOUtils.write(fileTiffOriginal, out,StandardCharsets.UTF_8.displayName());
//change the current mimetype to the tiff mimetype for alfresco
String guessMimeType2 = "image/tiff ";
if(guessMimeType!=null){
contentWriter.setMimetype(guessMimeType2);
}
}catch(IOException e){
e.printStackTrace();
}
finally
{
if (reader != null)
{
try{reader.close(); }
catch (Throwable e){e.printStackTrace();}
}
if (out != null) {
try{out.close();}
catch (Throwable e){e.printStackTrace();}
}
if(inStream != null){
try{inStream.close();}
catch (Throwable e){e.printStackTrace();}
}
if(is != null){
try{is.close();}
catch (Throwable e){e.printStackTrace();}
}
}
}
/**
* Manage the inner warnings of alfresco 5.2
* @param reader the reader of the current document
* @param writer the writer of the current document
* @param options the transform options of the current document
* @return the mimetype suggested from share
* @throws UnsupportedTransformationException
*/
private String myStrictMimetypeCheck(ContentReader reader,ContentWriter writer, TransformationOptions options)throws UnsupportedTransformationException
{
String mimeTypeOfAlfresco = "";
String sourceMimetype = reader.getMimetype();
String targetMimetype = writer.getMimetype();
String differentType = getMimetypeService().getMimetypeIfNotMatches(reader.getReader());
if (!transformerConfig.strictMimetypeCheck(sourceMimetype, differentType))
{
String fileName = transformerDebug.getFileName(options, true, 0);
String readerSourceMimetype = reader.getMimetype();
String message = "Transformation of ("+fileName+
") has not taken place because the declared mimetype ("+
readerSourceMimetype+") does not match the detected mimetype ("+
differentType+").";
logger.warn(message);
logger.debug("Cambiamo il mimetype con quello voluto da alfresco per evitare stackstrace del warning");
mimeTypeOfAlfresco = differentType;
}else{
logger.debug("Mimetype ok : mimeTypeOfAlfresco = "+mimeTypeOfAlfresco+ " , sourceMimetype = "+sourceMimetype);
mimeTypeOfAlfresco = sourceMimetype;
}
return mimeTypeOfAlfresco;
}
}
========================================================================================
The Alfresco version i use , is the 5.2 community.
It's seem i make some grave mistake with the code.
ty in adavcne for any help.
Greetings.
Solved! Go to Solution.
It's been a while, but i finally come around with a solution, hope it can help someone:
=================================================================
/src/main/java/org/alfresco/transformers/P7m2PdfTransformer.java
NOTE: The Object MIMETYPE it's just a wrapper for the apache-tika parser
=================================================================
package org.alfresco.transformer;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.content.transform.AbstractContentTransformer2;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.repository.ContentAccessor;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.TempFileProvider;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.DERObject;
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.cms.CMSProcessableByteArray;
import org.bouncycastle.cms.CMSSignedData;
import org.alfresco.common.MIMETYPE;
//import com.artofsolving.jodconverter.DocumentConverter;
//import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
//import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
//import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import org.alfresco.sign.exception.SignerException;
import net.sf.jooreports.converter.DocumentConverter;
import net.sf.jooreports.openoffice.connection.OpenOfficeConnection;
import net.sf.jooreports.openoffice.connection.SocketOpenOfficeConnection;
import net.sf.jooreports.openoffice.converter.OpenOfficeDocumentConverter;
public class P7m2PdfTransformer extends AbstractContentTransformer2
{
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(P7m2PdfTransformer.class);
public final String MIMETYPE_P7M = "application/pkcs7-mime";
public final String MIMETYPE_P7MX = "application/x-pkcs7-mime";
public final String MIMETYPE_SIGNED = "application/pkcs7-signature";
public final String EXTENSION_P7M = "p7m";
private TransactionService transactionService;
private NodeService nodeService;
//private AlfrescoSigner signer;
protected Properties alfrescoGlobalProperties;
public void setAlfrescoGlobalProperties(Properties alfrescoGlobalProperties) {
this.alfrescoGlobalProperties = alfrescoGlobalProperties;
}
public P7m2PdfTransformer() {
super();
}
public void setTransactionService(TransactionService transactionService) {
this.transactionService = transactionService;
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
//public void setSigner(final AlfrescoSigner signer) {
// this.signer = signer;
//}
public boolean isTransformable(final String sourceMimetype, final String targetMimetype, final TransformationOptions options) {
logger.debug("sourceMimetype = " + sourceMimetype);
logger.debug("targetMimetype = " + targetMimetype);
return "application/pkcs7-mime".equals(sourceMimetype) || "application/x-pkcs7-mime".equals(sourceMimetype) || "application/pkcs7-signature".equals(sourceMimetype);
}
protected void transformInternal(final ContentReader reader, final ContentWriter writer, final TransformationOptions options) throws Exception {
logger.debug("Inizio conversione P7M2PDF");
String mimetypeSource = this.getMimetype((ContentAccessor)reader);
String mimetypeTarget = this.getMimetype((ContentAccessor)writer);
String extensionSource = this.getMimetypeService().getExtension(mimetypeSource);
String extensionTarget = this.getMimetypeService().getExtension(mimetypeTarget);
String original_file = (String) nodeService.getProperty(options.getSourceNodeRef(),ContentModel.PROP_NAME);
//String signed_file = SignAlfrescoUtils.manageFileBeforeSignature( original_file, false , SignatureForm.CAdES);
String retrieveOriFileName = original_file.replace(".p7m", "").replace(".p7s", "");
if (extensionSource == null || extensionTarget == null) {
throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n source mimetype: " + mimetypeSource + "\n source extension: " + extensionSource + "\n target mimetype: " + mimetypeTarget + "\n target extension: " + extensionTarget);
}
//METTIAMO LA TRASFORMAZIONE ALL'INTERNO DELLA TRANSAZIONE
final byte[] data = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<byte[]>() {
@Override
public byte[] execute() throws Throwable {
logger.debug("VERIFICA STREAM P7M2PDF");
try (final InputStream contentInputStream = reader.getContentInputStream()) {
try{
//File tempFileSource = TempFileProvider.createTempFile(this.getClass().getSimpleName() + "_source_", "." + "p7m");
File tempFileTarget = TempFileProvider.createTempFile(this.getClass().getSimpleName() + "_target_", "." + extensionTarget);
String nameTarget = tempFileTarget.getName();//this.getClass().getSimpleName() + "_target_" + "." + extensionTarget;
final byte[] bytes = IOUtils.toByteArray(contentInputStream);
//final byte[] verify = signer.verify(bytes,true);
byte[] verify = null;
//try{
// verify =GetOriginalContentFromFileSigned.getOriginalDocumentBinaries(new ByteArrayInputStream(bytes));
// if(verify==null){
// throw new SignerException("The content retireved is NULL");
// }
// }catch(Throwable ex){
// verify = signer.verify(bytes,true);
//}
verify = getSignedContent(bytes);
//AGGIUNGERE CONTROLLO PRELIMINARE NOME SE PRESENTE
MIMETYPE mimetype = null;
if(StringUtils.isNotBlank(retrieveOriFileName)){
try{
mimetype = MIMETYPE.forExtensions(FilenameUtils.getExtension(retrieveOriFileName));
}catch(IllegalArgumentException ex){
//DO NOTHING
}
}
//PRIMA DI SCRIVERE LO STREAM PROVIAMO A IDENTIFICARE IL MIMETYPE
//PER ATTIVARE I TRANSFOMER DI ALFRESCO UTILIZZANDO
//APACHE TIKA
if(mimetype==null){
mimetype = MIMETYPE.forBytes(verify);
}
//SE il file in formato p7m era un pdf non faccio la conversione esplicita con libreoffice
if(mimetype.equals(MIMETYPE.pdf)){
return verify;
}else{
String extensionIntermidiate = mimetype.getExtensions();
String mimetypeIntermidiate = mimetype.getMimetype();
File tempFileIntermidiate = TempFileProvider.createTempFile(this.getClass().getSimpleName() + "_intermidiate_", "." + extensionIntermidiate);
String nameIntermidiate = tempFileIntermidiate.getName();//this.getClass().getSimpleName() + "_intermidiate_" + "." + extensionIntermidiate;
FileUtils.writeByteArrayToFile(tempFileIntermidiate, verify);
//SI PUO' UTILIZZARE OPEBNOFFICE PER CONVERTIRE QUALUNQUE DOCUMENTO IN PDF
//http://satyabrata-mahapatra.blogspot.com/2010/09/start-openoffice-org-service-for.html
// connect to an OpenOffice.org instance running on port 8100
int port = 8100; //default
if(Boolean.parseBoolean(alfrescoGlobalProperties.getProperty("ooo.enabled"))){
port = Integer.valueOf(alfrescoGlobalProperties.getProperty("ooo.port"));
}else if(Boolean.parseBoolean(alfrescoGlobalProperties.getProperty("jodconverter.enabled"))){
port = Integer.valueOf(alfrescoGlobalProperties.getProperty("jodconverter.portNumbers"));
}else{
throw new AlfrescoRuntimeException("Impossibile recuperare la porta di comunicazione con libreoffice e/o jodconverter verifica le proprieta su alfresco global");
}
OpenOfficeConnection connection = new SocketOpenOfficeConnection(port);
try{
connection.connect();
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
//DocumentFormat inputFormat = new DocumentFormat(nameIntermidiate, mimetypeIntermidiate, extensionIntermidiate);
//DocumentFormat outputFormat = new DocumentFormat(nameTarget, mimetypeTarget, extensionTarget);
//converter.convert(tempFileIntermidiate, inputFormat, tempFileTarget, outputFormat);
converter.convert(tempFileIntermidiate, tempFileTarget);
return FileUtils.readFileToByteArray(tempFileTarget);
}catch(java.lang.IllegalArgumentException ex2){
//if(ex2.getMessage().contains("unsupported input format")){
// if(mimetypeIntermidiate.equals(MimetypeMap.MIMETYPE_TEXT_PLAIN)){
// PDFUtilities.convertTextToPDF(tempFileIntermidiate, tempFileTarget);
// return FileUtils.readFileToByteArray(tempFileTarget);
// }else{
// throw new AlfrescoRuntimeException(ex2.getMessage());
// }
//}else{
throw new AlfrescoRuntimeException(ex2.getMessage());
//}
}catch(Exception ex){
throw new AlfrescoRuntimeException(ex.getMessage());
}finally{
if(connection!=null){
// close the connection
connection.disconnect();
}
FileUtils.deleteQuietly(tempFileIntermidiate);
FileUtils.deleteQuietly(tempFileTarget);
}
}
}catch(Exception ex){
throw new AlfrescoRuntimeException(ex.getMessage());
}
}
}
}, false, true);
logger.debug("Fine conversione P7M2PDF");
writer.guessEncoding();
writer.setMimetype(MimetypeMap.MIMETYPE_PDF);
try (final OutputStream contentOutputStream = writer.getContentOutputStream()) {
contentOutputStream.write(data);
}
}
private byte[] getSignedContent(final byte[] signedDoc) throws SignerException {
ASN1InputStream asn1InputStream = null;
try {
asn1InputStream = new ASN1InputStream(new ByteArrayInputStream(signedDoc));
DERObject signedContent;
try {
signedContent = asn1InputStream.readObject();
}
catch (IOException cause) {
logger.error(cause.getMessage(), (Throwable)cause);
throw new SignerException(cause.getMessage(), cause);
}
CMSSignedData cmsSignedData;
try {
cmsSignedData = new CMSSignedData(ContentInfo.getInstance(signedContent));
}
catch (IllegalArgumentException cause2) {
logger.error(cause2.getMessage(), (Throwable)cause2);
throw new SignerException(cause2.getMessage(), cause2);
}catch (Throwable cause2) {
throw new SignerException(cause2.getMessage(), cause2);
}
return (byte[])((CMSProcessableByteArray)cmsSignedData.getSignedContent()).getContent();
}catch(Exception ex){
logger.error(ex.getMessage(),ex);
throw new SignerException(ex);
}
finally {
try {
asn1InputStream.close();
}
catch (IOException ex) {}
}
}
}
=================================================================
/src/main/resources/alfresco/module/<MODULE_NAME>/context/transform-p7m-p7s-context.xml
=================================================================
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!--
-verify to tell openssl that you will feed a signed mail message on input and outputs the signed data.
-noverify do not verify the signers certificate of a signed message.
-signer output the signer cert to the cert.pem file.
-->
<!-- ========================================================= -->
<!-- P7S TO GENERIC DOC -->
<!-- http://moldovan.it/blog/open-and-read-p7s-files-in-ubuntu-linux/ -->
<!-- ========================================================= -->
<bean id="transformer.worker.p7s2doc" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
<property name="mimetypeService">
<ref bean="mimetypeService" />
</property>
<property name="checkCommand">
<bean name="transformer.p7s2doc" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl version</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl version</value>
</list>
</entry>
</map>
</property>
<!-- Error codes unknown -->
</bean>
</property>
<property name="transformCommand">
<bean name="transformer.p7s2doc" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl smime -inform DER -decrypt -verify -noverify -in ${source} -out ${target}</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl smime -inform DER -decrypt -verify -noverify -in ${source} -out ${target}</value>
</list>
</entry>
</map>
</property>
<property name="waitForCompletion">
<value>true</value>
</property>
<!-- Error codes unknown -->
</bean>
</property>
</bean>
<!-- ========================================================= -->
<!-- P7M TO GENERIC DOC -->
<!-- http://enricorossi.org/blog/2016/view_p7m_file_with_openssl/ -->
<!-- http://www.thinkitbetter.com/tibj/index.php/component/content/article?id=8:firma-digitale-come-si-es... -->
<!-- ========================================================= -->
<bean id="transformer.worker.p7m2doc" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
<property name="mimetypeService">
<ref bean="mimetypeService" />
</property>
<property name="checkCommand">
<bean name="transformer.p7m2doc" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl version</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl version</value>
</list>
</entry>
</map>
</property>
<!-- Error codes unknown -->
</bean>
</property>
<property name="transformCommand">
<bean name="transformer.p7m2doc" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl smime -inform DER -decrypt -verify -noverify -in ${source} -out ${target}</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl smime -inform DER -decrypt -verify -noverify -in ${source} -out ${target}</value>
</list>
</entry>
</map>
</property>
<property name="waitForCompletion">
<value>true</value>
</property>
<!-- Error codes unknown -->
</bean>
</property>
</bean>
<!-- ========================================================= -->
<!-- GENERIC DOC TO PDF -->
<!-- http://blog.vogella.com/2012/02/27/batch-converting-libreoffice-documents-into-pdf/ -->
<!-- https://opensource.com/life/16/10/3-file-conversion-tools-linux-command-line -->
<!-- http://satyabrata-mahapatra.blogspot.com/2010/09/start-openoffice-org-service-for.html -->
<!-- https://bitbucket.org/xenit/alfresco-remote-jodconverter/src/master/ -->
<!-- TODO PROBLEMA DA LINEA DI COMANDO NON SPECIFICA IL TARGET -->
<!-- ========================================================= -->
<bean id="transformer.worker.doc2pdf" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
<property name="mimetypeService">
<ref bean="mimetypeService" />
</property>
<property name="checkCommand">
<bean name="transformer.doc2pdf" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>${ooo.exe} --version</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>${ooo.exe} --version</value>
</list>
</entry>
</map>
</property>
</bean>
</property>
<property name="transformCommand">
<bean name="transformer.doc2pdf" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value></value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value></value>
</list>
</entry>
</map>
</property>
<property name="waitForCompletion">
<value>true</value>
</property>
</bean>
</property>
</bean>
<!-- =============================================== -->
<!-- TRANSFORMER -->
<!-- =============================================== -->
<bean id="transformer.p7m2pdf" class="org.alfresco.transformer.P7m2PdfTransformer" parent="baseContentTransformer">
<!-- <property name="signer" ref="signer" /> -->
<property name="transactionService" ref="TransactionService" />
<property name="nodeService" ref="NodeService" />
<property name="alfrescoGlobalProperties">
<ref bean="global-properties" />
</property>
</bean>
<bean id="transformer.complex.p7m2image" class="org.alfresco.repo.content.transform.ComplexContentTransformer" parent="baseContentTransformer">
<property name="transformers">
<list>
<ref bean="transformer.p7m2pdf" />
<ref bean="transformer.ImageMagick" />
</list>
</property>
<property name="intermediateMimetypes">
<list>
<value>application/pdf</value>
</list>
</property>
</bean>
</beans>
=================================================================
/src/main/resources/alfresco/module/<MODULE_NAME>/mimetype/mimetype-map.xml
=================================================================
<alfresco-config area="mimetype-map">
<config evaluator="string-compare" condition="Mimetype Map">
<mimetypes>
<!-- SIGNED FILE -->
<mimetype mimetype="application/pkcs7-signature" display="application/pkcs7-signature">
<extension default="true">p7s</extension>
</mimetype>
<mimetype mimetype="application/cms" display="application/cms">
<extension>csig</extension>
</mimetype>
<mimetype mimetype="text/xml" display="text/xml (xsig)">
<extension>xsig</extension>
</mimetype>
<mimetype mimetype="application/pkcs7-mime" display="application/pkcs7-mime">
<extension>p7m</extension>
</mimetype>
<mimetype mimetype="application/x-pkcs7-mime" display="application/x-pkcs7-mime">
<extension>p7m</extension>
</mimetype>
</mimetypes>
</config>
</alfresco-config>
=================================================================
/src/main/resources/alfresco/extension/mimetype/mimetypes-extension-map.xml
=================================================================
<alfresco-config area="mimetype-map">
<config evaluator="string-compare" condition="Mimetype Map">
<mimetypes>
<!-- SIGNED FILE -->
<mimetype mimetype="application/pkcs7-signature" display="application/pkcs7-signature">
<extension default="true">p7s</extension>
</mimetype>
<mimetype mimetype="application/cms" display="application/cms">
<extension>csig</extension>
</mimetype>
<mimetype mimetype="text/xml" display="text/xml (xsig)">
<extension>xsig</extension>
</mimetype>
<mimetype mimetype="application/pkcs7-mime" display="application/pkcs7-mime">
<extension>p7m</extension>
</mimetype>
<mimetype mimetype="application/x-pkcs7-mime" display="application/x-pkcs7-mime">
<extension>p7m</extension>
</mimetype>
</mimetypes>
</config>
</alfresco-config>
=================================================================
/src/main/resources/alfresco/module/<MODULE_NAME>/alfresco-global.properties
=================================================================
...................................
### transform-p7m-p7s-context.xml ###
# --------------------------------------------
# P7M
# --------------------------------------------
content.transformer.p7m2pdf.priority=50
content.transformer.p7m2pdf.extensions.p7m.pdf.supported=true
content.transformer.p7m2pdf.extensions.p7m.pdf.priority=50
content.transformer.p7m2pdf.extensions.p7m.pdf.maxSourceSizeKBytes=25600
content.transformer.complex.p7m2image.priority=50
content.transformer.complex.p7m2image.extensions.p7m.png.supported=true
content.transformer.complex.p7m2image.extensions.p7m.png.priority=50
content.transformer.complex.p7m2image.extensions.p7m.png.maxSourceSizeKBytes=25600
It's been a while, but i finally come around with a solution, hope it can help someone:
=================================================================
/src/main/java/org/alfresco/transformers/P7m2PdfTransformer.java
NOTE: The Object MIMETYPE it's just a wrapper for the apache-tika parser
=================================================================
package org.alfresco.transformer;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Properties;
import org.alfresco.error.AlfrescoRuntimeException;
import org.alfresco.model.ContentModel;
import org.alfresco.repo.content.MimetypeMap;
import org.alfresco.repo.content.transform.AbstractContentTransformer2;
import org.alfresco.repo.transaction.RetryingTransactionHelper;
import org.alfresco.service.cmr.repository.ContentAccessor;
import org.alfresco.service.cmr.repository.ContentReader;
import org.alfresco.service.cmr.repository.ContentWriter;
import org.alfresco.service.cmr.repository.NodeService;
import org.alfresco.service.cmr.repository.TransformationOptions;
import org.alfresco.service.transaction.TransactionService;
import org.alfresco.util.TempFileProvider;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.bouncycastle.asn1.ASN1InputStream;
import org.bouncycastle.asn1.DERObject;
import org.bouncycastle.asn1.cms.ContentInfo;
import org.bouncycastle.cms.CMSProcessableByteArray;
import org.bouncycastle.cms.CMSSignedData;
import org.alfresco.common.MIMETYPE;
//import com.artofsolving.jodconverter.DocumentConverter;
//import com.artofsolving.jodconverter.openoffice.connection.OpenOfficeConnection;
//import com.artofsolving.jodconverter.openoffice.connection.SocketOpenOfficeConnection;
//import com.artofsolving.jodconverter.openoffice.converter.OpenOfficeDocumentConverter;
import org.alfresco.sign.exception.SignerException;
import net.sf.jooreports.converter.DocumentConverter;
import net.sf.jooreports.openoffice.connection.OpenOfficeConnection;
import net.sf.jooreports.openoffice.connection.SocketOpenOfficeConnection;
import net.sf.jooreports.openoffice.converter.OpenOfficeDocumentConverter;
public class P7m2PdfTransformer extends AbstractContentTransformer2
{
private static final org.slf4j.Logger logger = org.slf4j.LoggerFactory.getLogger(P7m2PdfTransformer.class);
public final String MIMETYPE_P7M = "application/pkcs7-mime";
public final String MIMETYPE_P7MX = "application/x-pkcs7-mime";
public final String MIMETYPE_SIGNED = "application/pkcs7-signature";
public final String EXTENSION_P7M = "p7m";
private TransactionService transactionService;
private NodeService nodeService;
//private AlfrescoSigner signer;
protected Properties alfrescoGlobalProperties;
public void setAlfrescoGlobalProperties(Properties alfrescoGlobalProperties) {
this.alfrescoGlobalProperties = alfrescoGlobalProperties;
}
public P7m2PdfTransformer() {
super();
}
public void setTransactionService(TransactionService transactionService) {
this.transactionService = transactionService;
}
public void setNodeService(NodeService nodeService) {
this.nodeService = nodeService;
}
//public void setSigner(final AlfrescoSigner signer) {
// this.signer = signer;
//}
public boolean isTransformable(final String sourceMimetype, final String targetMimetype, final TransformationOptions options) {
logger.debug("sourceMimetype = " + sourceMimetype);
logger.debug("targetMimetype = " + targetMimetype);
return "application/pkcs7-mime".equals(sourceMimetype) || "application/x-pkcs7-mime".equals(sourceMimetype) || "application/pkcs7-signature".equals(sourceMimetype);
}
protected void transformInternal(final ContentReader reader, final ContentWriter writer, final TransformationOptions options) throws Exception {
logger.debug("Inizio conversione P7M2PDF");
String mimetypeSource = this.getMimetype((ContentAccessor)reader);
String mimetypeTarget = this.getMimetype((ContentAccessor)writer);
String extensionSource = this.getMimetypeService().getExtension(mimetypeSource);
String extensionTarget = this.getMimetypeService().getExtension(mimetypeTarget);
String original_file = (String) nodeService.getProperty(options.getSourceNodeRef(),ContentModel.PROP_NAME);
//String signed_file = SignAlfrescoUtils.manageFileBeforeSignature( original_file, false , SignatureForm.CAdES);
String retrieveOriFileName = original_file.replace(".p7m", "").replace(".p7s", "");
if (extensionSource == null || extensionTarget == null) {
throw new AlfrescoRuntimeException("Unknown extensions for mimetypes: \n source mimetype: " + mimetypeSource + "\n source extension: " + extensionSource + "\n target mimetype: " + mimetypeTarget + "\n target extension: " + extensionTarget);
}
//METTIAMO LA TRASFORMAZIONE ALL'INTERNO DELLA TRANSAZIONE
final byte[] data = transactionService.getRetryingTransactionHelper().doInTransaction(new RetryingTransactionHelper.RetryingTransactionCallback<byte[]>() {
@Override
public byte[] execute() throws Throwable {
logger.debug("VERIFICA STREAM P7M2PDF");
try (final InputStream contentInputStream = reader.getContentInputStream()) {
try{
//File tempFileSource = TempFileProvider.createTempFile(this.getClass().getSimpleName() + "_source_", "." + "p7m");
File tempFileTarget = TempFileProvider.createTempFile(this.getClass().getSimpleName() + "_target_", "." + extensionTarget);
String nameTarget = tempFileTarget.getName();//this.getClass().getSimpleName() + "_target_" + "." + extensionTarget;
final byte[] bytes = IOUtils.toByteArray(contentInputStream);
//final byte[] verify = signer.verify(bytes,true);
byte[] verify = null;
//try{
// verify =GetOriginalContentFromFileSigned.getOriginalDocumentBinaries(new ByteArrayInputStream(bytes));
// if(verify==null){
// throw new SignerException("The content retireved is NULL");
// }
// }catch(Throwable ex){
// verify = signer.verify(bytes,true);
//}
verify = getSignedContent(bytes);
//AGGIUNGERE CONTROLLO PRELIMINARE NOME SE PRESENTE
MIMETYPE mimetype = null;
if(StringUtils.isNotBlank(retrieveOriFileName)){
try{
mimetype = MIMETYPE.forExtensions(FilenameUtils.getExtension(retrieveOriFileName));
}catch(IllegalArgumentException ex){
//DO NOTHING
}
}
//PRIMA DI SCRIVERE LO STREAM PROVIAMO A IDENTIFICARE IL MIMETYPE
//PER ATTIVARE I TRANSFOMER DI ALFRESCO UTILIZZANDO
//APACHE TIKA
if(mimetype==null){
mimetype = MIMETYPE.forBytes(verify);
}
//SE il file in formato p7m era un pdf non faccio la conversione esplicita con libreoffice
if(mimetype.equals(MIMETYPE.pdf)){
return verify;
}else{
String extensionIntermidiate = mimetype.getExtensions();
String mimetypeIntermidiate = mimetype.getMimetype();
File tempFileIntermidiate = TempFileProvider.createTempFile(this.getClass().getSimpleName() + "_intermidiate_", "." + extensionIntermidiate);
String nameIntermidiate = tempFileIntermidiate.getName();//this.getClass().getSimpleName() + "_intermidiate_" + "." + extensionIntermidiate;
FileUtils.writeByteArrayToFile(tempFileIntermidiate, verify);
//SI PUO' UTILIZZARE OPEBNOFFICE PER CONVERTIRE QUALUNQUE DOCUMENTO IN PDF
//http://satyabrata-mahapatra.blogspot.com/2010/09/start-openoffice-org-service-for.html
// connect to an OpenOffice.org instance running on port 8100
int port = 8100; //default
if(Boolean.parseBoolean(alfrescoGlobalProperties.getProperty("ooo.enabled"))){
port = Integer.valueOf(alfrescoGlobalProperties.getProperty("ooo.port"));
}else if(Boolean.parseBoolean(alfrescoGlobalProperties.getProperty("jodconverter.enabled"))){
port = Integer.valueOf(alfrescoGlobalProperties.getProperty("jodconverter.portNumbers"));
}else{
throw new AlfrescoRuntimeException("Impossibile recuperare la porta di comunicazione con libreoffice e/o jodconverter verifica le proprieta su alfresco global");
}
OpenOfficeConnection connection = new SocketOpenOfficeConnection(port);
try{
connection.connect();
// convert
DocumentConverter converter = new OpenOfficeDocumentConverter(connection);
//DocumentFormat inputFormat = new DocumentFormat(nameIntermidiate, mimetypeIntermidiate, extensionIntermidiate);
//DocumentFormat outputFormat = new DocumentFormat(nameTarget, mimetypeTarget, extensionTarget);
//converter.convert(tempFileIntermidiate, inputFormat, tempFileTarget, outputFormat);
converter.convert(tempFileIntermidiate, tempFileTarget);
return FileUtils.readFileToByteArray(tempFileTarget);
}catch(java.lang.IllegalArgumentException ex2){
//if(ex2.getMessage().contains("unsupported input format")){
// if(mimetypeIntermidiate.equals(MimetypeMap.MIMETYPE_TEXT_PLAIN)){
// PDFUtilities.convertTextToPDF(tempFileIntermidiate, tempFileTarget);
// return FileUtils.readFileToByteArray(tempFileTarget);
// }else{
// throw new AlfrescoRuntimeException(ex2.getMessage());
// }
//}else{
throw new AlfrescoRuntimeException(ex2.getMessage());
//}
}catch(Exception ex){
throw new AlfrescoRuntimeException(ex.getMessage());
}finally{
if(connection!=null){
// close the connection
connection.disconnect();
}
FileUtils.deleteQuietly(tempFileIntermidiate);
FileUtils.deleteQuietly(tempFileTarget);
}
}
}catch(Exception ex){
throw new AlfrescoRuntimeException(ex.getMessage());
}
}
}
}, false, true);
logger.debug("Fine conversione P7M2PDF");
writer.guessEncoding();
writer.setMimetype(MimetypeMap.MIMETYPE_PDF);
try (final OutputStream contentOutputStream = writer.getContentOutputStream()) {
contentOutputStream.write(data);
}
}
private byte[] getSignedContent(final byte[] signedDoc) throws SignerException {
ASN1InputStream asn1InputStream = null;
try {
asn1InputStream = new ASN1InputStream(new ByteArrayInputStream(signedDoc));
DERObject signedContent;
try {
signedContent = asn1InputStream.readObject();
}
catch (IOException cause) {
logger.error(cause.getMessage(), (Throwable)cause);
throw new SignerException(cause.getMessage(), cause);
}
CMSSignedData cmsSignedData;
try {
cmsSignedData = new CMSSignedData(ContentInfo.getInstance(signedContent));
}
catch (IllegalArgumentException cause2) {
logger.error(cause2.getMessage(), (Throwable)cause2);
throw new SignerException(cause2.getMessage(), cause2);
}catch (Throwable cause2) {
throw new SignerException(cause2.getMessage(), cause2);
}
return (byte[])((CMSProcessableByteArray)cmsSignedData.getSignedContent()).getContent();
}catch(Exception ex){
logger.error(ex.getMessage(),ex);
throw new SignerException(ex);
}
finally {
try {
asn1InputStream.close();
}
catch (IOException ex) {}
}
}
}
=================================================================
/src/main/resources/alfresco/module/<MODULE_NAME>/context/transform-p7m-p7s-context.xml
=================================================================
<?xml version='1.0' encoding='UTF-8'?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!--
-verify to tell openssl that you will feed a signed mail message on input and outputs the signed data.
-noverify do not verify the signers certificate of a signed message.
-signer output the signer cert to the cert.pem file.
-->
<!-- ========================================================= -->
<!-- P7S TO GENERIC DOC -->
<!-- http://moldovan.it/blog/open-and-read-p7s-files-in-ubuntu-linux/ -->
<!-- ========================================================= -->
<bean id="transformer.worker.p7s2doc" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
<property name="mimetypeService">
<ref bean="mimetypeService" />
</property>
<property name="checkCommand">
<bean name="transformer.p7s2doc" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl version</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl version</value>
</list>
</entry>
</map>
</property>
<!-- Error codes unknown -->
</bean>
</property>
<property name="transformCommand">
<bean name="transformer.p7s2doc" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl smime -inform DER -decrypt -verify -noverify -in ${source} -out ${target}</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl smime -inform DER -decrypt -verify -noverify -in ${source} -out ${target}</value>
</list>
</entry>
</map>
</property>
<property name="waitForCompletion">
<value>true</value>
</property>
<!-- Error codes unknown -->
</bean>
</property>
</bean>
<!-- ========================================================= -->
<!-- P7M TO GENERIC DOC -->
<!-- http://enricorossi.org/blog/2016/view_p7m_file_with_openssl/ -->
<!-- http://www.thinkitbetter.com/tibj/index.php/component/content/article?id=8:firma-digitale-come-si-es... -->
<!-- ========================================================= -->
<bean id="transformer.worker.p7m2doc" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
<property name="mimetypeService">
<ref bean="mimetypeService" />
</property>
<property name="checkCommand">
<bean name="transformer.p7m2doc" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl version</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl version</value>
</list>
</entry>
</map>
</property>
<!-- Error codes unknown -->
</bean>
</property>
<property name="transformCommand">
<bean name="transformer.p7m2doc" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl smime -inform DER -decrypt -verify -noverify -in ${source} -out ${target}</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>openssl smime -inform DER -decrypt -verify -noverify -in ${source} -out ${target}</value>
</list>
</entry>
</map>
</property>
<property name="waitForCompletion">
<value>true</value>
</property>
<!-- Error codes unknown -->
</bean>
</property>
</bean>
<!-- ========================================================= -->
<!-- GENERIC DOC TO PDF -->
<!-- http://blog.vogella.com/2012/02/27/batch-converting-libreoffice-documents-into-pdf/ -->
<!-- https://opensource.com/life/16/10/3-file-conversion-tools-linux-command-line -->
<!-- http://satyabrata-mahapatra.blogspot.com/2010/09/start-openoffice-org-service-for.html -->
<!-- https://bitbucket.org/xenit/alfresco-remote-jodconverter/src/master/ -->
<!-- TODO PROBLEMA DA LINEA DI COMANDO NON SPECIFICA IL TARGET -->
<!-- ========================================================= -->
<bean id="transformer.worker.doc2pdf" class="org.alfresco.repo.content.transform.RuntimeExecutableContentTransformerWorker">
<property name="mimetypeService">
<ref bean="mimetypeService" />
</property>
<property name="checkCommand">
<bean name="transformer.doc2pdf" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value>${ooo.exe} --version</value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value>${ooo.exe} --version</value>
</list>
</entry>
</map>
</property>
</bean>
</property>
<property name="transformCommand">
<bean name="transformer.doc2pdf" class="org.alfresco.util.exec.RuntimeExec">
<property name="commandsAndArguments">
<map>
<entry key="Linux">
<list>
<value>sh</value>
<value>-c</value>
<value></value>
</list>
</entry>
<entry key="*">
<list>
<value>sh</value>
<value>-c</value>
<value></value>
</list>
</entry>
</map>
</property>
<property name="waitForCompletion">
<value>true</value>
</property>
</bean>
</property>
</bean>
<!-- =============================================== -->
<!-- TRANSFORMER -->
<!-- =============================================== -->
<bean id="transformer.p7m2pdf" class="org.alfresco.transformer.P7m2PdfTransformer" parent="baseContentTransformer">
<!-- <property name="signer" ref="signer" /> -->
<property name="transactionService" ref="TransactionService" />
<property name="nodeService" ref="NodeService" />
<property name="alfrescoGlobalProperties">
<ref bean="global-properties" />
</property>
</bean>
<bean id="transformer.complex.p7m2image" class="org.alfresco.repo.content.transform.ComplexContentTransformer" parent="baseContentTransformer">
<property name="transformers">
<list>
<ref bean="transformer.p7m2pdf" />
<ref bean="transformer.ImageMagick" />
</list>
</property>
<property name="intermediateMimetypes">
<list>
<value>application/pdf</value>
</list>
</property>
</bean>
</beans>
=================================================================
/src/main/resources/alfresco/module/<MODULE_NAME>/mimetype/mimetype-map.xml
=================================================================
<alfresco-config area="mimetype-map">
<config evaluator="string-compare" condition="Mimetype Map">
<mimetypes>
<!-- SIGNED FILE -->
<mimetype mimetype="application/pkcs7-signature" display="application/pkcs7-signature">
<extension default="true">p7s</extension>
</mimetype>
<mimetype mimetype="application/cms" display="application/cms">
<extension>csig</extension>
</mimetype>
<mimetype mimetype="text/xml" display="text/xml (xsig)">
<extension>xsig</extension>
</mimetype>
<mimetype mimetype="application/pkcs7-mime" display="application/pkcs7-mime">
<extension>p7m</extension>
</mimetype>
<mimetype mimetype="application/x-pkcs7-mime" display="application/x-pkcs7-mime">
<extension>p7m</extension>
</mimetype>
</mimetypes>
</config>
</alfresco-config>
=================================================================
/src/main/resources/alfresco/extension/mimetype/mimetypes-extension-map.xml
=================================================================
<alfresco-config area="mimetype-map">
<config evaluator="string-compare" condition="Mimetype Map">
<mimetypes>
<!-- SIGNED FILE -->
<mimetype mimetype="application/pkcs7-signature" display="application/pkcs7-signature">
<extension default="true">p7s</extension>
</mimetype>
<mimetype mimetype="application/cms" display="application/cms">
<extension>csig</extension>
</mimetype>
<mimetype mimetype="text/xml" display="text/xml (xsig)">
<extension>xsig</extension>
</mimetype>
<mimetype mimetype="application/pkcs7-mime" display="application/pkcs7-mime">
<extension>p7m</extension>
</mimetype>
<mimetype mimetype="application/x-pkcs7-mime" display="application/x-pkcs7-mime">
<extension>p7m</extension>
</mimetype>
</mimetypes>
</config>
</alfresco-config>
=================================================================
/src/main/resources/alfresco/module/<MODULE_NAME>/alfresco-global.properties
=================================================================
...................................
### transform-p7m-p7s-context.xml ###
# --------------------------------------------
# P7M
# --------------------------------------------
content.transformer.p7m2pdf.priority=50
content.transformer.p7m2pdf.extensions.p7m.pdf.supported=true
content.transformer.p7m2pdf.extensions.p7m.pdf.priority=50
content.transformer.p7m2pdf.extensions.p7m.pdf.maxSourceSizeKBytes=25600
content.transformer.complex.p7m2image.priority=50
content.transformer.complex.p7m2image.extensions.p7m.png.supported=true
content.transformer.complex.p7m2image.extensions.p7m.png.priority=50
content.transformer.complex.p7m2image.extensions.p7m.png.maxSourceSizeKBytes=25600
That would be a nice addon to have on github
Hi, I'm an Italian user who uses dockerized Alfresco Community 6.2. The p7m format is typically used in Italy for the signature of pdf files and being able to access the content in order to index it is absolutely a priority.
I have inspected the "n" dockers that have been created to manage the environment but I can't find where to put the various files you propose in your solution.
For example: "/ src / main / java / org / alfresco / transformers /" I can't find it (especially the "transformers" folder)
Anyone know if there is an addon on github?
Thank you, see you soon!
Andrew
@andrea65 The transformer construct used as the basis for those Docker images is significantly different from the old in-process transformers. None of the files can be re-used as-is to build a Docker-based transformer. A general description of how new transformers are implemented can be found in the ACS Packaging project.
Hello to all,
I would have found a way to transform p7m files into pdf with the following command (from linux shell):
for i in `ls *.pdf.p7m`; do openssl smime -decrypt -verify -inform DER -in $i -noverify -out $i.pdf;done
I would like to turn it into a js script to use it as a rule ...
I thought I would write it like this:
var outputFile = $ .pdf;
var inFile = $ .pdf.p7m ";
openssl smime -decrypt -verify -inform DER -in inFile -noverify -out outputFile
but it doesn't work ... how can I make it work?
The script should just transform the file on the fly the moment I put it in a folder.
Thank you all!
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.