From 2a9037c749d3395ac65105604ab4936c4af0fc56 Mon Sep 17 00:00:00 2001 From: Arne Schwabe Date: Mon, 20 May 2013 09:55:50 +0200 Subject: Add certificate CN print Need to fix string for email and order --HG-- extra : rebase_source : c3d5858d53d2f8f340b0d4a07434021f194a247a --- src/de/blinkt/openvpn/FileSelectLayout.java | 33 +++++---- src/de/blinkt/openvpn/VpnProfile.java | 21 ++---- src/de/blinkt/openvpn/core/X509Utils.java | 78 ++++++++++++++++++++++ .../blinkt/openvpn/fragments/Settings_Basic.java | 8 +-- 4 files changed, 108 insertions(+), 32 deletions(-) create mode 100644 src/de/blinkt/openvpn/core/X509Utils.java (limited to 'src/de/blinkt/openvpn') diff --git a/src/de/blinkt/openvpn/FileSelectLayout.java b/src/de/blinkt/openvpn/FileSelectLayout.java index b7e28b5c..d7bcc475 100644 --- a/src/de/blinkt/openvpn/FileSelectLayout.java +++ b/src/de/blinkt/openvpn/FileSelectLayout.java @@ -1,5 +1,6 @@ package de.blinkt.openvpn; +import de.blinkt.openvpn.core.X509Utils; import android.app.Fragment; import android.content.Context; import android.content.Intent; @@ -22,19 +23,21 @@ public class FileSelectLayout extends LinearLayout implements OnClickListener { private boolean mBase64Encode; private String mTitle; private boolean mShowClear; + private TextView mDataDetails; public FileSelectLayout( Context context,AttributeSet attrset) { super(context,attrset); inflate(getContext(), R.layout.file_select, this); - + TypedArray ta = context.obtainStyledAttributes(attrset,R.styleable.FileSelectLayout); - + mTitle = ta.getString(R.styleable.FileSelectLayout_title); - + TextView tview = (TextView) findViewById(R.id.file_title); tview.setText(mTitle); - + mDataView = (TextView) findViewById(R.id.file_selected_item); + mDataDetails = (TextView) findViewById(R.id.file_selected_description); mSelectButton = (Button) findViewById(R.id.file_select_button); mSelectButton.setOnClickListener(this); @@ -46,7 +49,7 @@ public class FileSelectLayout extends LinearLayout implements OnClickListener { mTaskId = i; mFragment = fragment; } - + public void getCertificateFileDialog() { Intent startFC = new Intent(getContext(),FileSelect.class); startFC.putExtra(FileSelect.START_DATA, mData); @@ -58,20 +61,24 @@ public class FileSelectLayout extends LinearLayout implements OnClickListener { mFragment.startActivityForResult(startFC,mTaskId); } - + public String getData() { return mData; } public void setData(String data) { mData = data; - if(data==null) + if(data==null) { mDataView.setText(mFragment.getString(R.string.no_data)); - else if(mData.startsWith(VpnProfile.INLINE_TAG)) - mDataView.setText(R.string.inline_file_data); - else - mDataView.setText(data); - + mDataDetails.setText(""); + }else { + if(mData.startsWith(VpnProfile.INLINE_TAG)) + mDataView.setText(R.string.inline_file_data); + else + mDataView.setText(data); + mDataDetails.setText(X509Utils.getCertificateFriendlyName(data)); + } + } @Override @@ -88,5 +95,5 @@ public class FileSelectLayout extends LinearLayout implements OnClickListener { public void setShowClear() { mShowClear=true; } - + } diff --git a/src/de/blinkt/openvpn/VpnProfile.java b/src/de/blinkt/openvpn/VpnProfile.java index 9d183897..03fcbc1b 100644 --- a/src/de/blinkt/openvpn/VpnProfile.java +++ b/src/de/blinkt/openvpn/VpnProfile.java @@ -45,6 +45,7 @@ import de.blinkt.openvpn.R; import de.blinkt.openvpn.core.NativeUtils; import de.blinkt.openvpn.core.OpenVPN; import de.blinkt.openvpn.core.OpenVpnService; +import de.blinkt.openvpn.core.X509Utils; public class VpnProfile implements Serializable{ // Note that this class cannot be moved to core where it belongs since @@ -52,7 +53,7 @@ public class VpnProfile implements Serializable{ // The Serializable documentation mentions that class name change are possible // but the how is unclear // - + private static final long serialVersionUID = 7085688938959334563L; public static final int TYPE_CERTIFICATES=0; public static final int TYPE_PKCS12=1; @@ -79,7 +80,7 @@ public class VpnProfile implements Serializable{ public transient String mTransientPW=null; public transient String mTransientPCKS12PW=null; private transient PrivateKey mPrivateKey; - + // variable named wrong and should haven beeen transient // but needs to keep wrong name to guarante loading of old // profiles @@ -590,7 +591,7 @@ public class VpnProfile implements Serializable{ if(nonNull(mCaFilename)) { try { - Certificate cacert = getCacertFromFile(); + Certificate cacert = X509Utils.getCertificateFromFile(mCaFilename); X509Certificate[] newcachain = new X509Certificate[cachain.length+1]; for(int i=0;i