Methods Summary |
---|
public abstract java.util.Enumeration | engineAliases()Returns an {@code Enumeration} over all alias names stored in this
{@code KeyStoreSpi}.
|
public abstract boolean | engineContainsAlias(java.lang.String alias)Indicates whether the given alias is present in this {@code KeyStoreSpi}.
|
public abstract void | engineDeleteEntry(java.lang.String alias)Deletes the entry identified with the given alias from this {@code
KeyStoreSpi}.
|
public boolean | engineEntryInstanceOf(java.lang.String alias, java.lang.Class entryClass)Indicates whether the entry for the given alias is assignable to the
provided {@code Class}.
if (!engineContainsAlias(alias)) {
return false;
}
try {
if (engineIsCertificateEntry(alias)) {
return entryClass
.isAssignableFrom(Class
.forName("java.security.KeyStore$TrustedCertificateEntry")); //$NON-NLS-1$
}
if (engineIsKeyEntry(alias)) {
if (entryClass.isAssignableFrom(Class
.forName("java.security.KeyStore$PrivateKeyEntry"))) { //$NON-NLS-1$
return engineGetCertificate(alias) != null;
}
if (entryClass.isAssignableFrom(Class
.forName("java.security.KeyStore$SecretKeyEntry"))) { //$NON-NLS-1$
return engineGetCertificate(alias) == null;
}
}
} catch (ClassNotFoundException ignore) {}
return false;
|
public abstract java.security.cert.Certificate | engineGetCertificate(java.lang.String alias)Returns the trusted certificate for the entry with the given alias.
|
public abstract java.lang.String | engineGetCertificateAlias(java.security.cert.Certificate cert)Returns the alias associated with the first entry whose certificate
matches the specified certificate.
|
public abstract java.security.cert.Certificate[] | engineGetCertificateChain(java.lang.String alias)Returns the certificate chain for the entry with the given alias.
|
public abstract java.util.Date | engineGetCreationDate(java.lang.String alias)Returns the creation date of the entry with the given alias.
|
public java.security.KeyStore$Entry | engineGetEntry(java.lang.String alias, java.security.KeyStore$ProtectionParameter protParam)Returns the {@code Entry} with the given alias, using the specified
{@code ProtectionParameter}.
if (!engineContainsAlias(alias)) {
return null;
}
if (engineIsCertificateEntry(alias)) {
return new KeyStore.TrustedCertificateEntry(
engineGetCertificate(alias));
}
char[] passW = null;
if (protParam != null) {
if (protParam instanceof KeyStore.PasswordProtection) {
try {
passW = ((KeyStore.PasswordProtection) protParam)
.getPassword();
} catch (IllegalStateException ee) {
throw new KeyStoreException(Messages.getString("security.36"), ee); //$NON-NLS-1$
}
} else if (protParam instanceof KeyStore.CallbackHandlerProtection) {
passW = getPasswordFromCallBack(protParam);
} else {
throw new UnrecoverableEntryException(
Messages.getString("security.37", //$NON-NLS-1$
protParam.toString()));
}
}
if (engineIsKeyEntry(alias)) {
try {
Key key = engineGetKey(alias, passW);
if (key instanceof PrivateKey) {
return new KeyStore.PrivateKeyEntry((PrivateKey) key,
engineGetCertificateChain(alias));
}
if (key instanceof SecretKey) {
return new KeyStore.SecretKeyEntry((SecretKey) key);
}
} catch (UnrecoverableKeyException e) {
throw new KeyStoreException(e);
}
}
throw new NoSuchAlgorithmException(Messages.getString("security.38")); //$NON-NLS-1$
|
public abstract java.security.Key | engineGetKey(java.lang.String alias, char[] password)Returns the key with the given alias, using the password to recover the
key from the store.
|
public abstract boolean | engineIsCertificateEntry(java.lang.String alias)Indicates whether the specified alias is associated with a
{@link KeyStore.TrustedCertificateEntry}.
|
public abstract boolean | engineIsKeyEntry(java.lang.String alias)Indicates whether the specified alias is associated with either a
{@link KeyStore.PrivateKeyEntry} or a {@link KeyStore.SecretKeyEntry}.
|
public abstract void | engineLoad(java.io.InputStream stream, char[] password)Loads this {@code KeyStoreSpi} from the given {@code InputStream}.
Utilizes the given password to verify the stored data.
|
public void | engineLoad(java.security.KeyStore$LoadStoreParameter param)Loads this {@code KeyStoreSpi} using the specified {@code
LoadStoreParameter}.
if (param == null) {
engineLoad(null, null);
return;
}
char[] pwd;
KeyStore.ProtectionParameter pp = param.getProtectionParameter();
if (pp instanceof KeyStore.PasswordProtection) {
try {
pwd = ((KeyStore.PasswordProtection) pp).getPassword();
engineLoad(null, pwd);
return;
} catch (IllegalStateException e) {
throw new IllegalArgumentException(e);
}
}
if (pp instanceof KeyStore.CallbackHandlerProtection) {
try {
pwd = getPasswordFromCallBack(pp);
engineLoad(null, pwd);
return;
} catch (UnrecoverableEntryException e) {
throw new IllegalArgumentException(e);
}
}
throw new UnsupportedOperationException(
Messages.getString("security.35")); //$NON-NLS-1$
|
public abstract void | engineSetCertificateEntry(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.
|
public void | engineSetEntry(java.lang.String alias, java.security.KeyStore$Entry entry, java.security.KeyStore$ProtectionParameter protParam)Stores the given {@code Entry} in this {@code KeyStoreSpi} 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 (entry == null) {
throw new KeyStoreException(Messages.getString("security.39")); //$NON-NLS-1$
}
if (engineContainsAlias(alias)) {
engineDeleteEntry(alias);
}
if (entry instanceof KeyStore.TrustedCertificateEntry) {
KeyStore.TrustedCertificateEntry trE = (KeyStore.TrustedCertificateEntry) entry;
engineSetCertificateEntry(alias, trE.getTrustedCertificate());
return;
}
char[] passW = null;
if (protParam instanceof KeyStore.PasswordProtection) {
try {
passW = ((KeyStore.PasswordProtection) protParam).getPassword();
} catch (IllegalStateException ee) {
throw new KeyStoreException(Messages.getString("security.36"), ee); //$NON-NLS-1$
}
} else {
if (protParam instanceof KeyStore.CallbackHandlerProtection) {
try {
passW = getPasswordFromCallBack(protParam);
} catch (Exception e) {
throw new KeyStoreException(e);
}
} else {
throw new KeyStoreException(
Messages.getString("security.3A")); //$NON-NLS-1$
}
}
if (entry instanceof KeyStore.PrivateKeyEntry) {
KeyStore.PrivateKeyEntry prE = (KeyStore.PrivateKeyEntry) entry;
engineSetKeyEntry(alias, prE.getPrivateKey(), passW, prE
.getCertificateChain());
return;
}
if (entry instanceof KeyStore.SecretKeyEntry) {
KeyStore.SecretKeyEntry skE = (KeyStore.SecretKeyEntry) entry;
engineSetKeyEntry(alias, skE.getSecretKey(), passW, null);
// engineSetKeyEntry(alias, skE.getSecretKey().getEncoded(), null);
return;
}
throw new KeyStoreException(
Messages.getString("security.3B", entry.toString())); //$NON-NLS-1$
|
public abstract void | engineSetKeyEntry(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.
|
public abstract void | engineSetKeyEntry(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.
|
public abstract int | engineSize()Returns the number of entries stored in this {@code KeyStoreSpi}.
|
public abstract void | engineStore(java.io.OutputStream stream, char[] password)Writes this {@code KeyStoreSpi} to the specified {@code OutputStream}.
The data written to the {@code OutputStream} is protected by the
specified password.
|
public void | engineStore(java.security.KeyStore$LoadStoreParameter param)Stores this {@code KeyStoreSpi} using the specified {@code
LoadStoreParameter}.
throw new UnsupportedOperationException(Messages.getString("security.33")); //$NON-NLS-1$
|
static char[] | getPasswordFromCallBack(java.security.KeyStore$ProtectionParameter protParam)
if (protParam == null) {
return null;
}
if (!(protParam instanceof KeyStore.CallbackHandlerProtection)) {
throw new UnrecoverableEntryException(
Messages.getString("security.3C")); //$NON-NLS-1$
}
String clName = Security
.getProperty("auth.login.defaultCallbackHandler"); //$NON-NLS-1$
if (clName == null) {
throw new UnrecoverableEntryException(
Messages.getString("security.3D")); //$NON-NLS-1$
}
try {
Class<?> cl = Class.forName(clName);
CallbackHandler cbHand = (CallbackHandler) cl.newInstance();
PasswordCallback[] pwCb = { new PasswordCallback("password: ", true) }; //$NON-NLS-1$
cbHand.handle(pwCb);
return pwCb[0].getPassword();
} catch (Exception e) {
throw new UnrecoverableEntryException(e.toString());
}
|