From 26d66a9b4659082efeb4b99224d22120a8f4632d Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Thu, 6 Aug 2015 15:20:45 +0200 Subject: Ignore crl config option by default, only add it when a matching file was found --- .../blinkt/openvpn/activities/ConfigConverter.java | 35 ++++++++++++---------- .../openvpn/fragments/Settings_Connections.java | 1 + 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java b/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java index a1012f32..e50250cf 100644 --- a/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java +++ b/main/src/main/java/de/blinkt/openvpn/activities/ConfigConverter.java @@ -63,7 +63,7 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie public static final String VPNPROFILE = "vpnProfile"; private VpnProfile mResult; - + private transient List mPathsegments; private String mAliasName = null; @@ -118,7 +118,6 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie outState.putString("mAliasName", mAliasName); - String[] logentries = mLogEntries.toArray(new String[mLogEntries.size()]); outState.putStringArray("logentries", logentries); @@ -130,7 +129,7 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie k++; } outState.putIntArray("fileselects", fileselects); - outState.putString("pwfile",mEmbeddedPwFile); + outState.putString("pwfile", mEmbeddedPwFile); outState.putString("crlfile", mCrlFileName); } @@ -186,11 +185,12 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie if (!TextUtils.isEmpty(mEmbeddedPwFile)) ConfigParser.useEmbbedUserAuth(mResult, mEmbeddedPwFile); - if (!TextUtils.isEmpty(mCrlFileName)) - { - // TODO: COnvert this to a real config option that is parsed - ConfigParser.removeCRLCustomOption(mResult); - mResult.mCustomConfigOptions += "crl-verify " + mCrlFileName; + + // Only use crl on import if it is found + ConfigParser.removeCRLCustomOption(mResult); + if (TextUtils.isEmpty(mCrlFileName)) { + // TODO: Convert this to a real config option that is parsed + mResult.mCustomConfigOptions += "\ncrl-verify " + mCrlFileName; } vpl.addProfile(mResult); @@ -303,7 +303,7 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie return true; } - private String embedFile(String filename, Utils.FileType type, boolean onlyFindFile) { + private String embedFile(String filename, Utils.FileType type, boolean onlyFindFileAndNullonNotFound) { if (filename == null) return null; @@ -313,8 +313,11 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie File possibleFile = findFile(filename, type); if (possibleFile == null) - return filename; - else if (onlyFindFile) + if (onlyFindFileAndNullonNotFound) + return null; + else + return filename; + else if (onlyFindFileAndNullonNotFound) return possibleFile.getAbsolutePath(); else return readFileContent(possibleFile, type == Utils.FileType.PKCS12); @@ -524,7 +527,7 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie super.onCreate(savedInstanceState); ImageButton fab_button = (ImageButton) findViewById(R.id.fab_save); - if(fab_button!=null) + if (fab_button != null) fab_button.setOnClickListener(this); if (savedInstanceState != null && savedInstanceState.containsKey(VPNPROFILE)) { @@ -571,12 +574,12 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie mPathsegments = data.getPathSegments(); Cursor cursor = null; - if (data!=null) - cursor = getContentResolver().query(data, null, null, null, null); + if (data != null) + cursor = getContentResolver().query(data, null, null, null, null); try { - if (cursor!=null && cursor.moveToFirst()) { + if (cursor != null && cursor.moveToFirst()) { int columnIndex = cursor.getColumnIndex(OpenableColumns.DISPLAY_NAME); if (columnIndex != -1) { @@ -590,7 +593,7 @@ public class ConfigConverter extends Activity implements FileSelectCallback, Vie } } } finally { - if(cursor!=null) + if (cursor != null) cursor.close(); } if (possibleName != null) { diff --git a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java index 03c5f27e..619d39a6 100644 --- a/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java +++ b/main/src/main/java/de/blinkt/openvpn/fragments/Settings_Connections.java @@ -11,6 +11,7 @@ import android.os.Bundle; import android.support.annotation.Nullable; import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.RecyclerView; +import android.support.v7.widget.StaggeredGridLayoutManager; import android.view.LayoutInflater; import android.view.Menu; import android.view.MenuInflater; -- cgit v1.2.3