Exemplo n.º 1
0
        /// <summary>
        /// Decrypt cKeyData.
        /// </summary>
        ///
        /// <param name="cKeyData">The C-KEY data packet.</param>
        /// <param name="onPlainText_0"></param>
        /// <param name="onError_1">This calls onError.onError(errorCode, message) for an error.</param>
        internal void decryptCKey(Data cKeyData, Consumer.OnPlainText onPlainText_0,
                                  net.named_data.jndn.encrypt.EncryptError.OnError onError_1)
        {
            // Get the encrypted content.
            Blob             cKeyContent            = cKeyData.getContent();
            EncryptedContent cKeyEncryptedContent_2 = new EncryptedContent();

            try {
                cKeyEncryptedContent_2.wireDecode(cKeyContent);
            } catch (EncodingException ex) {
                try {
                    onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.InvalidEncryptedFormat,
                                      ex.Message);
                } catch (Exception exception) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception);
                }
                return;
            }
            Name eKeyName   = cKeyEncryptedContent_2.getKeyLocator().getKeyName();
            Name dKeyName_3 = eKeyName.getPrefix(-3);

            dKeyName_3.append(net.named_data.jndn.encrypt.algo.Encryptor.NAME_COMPONENT_D_KEY).append(
                eKeyName.getSubName(-2));

            // Check if the decryption key is already in the store.
            Blob dKey = (Blob)ILOG.J2CsMapping.Collections.Collections.Get(dKeyMap_, dKeyName_3);

            if (dKey != null)
            {
                decrypt(cKeyEncryptedContent_2, dKey, onPlainText_0, onError_1);
            }
            else
            {
                // Get the D-Key Data.
                Name interestName = new Name(dKeyName_3);
                interestName.append(net.named_data.jndn.encrypt.algo.Encryptor.NAME_COMPONENT_FOR).append(
                    consumerName_);
                Interest interest_4 = new Interest(interestName);

                // Prepare the callback functions.
                OnData onData_5 = new Consumer.Anonymous_C2(this, onError_1, onPlainText_0, cKeyEncryptedContent_2,
                                                            dKeyName_3);

                OnTimeout onTimeout = new Consumer.Anonymous_C1(this, interest_4, onData_5, onError_1);

                // Express the Interest.
                try {
                    face_.expressInterest(interest_4, onData_5, onTimeout);
                } catch (IOException ex_6) {
                    try {
                        onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.IOException,
                                          "expressInterest error: " + ex_6.Message);
                    } catch (Exception exception_7) {
                        logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception_7);
                    }
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Express the interest, call verifyData for the fetched Data packet and call
        /// onVerified if verify succeeds. If verify fails, call
        /// onError.onError(ErrorCode.Validation, "verifyData failed"). If the interest
        /// times out, re-express nRetrials times. If the interest times out nRetrials
        /// times, or for a network Nack, call
        /// onError.onError(ErrorCode.DataRetrievalFailure, interest.getName().toUri()).
        /// </summary>
        ///
        /// <param name="interest">The Interest to express.</param>
        /// <param name="nRetrials_0">The number of retrials left after a timeout.</param>
        /// <param name="link_1">zero, don't use it.</param>
        /// <param name="onVerified_2"></param>
        /// <param name="onError_3">This calls onError.onError(errorCode, message) for an error.</param>
        internal void sendInterest(Interest interest, int nRetrials_0,
                                   Link link_1, OnVerified onVerified_2, net.named_data.jndn.encrypt.EncryptError.OnError onError_3)
        {
            // Prepare the callback functions.
            OnData onData = new Consumer.Anonymous_C2(this, onError_3, onVerified_2);

            OnNetworkNack onNetworkNack = new Consumer.Anonymous_C1(onError_3);

            OnTimeout onTimeout = new Consumer.Anonymous_C0(this, onError_3, onVerified_2, link_1, nRetrials_0);

            Interest request;

            if (link_1.getDelegations().size() == 0)
            {
                // We can use the supplied interest without copying.
                request = interest;
            }
            else
            {
                // Copy the supplied interest and add the Link.
                request = new Interest(interest);
                // This will use a cached encoding if available.
                request.setLinkWireEncoding(link_1.wireEncode());
            }

            try {
                face_.expressInterest(request, onData, onTimeout, onNetworkNack);
            } catch (IOException ex) {
                try {
                    onError_3.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.IOException,
                                      "expressInterest error: " + ex.Message);
                } catch (Exception exception) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception);
                }
            }
        }
Exemplo n.º 3
0
 public Anonymous_C7(Consumer.Anonymous_C1  paramouter_Anonymous_C1)
 {
     this.outer_Anonymous_C1 = paramouter_Anonymous_C1;
 }
Exemplo n.º 4
0
 public Anonymous_C7(Consumer.Anonymous_C1 paramouter_Anonymous_C1)
 {
     this.outer_Anonymous_C1 = paramouter_Anonymous_C1;
 }
Exemplo n.º 5
0
        /// <summary>
        /// Decrypt cKeyData.
        /// </summary>
        ///
        /// <param name="cKeyData">The C-KEY data packet.</param>
        /// <param name="onPlainText_0"></param>
        /// <param name="onError_1">This calls onError.onError(errorCode, message) for an error.</param>
        internal void decryptCKey(Data cKeyData, Consumer.OnPlainText  onPlainText_0,
				net.named_data.jndn.encrypt.EncryptError.OnError  onError_1)
        {
            // Get the encrypted content.
            Blob cKeyContent = cKeyData.getContent();
            EncryptedContent cKeyEncryptedContent_2 = new EncryptedContent();
            try {
                cKeyEncryptedContent_2.wireDecode(cKeyContent);
            } catch (EncodingException ex) {
                try {
                    onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.InvalidEncryptedFormat,
                            ex.Message);
                } catch (Exception exception) {
                    logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception);
                }
                return;
            }
            Name eKeyName = cKeyEncryptedContent_2.getKeyLocator().getKeyName();
            Name dKeyName_3 = eKeyName.getPrefix(-3);
            dKeyName_3.append(net.named_data.jndn.encrypt.algo.Encryptor.NAME_COMPONENT_D_KEY).append(
                    eKeyName.getSubName(-2));

            // Check if the decryption key is already in the store.
            Blob dKey = (Blob) ILOG.J2CsMapping.Collections.Collections.Get(dKeyMap_,dKeyName_3);
            if (dKey != null)
                decrypt(cKeyEncryptedContent_2, dKey, onPlainText_0, onError_1);
            else {
                // Get the D-Key Data.
                Name interestName = new Name(dKeyName_3);
                interestName.append(net.named_data.jndn.encrypt.algo.Encryptor.NAME_COMPONENT_FOR).append(
                        consumerName_);
                Interest interest_4 = new Interest(interestName);

                // Prepare the callback functions.
                OnData onData_5 = new Consumer.Anonymous_C2 (this, onError_1, onPlainText_0, dKeyName_3,
                        cKeyEncryptedContent_2);

                OnTimeout onTimeout = new Consumer.Anonymous_C1 (this, interest_4, onData_5, onError_1);

                // Express the Interest.
                try {
                    face_.expressInterest(interest_4, onData_5, onTimeout);
                } catch (IOException ex_6) {
                    try {
                        onError_1.onError(net.named_data.jndn.encrypt.EncryptError.ErrorCode.IOException,
                                "expressInterest error: " + ex_6.Message);
                    } catch (Exception exception_7) {
                        logger_.log(ILOG.J2CsMapping.Util.Logging.Level.SEVERE, "Error in onError", exception_7);
                    }
                }
            }
        }