Download .zip |
Info | Documentation | View files (159) | Download .zip | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2019-11-06 (2 months ago) | Not yet rated by the users | Total: 81 This week: 5 | All time: 9,441 This week: 59 |
Version | License | PHP version | Categories | |||
dsigsdk 1.0.0 | GNU Lesser Genera... | 5 | XML, PHP 5, Cryptography |
and provide
For help finding a good PHP cryptography library, please review * Choosing the Right Cryptography Library for your PHP Project: A Guide
To parse an Dsig (Signature root) XML file (using XMLReader) :
<?php
namespace Kigkonsult\DsigSdk;
use Kigkonsult\DsigSdk\XMLParse\DsigParser;
$dsig = DsigParser::factory()->parse(
file_get_contents( 'DsigFile.xml' )
);
$signedInfo = $dsig->getsignedInfo();
...
The XML parser save the XMLreader node properties (baseURI, localName, name, namespaceURI, prefix) for each XML (Dto) element as 'XMLattributes' as well as XML attributes (xmlns, xmlns:*, schemaLocation), if set (more info below).
'any' [XSD] elements are accepted as 'Anytype' object instances (more info below, 'AnyType').
To build up dsig structure:
<?php
namespace Kigkonsult\DsigSdk;
use Kigkonsult\DsigSdk\Dto\AnyType;
use Kigkonsult\DsigSdk\Dto\CanonicalizationMethodType;
use Kigkonsult\DsigSdk\Dto\KeyInfoType;
use Kigkonsult\DsigSdk\Dto\SignedInfoType;
use Kigkonsult\DsigSdk\Dto\SignatureType;
use Kigkonsult\DsigSdk\Dto\SignatureValueType;
$dsig = SignatureType::factory()
->setSignedInfo(
SignedInfoType::factory()
->setCanonicalizationMethod(
CanonicalizationMethodType::factory()
->setAlgorithm( SignatureType::MINICANONICAL )
->setAny( [
AnyType::factory()
->setElementName( 'nonSchemaElement1')
->setAttributes( [
'id' => '12345'
] )
->setContent( 'Lr1mKGxP7VAgMB...' ),
AnyType::factory()
->setElementName( 'nonSchemaElement2')
->setSubElements( [
AnyType::factory()
->setElementName( 'nonSchemaElement3')
->setContent( 'Lr1mKGxP7VAgMB...' ),
] )
]
)
)
)
->setSignatureValue(
SignatureValueType::factory()
->setSignatureValueType( 'vgGZnRlm8...' )
)
->setKeyInfo(
KeyInfoType::factory()
->setKeyInfoType( [
[ // one set of elements
[ // element
SignatureType::X509DATA =>
X509DataType::factory()
->setX509Certificate( ... )
],
],
] )
)
->setObject(
...
)
...
You can set (single 'element') XMLattribute using
$dsig->setXMLAttribut( <key>, <value> );
To set (ex. prefix) and 'propagate' down in hierarchy:
$dsig->setXMLAttribut( SignatureType::PREFIX, <value>, true );
You can remove (single 'element') XMLattribute using
$dsig->unsetXMLAttribut( <key> );
To unset (ex. prefix) and 'propagate' down in hierarchy:
$dsig->unsetXMLAttribut( SignatureType::PREFIX, true );
To fetch and iterate over XMLAttributes
foreach( $dsig->getXMLAttributes() as $key => $value {
...
}
Anytype object instances are used for 'any' [XSD] elements. The element name are stored and fetched with
$anytype->setElementName( <name> );
$anytypeName = $anytype->getElementName();
The 'any' [XSD] element attributes may include XML attributes.
The AnyType attributes are stored and fetched as array.
$anytype->setAttributes( [ <key> => <value> ] );
foreach( $anytype->getAttributes() as $key => $value {
...
}
Note, an AnyType instance may have * content * type string, * AnyType::setContent() * AnyType::getContent()
or * sub-elements type array [AnyType] * AnyType::setSubElements() * AnyType::getSubElements()
but not both.
DsigSdk uses XMLWriter creating output.
$XMLstring = DsigWriter::factory()->write( $dsig );
The XMLwriter adds for each element * element name with prefix, if exists XMLattribute xmlns, xmlns: and schemaLocation, if exists.
$domNode = DsigWriter::factory()->write( $dsig, true );
For class structure and architecture, please review * the [XSD] * docs/Dsig.png class design * the src/DsigLoader directory
You may find convenient constants in - src/DsigInterface - src/XMLAttributesInterface
For base64Encode/base64Decode/hash support, please review src/Impl/Impl.md
From the Command Line:
composer require kigkonsult/dsigsdk
In your composer.json
:
{
"require": {
"kigkonsult/dsigsdk": "dev-master"
}
}
Acquire access
namespace Kigkonsult\DsigSdk;
...
include 'vendor/autoload.php';
Run tests
cd pathToSource/DsigSdk
vendor/bin/phpunit
Download and acquire..
namepace Kigkonsult\DsigSdk;
...
include 'pathToSource/DsigSdk/autoload.php';
For support, please use [Github]/issues.
This project is licensed under the LGPLv3 License
[Composer]:https://getcomposer.org/ [Github]:https://github.com/iCalcreator/dsigsdk/issues [http://www.w3.org/2000/09/xmldsig#]:http://www.w3.org/2000/09/xmldsig# [XSD]:https://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd
Files |
File | Role | Description | ||
---|---|---|---|---|
docs (6 files) | ||||
src (4 files, 5 directories) | ||||
test (2 files, 1 directory) | ||||
autoload.php | Aux. | Auxiliary script | ||
composer.json | Data | Auxiliary data | ||
phpunit.xml | Data | Auxiliary data | ||
README.md | Doc. | Read me |
Files | / | docs |
File | Role | Description |
---|---|---|
Dsig.png | Data | Auxiliary data |
lgpl.txt | Doc. | Documentation |
README.Impl.txt | Doc. | Documentation |
README.txt | Doc. | Documentation |
rfc4051.txt | Doc. | Documentation |
xmldsig-core-schema.xsd | Data | Auxiliary data |
Files | / | src |
File | Role | Description | ||
---|---|---|---|---|
DsigLoader (26 files) | ||||
Dto (46 files) | ||||
Impl (14 files) | ||||
XMLParse (26 files) | ||||
XMLWrite (25 files) | ||||
DsigBase.php | Class | Class source | ||
DsigIdentifiersInterface.php | Class | Class source | ||
DsigInterface.php | Class | Class source | ||
XMLAttributesInterface.php | Class | Class source |
Files | / | src | / | DsigLoader |
File | Role | Description |
---|---|---|
AnyType.php | Class | Class source |
CanonicalizationMethodType.php | Class | Class source |
DigestMethodType.php | Class | Class source |
DSAKeyValueType.php | Class | Class source |
DsigLoaderInterface.php | Class | Class source |
KeyInfoType.php | Class | Class source |
KeyValueType.php | Class | Class source |
ManifestType.php | Class | Class source |
ObjectType.php | Class | Class source |
PGPDataType.php | Class | Class source |
ReferenceType.php | Class | Class source |
RetrievalMethodType.php | Class | Class source |
RSAKeyValueType.php | Class | Class source |
SignatureMethodType.php | Class | Class source |
SignaturePropertiesType.php | Class | Class source |
SignaturePropertyType.php | Class | Class source |
SignatureType.php | Class | Class source |
SignatureType1.php | Class | Class source |
SignatureType2.php | Class | Class source |
SignatureValueType.php | Class | Class source |
SignedInfoType.php | Class | Class source |
SPKIDataType.php | Class | Class source |
TransformsType.php | Class | Class source |
TransformType.php | Class | Class source |
X509DataType.php | Class | Class source |
X509IssuerSerialType.php | Class | Class source |
Files | / | src | / | Dto |
File | Role | Description |
---|---|---|
Any.php | Class | Class source |
AnyType.php | Class | Class source |
CanonicalizationMethod.php | Class | Class source |
CanonicalizationMethodType.php | Class | Class source |
DigestMethod.php | Class | Class source |
DigestMethodType.php | Class | Class source |
DSAKeyValue.php | Class | Class source |
DSAKeyValueType.php | Class | Class source |
DsigBase.php | Class | Class source |
KeyInfo.php | Class | Class source |
KeyInfoType.php | Class | Class source |
KeyValue.php | Class | Class source |
KeyValueType.php | Class | Class source |
Manifest.php | Class | Class source |
ManifestType.php | Class | Class source |
Object.php | Class | Class source |
ObjectType.php | Class | Class source |
PGPData.php | Class | Class source |
PGPDataType.php | Class | Class source |
Reference.php | Class | Class source |
ReferenceType.php | Class | Class source |
RetrievalMethod.php | Class | Class source |
RetrievalMethodType.php | Class | Class source |
RSAKeyValue.php | Class | Class source |
RSAKeyValueType.php | Class | Class source |
Signature.php | Class | Class source |
SignatureMethod.php | Class | Class source |
SignatureMethodType.php | Class | Class source |
SignatureProperties.php | Class | Class source |
SignaturePropertiesType.php | Class | Class source |
SignatureProperty.php | Class | Class source |
SignaturePropertyType.php | Class | Class source |
SignatureType.php | Class | Class source |
SignatureValue.php | Class | Class source |
SignatureValueType.php | Class | Class source |
SignedInfo.php | Class | Class source |
SignedInfoType.php | Class | Class source |
SPKIData.php | Class | Class source |
SPKIDataType.php | Class | Class source |
Transform.php | Class | Class source |
Transforms.php | Class | Class source |
TransformsType.php | Class | Class source |
TransformType.php | Class | Class source |
X509Data.php | Class | Class source |
X509DataType.php | Class | Class source |
X509IssuerSerialType.php | Class | Class source |
Files | / | src | / | Impl |
File | Role | Description |
---|---|---|
Common.md | Data | Auxiliary data |
CommonFactory.php | Class | Class source |
Hash.md | Data | Auxiliary data |
HashFactory.php | Class | Class source |
HmacHash.md | Data | Auxiliary data |
HmacHashFactory.php | Class | Class source |
ImplBase.php | Class | Class source |
Misc.md | Data | Auxiliary data |
OpenSSL.md | Data | Auxiliary data |
OpenSSLBase.php | Class | Class source |
OpenSSLFactory.php | Class | Class source |
OpenSSLInterface.php | Class | Class source |
PhpErrorException.php | Class | Class source |
PKCSFactory.php | Class | Class source |
Files | / | src | / | XMLParse |
File | Role | Description |
---|---|---|
AnyTypeParser.php | Class | Class source |
CanonicalizationMethodTypeParser.php | Class | Class source |
DigestMethodTypeParser.php | Class | Class source |
DSAKeyValueTypeParser.php | Class | Class source |
DsigParser.php | Class | Class source |
DsigParserBase.php | Class | Class source |
KeyInfoTypeParser.php | Class | Class source |
KeyValueTypeParser.php | Class | Class source |
LibXmlUtilTrait.php | Class | Class source |
ManifestTypeParser.php | Class | Class source |
ObjectTypeParser.php | Class | Class source |
PGPDataTypeParser.php | Class | Class source |
ReferenceTypeParser.php | Class | Class source |
RetrievalMethodTypeParser.php | Class | Class source |
RSAKeyValueTypeParser.php | Class | Class source |
SignatureMethodTypeParser.php | Class | Class source |
SignaturePropertiesTypeParser.php | Class | Class source |
SignaturePropertyTypeParser.php | Class | Class source |
SignatureTypeParser.php | Class | Class source |
SignatureValueTypeParser.php | Class | Class source |
SignedInfoTypeParser.php | Class | Class source |
SPKIDataTypeParser.php | Class | Class source |
TransformsTypeParser.php | Class | Class source |
TransformTypeParser.php | Class | Class source |
X509DataTypeParser.php | Class | Class source |
X509IssuerSerialTypeParser.php | Class | Class source |
Files | / | src | / | XMLWrite |
File | Role | Description |
---|---|---|
AnyTypeWriter.php | Class | Class source |
CanonicalizationMethodTypeWriter.php | Class | Class source |
DigestMethodTypeWriter.php | Class | Class source |
DSAKeyValueTypeWriter.php | Class | Class source |
DsigWriter.php | Class | Class source |
DsigWriterBase.php | Class | Class source |
KeyInfoTypeWriter.php | Class | Class source |
KeyValueTypeWriter.php | Class | Class source |
ManifestTypeWriter.php | Class | Class source |
ObjectTypeWriter.php | Class | Class source |
PGPDataTypeWriter.php | Class | Class source |
ReferenceTypeWriter.php | Class | Class source |
RetrievalMethodTypeWriter.php | Class | Class source |
RSAKeyValueTypeWriter.php | Class | Class source |
SignatureMethodTypeWriter.php | Class | Class source |
SignaturePropertiesTypeWriter.php | Class | Class source |
SignaturePropertyTypeWriter.php | Class | Class source |
SignatureTypeWriter.php | Class | Class source |
SignatureValueTypeWriter.php | Class | Class source |
SignedInfoTypeWriter.php | Class | Class source |
SPKIDataTypeWriter.php | Class | Class source |
TransformsTypeWriter.php | Class | Class source |
TransformTypeWriter.php | Class | Class source |
X509DataTypeWriter.php | Class | Class source |
X509IssuerSerialTypeWriter.php | Class | Class source |
Files | / | test |
File | Role | Description | ||
---|---|---|---|---|
Impl (6 files) | ||||
BaseTest.php | Class | Class source | ||
SignatureTest.php | Class | Class source |
Files | / | test | / | Impl |
File | Role | Description |
---|---|---|
CommonFactoryTest.php | Class | Class source |
HashFactoryTest.php | Class | Class source |
HmacHashFactoryTest.php | Class | Class source |
OpenSSLBaseTest.php | Class | Class source |
OpenSSLFactoryTest.php | Class | Class source |
PKCSFactoryTest.php | Class | Class source |
Version Control | Unique User Downloads | Download Rankings | |||||||||||||||
100% |
|
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.