diff options
author | Arne Schwabe <arne@rfc2549.org> | 2014-01-25 14:57:40 +0100 |
---|---|---|
committer | Arne Schwabe <arne@rfc2549.org> | 2014-01-25 14:57:40 +0100 |
commit | 0cf62450e017a031afc637841a34105c25279067 (patch) | |
tree | 03817181a371a492b8b84ec73af24f80deb4f3b0 /src/de/blinkt/openvpn/fragments | |
parent | 491ea0e8bd9a9e200d2fe4e54c0084d54642eb3e (diff) |
Add the ability to select missing files from Convert Dialog
Diffstat (limited to 'src/de/blinkt/openvpn/fragments')
-rw-r--r-- | src/de/blinkt/openvpn/fragments/Settings_Basic.java | 8 | ||||
-rw-r--r-- | src/de/blinkt/openvpn/fragments/Utils.java | 51 |
2 files changed, 49 insertions, 10 deletions
diff --git a/src/de/blinkt/openvpn/fragments/Settings_Basic.java b/src/de/blinkt/openvpn/fragments/Settings_Basic.java index f2fab505..4145c65f 100644 --- a/src/de/blinkt/openvpn/fragments/Settings_Basic.java +++ b/src/de/blinkt/openvpn/fragments/Settings_Basic.java @@ -35,7 +35,7 @@ import de.blinkt.openvpn.core.X509Utils; import java.security.cert.X509Certificate; -public class Settings_Basic extends Fragment implements View.OnClickListener, OnItemSelectedListener, Callback { +public class Settings_Basic extends Fragment implements View.OnClickListener, OnItemSelectedListener, Callback, FileSelectLayout.FileSelectCallback { private static final int CHOOSE_FILE_OFFSET = 1000; private static final int UPDATE_ALIAS = 20; @@ -66,7 +66,7 @@ public class Settings_Basic extends Fragment implements View.OnClickListener, On private void addFileSelectLayout (FileSelectLayout fsl, Utils.FileType type) { int i = fileselects.size() + CHOOSE_FILE_OFFSET; fileselects.put(i, fsl); - fsl.setFragment(this,i,type); + fsl.setCaller(this, i, type); } public void onCreate(Bundle savedInstanceState) { @@ -140,8 +140,8 @@ public class Settings_Basic extends Fragment implements View.OnClickListener, On mPassword = (EditText) mView.findViewById(R.id.auth_password); mKeyPassword = (EditText) mView.findViewById(R.id.key_password); - addFileSelectLayout(mCaCert, Utils.FileType.CERTIFICATE); - addFileSelectLayout(mClientCert, Utils.FileType.CERTIFICATE); + addFileSelectLayout(mCaCert, Utils.FileType.CA_CERTIFICATE); + addFileSelectLayout(mClientCert, Utils.FileType.CLIENT_CERTIFICATE); addFileSelectLayout(mClientKey, Utils.FileType.KEYFILE); addFileSelectLayout(mpkcs12, Utils.FileType.PKCS12); mCaCert.setShowClear(); diff --git a/src/de/blinkt/openvpn/fragments/Utils.java b/src/de/blinkt/openvpn/fragments/Utils.java index d7a144ed..f13b1987 100644 --- a/src/de/blinkt/openvpn/fragments/Utils.java +++ b/src/de/blinkt/openvpn/fragments/Utils.java @@ -7,6 +7,7 @@ import android.net.Uri; import android.os.Build; import android.util.Base64; import android.webkit.MimeTypeMap; +import junit.framework.Assert; import java.io.*; import java.util.TreeSet; @@ -28,7 +29,8 @@ public class Utils { extensions.add("p12"); extensions.add("pfx"); break; - case CERTIFICATE: + case CLIENT_CERTIFICATE: + case CA_CERTIFICATE: i.setType("application/x-pem-file"); supportedMimeTypes.add("application/x-x509-ca-cert"); supportedMimeTypes.add("application/x-x509-user-cert"); @@ -61,6 +63,9 @@ public class Utils { extensions.add("txt"); extensions.add("key"); break; + case USERPW_FILE: + Assert.fail(); + break; } MimeTypeMap mtm = MimeTypeMap.getSingleton(); @@ -78,11 +83,45 @@ public class Utils { } public enum FileType { - PKCS12, - CERTIFICATE, - OVPN_CONFIG, - KEYFILE, - TLS_AUTH_FILE + PKCS12(0), + CLIENT_CERTIFICATE(1), + CA_CERTIFICATE(2), + OVPN_CONFIG(3), + KEYFILE(4), + TLS_AUTH_FILE(5), + USERPW_FILE(6); + + private int value; + + FileType(int i) { + value=i; + } + + public static FileType getFileTypeByValue(int value) + { + switch(value) { + case 0: + return PKCS12; + case 1: + return CLIENT_CERTIFICATE; + case 2: + return CA_CERTIFICATE; + case 3: + return OVPN_CONFIG; + case 4: + return KEYFILE; + case 5: + return TLS_AUTH_FILE; + case 6: + return USERPW_FILE; + default: + return null; + } + } + + public int getValue() { + return value; + } } static private byte[] readBytesFromStream(InputStream input) throws IOException { |