From 68edc2ac0627b5ddd3dbf3d13ecc937ad1414037 Mon Sep 17 00:00:00 2001 From: weijun Date: Thu, 7 Jun 2012 22:33:34 +0800 Subject: [PATCH] 7175041: HttpTimestamper should accept https URI Reviewed-by: mullan --- .../sun/security/timestamp/HttpTimestamper.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/share/classes/sun/security/timestamp/HttpTimestamper.java b/src/share/classes/sun/security/timestamp/HttpTimestamper.java index a4a1921bb..50cef6ec0 100644 --- a/src/share/classes/sun/security/timestamp/HttpTimestamper.java +++ b/src/share/classes/sun/security/timestamp/HttpTimestamper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -68,12 +68,15 @@ public class HttpTimestamper implements Timestamper { /** * Creates a timestamper that connects to the specified TSA. * - * @param tsa The location of the TSA. It must be an HTTP URI. - * @throws IllegalArgumentException if tsaURI is not an HTTP URI + * @param tsa The location of the TSA. It must be an HTTP or HTTPS URI. + * @throws IllegalArgumentException if tsaURI is not an HTTP or HTTPS URI */ public HttpTimestamper(URI tsaURI) { - if (!tsaURI.getScheme().equalsIgnoreCase("http")) - throw new IllegalArgumentException("TSA must be an HTTP URI"); + if (!tsaURI.getScheme().equalsIgnoreCase("http") && + !tsaURI.getScheme().equalsIgnoreCase("https")) { + throw new IllegalArgumentException( + "TSA must be an HTTP or HTTPS URI"); + } this.tsaURI = tsaURI; } @@ -144,13 +147,12 @@ public class HttpTimestamper implements Timestamper { } verifyMimeType(connection.getContentType()); - int total = 0; int contentLength = connection.getContentLength(); replyBuffer = IOUtils.readFully(input, contentLength, false); if (debug != null) { debug.println("received timestamp response (length=" + - total + ")"); + replyBuffer.length + ")"); } } finally { if (input != null) { -- GitLab