@Nonnull @Override public Iterable<PublicKeyMatcher> getMatchers( @Nonnull AuthorizedKeyDataSource dataSource, @Nonnull Iterable<PublicKeyMatcherFactory> factories) { Iterable<AuthorizedKey> keys; try { keys = dataSource.loadKeys(); } catch (IOException e) { logger.warn("Could not read authorized keys", e); return newArrayList(); } List<PublicKeyMatcher> matchers = newArrayList(); for (AuthorizedKey key : keys) { PublicKeyMatcherFactory factory = getFirst(filter(factories, new KeyTypePredicate(key.getType())), null); if (factory == null) { logger.warn("No matcher factories for key type: <" + key.getType() + ">"); continue; } try { matchers.add(factory.buildMatcher(key)); } catch (InvalidKeySpecException e) { logger.warn("Could not parse key data", e); } logger.debug("Parsed key with comment <" + key.getComment() + ">"); } return matchers; }
@Override public boolean apply(@Nullable PublicKeyMatcherFactory input) { return input.getKeyType().equals(type); }