Hello
I've made the following script in php in order to generate the url integration from an extranet.
Despite many researches, i can't find what is wrong. I always get the error message "DocuWare.Gapi.Utils.Web.DWIntegration.EX_INVALID_PASS_PHRASE".
I've tried to compare my results with the application URL creator but i never get the same url.
I'm not sure that my code is correct to hash the passphrase and split it to get the key and iv.
Any help would be very appreciated. Thank you
<?php
//script php to generate url integration for docuware
//hash passphrase with sha512 and get key and iv ( http://help.docuware.com/en/#b64090t60297n89509 )
$passphrase = hash('sha512', 'xxxxx');
$encryption_key = substr($passphrase,0,32);
$iv = substr($passphrase,32,16);
echo "Passphrase hash: $passphrase\n";
echo "encryption_key: $encryption_key\n";
echo "iv: $iv\n";
//create parameters string to encrypt ( http://help.docuware.com/en/#b64090t61532n89494 )
//p=D for Download
$param = '&p=D';
//Docuware login in base64
$lc = 'User=xxx\nPwd=xxx';
$lc = convertToUrlTokenFormat(base64_encode($lc));
$param = $param . '&lc=' . $lc;
//fc=guid of the concerned file cabinet
$param = $param . '&fc=xxx';
//request in base64
$q = '[N__DOCUMENT]=xxx';
$q = convertToUrlTokenFormat(base64_encode($q));
$param = $param . '&q=' . $q ;
//download type
$param = $param . '&dt=Download';
echo "Before encryption: $param\n";
// Encrypt $param using aes-256-cbc cipher with the given encryption key and iv
// The 0 gives us the default options, but can be changed to OPENSSL_RAW_param or OPENSSL_ZERO_PADDING
$encrypted = openssl_encrypt($param, 'aes-256-cbc', $encryption_key, 0, $iv);
echo "Encrypted: $encrypted\n";
//Encrypted paramters string encrypted again in base64 (see https://support.docuware.com/fr-fr/knowledgebase/article/KBA-35664 )
$encryptedbase64 = convertToUrlTokenFormat(base64_encode($encrypted));
echo "EncryptedBase64: $encryptedbase64\n\n";
$url = 'http://xxx/DocuWare/Platform/WebClient/1/Integration?&ep=' . $encryptedbase64;
echo "URL: $url\n";
function convertToUrlTokenFormat($val)
{
$padding = substr_count($val, '=');
$val = str_replace('=', '', $val);
$val .= $padding;
$val = str_replace('+', '-', str_replace('/', '_', $val));
return $val;
}
?>