Package com.google.nigori.common

Examples of com.google.nigori.common.Nonce


  }

  @Test
  public void clearOldNonces() throws UserNotFoundException {
    database.clearOldNonces();
    Nonce oldNonce = new LyingNonce(0);
    Nonce freshNonce = new Nonce();
    database.addUser(publicKey, publicHash);
    User user = database.getUser(publicHash);
    try {
      assertTrue(database.checkAndAddNonce(oldNonce, publicHash));
      assertTrue(database.checkAndAddNonce(freshNonce, publicHash));
View Full Code Here


    byte[] publicHash = auth.getPublicKey().toByteArray();
    List<byte[]> byteSig = Util.splitBytes(auth.getSig().toByteArray());
    byte[] dsaR = byteSig.get(0);
    byte[] dsaS = byteSig.get(1);
    Nonce nonce = new Nonce(auth.getNonce().toByteArray());
    String serverName = auth.getServerName();
    try {
      byte[] publicKey = database.getPublicKey(publicHash);

      DSASignature sig =
          new DSASignature(dsaR, dsaS, Util.joinBytes(toBytes(serverName), nonce.nt(), nonce.nr(), toBytes(command), Util.joinBytes(payload)));
      try {
        DSAVerify v = new DSAVerify(publicKey);

        if (v.verify(sig)) {
          boolean validNonce = database.checkAndAddNonce(nonce, publicHash);
View Full Code Here

    assertFalse(database.haveUser(publicHash));
  }

  @Test
  public void newNoncePasses() {
    Nonce nonce = new Nonce();
    assertTrue(database.checkAndAddNonce(nonce, publicHash));
  }
View Full Code Here

    assertTrue(database.checkAndAddNonce(nonce, publicHash));
  }

  @Test
  public void repeatedNonceFails() {
    Nonce nonce = new Nonce();
    assertTrue(database.checkAndAddNonce(nonce, publicHash));
    assertFalse(database.checkAndAddNonce(nonce, publicHash));
  }
View Full Code Here

  @Override
  public void clearOldNonces() {
    for (Set<Nonce> nonceSet : nonces.values()){
      Iterator<Nonce> nonceIterator = nonceSet.iterator();
      Nonce nonce;
      while (nonceIterator.hasNext()){
        nonce = nonceIterator.next();
        if (!nonce.isRecent()){
          nonceIterator.remove();
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of com.google.nigori.common.Nonce

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.