From f76fee63ed9cb3a30d3c0c092d860b1cb93a481b Mon Sep 17 00:00:00 2001
From: Gerard Smyth <gerard.smyth@gmail.com>
Date: Thu, 08 May 2014 13:09:30 -0400
Subject: [PATCH] Updated the SyndicationServlet to provide an additional option to return details of the tags in the repository instead of the commits. This uses a new 'ot' request parameter to indicate the object type of the content to return, which can be ither TAG or COMMIT. If this is not provided, then COMMIT is assumed to maintain backwards compatability. If tags are returned, then the paging parameters, 'l' and 'pg' are still supported, but searching options are currently ignored.
---
src/main/java/com/gitblit/transport/ssh/IPublicKeyManager.java | 35 +++++++++++++++++++++++++----------
1 files changed, 25 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/gitblit/transport/ssh/IPublicKeyManager.java b/src/main/java/com/gitblit/transport/ssh/IPublicKeyManager.java
index d213514..1e74b2f 100644
--- a/src/main/java/com/gitblit/transport/ssh/IPublicKeyManager.java
+++ b/src/main/java/com/gitblit/transport/ssh/IPublicKeyManager.java
@@ -15,8 +15,8 @@
*/
package com.gitblit.transport.ssh;
-import java.security.PublicKey;
import java.text.MessageFormat;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
@@ -31,7 +31,7 @@
import com.google.common.cache.LoadingCache;
/**
- * Parent class for public key managers.
+ * Parent class for ssh public key managers.
*
* @author James Moger
*
@@ -40,14 +40,18 @@
protected final Logger log = LoggerFactory.getLogger(getClass());
- protected final LoadingCache<String, List<PublicKey>> keyCache = CacheBuilder
+ protected final LoadingCache<String, List<SshKey>> keyCache = CacheBuilder
.newBuilder().
expireAfterAccess(15, TimeUnit.MINUTES).
maximumSize(100)
- .build(new CacheLoader<String, List<PublicKey>>() {
+ .build(new CacheLoader<String, List<SshKey>>() {
@Override
- public List<PublicKey> load(String username) {
- return getKeysImpl(username);
+ public List<SshKey> load(String username) {
+ List<SshKey> keys = getKeysImpl(username);
+ if (keys == null) {
+ return Collections.emptyList();
+ }
+ return Collections.unmodifiableList(keys);
}
});
@@ -59,7 +63,7 @@
@Override
public abstract IPublicKeyManager stop();
- public final List<PublicKey> getKeys(String username) {
+ public final List<SshKey> getKeys(String username) {
try {
if (isStale(username)) {
keyCache.invalidate(username);
@@ -75,13 +79,24 @@
return null;
}
+ public final void renameUser(String oldName, String newName) {
+ List<SshKey> keys = getKeys(oldName);
+ if (keys == null || keys.isEmpty()) {
+ return;
+ }
+ removeAllKeys(oldName);
+ for (SshKey key : keys) {
+ addKey(newName, key);
+ }
+ }
+
protected abstract boolean isStale(String username);
- protected abstract List<PublicKey> getKeysImpl(String username);
+ protected abstract List<SshKey> getKeysImpl(String username);
- public abstract boolean addKey(String username, String data);
+ public abstract boolean addKey(String username, SshKey key);
- public abstract boolean removeKey(String username, String data);
+ public abstract boolean removeKey(String username, SshKey key);
public abstract boolean removeAllKeys(String username);
}
--
Gitblit v1.9.1