Skip to content

Commit

Permalink
Add withAdditionalExtensions
Browse files Browse the repository at this point in the history
  • Loading branch information
sop committed Jun 22, 2016
1 parent fb1238b commit 0989e16
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
13 changes: 13 additions & 0 deletions lib/X509/AttributeCertificate/AttributeCertificateInfo.php
Expand Up @@ -9,6 +9,7 @@
use CryptoUtil\ASN1\AlgorithmIdentifier\Feature\SignatureAlgorithmIdentifier;
use CryptoUtil\ASN1\PrivateKeyInfo;
use CryptoUtil\Crypto\Crypto;
use X509\Certificate\Extension\Extension;
use X509\Certificate\Extensions;
use X509\Certificate\UniqueIdentifier;

Expand Down Expand Up @@ -256,6 +257,18 @@ public function withExtensions(Extensions $extensions) {
return $obj;
}

/**
* Get self with extensions added.
*
* @param Extension ...$exts One or more Extension objects
* @return self
*/
public function withAdditionalExtensions(Extension ...$exts) {
$obj = clone $this;
$obj->_extensions = $obj->_extensions->withExtensions(...$exts);
return $obj;
}

/**
* Get version.
*
Expand Down
12 changes: 12 additions & 0 deletions test/unit/ac/AttributeCertificateInfoTest.php
Expand Up @@ -301,6 +301,18 @@ public function testWithExtensions(AttributeCertificateInfo $aci) {
return $aci;
}

/**
* @depends testCreate
*
* @param AttributeCertificateInfo $aci
*/
public function testWithAdditionalExtensions(AttributeCertificateInfo $aci) {
$aci = $aci->withAdditionalExtensions(
new AuthorityKeyIdentifierExtension(true, "test"));
$this->assertInstanceOf(AttributeCertificateInfo::class, $aci);
return $aci;
}

/**
* @depends testCreateWithAll
* @expectedException UnexpectedValueException
Expand Down

0 comments on commit 0989e16

Please sign in to comment.