/*
- * Copyright (C) 2014 Tobias Brunner
- * Hochschule fuer Technik Rapperswil
+ * Copyright (C) 2014-2017 Tobias Brunner
+ * HSR Hochschule fuer Technik Rapperswil
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
}
return new String(hex);
}
+
+ /**
+ * Validate the given proposal string
+ *
+ * @param ike true for IKE, false for ESP
+ * @param proposal proposal string
+ * @return true if valid
+ */
+ public native static boolean isProposalValid(boolean ike, String proposal);
}
initiate(settings);
}
+
+/**
+ * Utility function to verify proposal strings (static, so `this` is the class)
+ */
+JNI_METHOD_P(org_strongswan_android_utils, Utils, isProposalValid, jboolean,
+ jboolean ike, jstring proposal)
+{
+ proposal_t *prop;
+ char *str;
+ bool valid;
+
+ dbg = dbg_android;
+
+ if (!library_init(NULL, "charon"))
+ {
+ library_deinit();
+ return FALSE;
+ }
+ str = androidjni_convert_jstring(env, proposal);
+ prop = proposal_create_from_string(ike ? PROTO_IKE : PROTO_ESP, str);
+ valid = prop != NULL;
+ DESTROY_IF(prop);
+ free(str);
+ library_deinit();
+ return valid;
+}