import com.gitblit.manager.IManager;
import com.google.common.cache.CacheBuilder;
import com.google.common.cache.CacheLoader;
+import com.google.common.cache.CacheLoader.InvalidCacheLoadException;
import com.google.common.cache.LoadingCache;
/**
keyCache.invalidate(username);
}
return keyCache.get(username);
+ } catch (InvalidCacheLoadException e) {
+ if (e.getMessage() == null || !e.getMessage().contains("returned null")) {
+ log.error(MessageFormat.format("failed to retrieve keys for {0}", username), e);
+ }
} catch (ExecutionException e) {
log.error(MessageFormat.format("failed to retrieve keys for {0}", username), e);
}
@Override
public void run() {
IPublicKeyManager keyManager = getContext().getGitblit().getPublicKeyManager();
- List<PublicKey> keys = keyManager.getKeys(getContext().getClient().getUsername());
-
+ String username = getContext().getClient().getUsername();
+ List<PublicKey> keys = keyManager.getKeys(username);
+ if (keys == null) {
+ stdout.println(String.format("%s has not added any public keys for ssh authentication", username));
+ return;
+ }
for (PublicKey key : keys) {
// two-steps - perhaps this could be improved
Buffer buf = new Buffer();