Examples of TimeStampResponse


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);
    tsresponse.validate(otherTimeStampRequest); // This will fail
  }
View Full Code Here

Examples of org.bouncycastle.tsp.TimeStampResponse

   
    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

Examples of org.bouncycastle.tsp.TimeStampResponse

        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

Examples of org.bouncycastle.tsp.TimeStampResponse

   
    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

Examples of org.bouncycastle.tsp.TimeStampResponse

          } 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

Examples of org.bouncycastle.tsp.TimeStampResponse

        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

Examples of org.bouncycastle.tsp.TimeStampResponse

  @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

Examples of org.bouncycastle.tsp.TimeStampResponse

  @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

Examples of org.bouncycastle.tsp.TimeStampResponse

        this.saveRequest(timeStampRequest, dir, id);
      }

      byte[] responseBytes = this.sendRequest(timeStampRequest);

      TimeStampResponse response = this.getTimeStampResponse(timeStampRequest, responseBytes);

      if (this.debug) {
        this.saveResponse(response, dir, id);
      }

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

Examples of org.bouncycastle.tsp.TimeStampResponse

      throw new TimeStampException(e);
    }
  }

  protected TimeStampResponse getTimeStampResponse(final TimeStampRequest request, final byte[] responseBytes) throws IOException, TSPException {
    TimeStampResponse response = new TimeStampResponse(responseBytes);

    response.validate(request);
    PKIFailureInfo failure = response.getFailInfo();

    if ((failure != null) && (failure.intValue() != 0)) {
      throw new IllegalStateException("Failure Status " + failure.intValue());
    }

    TimeStampToken timeStampToken = response.getTimeStampToken();
    if (timeStampToken == null) {
      throw new IllegalStateException("TimeStampToken not found in response");
    }
    return response;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.