Guest User

Untitled

a guest
Jan 10th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.00 KB | None | 0 0
  1. package bla;
  2.  
  3. import org.apache.cordova.CordovaPlugin;
  4. import org.apache.cordova.CallbackContext;
  5. import org.json.JSONArray;
  6. import org.json.JSONException;
  7. import org.json.JSONObject;
  8. import net.veritran.vttoken.sdk.AndroidSetup;
  9. import net.veritran.vttoken.sdk.VTResult;
  10. import net.veritran.vttoken.sdk.VTTokenAPI;
  11.  
  12. public class verit extends CordovaPlugin {
  13.  
  14. VTTokenAPI api;
  15.  
  16.  
  17. @Override
  18. public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
  19. if (action.equals("iniciar")) {
  20.  
  21. AndroidSetup.getInstance().init(cordova.getActivity());
  22. api = new VTTokenAPI("FFFFFF");
  23. } else {
  24.  
  25.  
  26. try {
  27. String msj = "";
  28.  
  29. VTResult res = api.getStatus();
  30. //callbackContext.success(/*res.getResponseCode() + */"solo hasta aqui");
  31. //String message = args.getString(0);
  32. // callbackContext.success(action);
  33.  
  34. if ( action.equals("getstatus")) {
  35. res = api.getStatus();
  36. callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus());
  37. return true;
  38.  
  39. } else if ( action.equals("Set Password")) {
  40. res = api.setPassword("password", null, null, 7);
  41. callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus());
  42. return true;
  43.  
  44. } else if ( action.equals("Init Session")) {
  45. res = api.initSession("password");
  46. callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus());
  47. return true;
  48.  
  49. } else if ( action.equals("Activate Token")) {
  50. res = api.activateToken("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa");
  51. callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus());
  52. return true;
  53. }
  54. else if ( action.equals("Generate OTP")) {
  55. res = api.generateOTP("VRTR-1:HOTP-SHA1-5:C-S", null, null, null, null);
  56. callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus() + "otp: " + res.getOtp());
  57. return true;
  58. } else if ( action.equals("Destroy Token")) {
  59. res = api.destroyToken();
  60. callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus());
  61. return true;
  62.  
  63. }
  64.  
  65. } catch(Exception e) {
  66. callbackContext.success("ERROR" + e.getMessage());
  67. return true;
  68. }
  69.  
  70.  
  71.  
  72. }
  73.  
  74.  
  75.  
  76. return true;
  77.  
  78. }
  79.  
  80.  
  81. }
  82.  
  83. var coolMethod = {
  84.  
  85. send: function(successCallback, errorCallback,accion, activationCode, ctkipURL){
  86. cordova.exec(successCallback,
  87. errorCallback,
  88. "verit",
  89. accion,
  90. [activationCode,ctkipURL]
  91. );
  92.  
  93. }
  94. }
Add Comment
Please, Sign In to add comment