APIdia Launch Partner
Top Description Constructors Methods
sun.security.tools

public Class KeyStoreUtil

extends Object
Class Inheritance
Imports
java.io.BufferedReader, .File, .FileInputStream, .IOException, .InputStreamReader, .StreamTokenizer, .StringReader, java.net.URL, java.security.KeyStore, .Provider, .Security, java.security.cert.X509Certificate, java.text.Collator, java.util.ArrayList, .Arrays, .List, .Locale, .Properties, .ResourceBundle, .ServiceLoader, sun.security.util.FilePaths, .PropertyExpander

This class provides several utilities to KeyStore.

Since
1.6.0

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static String[]

Returns:

arguments combined
expandArgs
(String
the name of the tool, can be "keytool" or "jarsigner"
tool
,
String
the pre-configured options file
file
,
String
the name of the command, with the "-" prefix, must not be null
c1
,
String
the alternative command name, with the "-" prefix, null if none. For example, "genkey" is alt name for "genkeypair". A command can only have one alt name now.
c2
,
String[]
existing arguments
args
)

Prepends matched options from a pre-configured options file.

public static String
getCacerts()

Returns the file name of the keystore with the configured CA certificates.

public static KeyStore
getCacertsKeyStore()

Returns the keystore with the configured CA certificates.

public static char[]
public static boolean
isSelfSigned(X509Certificate cert)

Returns true if the certificate is self-signed, false otherwise.

public static boolean
isWindowsKeyStore(String storetype)

Returns true if KeyStore has a password.

public static void
loadProviderByClass(String
the class name
provClass
,
String
optional arg
arg
,
ClassLoader
optional class loader
cl
)

Loads a security provider by a fully-qualified class name.

public static void
loadProviderByName(String
the name
provName
,
String
optional arg
arg
)

Loads a security provider as a service.

public static String
niceStoreTypeName(String storetype)

Returns standard-looking names for storetype

private static void
parseArgsLine(List<String>
the list to fill into
list
,
String
the line
s
)

Parses an option line likes -genkaypair -dname "CN=Me" and add the results into a list

public static boolean
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

KeyStoreUtilback to summary
private KeyStoreUtil()

Method Detail

expandArgsback to summary
public static String[] expandArgs(String tool, String file, String c1, String c2, String[] args) throws IOException, ExpandException

Prepends matched options from a pre-configured options file.

Parameters
tool:String

the name of the tool, can be "keytool" or "jarsigner"

file:String

the pre-configured options file

c1:String

the name of the command, with the "-" prefix, must not be null

c2:String

the alternative command name, with the "-" prefix, null if none. For example, "genkey" is alt name for "genkeypair". A command can only have one alt name now.

args:String[]

existing arguments

Returns:String[]

arguments combined

Exceptions
IOException:
if there is a file I/O or format error
ExpandException:
if there is a property expansion error
getCacertsback to summary
public static String getCacerts()

Returns the file name of the keystore with the configured CA certificates.

getCacertsKeyStoreback to summary
public static KeyStore getCacertsKeyStore() throws Exception

Returns the keystore with the configured CA certificates.

getPassWithModifierback to summary
public static char[] getPassWithModifier(String modifier, String arg, ResourceBundle rb, Collator collator)
isSelfSignedback to summary
public static boolean isSelfSigned(X509Certificate cert)

Returns true if the certificate is self-signed, false otherwise.

isWindowsKeyStoreback to summary
public static boolean isWindowsKeyStore(String storetype)

Returns true if KeyStore has a password. This is true except for MSCAPI KeyStores

loadProviderByClassback to summary
public static void loadProviderByClass(String provClass, String arg, ClassLoader cl)

Loads a security provider by a fully-qualified class name.

Parameters
provClass:String

the class name

arg:String

optional arg

cl:ClassLoader

optional class loader

Exceptions
IllegalArgumentException:
if no provider matches the class name
ClassCastException:
if the class has not extended Provider
loadProviderByNameback to summary
public static void loadProviderByName(String provName, String arg)

Loads a security provider as a service.

Parameters
provName:String

the name

arg:String

optional arg

Exceptions
IllegalArgumentException:
if no provider matches the name
niceStoreTypeNameback to summary
public static String niceStoreTypeName(String storetype)

Returns standard-looking names for storetype

parseArgsLineback to summary
private static void parseArgsLine(List<String> list, String s) throws IOException, ExpandException

Parses an option line likes -genkaypair -dname "CN=Me" and add the results into a list

Parameters
list:List<String>

the list to fill into

s:String

the line

signedByback to summary
public static boolean signedBy(X509Certificate end, X509Certificate ca)