Package com.trilead.ssh2.crypto.cipher

Examples of com.trilead.ssh2.crypto.cipher.AES


      String strHostName = objCO.getHost().Value();
      int intPortNo = objCO.getPort().value();
      this.setSshConnection(new Connection(strHostName, intPortNo));

      if (objCO.getProxy_host().IsNotEmpty()) {
        HTTPProxyData objProxy = null;
        if (objCO.getProxy_user().IsEmpty()) {
          objProxy = new HTTPProxyData(objCO.getProxy_host().Value(), objCO.getProxy_port().value());
        }
        else {
          objProxy = new HTTPProxyData(objCO.getProxy_host().Value(), objCO.getProxy_port().value(), objCO.getProxy_user().Value(),
              objCO.getProxy_password().Value());
        }
        this.getSshConnection().setProxyData(objProxy);
      }
      this.getSshConnection().connect();
View Full Code Here


            boolean isAuthenticated = false;
            this.setSshConnection(new Connection(this.getHost(), this.getPort()));
               
            if (this.getProxyHost() != null && this.getProxyHost().length() > 0) {
                if (this.getProxyUser() != null && this.getProxyUser().length() > 0) {
                    this.getSshConnection().setProxyData(new HTTPProxyData(this.getProxyHost(), this.getProxyPort()));
                } else {
                    this.getSshConnection().setProxyData(new HTTPProxyData(this.getProxyHost(), this.getProxyPort(), this.getProxyUser(), this.getProxyPassword()));
                }
            }
               
            this.getSshConnection().connect();
View Full Code Here

            boolean isAuthenticated = false;
            sshConnection = new Connection(this.getHost(), this.getPort());
               
            if (this.getProxyHost() != null && this.getProxyHost().length() > 0) {
                if (this.getProxyUser() != null && this.getProxyUser().length() > 0) {                   
                    sshConnection.setProxyData(new HTTPProxyData(this.getProxyHost(), this.getProxyPort(), this.getProxyUser(), this.getProxyPassword()));
                } else {
                  sshConnection.setProxyData(new HTTPProxyData(this.getProxyHost(), this.getProxyPort()));
                }
            }
               
            sshConnection.connect();
View Full Code Here

      boolean isAuthenticated = false;
      this.setSshConnection(new Connection(Options().host.Value(), objOptions.port.value()));

      if (objOptions.proxy_host.IsEmpty() == false) {
        if (objOptions.proxy_user.IsEmpty() == false) {
          this.getSshConnection().setProxyData(new HTTPProxyData(objOptions.proxy_host.Value(), objOptions.proxy_port.value()));
        }
        else {
          this.getSshConnection().setProxyData(
              new HTTPProxyData(objOptions.proxy_host.Value(), objOptions.proxy_port.value(), objOptions.proxy_user.Value(),
                  objOptions.proxy_password.Value()));
        }
      }

      this.getSshConnection().connect();
View Full Code Here

   
    public boolean spooler_process() {

        Order order = null;
        Variable_set params = null;
        SCPClient scpClient = null;

        try {
            try { // to fetch parameters from orders that have precedence over job parameters
                params = spooler_task.params();
               
                if (spooler_task.job().order_queue() != null) {
                    order = spooler_task.order();
                    if ( order.params() != null)
                      params.merge(order.params());
                }
               
                // get basic authentication parameters
                this.getBaseParameters();
               
                if (params.value("action") != null && params.value("action").length() > 0) {
                    if (!params.value("action").equalsIgnoreCase("get") && !params.value("action").equalsIgnoreCase("put"))
                        throw new Exception("invalid action parameter [action] specified, expected get, put: " + params.value("action"));
                    this.setAction(params.value("action").toLowerCase());
                    spooler_log.info(".. parameter [action]: " + this.getAction());
                } else {
                    throw new Exception("no action parameter [action] was specified");
                }

                if (params.value("file_list") != null && params.value("file_list").length() > 0) {
                    this.setFileList(params.value("file_list"));
                    spooler_log.info(".. parameter [file_list]: " + this.getFileList());
                } else {
                    if (this.getAction().equals("get")) throw new Exception("action [get] requires filenames being specified as parameter [file_list]");
                    this.setFileList("");
                }

               if (params.value("file_spec") != null && params.value("file_spec").length() > 0) {
                   this.setFileSpec(params.value("file_spec"));
                   spooler_log.info(".. parameter [file_spec]: " + this.getFileSpec());
               } else {
                   this.setFileSpec("^(.*)$");
               }

               if (params.value("local_dir") != null && params.value("local_dir").length() > 0) {
                   this.setLocalDir(this.normalizePath(params.value("local_dir")));
                   spooler_log.info(".. parameter [local_dir]: " + this.getLocalDir());
               } else {
                   this.setLocalDir(".");
               }

               if (params.value("remote_dir") != null && params.value("remote_dir").length() > 0) {
                   this.setRemoteDir(this.normalizePath(params.value("remote_dir")));
                   spooler_log.info(".. parameter [remote_dir]: " + this.getRemoteDir());
               } else {
                   this.setRemoteDir(".");
               }

               if (params.value("create_dir") != null && params.value("create_dir").length() > 0) {
                   if (params.value("create_dir").equalsIgnoreCase("true") || params.value("create_dir").equalsIgnoreCase("yes") || params.value("create_dir").equals("1")) {
                       this.setCreateDir(true);
                   } else {
                       this.setCreateDir(false);
                   }
                   spooler_log.info(".. parameter [create_dir]: " + this.isCreateDir());
               } else {
                   this.setCreateDir(true);
               }

               if (params.value("recursive") != null && params.value("recursive").length() > 0) {
                   if (params.value("recursive").equalsIgnoreCase("true") || params.value("recursive").equalsIgnoreCase("yes") || params.value("recursive").equals("1")) {
                       this.setRecursive(true);
                   } else {
                       this.setRecursive(false);
                   }
                   spooler_log.info(".. parameter [recursive]: " + this.isRecursive());
               } else {
                   this.setRecursive(false);
               }

               if (params.value("permissions") != null && params.value("permissions").length() > 0) {
                   try {
                       this.setPermissions(Integer.parseInt(params.value("permissions")));
                       spooler_log.info(".. parameter [permissions]: " + this.getPermissions());
                   } catch (Exception e) {
                       throw new Exception("illegal octal value for parameter [permissions]: " + params.value("permissions"));  
                   }
               } else {
                   this.setPermissions(0);
               }

           } catch (Exception e) {
               throw new Exception("error occurred processing parameters: " + e.getMessage());
           }
           
       
            try { // to connect, authenticate and process files
                this.getBaseAuthentication();
               
               
                scpClient = new SCPClient(this.getSshConnection());
               
               
                File localCheckDir = new File(this.getLocalDir());
                if (!localCheckDir.exists()) {
                    if (this.isCreateDir()) {
                        try {
                            // TODO use permissions: should no explicit permissions have been set then use the default permissions of the users home directory
                            localCheckDir.mkdirs();
                        } catch (Exception e) {
                            throw new Exception("error occurred creating local directory [" + this.getLocalDir() + "]: " + e.getMessage());
                        }
                    } else {
                        throw new Exception("local directory does not exist: " + this.getLocalDir());
                    }
                }
               
               
                // we know what we do: either String or File objects are stored in this Vector
                if (this.getFileList() != null && this.getFileList().length() > 0) {
                    // list of files for get or put operations
                    this.setFilenames(new Vector(Arrays.asList(this.getFileList().split(";"))));
                } else {
                    // list of files for put operations only
                  this.setFilenames(SOSFile.getFilelist( new File(this.getLocalDir()).getAbsolutePath(), this.getFileSpec(), java.util.regex.Pattern.MULTILINE,this.isRecursive()));
                }
               
               
                int count = 0;
                for(int i=0; i<this.getFilenames().size(); i++) {
                    try {
                        String filename = null;
                       
                        if (this.getFileList() != null && this.getFileList().length() > 0) {
                            filename = (String) this.getFilenames().get(i);
                        } else {
                            filename = ((File) this.getFilenames().get(i)).getAbsolutePath();
                        }
                       
                        if (this.getAction().equals("get")) {
                            if (this.getRemoteDir() != null && !this.getRemoteDir().equals(".")
                                && !filename.startsWith("/") && !filename.startsWith(":\\", 1))
                                filename = this.getRemoteDir() + "/" + filename;
                            spooler_log.info("file to receive: " + filename);
                        } else {
                            if (this.getLocalDir() != null && !this.getLocalDir().equals(".")
                                && !filename.startsWith("/") && !filename.startsWith(":\\", 1))
                                filename = this.getLocalDir() + "/" + filename;
                            spooler_log.info("file to send: " + filename);
                        }
                        this.getFilenames().setElementAt(filename, i);
                        count++;
                   
                    } catch (Exception e) {
                        throw new Exception(e.getMessage());
                    }
                }
               
                String[] files = new String[this.getFilenames().size()];
                this.getFilenames().toArray(files);
                if (this.getAction().equals("get")) {
                    scpClient.get(files, this.getLocalDir());
                } else {
                    if (this.getPermissions() > 0) {
                      if ( isRecursive() )
                           scp_recursive(new File(this.getLocalDir()),this.getRemoteDir(), scpClient);
                      else
                      scpClient.put(files, this.getRemoteDir());
                    } else {
                      if ( isRecursive() )
                      scp_recursive(new File(this.getLocalDir()),this.getRemoteDir(), scpClient);
                      else
                          scpClient.put(files, this.getRemoteDir());
                    }
                }
               
                switch (count) {
                    case 0:     throw new Exception("no matching files found");
View Full Code Here

      if (!SSHCmdHelper.sshExecuteCmd(sshConnection, "[ -f '/usr/sbin/dnsmasq' ]")) {
        throw new ConfigurationException("Cannot find dnsmasq at /usr/sbin/dnsmasq on " + _ip);
      }

      SCPClient scp = new SCPClient(sshConnection);
     
      String editHosts = "scripts/network/exdhcp/dnsmasq_edithosts.sh";
      String editHostsPath = Script.findScript("", editHosts);
      if (editHostsPath == null) {
        throw new ConfigurationException("Can not find script dnsmasq_edithosts.sh at " + editHosts);
      }
      scp.put(editHostsPath, "/usr/bin/", "0755");
     
      String prepareDnsmasq = "scripts/network/exdhcp/prepare_dnsmasq.sh";
      String prepareDnsmasqPath = Script.findScript("", prepareDnsmasq);
      if (prepareDnsmasqPath == null) {
        throw new ConfigurationException("Can not find script prepare_dnsmasq.sh at " + prepareDnsmasq);
      }
      scp.put(prepareDnsmasqPath, "/usr/bin/", "0755");

            /*
      String prepareCmd = String.format("sh /usr/bin/prepare_dnsmasq.sh %1$s %2$s %3$s", _gateway, _dns, _ip);
      if (!SSHCmdHelper.sshExecuteCmd(sshConnection, prepareCmd)) {
        throw new ConfigurationException("prepare dnsmasq at " + _ip + " failed");
View Full Code Here

            String cmd = String.format("[ -f /%1$s/pxelinux.0 ]", _tftpDir);
            if (!SSHCmdHelper.sshExecuteCmd(sshConnection, cmd)) {
                throw new ConfigurationException("Miss files in TFTP directory at " + _tftpDir + " check if pxelinux.0 are here");
            }

            SCPClient scp = new SCPClient(sshConnection);
            String prepareScript = "scripts/network/ping/prepare_kickstart_bootfile.py";
            String prepareScriptPath = Script.findScript("", prepareScript);
            if (prepareScriptPath == null) {
                throw new ConfigurationException("Can not find prepare_kickstart_bootfile.py at " + prepareScript);
            }
            scp.put(prepareScriptPath, "/usr/bin/", "0755");

            String cpScript = "scripts/network/ping/prepare_kickstart_kernel_initrd.py";
            String cpScriptPath = Script.findScript("", cpScript);
            if (cpScriptPath == null) {
                throw new ConfigurationException("Can not find prepare_kickstart_kernel_initrd.py at " + cpScript);
            }
            scp.put(cpScriptPath, "/usr/bin/", "0755");

            String userDataScript = "scripts/network/ping/baremetal_user_data.py";
            String userDataScriptPath = Script.findScript("", userDataScript);
            if (userDataScriptPath == null) {
                throw new ConfigurationException("Can not find baremetal_user_data.py at " + userDataScript);
            }
            scp.put(userDataScriptPath, "/usr/bin/", "0755");

            return true;
        } catch (Exception e) {
            throw new CloudRuntimeException(e);
        } finally {
View Full Code Here

        boolean success = false;
        boolean isAuthenticated = conn.authenticateWithPassword("vmops", "vmops");
        if (isAuthenticated == false) {
          return "Authentication failed";
        }
        SCPClient scp = new SCPClient(conn);
       
        scp.put("wget.exe", "");
       
        Session sess = conn.openSession();
        s_logger.info("Executing : wget http://172.16.0.220/dump.bin");
        sess.execCommand("wget http://172.16.0.220/dump.bin && dir dump.bin");
       
View Full Code Here

                } else {
                    s_logger.info("Authentication is successfull");
                }

                try {
                    SCPClient scp = new SCPClient(conn);
                    scp.put("wget.exe", "wget.exe", "C:\\Users\\Administrator", "0777");
                    s_logger.info("Successfully put wget.exe file");
                } catch (Exception ex) {
                    s_logger.error("Unable to put wget.exe " + ex);
                }
View Full Code Here

      String cmd = String.format("[ -f /%1$s/pxelinux.0 ] && [ -f /%2$s/kernel ] && [ -f /%3$s/initrd.gz ] ", _tftpDir, _tftpDir, _tftpDir);
      if (!SSHCmdHelper.sshExecuteCmd(sshConnection, cmd)) {
        throw new ConfigurationException("Miss files in TFTP directory at " + _tftpDir + " check if pxelinux.0, kernel initrd.gz are here");
      }
     
      SCPClient scp = new SCPClient(sshConnection)
      String prepareScript = "scripts/network/ping/prepare_tftp_bootfile.py";
      String prepareScriptPath = Script.findScript("", prepareScript);
      if (prepareScriptPath == null) {
        throw new ConfigurationException("Can not find prepare_tftp_bootfile.py at " + prepareScriptPath);
      }
      scp.put(prepareScriptPath, "/usr/bin/", "0755");
     
      String userDataScript = "scripts/network/ping/baremetal_user_data.py";
      String userDataScriptPath = Script.findScript("", userDataScript);
      if (userDataScriptPath == null) {
        throw new ConfigurationException("Can not find baremetal_user_data.py at " + userDataScriptPath);
      }
      scp.put(userDataScriptPath, "/usr/bin/", "0755");
     
      return true;
    } catch (Exception e) {
      throw new ConfigurationException(e.getMessage());
    } finally {
View Full Code Here

TOP

Related Classes of com.trilead.ssh2.crypto.cipher.AES

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.