Examples of PublickeyAuthenticator


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);
            buf.putString(alg);
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

        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

        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

        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 (!hasSig) {
            if (authenticator.hasKey(username, key, session)) {
                Buffer buf = session.createBuffer(SshConstants.Message.SSH_MSG_USERAUTH_PK_OK);
                buf.putString(alg);
                buf.putRawBytes(buffer.array(), oldPos, 4 + len);
                session.writePacket(buf);
                return null;
            } else {
                throw new Exception("Unsupported key for user");
            }
        } else {
            if (!authenticator.hasKey(username, key, session)) {
                throw new Exception("Unsupported key for user");
            }
            Buffer buf = new Buffer();
            buf.putString(session.getKex().getH());
            buf.putCommand(SshConstants.Message.SSH_MSG_USERAUTH_REQUEST);
View Full Code Here

Examples of org.apache.sshd.server.PublickeyAuthenticator

            sshd.setPort(getPort());
            sshd.setKeyPairProvider(new FileKeyPairProvider(new String[]{"src/test/resources/hostkey.pem"}));
            sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
            sshd.setCommandFactory(new ScpCommandFactory());
            sshd.setPasswordAuthenticator(new MyPasswordAuthenticator());
            PublickeyAuthenticator publickeyAuthenticator = new PublickeyAuthenticator() {
                // consider all keys as authorized for all users
                @Override
                public boolean authenticate(String username, PublicKey key, ServerSession session) {
                    return true;
                }
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

        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.setPort(getPort());
            sshd.setKeyPairProvider(new FileKeyPairProvider(new String[]{"src/test/resources/hostkey.pem"}));
            sshd.setSubsystemFactories(Arrays.<NamedFactory<Command>>asList(new SftpSubsystem.Factory()));
            sshd.setCommandFactory(new ScpCommandFactory());
            sshd.setPasswordAuthenticator(new MyPasswordAuthenticator());
            PublickeyAuthenticator publickeyAuthenticator = new PublickeyAuthenticator() {
                // consider all keys as authorized for all users
                @Override
                public boolean authenticate(String username, PublicKey key, ServerSession session) {
                    return true;
                }
View Full Code Here

Examples of org.apache.sshd.server.PublickeyAuthenticator

      sshd.setCommandFactory(new ScpCommandFactory(new CommandFactory() {
         public Command createCommand(String command) {
            return new ProcessShellFactory(command.split(" ")).create();
         }
      }));
      sshd.setPublickeyAuthenticator(new PublickeyAuthenticator() {
         @Override
         public boolean authenticate(String s, PublicKey publicKey, ServerSession serverSession) {
            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.