• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AuthenticationProtocolState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.sshtools.j2ssh.authentication.AuthenticationProtocolState的典型用法代码示例。如果您正苦于以下问题:Java AuthenticationProtocolState类的具体用法?Java AuthenticationProtocolState怎么用?Java AuthenticationProtocolState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AuthenticationProtocolState类属于com.sshtools.j2ssh.authentication包,在下文中一共展示了AuthenticationProtocolState类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: connectSsh

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
/**
 * connect to host
 * 
 * @return
 * @throws Exception
 */
private static SshClient connectSsh() throws Exception {
	SshClient ssh = new SshClient();

	HostKeyVerification host = new IgnoreHostKeyVerification();
	String hostStr = getBundle().getString("ssh.host");
	ssh.connect(hostStr, host);
	PasswordAuthenticationClient auth = new PasswordAuthenticationClient();
	auth.setUsername(getBundle().getString("ssh.user"));
	auth.setPassword(getBundle().getString("ssh.pwd"));
	int result = ssh.authenticate(auth);

	System.out.println("Status " + result);
	if ((result == AuthenticationProtocolState.CANCELLED) || (result == AuthenticationProtocolState.FAILED)) {
		throw new Exception("Authentication Error.");
	}
	return ssh;
}
 
开发者ID:qmetry,项目名称:qaf,代码行数:24,代码来源:SshUtil.java


示例2: connect

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
public boolean connect(String host, String user, String password) {		
	try {
		// Connect to host ignoring host key verification
		ssh.connect(host, new IgnoreHostKeyVerification());
		
		PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
		pwd.setUsername(user);
		pwd.setPassword(password);
		
		status = ssh.authenticate(pwd);
		
		if (status == AuthenticationProtocolState.COMPLETE)
			return true;
		else
			return false;			
	} catch (IOException ioe) {
		System.out.println("Error in connecting to "+host+" with user "+user);
		return false;			
	}		
}
 
开发者ID:vagfed,项目名称:hmcScanner,代码行数:21,代码来源:SSHManager.java


示例3: assureAuthenticatedConnection

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
private void assureAuthenticatedConnection() throws Exception {
	
	boolean reEstablished = false;
	
	if (!ssh.isConnected()) { 
		connect();
		reEstablished = true;
	}
	
	if (reEstablished || !ssh.isAuthenticated())  {
		if (ssh.authenticate(pwd)!=AuthenticationProtocolState.COMPLETE) {
			throw new RuntimeException("SSH authentication error");
		}
		reEstablished = true;
	}
	
	if (reEstablished) {
		session = null;
		scp = null;
	}
				
}
 
开发者ID:hpiasg,项目名称:desij,代码行数:23,代码来源:SshConnection.java


示例4: connectToLinux

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
public boolean connectToLinux(String ipAddress) {
	boolean isConnect = false;
	try {
		SshClient client = new SshClient();
		client.connect(ipAddress, 22);// IP�Ͷ˿�
		// �����û���������
		PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
		pwd.setUsername("root");
		pwd.setPassword("chenzhao");
		int result = client.authenticate(pwd);
		if (result == AuthenticationProtocolState.COMPLETE) {// ����������
			isConnect = true;
		}
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();

	}
	return isConnect;
}
 
开发者ID:yifzhang,项目名称:storm-miclog,代码行数:21,代码来源:PingServerTest.java


示例5: connect

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
public void connect() throws IOException {
    lia.gsi.ssh.GSIAuthenticationClient gsiAuth = null;
    try {
        gsiAuth = new lia.gsi.ssh.GSIAuthenticationClient();
        gsiAuth.setUsername(username);
    } catch (GSSException e) {
        throw new IOException("Cannot load grid credentials.");
    }
    conn = new SshClient();
    SshToolsConnectionProfile properties = new SshToolsConnectionProfile();
    // TODO: add new "port" parameter
    properties.setPort(port);
    properties.setForwardingAutoStartMode(false);
    properties.setHost(hostname);
    properties.setUsername(username);
    conn.setUseDefaultForwarding(false);
    conn.connect(properties);
    try {
        // Authenticate the user
        int result = conn.authenticate(gsiAuth, hostname);
        if (result != AuthenticationProtocolState.COMPLETE) {
            throw new IOException("GSI authentication failed");
        }
        // Open a session channel
        sess = conn.openSessionChannel();
        sess.requestPseudoTerminal("javash", 0, 0, 0, 0, "");
    } catch (Throwable t) {
        throw new IOException(t.getMessage());
    }
}
 
开发者ID:fast-data-transfer,项目名称:fdt,代码行数:31,代码来源:GSISSHControlStream.java


示例6: connectKey

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
public boolean connectKey(String host, String user, String keyFile) {		
	try {
		// Connect to host ignoring host key verification
		ssh.connect(host, new IgnoreHostKeyVerification());
		
		PublicKeyAuthenticationClient sshClient = new PublicKeyAuthenticationClient();

		SshPrivateKeyFile sshPrivKeyFile = SshPrivateKeyFile.parse(new File(keyFile));
		
		SshPrivateKey sshPrivKey = null;
		try {
			sshPrivKey = sshPrivKeyFile.toPrivateKey("");
		} catch (InvalidSshKeyException iske) {
			System.out.println("Wrong key or unsupported usage of passphrase.");
			return false;
		}
		sshClient.setKey(sshPrivKey);
		sshClient.setUsername(user);
		
		status = ssh.authenticate(sshClient);
		
		if (status == AuthenticationProtocolState.COMPLETE)
			return true;
		else
			return false;			
	} catch (IOException ioe) {
		System.out.println("Error in connecting to "+host+" with keyfile "+keyFile);
		System.out.println(ioe);
		return false;			
	}		
}
 
开发者ID:vagfed,项目名称:hmcScanner,代码行数:32,代码来源:SSHManager.java


示例7: connect

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
/**
 * Connect. This action simulates all the actions required for a SSH connection
 *
 * @param host  the hostname of the host you want to connect to
 * @param port the port of the host you want to connect to
 * @param username the username required for authentication
 * @param password the password required for authentication
 * @return the ssh client you connected to
 * @throws IOException Signals that an I/O exception has occurred.
 */
public static SshClient connect(String host, int port,String username,String password) throws IOException {
	SSH_LOG.info("Connecting to " + host);
	SshClient ssh = new SshClient();
	ssh.connect(host, port, new IgnoreHostKeyVerification());
	PasswordAuthenticationClient passwordAuthenticationClient = new PasswordAuthenticationClient();
	passwordAuthenticationClient.setUsername(username);
	passwordAuthenticationClient.setPassword(password);
	int result = ssh.authenticate(passwordAuthenticationClient);
	if (result != AuthenticationProtocolState.COMPLETE) {
		throw new IOException("Login to " + host + ":" + port + " "+ username + "/" + password + " failed");
	}
	SSH_LOG.info("Connected " + host);
	return ssh;
}
 
开发者ID:persado,项目名称:stevia,代码行数:25,代码来源:SSHUtils.java


示例8: authenticateWithKBI

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
private boolean authenticateWithKBI(boolean force)
        throws InvalidSecurityContextException, IOException {
    final KBIAuthenticationClient kbi = new KBIAuthenticationClient();
    kbi.setKBIRequestHandler(new KBIRequestHandler() {
        public void showPrompts(String name, String instruction,
                KBIPrompt[] prompts) {
            if (prompts == null) {
                return;
            }
            Prompt[] p = new Prompt[prompts.length];
            for (int i = 0; i < prompts.length; i++) {
                p[i] = new Prompt(prompts[i].getPrompt(),
                    Prompt.TYPE_HIDDEN_TEXT);
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Displaying credential dialog");
            }
            char[][] results = CredentialsDialog.showCredentialsDialog(host
                    + (empty(name) ? "" : " - " + name) 
                    + (empty(instruction) ? "" : " - " + instruction), p);
            if (results != null) {
                for (int i = 0; i < prompts.length; i++) {
                    prompts[i].setResponse(new String(results[i]));
                }
            }
        }
    });

    if (logger.isDebugEnabled()) {
        logger.debug("Performing keyboard-interactive authentication");
    }
    if (username == null) {
        promptForUsername();
    }
    kbi.setUsername(username);
    int result = client.authenticate(kbi);
    if (result == AuthenticationProtocolState.COMPLETE) {
        if (logger.isDebugEnabled()) {
            logger.debug("Authentication complete");
        }
        return true;
    }
    else if (result == AuthenticationProtocolState.PARTIAL) {
        if (logger.isDebugEnabled()) {
            logger.error("Keyboard Interactive Authentication succeeded "
                    + "but further authentication required!");
        }
        if (force) {
            throw new InvalidSecurityContextException(
                "The server requested additional authentication, but none is possible.");
        }
        else {
            return false;
        }
    }
    else {
        if (force) {
            throw new InvalidSecurityContextException(
                "Keyboard Interactive Authentication failed");
        }
        else {
            return false;
        }
    }
}
 
开发者ID:swift-lang,项目名称:swift-k,代码行数:66,代码来源:Ssh.java


示例9: main

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
/**
 * The main program for the PasswordConnect class
 *
 * @param args The command line arguments
 */
public static void main(String args[]) {
  try {
    // Setup a logfile
    /*Handler fh = new FileHandler("example.log");
    fh.setFormatter(new SimpleFormatter());
    Logger.getLogger("com.sshtools").setUseParentHandlers(false);
    Logger.getLogger("com.sshtools").addHandler(fh);
    Logger.getLogger("com.sshtools").setLevel(Level.ALL);*/
    // Configure J2SSH (This will attempt to install the bouncycastle provider
    // under jdk 1.3.1)
    ConfigurationLoader.initialize(false);
    System.out.print("Connect to host? ");
    System.out.print("Connect to host? ");
    String hostname = reader.readLine();
    // Make a client connection
    SshClient ssh = new SshClient();
    SshConnectionProperties properties = new SshConnectionProperties();
    properties.setHost(hostname);
    // Connect to the host
    ssh.connect(properties);
    // Create a password authentication instance
    KBIAuthenticationClient kbi = new KBIAuthenticationClient();
    // Get the users name
    System.out.print("Username? ");
    // Read the password
    String username = reader.readLine();
    kbi.setUsername(username);
    kbi.setKBIRequestHandler(new KBIRequestHandler() {
      public void showPrompts(String name, String instructions,
                              KBIPrompt[] prompts) {
        System.out.println(name);
        System.out.println(instructions);
        String response;
        if (prompts != null) {
          for (int i = 0; i < prompts.length; i++) {
            System.out.print(prompts[i].getPrompt() + ": ");
            try {
              response = reader.readLine();
              prompts[i].setResponse(response);
            }
            catch (IOException ex) {
              prompts[i].setResponse("");
              ex.printStackTrace();
            }
          }
        }
      }
    });
    // Try the authentication
    int result = ssh.authenticate(kbi);
    // Evaluate the result
    if (result == AuthenticationProtocolState.COMPLETE) {
      // The connection is authenticated we can now do some real work!
      SessionChannelClient session = ssh.openSessionChannel();
      if(!session.requestPseudoTerminal("vt100", 80, 24, 0, 0, ""))
        System.out.println("Failed to allocate a pseudo terminal");
      if(session.startShell()) {
        IOStreamConnector input =
            new IOStreamConnector(System.in, session.getOutputStream());
        IOStreamConnector output =
            new IOStreamConnector(session.getInputStream(), System.out);
        output.getState().waitForState(IOStreamConnectorState.CLOSED);
      }else
        System.out.println("Failed to start the users shell");
      ssh.disconnect();
    }
  }
  catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:UniversityofWarwick,项目名称:j2ssh-fork,代码行数:77,代码来源:KBIConnect.java


示例10: main

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
/**
 * The main program for the PasswordConnect class
 *
 * @param args The command line arguments
 */
public static void main(String args[]) {
  try {
    // JDK > 1.4 ONLY
    /*Handler fh = new FileHandler("example.log");
    fh.setFormatter(new SimpleFormatter());
    Logger.getLogger("com.sshtools").setUseParentHandlers(false);
    Logger.getLogger("com.sshtools").addHandler(fh);
    Logger.getLogger("com.sshtools").setLevel(Level.ALL);*/
    // Configure J2SSH (This will attempt to install the bouncycastle provider
    // under jdk 1.3.1)
    ConfigurationLoader.initialize(false);
    BufferedReader reader =
        new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Connect to host? ");
    String hostname = reader.readLine();
    // Make a client connection
    SshClient ssh = new SshClient();
    ssh.setSocketTimeout(30000);
    SshConnectionProperties properties = new SshConnectionProperties();
    properties.setHost(hostname);
    properties.setPrefPublicKey("ssh-dss");
    // Connect to the host
    ssh.connect(properties);
    // Create a password authentication instance
    PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
    // Get the users name
    System.out.print("Username? ");
    // Read the password
    String username = reader.readLine();
    pwd.setUsername(username);
    // Get the password
    System.out.print("Password? ");
    String password = reader.readLine();
    pwd.setPassword(password);
    // Try the authentication
    int result = ssh.authenticate(pwd);
    // Evaluate the result
    if (result == AuthenticationProtocolState.COMPLETE) {
      // The connection is authenticated we can now do some real work!
      SessionChannelClient session = ssh.openSessionChannel();
      if(!session.requestPseudoTerminal("vt100", 80, 24, 0, 0, ""))
        System.out.println("Failed to allocate a pseudo terminal");
      if (session.startShell()) {
        IOStreamConnector input =
            new IOStreamConnector();
        IOStreamConnector output =
            new IOStreamConnector();
        IOStreamConnector error =
            new IOStreamConnector();
        output.setCloseOutput(false);
        input.setCloseInput(false);
        error.setCloseOutput(false);
        input.connect(System.in, session.getOutputStream());
        output.connect(session.getInputStream(), System.out);
        error.connect(session.getStderrInputStream(), System.out);
        session.getState().waitForState(ChannelState.CHANNEL_CLOSED);
      }else
        System.out.println("Failed to start the users shell");
      ssh.disconnect();
    }
  }
  catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:UniversityofWarwick,项目名称:j2ssh-fork,代码行数:71,代码来源:PasswordConnect.java


示例11: main

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
/**
 * The main program for the PasswordConnect class
 *
 * @param args The command line arguments
 */
public static void main(String args[]) {
  try {
    // Setup a logfile
    /*Handler fh = new FileHandler("example.log");
    fh.setFormatter(new SimpleFormatter());
    Logger.getLogger("com.sshtools").setUseParentHandlers(false);
    Logger.getLogger("com.sshtools").addHandler(fh);
    Logger.getLogger("com.sshtools").setLevel(Level.ALL);*/
    // Configure J2SSH (This will attempt to install the bouncycastle provider
    // under jdk 1.3.1)
    ConfigurationLoader.initialize(false);
    BufferedReader reader =
        new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Connect to host? ");
    String hostname = reader.readLine();
    // Make a client connection
    SshClient ssh = new SshClient();
    // Connect to the host
    ssh.connect(hostname);
    // Create a password authentication instance
    PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
    // Get the users name
    System.out.print("Username? ");
    String username = reader.readLine();
    pwd.setUsername(username);
    // Get the password
    System.out.print("Password? ");
    String password = reader.readLine();
    pwd.setPassword(password);
    // Try the authentication
    int result = ssh.authenticate(pwd);
    // Evaluate the result
    if (result == AuthenticationProtocolState.COMPLETE) {
      // The connection is authenticated we can now do some real work!
      SftpClient sftp = ssh.openSftpClient();
      // Make a directory
      try {
        sftp.mkdir("j2ssh");
      }
      catch (IOException ex) {
      }
      // Change directory
      sftp.cd("j2ssh");
      System.out.println(sftp.pwd());
      // Change the mode
      sftp.chmod(0777, "j2ssh");
      sftp.lcd("c:/");
      // Upload a file
      sftp.put("system.gif");
      // Change the local directory
      sftp.lcd("localdir");
      // Download a file
      sftp.get("somefile.txt", "anotherfile.txt");
      // Remove a directory or file
      sftp.rm("j2ssh");
      // Quit
      sftp.quit();
      ssh.disconnect();
    }
  }
  catch (Exception e) {
    e.printStackTrace();
  }
  finally {
    System.exit(0);
  }
}
 
开发者ID:UniversityofWarwick,项目名称:j2ssh-fork,代码行数:73,代码来源:SftpConnect.java


示例12: main

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
/**
 * The main program for the PortForwarding class
 *
 * @param args The command line arguments
 */
public static void main(String args[]) {
  try {
    // Setup a logfile
    /*Handler fh = new FileHandler("example.log");
    fh.setFormatter(new SimpleFormatter());
    Logger.getLogger("com.sshtools").setUseParentHandlers(false);
    Logger.getLogger("com.sshtools").addHandler(fh);
    Logger.getLogger("com.sshtools").setLevel(Level.ALL);*/
    // Configure J2SSH (This will attempt to install the bouncycastle provider
    // under jdk 1.3.1)
    ConfigurationLoader.initialize(false);
    BufferedReader reader =
        new BufferedReader(new InputStreamReader(System.in));
    System.out.print("Connect to host? ");
    String hostname = reader.readLine();
    // Make a client connection
    SshClient ssh = new SshClient();
    // Connect to the hos
    ssh.connect(hostname);
    // Create a password authentication instance
    PasswordAuthenticationClient pwd = new PasswordAuthenticationClient();
    // Get the users name
    System.out.print("Username? ");
    String username = reader.readLine();
    pwd.setUsername(username);
    // Get the password
    System.out.print("Password? ");
    String password = reader.readLine();
    pwd.setPassword(password);
    // Try the authentication
    int result = ssh.authenticate(pwd);
    // Evaluate the result
    if (result == AuthenticationProtocolState.COMPLETE) {
      ForwardingClient forwarding = ssh.getForwardingClient();
      forwarding.addLocalForwarding("Test Local", "0.0.0.0", 8081,
                                    "127.0.0.1", 80);
      forwarding.startLocalForwarding("Test Local");
      forwarding.addRemoteForwarding("Test Remote", "0.0.0.0", 8081,
                                     "127.0.0.1", 8080);
      forwarding.startRemoteForwarding("Test Remote");
    }
    ssh.getConnectionState().waitForState(TransportProtocolState.DISCONNECTED);
  }
  catch (Exception e) {
    e.printStackTrace();
  }
}
 
开发者ID:UniversityofWarwick,项目名称:j2ssh-fork,代码行数:53,代码来源:PortForwarding.java


示例13: onMsgUserAuthRequest

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
private void onMsgUserAuthRequest(final SshMsgUserAuthRequest msg)
    throws IOException {
    if (msg.getMethodName().equals("none")) {
        sendUserAuthFailure(false);
    } else {
        if (attempts >= (ConfigurationLoader.getConfiguration(
                    ServerConfiguration.class)).getMaxAuthentications()) {
            // Too many authentication attempts
            transport.disconnect("Too many failed authentication attempts");
        } else {
            // If the service is supported then perfrom the authentication
            if (acceptServices.containsKey(msg.getServiceName())) {
                final String method = msg.getMethodName();

                if (availableAuths.contains(method)) {
                    final SshAuthenticationServer auth = SshAuthenticationServerFactory.newInstance(method);
                    serviceToStart = msg.getServiceName();

                    final int result = auth.authenticate(this, msg);

                    if (result == AuthenticationProtocolState.FAILED) {
                        sendUserAuthFailure(false);
                    } else if (result == AuthenticationProtocolState.COMPLETE) {
                        completedAuthentications.add(auth.getMethodName());

                        final ServerConfiguration sc = ConfigurationLoader.getConfiguration(ServerConfiguration.class);
                        for (final String required : sc.getRequiredAuthentications()) {
                            if (!completedAuthentications.contains(required)) {
                                sendUserAuthFailure(true);
                                return;
                            }
                        }

                        thread.setUsername(msg.getUsername());
                        sendUserAuthSuccess();
                    } else {
                        // Authentication probably returned READY as no completion
                        // evaluation was needed
                    }
                } else {
                    sendUserAuthFailure(false);
                }
            } else {
                sendUserAuthFailure(false);
            }

            attempts++;
        }
    }
}
 
开发者ID:UniversityofWarwick,项目名称:j2ssh-fork,代码行数:51,代码来源:AuthenticationProtocolServer.java


示例14: openSessionChannel

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
/**
 *
 * <p>
 * Open's a session channel on the remote server.
 * </p>
 *
 * <p>
 * A session channel may be used to start the user's shell, execute a
 * command or start a subsystem such as SFTP.
 * </p>
 *
 * @param eventListener an event listner interface to add to the channel
 *
 * @return
 *
 * @throws IOException
 * @throws SshException
 */
public SessionChannelClient openSessionChannel(
    ChannelEventListener eventListener) throws IOException {
    if (authenticationState != AuthenticationProtocolState.COMPLETE) {
        throw new SshException("Authentication has not been completed!");
    }

    SessionChannelClient session = new SessionChannelClient();
    session.addEventListener(activeChannelListener);

    if (!connection.openChannel(session, eventListener)) {
        throw new SshException("The server refused to open a session");
    }

    return session;
}
 
开发者ID:UniversityofWarwick,项目名称:j2ssh-fork,代码行数:34,代码来源:SshClient.java


示例15: authenticate

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
/**
 * <p>
 * Authenticate the user on the remote host.
 * </p>
 *
 * <p>
 * To authenticate the user, create an <code>SshAuthenticationClient</code>
 * instance and configure it with the authentication details.
 * </p>
 * <code> PasswordAuthenticationClient pwd = new
 * PasswordAuthenticationClient(); pwd.setUsername("root");
 * pwd.setPassword("xxxxxxxxx"); int result = ssh.authenticate(pwd);
 * </code>
 *
 * <p>
 * The method returns a result value will one of the public static values
 * defined in <code>AuthenticationProtocolState</code>. These are<br>
 * <br>
 * COMPLETED - The authentication succeeded.<br>
 * PARTIAL   - The authentication succeeded but a further authentication
 * method is required.<br>
 * FAILED    - The authentication failed.<br>
 * CANCELLED - The user cancelled authentication (can only be returned
 * when the user is prompted for information.<br>
 * </p>
 *
 * @param auth A configured SshAuthenticationClient instance ready for
 *        authentication
 *
 * @return The authentication result
 *
 * @exception IOException If an IO error occurs during authentication
 *
 * @since 0.2.0
 */
public int authenticate(SshAuthenticationClient auth)
    throws IOException {
    // Do the authentication
    authenticationState = authentication.authenticate(auth, connection);

    if ((authenticationState == AuthenticationProtocolState.COMPLETE) &&
            useDefaultForwarding) {
        // Use some method to synchronize forwardings on the ForwardingClient
        forwarding.synchronizeConfiguration(transport.getProperties());
    }

    return authenticationState;
}
 
开发者ID:UniversityofWarwick,项目名称:j2ssh-fork,代码行数:49,代码来源:SshClient.java


示例16: acceptsKey

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
/**
 * <p>
 * Determine whether a private/public key pair will be accepted for public
 * key authentication.
 * </p>
 *
 * <p>
 * When using public key authentication, the signing of data could take
 * some time depending upon the available machine resources. By calling
 * this method, you can determine whether the server will accept a key for
 * authentication by providing the public key. The server will verify the
 * key against the user's authorized keys and return true should the
 * public key be authorized. The caller can then proceed with the private
 * key operation.
 * </p>
 *
 * @param username The username for authentication
 * @param key The public key for which authentication will be attempted
 *
 * @return true if the server will accept the key, otherwise false
 *
 * @exception IOException If an IO error occurs during the operation
 * @throws SshException
 *
 * @since 0.2.0
 */
public boolean acceptsKey(String username, SshPublicKey key)
    throws IOException {
    if (authenticationState != AuthenticationProtocolState.COMPLETE) {
        PublicKeyAuthenticationClient pk = new PublicKeyAuthenticationClient();

        return pk.acceptsKey(authentication, username,
            connection.getServiceName(), key);
    } else {
        throw new SshException("Authentication has been completed!");
    }
}
 
开发者ID:UniversityofWarwick,项目名称:j2ssh-fork,代码行数:38,代码来源:SshClient.java


示例17: openChannel

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
/**
 * <p>
 * Open's a channel.
 * </p>
 *
 * <p>
 * Call this method to open a custom channel. This method is used by all
 * other channel opening methods. For example the openSessionChannel
 * method could be implemented as:<br>
 * <blockquote><pre>
 * SessionChannelClient session =
 *                 new SessionChannelClient();
 * if(ssh.openChannel(session)) {
 *    // Channel is now open
 * }
 * </pre></blockquote>
 * </p>
 *
 * @param channel
 *
 * @return true if the channel was opened, otherwise false
 *
 * @exception IOException if an IO error occurs
 * @throws SshException
 *
 * @since 0.2.0
 */
public boolean openChannel(Channel channel) throws IOException {
    if (authenticationState != AuthenticationProtocolState.COMPLETE) {
        throw new SshException("Authentication has not been completed!");
    }

    // Open the channel providing our channel listener so we can track
    return connection.openChannel(channel, activeChannelListener);
}
 
开发者ID:UniversityofWarwick,项目名称:j2ssh-fork,代码行数:36,代码来源:SshClient.java


示例18: isAuthenticated

import com.sshtools.j2ssh.authentication.AuthenticationProtocolState; //导入依赖的package包/类
/**
 * <p>
 * Evaluate whether the client has successfully authenticated.
 * </p>
 *
 * @return true if the client is authenticated, otherwise false
 */
public boolean isAuthenticated() {
    return authenticationState == AuthenticationProtocolState.COMPLETE;
}
 
开发者ID:UniversityofWarwick,项目名称:j2ssh-fork,代码行数:11,代码来源:SshClient.java



注:本文中的com.sshtools.j2ssh.authentication.AuthenticationProtocolState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OFBsnSetAuxCxnsReply类代码示例发布时间:2022-05-22
下一篇:
Java ServiceConnectorConfig类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap