Package org.bouncycastle.tsp

Examples of org.bouncycastle.tsp.TimeStampResponse


    responseEntity.getContent().read(responseBytes);
   
    Assert.assertNotNull("Response content", responseBytes);
   
    responseBytes = Base64.decode(responseBytes);
    TimeStampResponse tsresponse = new TimeStampResponse(responseBytes);
    tsresponse.validate(timeStampRequest);
  }
View Full Code Here


 
      byte[] responseBytes = new byte[(int)responseEntity.getContentLength()];
      responseEntity.getContent().read(responseBytes);
     
      Assert.assertNotNull("Response content", responseBytes);
      TimeStampResponse tsresponse = new TimeStampResponse(responseBytes);
      tsresponse.validate(timeStampRequest);
    }
  }
View Full Code Here

      responseEntity.getContent().read(responseBytes);
     
      Assert.assertNotNull("Response content", responseBytes);
     
      responseBytes = Base64.decode(responseBytes);
      TimeStampResponse tsresponse = new TimeStampResponse(responseBytes);
      tsresponse.validate(timeStampRequest);
    }
  }
View Full Code Here

    responseEntity.getContent().read(responseBytes);
   
    Assert.assertNotNull("Response content", responseBytes);
   
    responseBytes = Base64.decode(responseBytes);
    TimeStampResponse tsresponse = new TimeStampResponse(responseBytes);
    tsresponse.validate(timeStampRequest);
    tsresponse.validate(otherTimeStampRequest); // This will fail
  }
View Full Code Here

   
    TimeStampRequestGenerator generator = new TimeStampRequestGenerator();
    TimeStampRequest timeStampRequest = generator.generate(
        TSPAlgorithms.SHA1, DigestHelper.digest("this is a test message"));
   
    TimeStampResponse response = null;
      response = new Timestamper(keystore).timestamp(timeStampRequest);
    Assert.assertNotNull("Timestamp Response should not be null", response);
    Assert.assertNotNull("Timestamp token should not be null", response.getTimeStampToken());
   
    response.validate(timeStampRequest);
  }
View Full Code Here

        TSPAlgorithms.SHA1, DigestHelper.digest("this is a test message"));

    TimeStampRequest timeStampRequest2 = generator.generate(
        TSPAlgorithms.SHA1, DigestHelper.digest("this is a another test message"));

    TimeStampResponse response = null;
    response = new Timestamper(keystore).timestamp(timeStampRequest);
    Assert.assertNotNull("Timestamp Response should not be null", response);
    Assert.assertNotNull("Timestamp token should not be null", response.getTimeStampToken());
   
    response.validate(timeStampRequest);
    response.validate(timeStampRequest2);
  }
View Full Code Here

   
    TimeStampResponseGenerator respGen = new TimeStampResponseGenerator(
        tokenGenerator, TSPAlgorithms.ALLOWED);
   
    Date tsDate = new Date();
    TimeStampResponse response;
    try {
      response = respGen.generate(timestampRequest, keystore.getCertificate().getSerialNumber(), tsDate);
    } catch (Exception e) {
      throw new RuntimeException("Could not generate timestamp response", e);
    }
View Full Code Here

          } finally {
            input.close();
          }

          try {
            TimeStampResponse timeStampResponse = new TimeStampResponse(buffer);
            timeStampResponse.validate(tsReq);
            System.out.println(timeStampValidatedSuccess);
          }
          catch (TSPValidationException e) {
            System.out.println(timeStampValidatedFailed);
            e.printStackTrace();
View Full Code Here

        if (bos.size() == 0) {
            throw new RuntimeException("Content-Length is zero");
        }

        // TSP response parsing and validation
        TimeStampResponse timeStampResponse = new TimeStampResponse(bos.toByteArray());
        timeStampResponse.validate(request);

        if (0 != timeStampResponse.getStatus()) {
            LOG.log(POILogger.DEBUG, "status: " + timeStampResponse.getStatus());
            LOG.log(POILogger.DEBUG, "status string: " + timeStampResponse.getStatusString());
            PKIFailureInfo failInfo = timeStampResponse.getFailInfo();
            if (null != failInfo) {
                LOG.log(POILogger.DEBUG, "fail info int value: " + failInfo.intValue());
                if (/*PKIFailureInfo.unacceptedPolicy*/(1 << 8) == failInfo.intValue()) {
                    LOG.log(POILogger.DEBUG, "unaccepted policy");
                }
            }
            throw new RuntimeException("timestamp response status != 0: "
                    + timeStampResponse.getStatus());
        }
        TimeStampToken timeStampToken = timeStampResponse.getTimeStampToken();
        SignerId signerId = timeStampToken.getSID();
        BigInteger signerCertSerialNumber = signerId.getSerialNumber();
        X500Name signerCertIssuer = signerId.getIssuer();
        LOG.log(POILogger.DEBUG, "signer cert serial number: " + signerCertSerialNumber);
        LOG.log(POILogger.DEBUG, "signer cert issuer: " + signerCertIssuer);
View Full Code Here

  @Override
  public byte[] getTimeStamp(final byte[] request) {
    try {
      TimeStampRequest timeStampRequest = new TimeStampRequest(request);
      TimeStampResponseGenerator timeStampResponseGenerator = new TimeStampResponseGenerator(this.timeStampTokenGenerator, TSPAlgorithms.ALLOWED);
      TimeStampResponse timeStampResponse = timeStampResponseGenerator.generate(timeStampRequest, this.getSerialNumber(), new Date());

      timeStampResponse.validate(timeStampRequest);

      return timeStampResponse.getEncoded();
    } catch (Exception e) {
      throw new TimeStampException(e);
    }
  }
View Full Code Here

TOP

Related Classes of org.bouncycastle.tsp.TimeStampResponse

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.