Package org.xulfactory.gliese.message

Examples of org.xulfactory.gliese.message.UserAuthRequestMessage


     *
     * @return a new {@code UserAuthRequestMessage}
     */
    protected UserAuthRequestMessage initUserAuthRequestMessage()
    {
      UserAuthRequestMessage msg = new UserAuthRequestMessage();
      msg.setUser(username);
      msg.setService("ssh-connection");
      return msg;
    }
View Full Code Here


    @Override
    public SSHMessage interact(SSHMessage lastMessage) throws SSHException
    {
      if (lastMessage == null) {
        UserAuthRequestMessage msg = initUserAuthRequestMessage();
        PublicKeyMethodData md = new PublicKeyMethodData(key.getName(), key.encode());
        msg.setAuthenticationData(md);
        return msg;
      } else if (lastMessage.getID() == UserAuthPublicKeyOk.ID) {
        UserAuthRequestMessage msg = initUserAuthRequestMessage();
        PublicKeyMethodData md = new PublicKeyMethodData(key.getName(), key.encode());
        md.prepareTBS();
        msg.setAuthenticationData(md);
        byte[] sig = null;
        try {
          signer.update(Utils.encodeBytes(transport.getSessionId()));
          signer.update(msg.getEncoding());
          sig = signer.sign();
        } catch (SignatureException e) {
          throw new SSHException("Signature failed", e);
        }
        md = new PublicKeyMethodData(key.getName(), key.encode());
        md.setSignature(sig);
        msg.setAuthenticationData(md);
        return msg;
      }
      throw new UnsupportedOperationException("Not supported yet.");
    }
View Full Code Here

    }
   
    @Override
    public SSHMessage interact(SSHMessage lastMessage)
    {
      UserAuthRequestMessage msg = initUserAuthRequestMessage();
      msg.setAuthenticationData(new PasswordMethodData(password));
      return msg;
    }
View Full Code Here

   
    @Override
    public SSHMessage interact(SSHMessage lastMessage)
    {
      if (lastMessage == null) {
        UserAuthRequestMessage msg = initUserAuthRequestMessage();
        msg.setAuthenticationData(new KeyboardInteractiveMethodData(""));
        return msg;
      }
      UserAuthInfoRequest req = (UserAuthInfoRequest)lastMessage;
      if (req.getInstruction() != null) {
        kbi.prompt(req.getInstruction());
View Full Code Here

    inorder.verify(transport, times(1)).writeMessage(any(SSHMessage.class));
    inorder.verify(transport, times(1)).writeMessage(argThat(new ArgumentMatcher<SSHMessage>() {
      @Override
      public boolean matches(Object arg)
      {
        UserAuthRequestMessage msg = (UserAuthRequestMessage)arg;
        assertTrue(msg.getAuthenticationData() instanceof PublicKeyMethodData);
        assertEquals("publickey", msg.getMethod());
        PublicKeyMethodData md = (PublicKeyMethodData)msg.getAuthenticationData();
        assertEquals("ssh-rsa", md.getAlgorithm());
        assertArrayEquals(pkey.encode(), md.getPubkey());
        return true;
      }
    }));
View Full Code Here

    inorder.verify(transport, times(1)).writeMessage(any(SSHMessage.class));
    inorder.verify(transport, times(1)).writeMessage(argThat(new ArgumentMatcher<SSHMessage>() {
      @Override
      public boolean matches(Object arg)
      {
        UserAuthRequestMessage msg = (UserAuthRequestMessage)arg;
        assertTrue(msg.getAuthenticationData() instanceof PublicKeyMethodData);
        assertEquals("publickey", msg.getMethod());
        PublicKeyMethodData md = (PublicKeyMethodData)msg.getAuthenticationData();
        assertEquals("ssh-rsa", md.getAlgorithm());
        assertArrayEquals(pkey.encode(), md.getPubkey());
        assertNotNull(md.getSignature());
        try {
          Signature verify = Signature.getInstance("SHA1withRSA");
View Full Code Here

TOP

Related Classes of org.xulfactory.gliese.message.UserAuthRequestMessage

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.