Android Open Source - SmartPass Send Password Task






From Project

Back to project page SmartPass.

License

The source code is released under:

Copyright (c) 2013 Dax Earl, Aaron Golliver Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal ...

If you think the Android project SmartPass listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.passwordLib;
//from w  w w  .ja v  a 2  s  . c  o m
import android.content.Context;
import android.os.AsyncTask;

import com.jcraft.jsch.Channel;
import com.jcraft.jsch.ChannelSftp;
import com.jcraft.jsch.JSch;
import com.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
import com.jcraft.jsch.SftpException;

public class SendPasswordTask extends AsyncTask<Object, Void, Boolean> {

  Context context;
  String username;
  String password;

  @Override
  protected Boolean doInBackground(Object... params) {
    System.out.println("get args " + params[0]);
    context = (Context) (params[0]);
    System.out.println("get args " + params[1]);
    username = (String) (params[1]);
    System.out.println("get args " + params[2]);
    password = (String) (params[2]);
    JSch jsch = new JSch();
    Session session = null;

    final String SERVER = "app.smartfile.com";
    final String USERNAME = PasswordFile.username;
    final String PASSWORD = PasswordFile.password;

    PasswordFile.saveFile();

    String fileName = PasswordFile.fileName;

    try {
      session = jsch.getSession(USERNAME, SERVER, 22);

      session.setConfig("StrictHostKeyChecking", "no");

      session.setPassword(PASSWORD);

      session.connect();

      Channel channel = session.openChannel("sftp");

      channel.connect();

      ChannelSftp sftpChannel = (ChannelSftp) channel;

      sftpChannel.put(context.getFilesDir() + "/" + fileName, fileName);

      sftpChannel.exit();

    } catch (JSchException e) {
      e.printStackTrace();
    } catch (SftpException e) {
      e.printStackTrace();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return true;
  }

  @Override
  protected void onPostExecute(Boolean result) {
    // do nothing
  }

}




Java Source Code List

com.example.smartpass.ClearClipboard.java
com.example.smartpass.CopyPasswordToClipboard.java
com.example.smartpass.CopyUsernameToClipboard.java
com.example.smartpass.DeletePassword.java
com.example.smartpass.LoginScreen.java
com.example.smartpass.NewAccount.java
com.example.smartpass.NewFolder.java
com.example.smartpass.PasswordList.java
com.example.smartpass.UserAccount.java
com.example.smartpass.Adapter.NothingSelectedSpinnerAdapter.java
com.example.smartpass.Adapter.PasswordListAdapter.java
com.example.smartpass.Classes.ExpandListChild.java
com.example.smartpass.Classes.ExpandListGroup.java
com.passwordLib.Main.java
com.passwordLib.PasswordFile.java
com.passwordLib.PasswordLib.java
com.passwordLib.RetrivePasswordTask.java
com.passwordLib.SendPasswordTask.java
com.passwordLib.SimpleCrypto.java