changeset 3215:e7ab4e27f1e1

6557615: Method toString() of java.security.Timestamp throws IndexOutOfBoundsException if CertPath has empty Reviewed-by: mullan
author vinnie
date Mon, 06 Dec 2010 18:52:23 +0000
parents fe9ead37938c
children 9758119b818c 8f0957d16c20
files src/share/classes/java/security/Timestamp.java
diffstat 1 files changed, 9 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/classes/java/security/Timestamp.java	Sun Dec 05 20:46:23 2010 -0800
+++ b/src/share/classes/java/security/Timestamp.java	Mon Dec 06 18:52:23 2010 +0000
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2010, 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
@@ -26,9 +26,11 @@
 package java.security;
 
 import java.io.Serializable;
+import java.security.cert.Certificate;
 import java.security.cert.CertPath;
 import java.security.cert.X509Extension;
 import java.util.Date;
+import java.util.List;
 
 /**
  * This class encapsulates information about a signed timestamp.
@@ -142,7 +144,12 @@
         StringBuffer sb = new StringBuffer();
         sb.append("(");
         sb.append("timestamp: " + timestamp);
-        sb.append("TSA: " + signerCertPath.getCertificates().get(0));
+        List<? extends Certificate> certs = signerCertPath.getCertificates();
+        if (!certs.isEmpty()) {
+            sb.append("TSA: " + certs.get(0));
+        } else {
+            sb.append("TSA: <empty>");
+        }
         sb.append(")");
         return sb.toString();
     }