jdk/src/share/classes/sun/security/timestamp/HttpTimestamper.java
changeset 10336 0bb1999251f8
parent 5506 202f599c92aa
child 10788 680a3dbfcaba
equal deleted inserted replaced
10335:3c7eda3ab2f5 10336:0bb1999251f8
     1 /*
     1 /*
     2  * Copyright (c) 2003, 2009, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
    28 import java.io.BufferedInputStream;
    28 import java.io.BufferedInputStream;
    29 import java.io.DataOutputStream;
    29 import java.io.DataOutputStream;
    30 import java.io.IOException;
    30 import java.io.IOException;
    31 import java.net.URL;
    31 import java.net.URL;
    32 import java.net.HttpURLConnection;
    32 import java.net.HttpURLConnection;
    33 import java.util.Iterator;
    33 import java.util.List;
       
    34 import java.util.Map;
    34 import java.util.Set;
    35 import java.util.Set;
    35 import java.util.Arrays;
       
    36 
    36 
    37 import sun.misc.IOUtils;
    37 import sun.misc.IOUtils;
    38 import sun.security.pkcs.*;
       
    39 
    38 
    40 /**
    39 /**
    41  * A timestamper that communicates with a Timestamping Authority (TSA)
    40  * A timestamper that communicates with a Timestamping Authority (TSA)
    42  * over HTTP.
    41  * over HTTP.
    43  * It supports the Time-Stamp Protocol defined in:
    42  * It supports the Time-Stamp Protocol defined in:
    93         connection.setRequestMethod("POST");
    92         connection.setRequestMethod("POST");
    94         // Avoids the "hang" when a proxy is required but none has been set.
    93         // Avoids the "hang" when a proxy is required but none has been set.
    95         connection.setConnectTimeout(CONNECT_TIMEOUT);
    94         connection.setConnectTimeout(CONNECT_TIMEOUT);
    96 
    95 
    97         if (DEBUG) {
    96         if (DEBUG) {
    98             Set headers = connection.getRequestProperties().entrySet();
    97             Set<Map.Entry<String, List<String>>> headers =
       
    98                     connection.getRequestProperties().entrySet();
    99             System.out.println(connection.getRequestMethod() + " " + tsaUrl +
    99             System.out.println(connection.getRequestMethod() + " " + tsaUrl +
   100                 " HTTP/1.1");
   100                 " HTTP/1.1");
   101             for (Iterator i = headers.iterator(); i.hasNext(); ) {
   101             for (Map.Entry<String, List<String>> entry : headers) {
   102                 System.out.println("  " + i.next());
   102                 System.out.println("  " + entry);
   103             }
   103             }
   104             System.out.println();
   104             System.out.println();
   105         }
   105         }
   106         connection.connect(); // No HTTP authentication is performed
   106         connection.connect(); // No HTTP authentication is performed
   107 
   107