Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package bla;
- import org.apache.cordova.CordovaPlugin;
- import org.apache.cordova.CallbackContext;
- import org.json.JSONArray;
- import org.json.JSONException;
- import org.json.JSONObject;
- import net.veritran.vttoken.sdk.AndroidSetup;
- import net.veritran.vttoken.sdk.VTResult;
- import net.veritran.vttoken.sdk.VTTokenAPI;
- public class verit extends CordovaPlugin {
- VTTokenAPI api;
- @Override
- public boolean execute(String action, JSONArray args, final CallbackContext callbackContext) throws JSONException {
- if (action.equals("iniciar")) {
- AndroidSetup.getInstance().init(cordova.getActivity());
- api = new VTTokenAPI("FFFFFF");
- } else {
- try {
- String msj = "";
- VTResult res = api.getStatus();
- //callbackContext.success(/*res.getResponseCode() + */"solo hasta aqui");
- //String message = args.getString(0);
- // callbackContext.success(action);
- if ( action.equals("getstatus")) {
- res = api.getStatus();
- callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus());
- return true;
- } else if ( action.equals("Set Password")) {
- res = api.setPassword("password", null, null, 7);
- callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus());
- return true;
- } else if ( action.equals("Init Session")) {
- res = api.initSession("password");
- callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus());
- return true;
- } else if ( action.equals("Activate Token")) {
- res = api.activateToken("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa", "aaaaaaaaaaaaaaaaaaaa");
- callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus());
- return true;
- }
- else if ( action.equals("Generate OTP")) {
- res = api.generateOTP("VRTR-1:HOTP-SHA1-5:C-S", null, null, null, null);
- callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus() + "otp: " + res.getOtp());
- return true;
- } else if ( action.equals("Destroy Token")) {
- res = api.destroyToken();
- callbackContext.success("response code: " + res.getResponseCode() + "status: " + res.getStatus());
- return true;
- }
- } catch(Exception e) {
- callbackContext.success("ERROR" + e.getMessage());
- return true;
- }
- }
- return true;
- }
- }
- var coolMethod = {
- send: function(successCallback, errorCallback,accion, activationCode, ctkipURL){
- cordova.exec(successCallback,
- errorCallback,
- "verit",
- accion,
- [activationCode,ctkipURL]
- );
- }
- }
Add Comment
Please, Sign In to add comment