Package freenet.store

Examples of freenet.store.SSKStore


    chkSlashdotcache = new CHKStore();
    chkSlashdotcacheStore = new SlashdotStore<CHKBlock>(chkSlashdotcache, maxSlashdotCacheKeys, slashdotCacheLifetime, PURGE_INTERVAL, ticker, this.clientCore.tempBucketFactory);
    pubKeySlashdotcache = new PubkeyStore();
    pubKeySlashdotcacheStore = new SlashdotStore<DSAPublicKey>(pubKeySlashdotcache, maxSlashdotCacheKeys, slashdotCacheLifetime, PURGE_INTERVAL, ticker, this.clientCore.tempBucketFactory);
    getPubKey.setLocalSlashdotcache(pubKeySlashdotcache);
    sskSlashdotcache = new SSKStore(getPubKey);
    sskSlashdotcacheStore = new SlashdotStore<SSKBlock>(sskSlashdotcache, maxSlashdotCacheKeys, slashdotCacheLifetime, PURGE_INTERVAL, ticker, this.clientCore.tempBucketFactory);

    // MAXIMUM seclevel = no slashdot cache.

    securityLevels.addNetworkThreatLevelListener(new SecurityLevelListener<NETWORK_THREAT_LEVEL>() {
View Full Code Here


  private void initRAMClientCacheFS() {
    chkClientcache = new CHKStore();
    new RAMFreenetStore<CHKBlock>(chkClientcache, (int) Math.min(Integer.MAX_VALUE, maxClientCacheKeys));
    pubKeyClientcache = new PubkeyStore();
    new RAMFreenetStore<DSAPublicKey>(pubKeyClientcache, (int) Math.min(Integer.MAX_VALUE, maxClientCacheKeys));
    sskClientcache = new SSKStore(getPubKey);
    new RAMFreenetStore<SSKBlock>(sskClientcache, (int) Math.min(Integer.MAX_VALUE, maxClientCacheKeys));
  }
View Full Code Here

  private void initNoClientCacheFS() {
    chkClientcache = new CHKStore();
    new NullFreenetStore<CHKBlock>(chkClientcache);
    pubKeyClientcache = new PubkeyStore();
    new NullFreenetStore<DSAPublicKey>(pubKeyClientcache);
    sskClientcache = new SSKStore(getPubKey);
    new NullFreenetStore<SSKBlock>(sskClientcache);
  }
View Full Code Here

    pubKeyDatastore = new PubkeyStore();
    new RAMFreenetStore<DSAPublicKey>(pubKeyDatastore, (int) Math.min(Integer.MAX_VALUE, maxStoreKeys));
    pubKeyDatacache = new PubkeyStore();
    getPubKey.setDataStore(pubKeyDatastore, pubKeyDatacache);
    new RAMFreenetStore<DSAPublicKey>(pubKeyDatacache, (int) Math.min(Integer.MAX_VALUE, maxCacheKeys));
    sskDatastore = new SSKStore(getPubKey);
    new RAMFreenetStore<SSKBlock>(sskDatastore, (int) Math.min(Integer.MAX_VALUE, maxStoreKeys));
    sskDatacache = new SSKStore(getPubKey);
    new RAMFreenetStore<SSKBlock>(sskDatacache, (int) Math.min(Integer.MAX_VALUE, maxCacheKeys));
  }
View Full Code Here

      final PubkeyStore pubKeyDatastore = new PubkeyStore();
      final FreenetStore<DSAPublicKey> pubkeyDataFS = makeStore("PUBKEY", true, pubKeyDatastore, dontResizeOnStart, masterKey);
      final PubkeyStore pubKeyDatacache = new PubkeyStore();
      final FreenetStore<DSAPublicKey> pubkeyCacheFS = makeStore("PUBKEY", false, pubKeyDatacache, dontResizeOnStart, masterKey);
      ((SaltedHashFreenetStore<DSAPublicKey>) pubkeyCacheFS.getUnderlyingStore()).setAltStore(((SaltedHashFreenetStore<DSAPublicKey>) pubkeyDataFS.getUnderlyingStore()));
      final SSKStore sskDatastore = new SSKStore(getPubKey);
      final FreenetStore<SSKBlock> sskDataFS = makeStore("SSK", true, sskDatastore, dontResizeOnStart, masterKey);
      final SSKStore sskDatacache = new SSKStore(getPubKey);
      final FreenetStore<SSKBlock> sskCacheFS = makeStore("SSK", false, sskDatacache, dontResizeOnStart, masterKey);
      ((SaltedHashFreenetStore<SSKBlock>) sskCacheFS.getUnderlyingStore()).setAltStore(((SaltedHashFreenetStore<SSKBlock>) sskDataFS.getUnderlyingStore()));
     
      boolean delay =
        chkDataFS.start(ticker, false) |
View Full Code Here

    try {
      final CHKStore chkClientcache = new CHKStore();
      final FreenetStore<CHKBlock> chkDataFS = makeClientcache("CHK", true, chkClientcache, dontResizeOnStart, clientCacheMasterKey);
      final PubkeyStore pubKeyClientcache = new PubkeyStore();
      final FreenetStore<DSAPublicKey> pubkeyDataFS = makeClientcache("PUBKEY", true, pubKeyClientcache, dontResizeOnStart, clientCacheMasterKey);
      final SSKStore sskClientcache = new SSKStore(getPubKey);
      final FreenetStore<SSKBlock> sskDataFS = makeClientcache("SSK", true, sskClientcache, dontResizeOnStart, clientCacheMasterKey);

      boolean delay =
        chkDataFS.start(ticker, false) |
        pubkeyDataFS.start(ticker, false) |
View Full Code Here

    try {

      nodeStats.avgRequestLocation.report(loc);
      SSKBlock block = sskDatastore.fetch(key, dontPromote || !canWriteDatastore, canReadClientCache, forULPR, ignoreOldBlocks, meta);
      if(block == null) {
        SSKStore store = oldSSK;
        if(store != null)
          block = store.fetch(key, dontPromote || !canWriteDatastore, canReadClientCache, forULPR, ignoreOldBlocks, meta);
      }
      if(block != null) {
      nodeStats.avgStoreSSKSuccess.report(loc);
      if (dist > nodeStats.furthestStoreSSKSuccess)
        nodeStats.furthestStoreSSKSuccess=dist;
        if(logDEBUG) Logger.debug(this, "Found key "+key+" in store");
        return block;
      }
      block=sskDatacache.fetch(key, dontPromote || !canWriteDatastore, canReadClientCache, forULPR, ignoreOldBlocks, meta);
      if(block == null) {
        SSKStore store = oldSSKCache;
        if(store != null)
          block = store.fetch(key, dontPromote || !canWriteDatastore, canReadClientCache, forULPR, ignoreOldBlocks, meta);
      }
      if (block != null) {
      nodeStats.avgCacheSSKSuccess.report(loc);
      if (dist > nodeStats.furthestCacheSSKSuccess)
        nodeStats.furthestCacheSSKSuccess=dist;
View Full Code Here

    final int keys = 5;
    PubkeyStore pk = new PubkeyStore();
    new RAMFreenetStore<DSAPublicKey>(pk, keys);
    GetPubkey pubkeyCache = new SimpleGetPubkey(pk);
    SSKStore store = new SSKStore(pubkeyCache);
    SaltedHashFreenetStore<SSKBlock> saltStore = SaltedHashFreenetStore.construct(f, "testSaltedHashFreenetStoreSSK", store, weakPRNG, 20, false, SemiOrderedShutdownHook.get(), true, true, ticker, null);
    saltStore.start(null, true);
    RandomSource random = new DummyRandomSource(12345);

    for(int i=0;i<5;i++) {
      String test = "test" + i;
      ClientSSKBlock block = encodeBlockSSK(test, random);
      SSKBlock sskBlock = (SSKBlock) block.getBlock();
      store.put(sskBlock, false, false);
      ClientSSK key = block.getClientKey();
      NodeSSK ssk = (NodeSSK) key.getNodeKey();
      pubkeyCache.cacheKey(ssk.getPubKeyHash(), ssk.getPubKey(), false, false, false, false, false);
      SSKBlock verify = store.fetch(ssk, false, false, false, false, null);
      String data = decodeBlockSSK(verify, key);
      assertEquals(test, data);
    }
   
    saltStore.close();
View Full Code Here

    final int keys = 5;
    PubkeyStore pk = new PubkeyStore();
    new RAMFreenetStore<DSAPublicKey>(pk, keys);
    GetPubkey pubkeyCache = new SimpleGetPubkey(pk);
    SSKStore store = new SSKStore(pubkeyCache);
    SaltedHashFreenetStore<SSKBlock> saltStore = SaltedHashFreenetStore.construct(f, "testSaltedHashFreenetStoreOnCloseSSK", store, weakPRNG, 10, true, SemiOrderedShutdownHook.get(), true, true, ticker, null);
    saltStore.start(null, true);
    RandomSource random = new DummyRandomSource(12345);
   
    final int CRYPTO_KEY_LENGTH = 32;
    byte[] ckey = new byte[CRYPTO_KEY_LENGTH];
    random.nextBytes(ckey);
    DSAGroup g = Global.DSAgroupBigA;
    DSAPrivateKey privKey = new DSAPrivateKey(g, random);
    DSAPublicKey pubKey = new DSAPublicKey(g, privKey);
    byte[] pkHash = SHA256.digest(pubKey.asBytes());
    String docName = "myDOC";
    InsertableClientSSK ik = new InsertableClientSSK(docName, pkHash, pubKey, privKey, ckey, Key.ALGO_AES_PCFB_256_SHA256);
   
    String test = "test";
    SimpleReadOnlyArrayBucket bucket = new SimpleReadOnlyArrayBucket(test.getBytes("UTF-8"));
    ClientSSKBlock block = ik.encode(bucket, false, false, (short)-1, bucket.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR, false);
    SSKBlock sskBlock = (SSKBlock) block.getBlock();
    store.put(sskBlock, false, false);
   
    //If the block is the same then there should not be a collision
    try {
      store.put(sskBlock, false, false);
      assertTrue(true);
    } catch (KeyCollisionException e) {
      assertTrue(false);
     
    }
   
    String test1 = "test1";
    SimpleReadOnlyArrayBucket bucket1 = new SimpleReadOnlyArrayBucket(test1.getBytes("UTF-8"));
    ClientSSKBlock block1 = ik.encode(bucket1, false, false, (short)-1, bucket1.size(), random, Compressor.DEFAULT_COMPRESSORDESCRIPTOR, false);
    SSKBlock sskBlock1 = (SSKBlock) block1.getBlock();
   
    //if it's different (e.g. different content, same key), there should be a KCE thrown
    try {
      store.put(sskBlock1, false, false);
      assertTrue(false);
    } catch (KeyCollisionException e) {
      assertTrue(true);
    }
   
    // if overwrite is set, then no collision should be thrown
    try {
      store.put(sskBlock1, true, false);
      assertTrue(true);
    } catch (KeyCollisionException e) {
      assertTrue(false);
     
    }
   
    ClientSSK key = block1.getClientKey();
    pubkeyCache.cacheKey(sskBlock.getKey().getPubKeyHash(), sskBlock.getKey().getPubKey(), false, false, false, false, false);
    // Check that it's in the cache, *not* the underlying store.
    NodeSSK ssk = (NodeSSK) key.getNodeKey();
    SSKBlock verify = store.fetch(ssk, false, false, false, false, null);
    String data = decodeBlockSSK(verify, key);
    assertEquals(test1, data);
   
    saltStore.close();
  }
View Full Code Here

TOP

Related Classes of freenet.store.SSKStore

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.