Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes post ELY-810 (latest CS changes) #606

Merged
merged 2 commits into from Dec 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -53,6 +53,7 @@
import java.util.Iterator;
import java.util.Locale;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
import java.util.regex.Matcher;
Expand Down Expand Up @@ -150,6 +151,7 @@ public void initialize(final Map<String, String> attributes, final CredentialSto
final String locationName = attributes.get("location");
this.location = locationName == null ? null : Paths.get(locationName);
load(attributes.getOrDefault("keyStoreType", KeyStore.getDefaultType()));
initialized = true;
}
}

Expand Down Expand Up @@ -713,6 +715,20 @@ public void flush() throws CredentialStoreException {
}
}

/**
* Returns credential aliases stored in this store as {@code Set<String>}.
* <p>
* It is not mandatory to override this method (throws {@link UnsupportedOperationException} by default).
*
* @return {@code Set<String>} of all keys stored in this store
* @throws UnsupportedOperationException when this method is not supported by the underlying credential store
* @throws CredentialStoreException if there is any problem with internal store
*/
@Override
public Set<String> getAliases() throws UnsupportedOperationException, CredentialStoreException {
return cache.keySet();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably should have either made a copy or made it unmodifiable. I've made a note to fix this later.

}

private Hold lockForRead() {
readWriteLock.readLock().lock();
return () -> readWriteLock.readLock().unlock();
Expand Down
Expand Up @@ -51,7 +51,7 @@ public AtomicFileOutputStream(final File file) throws IOException {

public AtomicFileOutputStream(final Path path) throws IOException {
final Path parent = path.getParent();
if (parent.getNameCount() != 0 && ! Files.exists(parent)) {
if (parent != null && parent.getNameCount() != 0 && ! Files.exists(parent)) {
Files.createDirectories(parent);
}
current = new OpenState(Files.newOutputStream(path.resolveSibling(path.getFileName() + ".new"), CREATE, TRUNCATE_EXISTING), path);
Expand Down