/// <summary>
        /// For each member using the given schedule, get the name and public key DER
        /// of the member's key.
        /// </summary>
        ///
        /// <param name="name">The name of the schedule.</param>
        /// <returns>a new Map where the map's key is the Name of the public key and the
        /// value is the Blob of the public key DER. (Use Map without generics so it
        /// works with older Java compilers.) Note that the member's identity name is
        /// keyName.getPrefix(-1). If the schedule name is not found, the map is empty.</returns>
        /// <exception cref="GroupManagerDb.Error">for a database error.</exception>
        public override IDictionary getScheduleMembers(String name)
        {
            IDictionary map = new Hashtable();

            try {
                PreparedStatement statement = database_
                        .prepareStatement(net.named_data.jndn.encrypt.Sqlite3GroupManagerDbBase.SELECT_getScheduleMembers);
                statement.setString(1, name);

                try {
                    SqlDataReader result = statement.executeQuery();

                    while (result.NextResult()) {
                        Name keyName = new Name();
                        try {
                            keyName.wireDecode(new Blob(result.getBytes(1), false),
                                    net.named_data.jndn.encoding.TlvWireFormat.get());
                        } catch (EncodingException ex) {
                            // We don't expect this to happen.
                            throw new GroupManagerDb.Error(
                                    "Sqlite3GroupManagerDb.getScheduleMembers: Error decoding name: "
                                            + ex);
                        }

                        ILOG.J2CsMapping.Collections.Collections.Put(map,keyName,new Blob(result.getBytes(2), false));
                    }
                } finally {
                    statement.close();
                }
            } catch (SQLException exception) {
                throw new GroupManagerDb.Error(
                        "Sqlite3GroupManagerDb.getScheduleMembers: SQLite error: "
                                + exception);
            }

            return map;
        }
        /// <summary>
        /// List all the members.
        /// </summary>
        ///
        /// <returns>A new List of Name with the names of all members. (Use List without
        /// generics so it works with older Java compilers.)</returns>
        /// <exception cref="GroupManagerDb.Error">for a database error.</exception>
        public override IList listAllMembers()
        {
            IList list = new ArrayList();

            try {
                PreparedStatement statement = database_
                        .prepareStatement(net.named_data.jndn.encrypt.Sqlite3GroupManagerDbBase.SELECT_listAllMembers);

                try {
                    SqlDataReader result = statement.executeQuery();

                    while (result.NextResult()) {
                        Name identity = new Name();
                        try {
                            identity.wireDecode(
                                    new Blob(result.getBytes(1), false),
                                    net.named_data.jndn.encoding.TlvWireFormat.get());
                        } catch (EncodingException ex) {
                            // We don't expect this to happen.
                            throw new GroupManagerDb.Error(
                                    "Sqlite3GroupManagerDb.listAllMembers: Error decoding name: "
                                            + ex);
                        }

                        ILOG.J2CsMapping.Collections.Collections.Add(list,identity);
                    }
                } finally {
                    statement.close();
                }
            } catch (SQLException exception) {
                throw new GroupManagerDb.Error(
                        "Sqlite3GroupManagerDb.listAllMembers: SQLite error: "
                                + exception);
            }

            return list;
        }
예제 #3
0
        public void testEncodeDecode()
        {
            Name name = new Name("/local/ndn/prefix");

            Blob encoding = name.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get());
            Assert.AssertTrue(encoding.equals(new Blob(TEST_NAME, false)));

            Name decodedName = new Name();
            try {
                decodedName.wireDecode(new Blob(TEST_NAME, false),
                        net.named_data.jndn.encoding.TlvWireFormat.get());
            } catch (EncodingException ex) {
                Assert.Fail("Can't decode TEST_NAME");
            }
            Assert.AssertEquals(decodedName, name);

            // Test ImplicitSha256Digest.
            Name name2 = new Name(
                    "/local/ndn/prefix/sha256digest="
                            + "000102030405060708090a0b0c0d0e0f101112131415161718191a1b1c1d1e1f");

            Blob encoding2 = name2.wireEncode(net.named_data.jndn.encoding.TlvWireFormat.get());
            Assert.AssertTrue(encoding2.equals(new Blob(TEST_NAME_IMPLICIT_DIGEST, false)));

            Name decodedName2 = new Name();
            try {
                decodedName2.wireDecode(new Blob(TEST_NAME_IMPLICIT_DIGEST, false),
                        net.named_data.jndn.encoding.TlvWireFormat.get());
            } catch (EncodingException ex_0) {
                Assert.Fail("Can't decode TEST_NAME");
            }
            Assert.AssertEquals(decodedName2, name2);
        }