< prev index next >
src/share/classes/com/sun/crypto/provider/JceKeyStore.java
Print this page
rev 13649 : 8218553: Enhance keystore load debug output
Reviewed-by: weijun
*** 1,7 ****
/*
! * Copyright (c) 1998, 2018, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
--- 1,7 ----
/*
! * Copyright (c) 1998, 2019, 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
*** 23,32 ****
--- 23,34 ----
* questions.
*/
package com.sun.crypto.provider;
+ import sun.security.util.Debug;
+
import java.io.*;
import java.util.*;
import java.security.AccessController;
import java.security.DigestInputStream;
import java.security.DigestOutputStream;
*** 59,68 ****
--- 61,71 ----
* @see java.security.KeyStoreSpi
*/
public final class JceKeyStore extends KeyStoreSpi {
+ private static final Debug debug = Debug.getInstance("keystore");
private static final int JCEKS_MAGIC = 0xcececece;
private static final int JKS_MAGIC = 0xfeedfeed;
private static final int VERSION_1 = 0x01;
private static final int VERSION_2 = 0x02;
*** 680,689 ****
--- 683,693 ----
MessageDigest md = null;
CertificateFactory cf = null;
Hashtable<String, CertificateFactory> cfs = null;
ByteArrayInputStream bais = null;
byte[] encoded = null;
+ int trustedKeyCount = 0, privateKeyCount = 0, secretKeyCount = 0;
if (stream == null)
return;
if (password != null) {
*** 726,736 ****
String alias;
tag = dis.readInt();
if (tag == 1) { // private-key entry
!
PrivateKeyEntry entry = new PrivateKeyEntry();
// read the alias
alias = dis.readUTF();
--- 730,740 ----
String alias;
tag = dis.readInt();
if (tag == 1) { // private-key entry
! privateKeyCount++;
PrivateKeyEntry entry = new PrivateKeyEntry();
// read the alias
alias = dis.readUTF();
*** 786,796 ****
// Add the entry to the list
entries.put(alias, entry);
} else if (tag == 2) { // trusted certificate entry
!
TrustedCertEntry entry = new TrustedCertEntry();
// read the alias
alias = dis.readUTF();
--- 790,800 ----
// Add the entry to the list
entries.put(alias, entry);
} else if (tag == 2) { // trusted certificate entry
! trustedKeyCount++;
TrustedCertEntry entry = new TrustedCertEntry();
// read the alias
alias = dis.readUTF();
*** 825,835 ****
// Add the entry to the list
entries.put(alias, entry);
} else if (tag == 3) { // secret-key entry
!
SecretKeyEntry entry = new SecretKeyEntry();
// read the alias
alias = dis.readUTF();
--- 829,839 ----
// Add the entry to the list
entries.put(alias, entry);
} else if (tag == 3) { // secret-key entry
! secretKeyCount++;
SecretKeyEntry entry = new SecretKeyEntry();
// read the alias
alias = dis.readUTF();
*** 858,869 ****
// Add the entry to the list
entries.put(alias, entry);
} else {
! throw new IOException("Unrecognized keystore entry");
}
}
/*
* If a password has been provided, we check the keyed digest
* at the end. If this check fails, the store has been tampered
--- 862,881 ----
// Add the entry to the list
entries.put(alias, entry);
} else {
! throw new IOException("Unrecognized keystore entry: " +
! tag);
! }
}
+
+ if (debug != null) {
+ debug.println("JceKeyStore load: private key count: " +
+ privateKeyCount + ". trusted key count: " +
+ trustedKeyCount + ". secret key count: " +
+ secretKeyCount);
}
/*
* If a password has been provided, we check the keyed digest
* at the end. If this check fails, the store has been tampered
< prev index next >