* TimeStampResp ::= SEQUENCE { * status PKIStatusInfo, * timeStampToken TimeStampToken OPTIONAL * } * * * @package asn1 * @subpackage tsp * * @link http://tools.ietf.org/html/rfc3161#section-2.4.2 RFC 3161: Time-Stamp Protocol */ class TSPTimeStampResp { private $status; private $token; /** * Constructs a new instance of TSPTimeStampResp. */ public function __construct() { } /** * Decodes the given ASN1Sequence as TSPTimeStampResp. * * @throws GTException * @param ASN1Sequence $object TSPTimeStampResp encoded as ASN1Sequence * @return void */ public function decode($object) { if (!$object instanceof ASN1Sequence) { throw new GTException("object must be an instance of ASN1Sequence"); } if ($object->getObjectCount() < 1 || $object->getObjectCount() > 2) { throw new GTException("invalid sequence size"); } $status = new PKIStatusInfo(); $status->decode($object->getObjectAt(0)); $this->status = $status; $code = $this->getStatusCode(); if ($code == 0 || $code == 1) { if ($object->getObjectCount() != 2) { throw new GTException("timestamp token is missing"); } $token = new CMSContentInfo(); $token->decode($object->getObjectAt(1)); $this->token = $token; } else if ($code >= 2 && $code <= 5) { if ($object->getObjectCount() == 2) { throw new GTException("unexpected timestamp token"); } } else { throw new GTException("invalid status code: {$code}"); } } /** * Gets the status. * * @return PKIStatusInfo status */ public function getStatus() { return $this->status; } /** * Gets the status code. * * @return int status code */ public function getStatusCode() { return $this->status->getStatus(); } /** * Gets the timestamp token. * * @return CMSContentInfo timestamp token */ public function getToken() { return $this->token; } } ?>