Examples of PublickeyAuthenticator


Examples of org.apache.sshd.server.PublickeyAuthenticator

  }

  @Override
  public void afterPropertiesSet() throws Exception {
    final PublicKey allowedKey = decodePublicKey();
    this.server.setPublickeyAuthenticator(new PublickeyAuthenticator() {

      @Override
      public boolean authenticate(String username, PublicKey key, ServerSession session) {
        return key.equals(allowedKey);
      }
View Full Code Here

Examples of org.apache.sshd.server.PublickeyAuthenticator

            public boolean authenticate(String username, String password, ServerSession session) {
                // dummy authentication: allow any user whose password is the same as the username
                return username != null && username.equals(password);
            }
        });
        sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
            @Override
            public boolean authenticate(String username, PublicKey key, ServerSession session) {
                return true;
            }
        });
View Full Code Here

Examples of org.apache.sshd.server.PublickeyAuthenticator

        verif.init(key, null);
        buffer.wpos(oldLim);

        byte[] sig = hasSig ? buffer.getBytes() : null;

        PublickeyAuthenticator authenticator = session.getServerFactoryManager().getPublickeyAuthenticator();
        if (authenticator == null) {
            throw new Exception("No PublickeyAuthenticator configured");
        }

        if (!authenticator.authenticate(username, key, session)) {
            return false;
        }
        if (!hasSig) {
            Buffer buf = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_PK_OK, 0);
            buf.putString(alg);
View Full Code Here

Examples of org.apache.sshd.server.PublickeyAuthenticator

        sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
            public boolean authenticate(String username, String password, ServerSession session) {
                return username != null && username.equals(password);
            }
        });
        sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
            public boolean authenticate(String username, PublicKey key, ServerSession session) {
                //File f = new File("/Users/" + username + "/.ssh/authorized_keys");
                return true;
            }
        });
View Full Code Here

Examples of org.apache.sshd.server.PublickeyAuthenticator

        sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
            public boolean authenticate(String username, String password, ServerSession session) {
                return username != null && username.equals(password);
            }
        });
        sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
            public boolean authenticate(String username, PublicKey key, ServerSession session) {
                //File f = new File("/Users/" + username + "/.ssh/authorized_keys");
                return true;
            }
        });
View Full Code Here

Examples of org.apache.sshd.server.PublickeyAuthenticator

    }

    @Test
    public void testPublicKeyAuthNewWithFailureOnFirstIdentity() throws Exception {
        final KeyPair pair = Utils.createTestHostKeyProvider().loadKey(KeyPairProvider.SSH_RSA);
        sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
            public boolean authenticate(String username, PublicKey key, ServerSession session) {
                return key.equals(pair.getPublic());
            }
        });
        SshClient client = SshClient.setUpDefaultClient();
View Full Code Here

Examples of org.apache.sshd.server.PublickeyAuthenticator

            public Command createCommand(String command) {
                return new UnknownCommand(command);
            }
        });
        sshd.getProperties().put(SshServer.AUTH_METHODS, "publickey");
        sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
            public boolean authenticate(String username, PublicKey key, ServerSession session) {
                return delegate.authenticate(username, key, session);
            }
        });
        sshd.start();
View Full Code Here

Examples of org.apache.sshd.server.PublickeyAuthenticator

    }

    @Test
    public void testPublicKeyAuthWithCache() throws Exception {
        final ConcurrentHashMap<String, AtomicInteger> count = new ConcurrentHashMap<String, AtomicInteger>();
        TestCachingPublicKeyAuthenticator auth = new TestCachingPublicKeyAuthenticator(new PublickeyAuthenticator() {
            public boolean authenticate(String username, PublicKey key,
                                        ServerSession session) {
                count.putIfAbsent(KeyUtils.getFingerPrint(key), new AtomicInteger());
                count.get(KeyUtils.getFingerPrint(key)).incrementAndGet();
                return key.equals(pairRsa.getPublic());
View Full Code Here

Examples of org.apache.sshd.server.PublickeyAuthenticator

    }

    @Test
    public void testPublicKeyAuthWithoutCache() throws Exception {
        final ConcurrentHashMap<String, AtomicInteger> count = new ConcurrentHashMap<String, AtomicInteger>();
        delegate = new PublickeyAuthenticator() {
            public boolean authenticate(String username, PublicKey key,
                                        ServerSession session) {
                count.putIfAbsent(KeyUtils.getFingerPrint(key), new AtomicInteger());
                count.get(KeyUtils.getFingerPrint(key)).incrementAndGet();
                return key.equals(pairRsa.getPublic());
View Full Code Here

Examples of org.apache.sshd.server.PublickeyAuthenticator

        sshd.setPasswordAuthenticator(new PasswordAuthenticator() {
            public boolean authenticate(String username, String password, ServerSession session) {
                return username != null && username.equals(password);
            }
        });
        sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
            public boolean authenticate(String username, PublicKey key, ServerSession session) {
                //File f = new File("/Users/" + username + "/.ssh/authorized_keys");
                return true;
            }
        });
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.