Android Open Source - dCache-Cloud Import Data Activity






From Project

Back to project page dCache-Cloud.

License

The source code is released under:

Copyright ? 2013, Michael Stapelberg and contributors All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following ...

If you think the Android project dCache-Cloud 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 de.desy.dCacheCloud.Activities;
/*from ww w  .j  a  v  a2s  . c o m*/
import android.app.Activity;
import android.os.Bundle;
import android.util.Base64;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import de.desy.dCacheCloud.CryptoHelper;
import de.desy.dCacheCloud.DatabaseHelper;
import de.desy.dCacheCloud.KeyStoreHelper;
import de.desy.dCacheCloud.R;

public class ImportDataActivity extends Activity implements android.view.View.OnClickListener{

  private EditText etData = null;
  private Button btnDataOk = null;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    setContentView(R.layout.activity_import_data);
    etData = (EditText)findViewById(R.id.etData);
    btnDataOk = (Button)findViewById(R.id.btnDataOk);
    btnDataOk.setOnClickListener(this);
    
    super.onCreate(savedInstanceState);
  }

  @Override
  protected void onResume() {
    super.onResume();
  }

  @Override
  public void onClick(View v) {

    switch (v.getId())
    {
    case R.id.btnDataOk:
      
      String content = etData.getText().toString();
      
      if (!content.equals(""))
      {
        DatabaseHelper dbh = new DatabaseHelper(getApplicationContext());
        
        // TODO: parse!
        byte[] encrypted = Base64.decode(content, Base64.DEFAULT);
        byte[] decrypted = CryptoHelper.decryptAsymmetric(encrypted, false, KeyStoreHelper.getOwnPriv());
        // decrypted is split in signature and message
        byte[] signature = new byte[1024];
        byte[] message = new byte[decrypted.length - 1024];
        System.arraycopy(decrypted, decrypted.length - 1024, signature, 0, 1024);
        System.arraycopy(decrypted, 0, message, 0, decrypted.length - 1024);
        
        byte[] messageHash = CryptoHelper.decryptAsymmetric(signature, true, dbh.getPersonPublicKey("???"));
        
        Toast.makeText(getApplicationContext(), content, Toast.LENGTH_LONG).show();
      }
      else
      {
        Toast.makeText(getApplicationContext(), "Please import data!", Toast.LENGTH_LONG).show();
      }
      
      break;
    }
    
  }

  
  
}




Java Source Code List

External.Contents.java
External.IntentIntegrator.java
External.IntentResult.java
External.QRCodeEncoder.java
de.desy.dCacheCloud.CountingInputStreamEntity.java
de.desy.dCacheCloud.CryptoHelper.java
de.desy.dCacheCloud.DatabaseHelper.java
de.desy.dCacheCloud.DownloadService.java
de.desy.dCacheCloud.KeyStoreHelper.java
de.desy.dCacheCloud.MySSLSocketFactory.java
de.desy.dCacheCloud.ServerHelper.java
de.desy.dCacheCloud.UploadService.java
de.desy.dCacheCloud.Activities.FriendFoundActivity.java
de.desy.dCacheCloud.Activities.ImportDataActivity.java
de.desy.dCacheCloud.Activities.MainActivity.java
de.desy.dCacheCloud.Activities.ProfileActivity.java
de.desy.dCacheCloud.Activities.ServerViewActivity.java
de.desy.dCacheCloud.Activities.SettingsActivity.java
de.desy.dCacheCloud.Activities.ShareDataActivity.java
de.desy.dCacheCloud.Activities.ShareWithFriendActivity.java
de.desy.dCacheCloud.Activities.UploadActivity.java
de.desy.dCacheCloud.Activities.UserPasswordActivity.java
de.desy.dCacheCloud.BCReceiver.NetworkReceiver.java
de.desy.dCacheCloud.BCReceiver.NewMediaReceiver.java