Examples of TimestampResponse


Examples of org.bouncycastle.tsp.TimeStampResponse

           
            // Call the communications layer
            respBytes = getTSAResponse(requestBytes);
           
            // Handle the TSA response
            TimeStampResponse response = new TimeStampResponse(respBytes);
           
            // validate communication level attributes (RFC 3161 PKIStatus)
            response.validate(request);
            PKIFailureInfo failure = response.getFailInfo();
            int value = (failure == null) ? 0 : failure.intValue();
            if (value != 0) {
                // @todo: Translate value of 15 error codes defined by PKIFailureInfo to string
                throw new IOException(MessageLocalization.getComposedMessage("invalid.tsa.1.response.code.2", tsaURL, String.valueOf(value)));
            }
            // @todo: validate the time stap certificate chain (if we want
            //        assure we do not sign using an invalid timestamp).
           
            // extract just the time stamp token (removes communication status info)
            TimeStampToken  tsToken = response.getTimeStampToken();
            if (tsToken == null) {
                throw new IOException(MessageLocalization.getComposedMessage("tsa.1.failed.to.return.time.stamp.token.2", tsaURL, response.getStatusString()));
            }
            TimeStampTokenInfo tsTokenInfo = tsToken.getTimeStampInfo(); // to view details
            byte[] encoded = tsToken.getEncoded();

            LOGGER.info("Timestamp generated: " + tsTokenInfo.getGenTime());
View Full Code Here

Examples of org.bouncycastle.tsp.TimeStampResponse

    try {
      TimeStampRequest request = this.getTimeStampRequest(data);

      byte[] response = this.processor.getBinaryResponse(request.getEncoded());

      TimeStampResponse timeStampResponse = new TimeStampResponse(response);

      TimeStampToken timeStampToken = timeStampResponse.getTimeStampToken();

      if (timeStampToken == null) {
        throw new IllegalStateException("TimeStampToken not found in response");
      }
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

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

        log.error("could not read timestamp request", e);
        resp.sendError(HttpServletResponse.SC_BAD_REQUEST, "could not read timestamp request");
        return;
      }
      log.debug(String.format("TS Request received from %s", req.getRemoteAddr()));
      TimeStampResponse stampResponse = stamper.timestamp(rq);
      if (stampResponse == null) {
        log.warn(String.format("TS Request received from %s is not acceptable",
            req.getRemoteAddr()));
        resp.sendError(HttpServletResponse.SC_NOT_ACCEPTABLE, "Could not generate timestamp response");
        return;
      }
      if (stampResponse.getTimeStampToken() == null) {
        log.warn(String.format("TS Request received from %s is not acceptable",
            req.getRemoteAddr()));
        resp.sendError(HttpServletResponse.SC_NOT_ACCEPTABLE, "Could not generate timestamp response");
        return;
      }
     
     
      byte[] response = stampResponse.getEncoded();
      if (isBase64(req)) {
        resp.setHeader(TRANSFER_ENCODING_HEADER, TRANSFER_ENCODING_BASE64);
        response = Base64.encode(response);
          log.debug(String.format("Responding to %s is in base64", req.getRemoteAddr()));
      } else {
View Full Code Here

Examples of org.bouncycastle.tsp.TimeStampResponse

   
    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

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

Examples of org.bouncycastle.tsp.TimeStampResponse

 
      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

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
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.