Package org.bouncycastle.tsp

Examples of org.bouncycastle.tsp.TimeStampRequest


    CloseableHttpClient client = builder.build();
    HttpHost host = new HttpHost(hostname, port);
    HttpPost post = new HttpPost("/tsa");
   
    TimeStampRequestGenerator generator = new TimeStampRequestGenerator();
    TimeStampRequest timeStampRequest = generator.generate(TSPAlgorithms.SHA1, DigestHelper.digest("this is a test message"));
   
    ByteArrayEntity entity = new ByteArrayEntity(timeStampRequest.getEncoded());
   
    post.setHeader("Content-Type", TimestampServlet.TIMESTAMP_QUERY_CONTENT_TYPE);
    post.setHeader(TimestampServlet.TRANSFER_ENCODING_HEADER, TimestampServlet.TRANSFER_ENCODING_BINARY);
    post.setEntity(entity);
   
View Full Code Here


    CloseableHttpClient client = builder.build();
    HttpHost host = new HttpHost(hostname, port);
    HttpPost post = new HttpPost("/tsa");
   
    TimeStampRequestGenerator generator = new TimeStampRequestGenerator();
    TimeStampRequest timeStampRequest = generator.generate(TSPAlgorithms.SHA1, DigestHelper.digest("this is a test message"));
   
    ByteArrayEntity entity = new ByteArrayEntity(Base64.encode(timeStampRequest.getEncoded()));
   
    post.setHeader("Content-Type", TimestampServlet.TIMESTAMP_QUERY_CONTENT_TYPE);
    post.setHeader(TimestampServlet.TRANSFER_ENCODING_HEADER, TimestampServlet.TRANSFER_ENCODING_BASE64);
    post.setEntity(entity);
   
View Full Code Here

    CloseableHttpClient client = builder.build();
    HttpHost host = new HttpHost(hostname, port);
   
    for (int i = 0; i < maxStress; i++) {
      TimeStampRequestGenerator generator = new TimeStampRequestGenerator();
      TimeStampRequest timeStampRequest = generator.generate(TSPAlgorithms.SHA1, DigestHelper.digest("this is a test message " + i));
     
      ByteArrayEntity entity = new ByteArrayEntity(timeStampRequest.getEncoded());
     
      HttpPost post = new HttpPost("/tsa");
      post.setHeader("Content-Type", TimestampServlet.TIMESTAMP_QUERY_CONTENT_TYPE);
      post.setHeader(TimestampServlet.TRANSFER_ENCODING_HEADER, TimestampServlet.TRANSFER_ENCODING_BINARY);
      post.setEntity(entity);
View Full Code Here

   
    for (int i = 0; i < maxStress; i++) {
      HttpPost post = new HttpPost("/tsa");
     
      TimeStampRequestGenerator generator = new TimeStampRequestGenerator();
      TimeStampRequest timeStampRequest = generator.generate(TSPAlgorithms.SHA1, DigestHelper.digest("this is a test message " + i));
     
      ByteArrayEntity entity = new ByteArrayEntity(Base64.encode(timeStampRequest.getEncoded()));
     
      post.setHeader("Content-Type", TimestampServlet.TIMESTAMP_QUERY_CONTENT_TYPE);
      post.setHeader(TimestampServlet.TRANSFER_ENCODING_HEADER, TimestampServlet.TRANSFER_ENCODING_BASE64);
      post.setEntity(entity);
     
View Full Code Here

    CloseableHttpClient client = builder.build();
    HttpHost host = new HttpHost(hostname, port);
    HttpPost post = new HttpPost("/tsa");
   
    TimeStampRequestGenerator generator = new TimeStampRequestGenerator();
    TimeStampRequest timeStampRequest = generator.generate(TSPAlgorithms.SHA1, DigestHelper.digest("this is a test message"));
    TimeStampRequest otherTimeStampRequest = generator.generate(TSPAlgorithms.SHA1, DigestHelper.digest("this is another test message"));
   
    ByteArrayEntity entity = new ByteArrayEntity(Base64.encode(timeStampRequest.getEncoded()));
   
    post.setHeader("Content-Type", TimestampServlet.TIMESTAMP_QUERY_CONTENT_TYPE);
    post.setHeader(TimestampServlet.TRANSFER_ENCODING_HEADER, TimestampServlet.TRANSFER_ENCODING_BASE64);
View Full Code Here

  @Test
  public void testTimestamp() throws TSPException {
    KeystoreHandler keystore = KeystoreHelper.getP12Keystore();
   
    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);
View Full Code Here

  @Test(expected=TSPException.class)
  public void testTimestampValidateWithOtherRequest() throws TSPException {
    KeystoreHandler keystore = KeystoreHelper.getP12Keystore();
   
    TimeStampRequestGenerator generator = new TimeStampRequestGenerator();
    TimeStampRequest timeStampRequest = generator.generate(
        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);
View Full Code Here

      byte[] hash = ce.computeStringHash(myString, hashAlgorithm);
      TimeStampRequestGenerator reqGen = new TimeStampRequestGenerator();
      reqGen.setCertReq(true);

      // Se podr�an agregar condiciones para cambiar los TSPAlgorithms a SHA256, SHA384, SHA512, etc.
      TimeStampRequest tsReq = reqGen.generate(TSPAlgorithms.SHA1, hash, BigInteger.valueOf(100));
      // Se convierte objeto de TimeStampRequest a arreglo de bytes.
      byte[] tsData = tsReq.getEncoded();

      // Leemos contenido con InputStreamReader
      // URL para abrir conexi�n
      URL url;
      try {
View Full Code Here

        String requestPolicy = signatureConfig.getTspRequestPolicy();
        if (requestPolicy != null) {
            requestGenerator.setReqPolicy(new ASN1ObjectIdentifier(requestPolicy));
        }
        ASN1ObjectIdentifier digestAlgoOid = mapDigestAlgoToOID(signatureConfig.getTspDigestAlgo());
        TimeStampRequest request = requestGenerator.generate(digestAlgoOid, digest, nonce);
        byte[] encodedRequest = request.getEncoded();

        // create the HTTP POST request
        Proxy proxy = Proxy.NO_PROXY;
        if (signatureConfig.getProxyUrl() != null) {
            URL proxyUrl = new URL(signatureConfig.getProxyUrl());
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);
View Full Code Here

TOP

Related Classes of org.bouncycastle.tsp.TimeStampRequest

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.