robrichards / xmlseclibs

A PHP library for XML Security
BSD 3-Clause "New" or "Revised" License
386 stars 180 forks source link

Adding a timestamp signature property #227

Closed bseddon closed 3 years ago

bseddon commented 3 years ago

My requirement is to be able to add a timestamp as a <SignatureProperty>. In issue #94 you comment that there is no support for <SignatureProperties>. While this PR does not include a generic mechanism to add properties, it does make use of addObject() to create function called addTimestamp to add a specific property. The technique used could be adapted by users to add any other named property and value.

To add a timestamp, pass an id (a new parameter) to the XMLSecurityDSig constructor:

$signatureId = 'someId';
$objDSig = new XMLSecurityDSig( 'ds', $signatureId );

then call the new function before signing:

$timestamp = date(DateTime::ISO8601);
$objDSig->addTimestamp( $timestamp, $signatureId );

This call might be placed before the security key is created in the example in the readme.

Other changes

No attempt has been made to run the tests to see it changes will cause regressions in those cases. For this and other reasons you may be reluctant to accept the PR. Even so, because the changes have been made it seems polite to share.

tvdijen commented 3 years ago

Just some random thoughts;

I think everything after the July 1st commits shouldn't be part of this PR. That's a change on it's own and personally I don't like the idea of people importing their own namespaces into another man's project. Might as well create a fork then.

bseddon commented 3 years ago

I agree. Although the changes are made to a fork as you suggest, I had failed to appreciate subsequent changes to the fork will also appear in the earlier PR so I've closed it. I hope this will address the issue.