Package org.apache.sshd.common

Examples of org.apache.sshd.common.KeyPairProvider


      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);
            }
View Full Code Here


        prepareServer(true);
        server.setHostKeyPath("/never/existing/directory");
        server.start();
        try {
            org.apache.sshd.SshServer sshd = (org.apache.sshd.SshServer) ReflectionTestUtils.getField(server, "sshd");
            KeyPairProvider prov = sshd.getKeyPairProvider();
            assertTrue(prov instanceof FileKeyPairProvider);
            Iterable<KeyPair> keys = prov.loadKeys();
            assertFalse(keys.iterator().hasNext());
        } finally {
            server.stop();
        }
    }
View Full Code Here

        if (!StringUtils.hasText(user)) {
            throw new CitrusRuntimeException("No 'user' provided (mandatory for authentication)");
        }
        sshd = org.apache.sshd.SshServer.setUpDefaultServer();
        sshd.setPort(port);
        KeyPairProvider prov =
                hostKeyPath != null ?
                        new FileKeyPairProvider(new String[] {hostKeyPath}) :
                        new ResourceKeyPairProvider(new String[] { "com/consol/citrus/ssh/citrus.pem" });
        sshd.setKeyPairProvider(prov);
View Full Code Here

        log.debug("Connected to {}:{}", getHost(), getPort());

        AuthFuture authResult;
        ClientSession session = connectFuture.getSession();

        KeyPairProvider keyPairProvider;
        final String certResource = getCertResource();
        if (certResource != null) {
            log.debug("Attempting to authenticate using ResourceKey '{}'...", certResource);
            keyPairProvider = new ResourceHelperKeyPairProvider(new String[]{certResource}, getCamelContext().getClassResolver());
        } else {
            keyPairProvider = getKeyPairProvider();
        }

        if (keyPairProvider != null) {
            log.debug("Attempting to authenticate username '{}' using Key...", getUsername());
            KeyPair pair = keyPairProvider.loadKey(getKeyType());
            authResult = session.authPublicKey(getUsername(), pair);
        } else {
            log.debug("Attempting to authenticate username '{}' using Password...", getUsername());
            authResult = session.authPassword(getUsername(), getPassword());
        }
View Full Code Here

TOP

Related Classes of org.apache.sshd.common.KeyPairProvider

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.