Methods Summary |
---|
public final java.util.Enumeration | aliases()Returns an {@code Enumeration} over all alias names stored in this
{@code KeyStore}.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
return implSpi.engineAliases();
|
public final boolean | containsAlias(java.lang.String alias)Indicates whether the given alias is present in this {@code KeyStore}.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
if (alias == null) {
throw new NullPointerException(Messages.getString("security.3F")); //$NON-NLS-1$
}
return implSpi.engineContainsAlias(alias);
|
public final void | deleteEntry(java.lang.String alias)Deletes the entry identified with the given alias from this {@code
KeyStore}.
// BEGIN android-changed
if (!isInit) {
throwNotInitialized();
}
// END android-changed
implSpi.engineDeleteEntry(alias);
|
public final boolean | entryInstanceOf(java.lang.String alias, java.lang.Class entryClass)Indicates whether the entry for the given alias is assignable to the
provided {@code Class}.
if (alias == null) {
throw new NullPointerException(Messages.getString("security.3F")); //$NON-NLS-1$
}
if (entryClass == null) {
throw new NullPointerException(Messages.getString("security.40")); //$NON-NLS-1$
}
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
return implSpi.engineEntryInstanceOf(alias, entryClass);
|
public final java.security.cert.Certificate | getCertificate(java.lang.String alias)Returns the trusted certificate for the entry with the given alias.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
return implSpi.engineGetCertificate(alias);
|
public final java.lang.String | getCertificateAlias(java.security.cert.Certificate cert)Returns the alias associated with the first entry whose certificate
matches the specified certificate.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
return implSpi.engineGetCertificateAlias(cert);
|
public final java.security.cert.Certificate[] | getCertificateChain(java.lang.String alias)Returns the certificate chain for the entry with the given alias.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
return implSpi.engineGetCertificateChain(alias);
|
public final java.util.Date | getCreationDate(java.lang.String alias)Returns the creation date of the entry with the given alias.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
return implSpi.engineGetCreationDate(alias);
|
public static final java.lang.String | getDefaultType()Returns the default type for {@code KeyStore} instances.
The default is specified in the {@code 'keystore.type'} property in the
file named {@code JAVA_HOME/lib/security/java.security}. If this property
is not set, {@code "jks"} will be used.
String dt = AccessController.doPrivileged(
new PrivilegedAction<String>() {
public String run() {
return Security.getProperty(PROPERTYNAME);
}
}
);
return (dt == null ? DEFAULT_KEYSTORE_TYPE : dt);
|
public final java.security.KeyStore$Entry | getEntry(java.lang.String alias, java.security.KeyStore$ProtectionParameter param)Returns the {@code Entry} with the given alias, using the specified
{@code ProtectionParameter}.
if (alias == null) {
throw new NullPointerException(Messages.getString("security.3F")); //$NON-NLS-1$
}
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
return implSpi.engineGetEntry(alias, param);
|
public static java.security.KeyStore | getInstance(java.lang.String type)Returns a new instance of {@code KeyStore} with the specified type.
if (type == null) {
throw new NullPointerException(Messages.getString("security.07")); //$NON-NLS-1$
}
synchronized (engine) {
try {
engine.getInstance(type, null);
return new KeyStore((KeyStoreSpi) engine.spi, engine.provider, type);
} catch (NoSuchAlgorithmException e) {
throw new KeyStoreException(e.getMessage());
}
}
|
public static java.security.KeyStore | getInstance(java.lang.String type, java.lang.String provider)Returns a new instance of {@code KeyStore} from the specified provider
with the given type.
if ((provider == null) || (provider.length() == 0)) {
throw new IllegalArgumentException(Messages.getString("security.02")); //$NON-NLS-1$
}
Provider impProvider = Security.getProvider(provider);
if (impProvider == null) {
throw new NoSuchProviderException(provider);
}
try {
return getInstance(type, impProvider);
} catch (Exception e) {
throw new KeyStoreException(e.getMessage(), e);
}
|
public static java.security.KeyStore | getInstance(java.lang.String type, java.security.Provider provider)Returns a new instance of {@code KeyStore} from the specified provider
with the given type.
// check parameters
if (provider == null) {
throw new IllegalArgumentException(Messages.getString("security.04")); //$NON-NLS-1$
}
if (type == null) {
throw new NullPointerException(Messages.getString("security.07")); //$NON-NLS-1$
}
// return KeyStore instance
synchronized (engine) {
try {
engine.getInstance(type, provider, null);
return new KeyStore((KeyStoreSpi) engine.spi, provider, type);
} catch (Exception e) {
// override exception
throw new KeyStoreException(e.getMessage());
}
}
|
public final java.security.Key | getKey(java.lang.String alias, char[] password)Returns the key with the given alias, using the password to recover the
key from the store.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
return implSpi.engineGetKey(alias, password);
|
public final java.security.Provider | getProvider()Returns the provider associated with this {@code KeyStore}.
return provider;
|
public final java.lang.String | getType()Returns the type of this {@code KeyStore}.
return type;
|
public final boolean | isCertificateEntry(java.lang.String alias)Indicates whether the specified alias is associated with a
{@link TrustedCertificateEntry}.
// BEGIN android-changed
if (!isInit) {
throwNotInitialized();
}
// END android-changed
return implSpi.engineIsCertificateEntry(alias);
|
public final boolean | isKeyEntry(java.lang.String alias)Indicates whether the specified alias is associated with either a
{@link PrivateKeyEntry} or a {@link SecretKeyEntry}.
// BEGIN android-changed
if (!isInit) {
throwNotInitialized();
}
// END android-changed
return implSpi.engineIsKeyEntry(alias);
|
public final void | load(java.io.InputStream stream, char[] password)Initializes this {@code KeyStore} from the provided {@code InputStream}.
Pass {@code null} as the {@code stream} argument to initialize an empty
{@code KeyStore} or to initialize a {@code KeyStore} which does not rely
on an {@code InputStream}. This {@code KeyStore} utilizes the given
password to verify the stored data.
implSpi.engineLoad(stream, password);
isInit = true;
|
public final void | load(java.security.KeyStore$LoadStoreParameter param)Loads this {@code KeyStore} using the specified {@code
LoadStoreParameter}.
implSpi.engineLoad(param);
isInit = true;
|
public final void | setCertificateEntry(java.lang.String alias, java.security.cert.Certificate cert)Associates the given alias with a certificate.
If the specified alias already exists, it will be reassigned.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
implSpi.engineSetCertificateEntry(alias, cert);
|
public final void | setEntry(java.lang.String alias, java.security.KeyStore$Entry entry, java.security.KeyStore$ProtectionParameter param)Stores the given {@code Entry} in this {@code KeyStore} and associates
the entry with the given {@code alias}. The entry is protected by the
specified {@code ProtectionParameter}.
If the specified alias already exists, it will be reassigned.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
if (alias == null) {
throw new NullPointerException(Messages.getString("security.3F")); //$NON-NLS-1$
}
if (entry == null) {
throw new NullPointerException(Messages.getString("security.39")); //$NON-NLS-1$
}
implSpi.engineSetEntry(alias, entry, param);
|
public final void | setKeyEntry(java.lang.String alias, java.security.Key key, char[] password, java.security.cert.Certificate[] chain)Associates the given alias with the key, password and certificate chain.
If the specified alias already exists, it will be reassigned.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
// Certificate chain is required for PrivateKey
if (null != key && key instanceof PrivateKey
&& (chain == null || chain.length == 0)) {
throw new IllegalArgumentException(Messages
.getString("security.52")); //$NON-NLS-1$
}
implSpi.engineSetKeyEntry(alias, key, password, chain);
|
public final void | setKeyEntry(java.lang.String alias, byte[] key, java.security.cert.Certificate[] chain)Associates the given alias with a key and a certificate chain.
If the specified alias already exists, it will be reassigned.
If this {@code KeyStore} is of type {@code "jks"}, {@code key} must be
encoded conform to the PKS#8 standard as an
{@link javax.crypto.EncryptedPrivateKeyInfo}.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
implSpi.engineSetKeyEntry(alias, key, chain);
|
public final int | size()Returns the number of entries stored in this {@code KeyStore}.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
return implSpi.engineSize();
|
public final void | store(java.io.OutputStream stream, char[] password)Writes this {@code KeyStore} to the specified {@code OutputStream}. The
data written to the {@code OutputStream} is protected by the specified
password.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
// BEGIN android-removed
// copied from a newer version of harmony
// Just delegate stream and password to implSpi
// if (stream == null) {
// throw new IOException(Messages.getString("security.51")); //$NON-NLS-1$
// }
// if (password == null) {
// throw new IOException(Messages.getString("security.50")); //$NON-NLS-1$
// }
// END android-removed
implSpi.engineStore(stream, password);
|
public final void | store(java.security.KeyStore$LoadStoreParameter param)Stores this {@code KeyStore} using the specified {@code
LoadStoreParameter}.
if (!isInit) {
// BEGIN android-changed
throwNotInitialized();
// END android-changed
}
implSpi.engineStore(param);
|
private static void | throwNotInitialized()Throws the standard "keystore not initialized" exception.
if (NOTINITKEYSTORE == null) {
NOTINITKEYSTORE = Messages.getString("security.4F"); //$NON-NLS-1$
}
throw new KeyStoreException(NOTINITKEYSTORE);
|