@Override public void init() { String authorizedKeyPath = getContext().getProperty(AUTHORIZED_KEY_PATH); if (authorizedKeyPath != null) { File f = new File(authorizedKeyPath); if (f.exists() && f.isFile()) { log.log(Level.FINE, "Found authorized key path " + authorizedKeyPath); Set<PublicKey> keys; keys = new LinkedHashSet<PublicKey>(); KeyPairProvider provider = new FilePublicKeyProvider(new String[]{authorizedKeyPath}); for (String type : TYPES) { KeyPair pair = provider.loadKey(type); if (pair != null) { PublicKey key = pair.getPublic(); if (key != null) { keys.add(key); } } } authorizedKeys = keys; } else { log.log(Level.FINE, "Ignoring invalid authorized key path " + authorizedKeyPath); } } }
keyFile }); KeyPair keyPair = keyPairProvider.loadKeys().iterator().next(); clientSession.addPublicKeyIdentity(keyPair);
private static void addPublicKey(final Collection<PublicKey> out, final KeyPairProvider p, final String type) { final KeyPair pair = p.loadKey(type); if (pair != null && pair.getPublic() != null) { out.add(pair.getPublic()); } }
private static void addPublicKey(final Collection<PublicKey> out, final KeyPairProvider p, final String type) { final KeyPair pair = p.loadKey(type); if (pair != null && pair.getPublic() != null) { out.add(pair.getPublic()); } }
@Override public void init() { String authorizedKeyPath = getContext().getProperty(AUTHORIZED_KEY_PATH); if (authorizedKeyPath != null) { File f = new File(authorizedKeyPath); if (f.exists() && f.isFile()) { log.log(Level.FINE, "Found authorized key path " + authorizedKeyPath); Set<PublicKey> keys; keys = new LinkedHashSet<PublicKey>(); KeyPairProvider provider = new FilePublicKeyProvider(new String[]{authorizedKeyPath}); for (String type : TYPES) { KeyPair pair = provider.loadKey(type); if (pair != null) { PublicKey key = pair.getPublic(); if (key != null) { keys.add(key); } } } authorizedKeys = keys; } else { log.log(Level.FINE, "Ignoring invalid authorized key path " + authorizedKeyPath); } } }
@Override public void init() { String authorizedKeyPath = getContext().getProperty(AUTHORIZED_KEY_PATH); if (authorizedKeyPath != null) { File f = new File(authorizedKeyPath); if (f.exists() && f.isFile()) { log.log(Level.FINE, "Found authorized key path " + authorizedKeyPath); Set<PublicKey> keys; keys = new LinkedHashSet<PublicKey>(); KeyPairProvider provider = new FilePublicKeyProvider(new String[]{authorizedKeyPath}); for (String type : TYPES) { KeyPair pair = provider.loadKey(type); if (pair != null) { PublicKey key = pair.getPublic(); if (key != null) { keys.add(key); } } } authorizedKeys = keys; } else { log.log(Level.FINE, "Ignoring invalid authorized key path " + authorizedKeyPath); } } }