From 70ef26d4d0fefcd5cd1aee8f63043753b2c4a97b Mon Sep 17 00:00:00 2001 From: Sean Mullan Date: Mon, 12 May 2014 10:18:51 -0400 Subject: [PATCH] 8038364: Use certificate exceptions correctly Reviewed-by: vinnie, skoivu --- .../security/cert/CertificateRevokedException.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/security/cert/CertificateRevokedException.java b/jdk/src/java.base/share/classes/java/security/cert/CertificateRevokedException.java index a545627061a..8c1f0664023 100644 --- a/jdk/src/java.base/share/classes/java/security/cert/CertificateRevokedException.java +++ b/jdk/src/java.base/share/classes/java/security/cert/CertificateRevokedException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, 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 @@ -84,6 +84,8 @@ public class CertificateRevokedException extends CertificateException { * @throws NullPointerException if {@code revocationDate}, * {@code reason}, {@code authority}, or * {@code extensions} is {@code null} + * @throws ClassCastException if {@code extensions} contains an incorrectly + * typed key or value */ public CertificateRevokedException(Date revocationDate, CRLReason reason, X500Principal authority, Map extensions) { @@ -94,7 +96,10 @@ public class CertificateRevokedException extends CertificateException { this.revocationDate = new Date(revocationDate.getTime()); this.reason = reason; this.authority = authority; - this.extensions = new HashMap(extensions); + // make sure Map only contains correct types + this.extensions = Collections.checkedMap(new HashMap<>(), + String.class, Extension.class); + this.extensions.putAll(extensions); } /** @@ -172,7 +177,8 @@ public class CertificateRevokedException extends CertificateException { public String getMessage() { return "Certificate has been revoked, reason: " + reason + ", revocation date: " + revocationDate - + ", authority: " + authority + ", extensions: " + extensions; + + ", authority: " + authority + ", extension OIDs: " + + extensions.keySet(); } /**