Beispiel #1
0
        /// <summary>
        /// Decrypt the data packet.
        /// </summary>
        ///
        /// <param name="data">The data packet.</param>
        /// <param name="onPlainText_0"></param>
        /// <param name="onError_1">This calls onError.onError(errorCode, message) for an error.</param>
        internal void decryptContent(Data data, Consumer.OnPlainText onPlainText_0,
                                     net.named_data.jndn.encrypt.EncryptError.OnError onError_1)
        {
            // Get the encrypted content.
            EncryptedContent dataEncryptedContent_2 = new EncryptedContent();

            try {
                dataEncryptedContent_2.wireDecode(data.getContent());
            } 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 cKeyName_3 = dataEncryptedContent_2.getKeyLocator().getKeyName();

            // Check if the content key is already in the store.
            Blob cKey = (Blob)ILOG.J2CsMapping.Collections.Collections.Get(cKeyMap_, cKeyName_3);

            if (cKey != null)
            {
                decrypt(dataEncryptedContent_2, cKey, onPlainText_0, onError_1);
            }
            else
            {
                // Retrieve the C-KEY Data from the network.
                Name interestName = new Name(cKeyName_3);
                interestName.append(net.named_data.jndn.encrypt.algo.Encryptor.NAME_COMPONENT_FOR)
                .append(groupName_);
                Interest interest_4 = new Interest(interestName);

                // Prepare the callback functions.
                OnData onData_5 = new Consumer.Anonymous_C4(this, cKeyName_3, dataEncryptedContent_2, onPlainText_0,
                                                            onError_1);

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

                // 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);
                    }
                }
            }
        }
Beispiel #2
0
 public Anonymous_C8(Consumer.Anonymous_C4 paramouter_Anonymous_C4)
 {
     this.outer_Anonymous_C4 = paramouter_Anonymous_C4;
 }
Beispiel #3
0
 public Anonymous_C13(Consumer.Anonymous_C4  paramouter_Anonymous_C4)
 {
     this.outer_Anonymous_C4 = paramouter_Anonymous_C4;
 }
Beispiel #4
0
        /// <summary>
        /// Decrypt the data packet.
        /// </summary>
        ///
        /// <param name="data">The data packet. This does not verify the packet.</param>
        /// <param name="onPlainText_0"></param>
        /// <param name="onError_1">This calls onError.onError(errorCode, message) for an error.</param>
        internal void decryptContent(Data data, Consumer.OnPlainText  onPlainText_0,
				net.named_data.jndn.encrypt.EncryptError.OnError  onError_1)
        {
            // Get the encrypted content.
            EncryptedContent dataEncryptedContent_2 = new EncryptedContent();
            try {
                dataEncryptedContent_2.wireDecode(data.getContent());
            } 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 cKeyName_3 = dataEncryptedContent_2.getKeyLocator().getKeyName();

            // Check if the content key is already in the store.
            Blob cKey = (Blob) ILOG.J2CsMapping.Collections.Collections.Get(cKeyMap_,cKeyName_3);
            if (cKey != null)
                decrypt(dataEncryptedContent_2, cKey, onPlainText_0, onError_1);
            else {
                // Retrieve the C-KEY Data from the network.
                Name interestName = new Name(cKeyName_3);
                interestName.append(net.named_data.jndn.encrypt.algo.Encryptor.NAME_COMPONENT_FOR)
                        .append(groupName_);
                Interest interest_4 = new Interest(interestName);

                // Prepare the callback functions.
                OnData onData_5 = new Consumer.Anonymous_C4 (this, cKeyName_3, onError_1, onPlainText_0,
                        dataEncryptedContent_2);

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

                // 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);
                    }
                }
            }
        }