import org.strongswan.android.ui.widget.TextInputLayoutHelper;
import org.strongswan.android.utils.Constants;
import org.strongswan.android.utils.IPRangeSet;
+import org.strongswan.android.utils.Utils;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
}
}
- profile.setIkeProposal(obj.optString("ike-proposal", null));
- profile.setEspProposal(obj.optString("esp-proposal", null));
+ profile.setIkeProposal(getProposal(obj, "ike-proposal", true));
+ profile.setEspProposal(getProposal(obj, "esp-proposal", false));
profile.setMTU(getInteger(obj, "mtu", Constants.MTU_MIN, Constants.MTU_MAX));
profile.setNATKeepAlive(getInteger(obj, "nat-keepalive", Constants.NAT_KEEPALIVE_MIN, Constants.NAT_KEEPALIVE_MAX));
JSONObject split = obj.optJSONObject("split-tunneling");
return res < min || res > max ? null : res;
}
+ private String getProposal(JSONObject obj, String key, boolean ike) throws JSONException
+ {
+ String value = obj.optString(key, null);
+ if (!TextUtils.isEmpty(value))
+ {
+ if (!Utils.isProposalValid(ike, value))
+ {
+ throw new JSONException(getString(R.string.profile_import_failed_value, key));
+ }
+ }
+ return value;
+ }
+
private String getSubnets(JSONObject split, String key) throws JSONException
{
ArrayList<String> subnets = new ArrayList<>();