HADOOP-12076. Incomplete Cache Mechanism in CredentialProvider API. Contributed by Larry McCay.
(cherry picked from commit fbf55dcaf4
)
This commit is contained in:
parent
4bfbc6b1d4
commit
63f3c24bb0
|
@ -374,6 +374,9 @@ Release 2.8.0 - UNRELEASED
|
||||||
HADOOP-12095. org.apache.hadoop.fs.shell.TestCount fails.
|
HADOOP-12095. org.apache.hadoop.fs.shell.TestCount fails.
|
||||||
(Brahma Reddy Battula via aajisaka)
|
(Brahma Reddy Battula via aajisaka)
|
||||||
|
|
||||||
|
HADOOP-12076. Incomplete Cache Mechanism in CredentialProvider API.
|
||||||
|
(Larry McCay via cnauroth)
|
||||||
|
|
||||||
Release 2.7.1 - UNRELEASED
|
Release 2.7.1 - UNRELEASED
|
||||||
|
|
||||||
INCOMPATIBLE CHANGES
|
INCOMPATIBLE CHANGES
|
||||||
|
|
|
@ -41,9 +41,7 @@ import java.security.UnrecoverableKeyException;
|
||||||
import java.security.cert.CertificateException;
|
import java.security.cert.CertificateException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.concurrent.locks.Lock;
|
import java.util.concurrent.locks.Lock;
|
||||||
import java.util.concurrent.locks.ReadWriteLock;
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
|
@ -174,13 +172,6 @@ public abstract class AbstractJavaKeyStoreProvider extends CredentialProvider {
|
||||||
return keyStore;
|
return keyStore;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, CredentialEntry> getCache() {
|
|
||||||
return cache;
|
|
||||||
}
|
|
||||||
|
|
||||||
private final Map<String, CredentialEntry> cache =
|
|
||||||
new HashMap<String, CredentialEntry>();
|
|
||||||
|
|
||||||
protected final String getPathAsString() {
|
protected final String getPathAsString() {
|
||||||
return getPath().toString();
|
return getPath().toString();
|
||||||
}
|
}
|
||||||
|
@ -213,9 +204,6 @@ public abstract class AbstractJavaKeyStoreProvider extends CredentialProvider {
|
||||||
try {
|
try {
|
||||||
SecretKeySpec key = null;
|
SecretKeySpec key = null;
|
||||||
try {
|
try {
|
||||||
if (cache.containsKey(alias)) {
|
|
||||||
return cache.get(alias);
|
|
||||||
}
|
|
||||||
if (!keyStore.containsAlias(alias)) {
|
if (!keyStore.containsAlias(alias)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -269,7 +257,7 @@ public abstract class AbstractJavaKeyStoreProvider extends CredentialProvider {
|
||||||
throws IOException {
|
throws IOException {
|
||||||
writeLock.lock();
|
writeLock.lock();
|
||||||
try {
|
try {
|
||||||
if (keyStore.containsAlias(alias) || cache.containsKey(alias)) {
|
if (keyStore.containsAlias(alias)) {
|
||||||
throw new IOException("Credential " + alias + " already exists in "
|
throw new IOException("Credential " + alias + " already exists in "
|
||||||
+ this);
|
+ this);
|
||||||
}
|
}
|
||||||
|
@ -296,7 +284,6 @@ public abstract class AbstractJavaKeyStoreProvider extends CredentialProvider {
|
||||||
} catch (KeyStoreException e) {
|
} catch (KeyStoreException e) {
|
||||||
throw new IOException("Problem removing " + name + " from " + this, e);
|
throw new IOException("Problem removing " + name + " from " + this, e);
|
||||||
}
|
}
|
||||||
cache.remove(name);
|
|
||||||
changed = true;
|
changed = true;
|
||||||
} finally {
|
} finally {
|
||||||
writeLock.unlock();
|
writeLock.unlock();
|
||||||
|
|
Loading…
Reference in New Issue