src/share/classes/sun/security/pkcs12/PKCS12KeyStore.java
Print this page
*** 1056,1065 ****
--- 1056,1098 ----
return false;
}
}
/**
+ * Determines if the keystore {@code Entry} for the specified
+ * {@code alias} is an instance or subclass of the specified
+ * {@code entryClass}.
+ *
+ * @param alias the alias name
+ * @param entryClass the entry class
+ *
+ * @return true if the keystore {@code Entry} for the specified
+ * {@code alias} is an instance or subclass of the
+ * specified {@code entryClass}, false otherwise
+ *
+ * @since 1.5
+ */
+ @Override
+ public boolean
+ engineEntryInstanceOf(String alias,
+ Class<? extends KeyStore.Entry> entryClass)
+ {
+ if (entryClass == KeyStore.TrustedCertificateEntry.class) {
+ return engineIsCertificateEntry(alias);
+ }
+
+ Entry entry = entries.get(alias.toLowerCase(Locale.ENGLISH));
+ if (entryClass == KeyStore.PrivateKeyEntry.class) {
+ return (entry != null && entry instanceof PrivateKeyEntry);
+ }
+ if (entryClass == KeyStore.SecretKeyEntry.class) {
+ return (entry != null && entry instanceof SecretKeyEntry);
+ }
+ return false;
+ }
+
+ /**
* Returns the (alias) name of the first keystore entry whose certificate
* matches the given certificate.
*
* <p>This method attempts to match the given certificate with each
* keystore entry. If the entry being considered
*** 1087,1097 ****
((CertEntry) entry).trustedKeyUsage != null) {
certElem = ((CertEntry) entry).cert;
} else {
continue;
}
! if (certElem.equals(cert)) {
return alias;
}
}
return null;
}
--- 1120,1130 ----
((CertEntry) entry).trustedKeyUsage != null) {
certElem = ((CertEntry) entry).cert;
} else {
continue;
}
! if (certElem != null && certElem.equals(cert)) {
return alias;
}
}
return null;
}
*** 1930,1939 ****
--- 1963,1977 ----
}
safeContentsData = safeContents.getData();
} else if (contentType.equals((Object)ContentInfo.ENCRYPTED_DATA_OID)) {
if (password == null) {
+
+ if (debug != null) {
+ debug.println("Warning: skipping PKCS#7 encryptedData" +
+ " content-type - no password was supplied");
+ }
continue;
}
if (debug != null) {
debug.println("Loading PKCS#7 encryptedData content-type");
*** 1972,1983 ****
// Retry using an empty password
// without a NULL terminator.
password = new char[1];
continue;
}
! throw new IOException(
! "failed to decrypt safe contents entry: " + e, e);
}
}
} else {
throw new IOException("public key protected PKCS12" +
" not supported");
--- 2010,2022 ----
// Retry using an empty password
// without a NULL terminator.
password = new char[1];
continue;
}
! throw new IOException("keystore password was incorrect",
! new UnrecoverableKeyException(
! "failed to decrypt safe contents entry: " + e));
}
}
} else {
throw new IOException("public key protected PKCS12" +
" not supported");