示例#1
0
 /// <summary>
 /// Create a new ValidityPeriod with a copy of the fields in the given
 /// validityPeriod.
 /// </summary>
 ///
 /// <param name="validityPeriod">The ValidityPeriod to copy.</param>
 public ValidityPeriod(ValidityPeriod validityPeriod)
 {
     this.notBefore_   = System.Double.MaxValue;
     this.notAfter_    = -System.Double.MaxValue;
     this.changeCount_ = 0;
     notBefore_        = validityPeriod.notBefore_;
     notAfter_         = validityPeriod.notAfter_;
 }
示例#2
0
 /// <summary>
 /// Create a SigningInfo as a copy of the given signingInfo. (This takes a
 /// pointer to the given signingInfo PibIdentity and PibKey without copying.)
 /// </summary>
 ///
 /// <param name="signingInfo">The SigningInfo to copy.</param>
 public SigningInfo(SigningInfo signingInfo)
 {
     this.validityPeriod_ = new ValidityPeriod();
     type_            = signingInfo.type_;
     name_            = new Name(signingInfo.name_);
     identity_        = signingInfo.identity_;
     key_             = signingInfo.key_;
     digestAlgorithm_ = signingInfo.digestAlgorithm_;
     validityPeriod_  = new ValidityPeriod(signingInfo.validityPeriod_);
 }
示例#3
0
        /// <summary>
        /// Check and set the signerType, and set others to default values. This does
        /// NOT reset the digest algorithm.
        /// </summary>
        ///
        /// <param name="signerType">The The type of signer.</param>
        private void reset(SigningInfo.SignerType signerType)
        {
            if (!(signerType == net.named_data.jndn.security.SigningInfo.SignerType.NULL || signerType == net.named_data.jndn.security.SigningInfo.SignerType.ID ||
                  signerType == net.named_data.jndn.security.SigningInfo.SignerType.KEY ||
                  signerType == net.named_data.jndn.security.SigningInfo.SignerType.CERT || signerType == net.named_data.jndn.security.SigningInfo.SignerType.SHA256))
            {
                throw new AssertionError("SigningInfo: The signerType is not valid");
            }

            type_           = signerType;
            name_           = new Name();
            identity_       = null;
            key_            = null;
            validityPeriod_ = new ValidityPeriod();
        }
示例#4
0
 /// <summary>
 /// Set the validity period for the signature info.
 /// Note that the equivalent ndn-cxx method uses a semi-prepared SignatureInfo,
 /// but this method only uses the ValidityPeriod from the SignatureInfo.
 /// </summary>
 ///
 /// <param name="validityPeriod">The validity period, which is copied.</param>
 /// <returns>This SigningInfo.</returns>
 public SigningInfo setValidityPeriod(ValidityPeriod validityPeriod)
 {
     validityPeriod_ = new ValidityPeriod(validityPeriod);
     return(this);
 }
示例#5
0
 /// <summary>
 /// Check if this is the same validity period as other.
 /// </summary>
 ///
 /// <param name="other">The other ValidityPeriod to compare with.</param>
 /// <returns>true if the validity periods are equal.</returns>
 public bool equals(ValidityPeriod other)
 {
     return(notBefore_ == other.notBefore_ && notAfter_ == other.notAfter_);
 }
        private static void decodeValidityPeriod(ValidityPeriod validityPeriod,
				TlvDecoder decoder)
        {
            int endOffset = decoder
                    .readNestedTlvsStart(net.named_data.jndn.encoding.tlv.Tlv.ValidityPeriod_ValidityPeriod);

            validityPeriod.clear();

            // Set copy false since we just immediately get the string.
            Blob isoString = new Blob(
                    decoder.readBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.ValidityPeriod_NotBefore), false);
            double notBefore = net.named_data.jndn.encrypt.Schedule.fromIsoString("" + isoString);
            isoString = new Blob(decoder.readBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.ValidityPeriod_NotAfter),
                    false);
            double notAfter = net.named_data.jndn.encrypt.Schedule.fromIsoString("" + isoString);

            validityPeriod.setPeriod(notBefore, notAfter);

            decoder.finishNestedTlvs(endOffset);
        }
        private static void encodeValidityPeriod(ValidityPeriod validityPeriod,
				TlvEncoder encoder)
        {
            int saveLength = encoder.getLength();

            // Encode backwards.
            encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.ValidityPeriod_NotAfter,
                    new Blob(net.named_data.jndn.encrypt.Schedule.toIsoString(validityPeriod.getNotAfter()))
                            .buf());
            encoder.writeBlobTlv(net.named_data.jndn.encoding.tlv.Tlv.ValidityPeriod_NotBefore,
                    new Blob(net.named_data.jndn.encrypt.Schedule.toIsoString(validityPeriod.getNotBefore()))
                            .buf());

            encoder.writeTypeAndLength(net.named_data.jndn.encoding.tlv.Tlv.ValidityPeriod_ValidityPeriod,
                    encoder.getLength() - saveLength);
        }
示例#8
0
 /// <summary>
 /// Check if this is the same validity period as other.
 /// </summary>
 ///
 /// <param name="other">The other ValidityPeriod to compare with.</param>
 /// <returns>true if the validity periods are equal.</returns>
 public bool equals(ValidityPeriod other)
 {
     return notBefore_ == other.notBefore_ && notAfter_ == other.notAfter_;
 }