android: Move TrustedCertificateEntry to a new package
authorTobias Brunner <tobias@strongswan.org>
Fri, 30 May 2014 10:40:53 +0000 (12:40 +0200)
committerTobias Brunner <tobias@strongswan.org>
Tue, 22 Jul 2014 08:41:49 +0000 (10:41 +0200)
src/frontends/android/src/org/strongswan/android/data/TrustedCertificateEntry.java [deleted file]
src/frontends/android/src/org/strongswan/android/security/TrustedCertificateEntry.java [new file with mode: 0644]
src/frontends/android/src/org/strongswan/android/ui/TrustedCertificateListFragment.java
src/frontends/android/src/org/strongswan/android/ui/TrustedCertificatesActivity.java
src/frontends/android/src/org/strongswan/android/ui/VpnProfileDetailActivity.java
src/frontends/android/src/org/strongswan/android/ui/adapter/TrustedCertificateAdapter.java

diff --git a/src/frontends/android/src/org/strongswan/android/data/TrustedCertificateEntry.java b/src/frontends/android/src/org/strongswan/android/data/TrustedCertificateEntry.java
deleted file mode 100644 (file)
index de7ea32..0000000
+++ /dev/null
@@ -1,133 +0,0 @@
-/*
- * Copyright (C) 2012 Tobias Brunner
- * 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
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
- * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
- * for more details.
- */
-
-package org.strongswan.android.data;
-
-import java.security.cert.X509Certificate;
-
-import android.net.http.SslCertificate;
-
-public class TrustedCertificateEntry implements Comparable<TrustedCertificateEntry>
-{
-       private final X509Certificate mCert;
-       private final String mAlias;
-       private String mSubjectPrimary;
-       private String mSubjectSecondary = "";
-       private String mString;
-
-       /**
-        * Create an entry for certificate lists.
-        *
-        * @param alias alias of the certificate (as used in the KeyStore)
-        * @param cert certificate associated with that alias
-        */
-       public TrustedCertificateEntry(String alias, X509Certificate cert)
-       {
-               mCert = cert;
-               mAlias = alias;
-
-               SslCertificate ssl = new SslCertificate(mCert);
-               String o = ssl.getIssuedTo().getOName();
-               String ou = ssl.getIssuedTo().getUName();
-               String cn = ssl.getIssuedTo().getCName();
-               if (!o.isEmpty())
-               {
-                       mSubjectPrimary = o;
-                       if (!cn.isEmpty())
-                       {
-                               mSubjectSecondary = cn;
-                       }
-                       else if (!ou.isEmpty())
-                       {
-                               mSubjectSecondary = ou;
-                       }
-               }
-               else if (!cn.isEmpty())
-               {
-                       mSubjectPrimary = cn;
-               }
-               else
-               {
-                       mSubjectPrimary = ssl.getIssuedTo().getDName();
-               }
-       }
-
-       /**
-        * The main subject of this certificate (O, CN or the complete DN, whatever
-        * is found first).
-        *
-        * @return the main subject
-        */
-       public String getSubjectPrimary()
-       {
-               return mSubjectPrimary;
-       }
-
-       /**
-        * Get the secondary subject of this certificate (either CN or OU if primary
-        * subject is O, empty otherwise)
-        *
-        * @return the secondary subject
-        */
-       public String getSubjectSecondary()
-       {
-               return mSubjectSecondary;
-       }
-
-       /**
-        * The alias associated with this certificate.
-        *
-        * @return KeyStore alias of this certificate
-        */
-       public String getAlias()
-       {
-               return mAlias;
-       }
-
-       /**
-        * The certificate.
-        *
-        * @return certificate
-        */
-       public X509Certificate getCertificate()
-       {
-               return mCert;
-       }
-
-       @Override
-       public String toString()
-       {       /* combination of both subject lines, used for filtering lists */
-               if (mString == null)
-               {
-                       mString = mSubjectPrimary;
-                       if (!mSubjectSecondary.isEmpty())
-                       {
-                               mString += ", " + mSubjectSecondary;
-                       }
-               }
-               return mString;
-       }
-
-       @Override
-       public int compareTo(TrustedCertificateEntry another)
-       {
-               int diff = mSubjectPrimary.compareToIgnoreCase(another.mSubjectPrimary);
-               if (diff == 0)
-               {
-                       diff = mSubjectSecondary.compareToIgnoreCase(another.mSubjectSecondary);
-               }
-               return diff;
-       }
-}
diff --git a/src/frontends/android/src/org/strongswan/android/security/TrustedCertificateEntry.java b/src/frontends/android/src/org/strongswan/android/security/TrustedCertificateEntry.java
new file mode 100644 (file)
index 0000000..143741f
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * Copyright (C) 2012 Tobias Brunner
+ * 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
+ * Free Software Foundation; either version 2 of the License, or (at your
+ * option) any later version.  See <http://www.fsf.org/copyleft/gpl.txt>.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * for more details.
+ */
+
+package org.strongswan.android.security;
+
+import java.security.cert.X509Certificate;
+
+import android.net.http.SslCertificate;
+
+public class TrustedCertificateEntry implements Comparable<TrustedCertificateEntry>
+{
+       private final X509Certificate mCert;
+       private final String mAlias;
+       private String mSubjectPrimary;
+       private String mSubjectSecondary = "";
+       private String mString;
+
+       /**
+        * Create an entry for certificate lists.
+        *
+        * @param alias alias of the certificate (as used in the KeyStore)
+        * @param cert certificate associated with that alias
+        */
+       public TrustedCertificateEntry(String alias, X509Certificate cert)
+       {
+               mCert = cert;
+               mAlias = alias;
+
+               SslCertificate ssl = new SslCertificate(mCert);
+               String o = ssl.getIssuedTo().getOName();
+               String ou = ssl.getIssuedTo().getUName();
+               String cn = ssl.getIssuedTo().getCName();
+               if (!o.isEmpty())
+               {
+                       mSubjectPrimary = o;
+                       if (!cn.isEmpty())
+                       {
+                               mSubjectSecondary = cn;
+                       }
+                       else if (!ou.isEmpty())
+                       {
+                               mSubjectSecondary = ou;
+                       }
+               }
+               else if (!cn.isEmpty())
+               {
+                       mSubjectPrimary = cn;
+               }
+               else
+               {
+                       mSubjectPrimary = ssl.getIssuedTo().getDName();
+               }
+       }
+
+       /**
+        * The main subject of this certificate (O, CN or the complete DN, whatever
+        * is found first).
+        *
+        * @return the main subject
+        */
+       public String getSubjectPrimary()
+       {
+               return mSubjectPrimary;
+       }
+
+       /**
+        * Get the secondary subject of this certificate (either CN or OU if primary
+        * subject is O, empty otherwise)
+        *
+        * @return the secondary subject
+        */
+       public String getSubjectSecondary()
+       {
+               return mSubjectSecondary;
+       }
+
+       /**
+        * The alias associated with this certificate.
+        *
+        * @return KeyStore alias of this certificate
+        */
+       public String getAlias()
+       {
+               return mAlias;
+       }
+
+       /**
+        * The certificate.
+        *
+        * @return certificate
+        */
+       public X509Certificate getCertificate()
+       {
+               return mCert;
+       }
+
+       @Override
+       public String toString()
+       {       /* combination of both subject lines, used for filtering lists */
+               if (mString == null)
+               {
+                       mString = mSubjectPrimary;
+                       if (!mSubjectSecondary.isEmpty())
+                       {
+                               mString += ", " + mSubjectSecondary;
+                       }
+               }
+               return mString;
+       }
+
+       @Override
+       public int compareTo(TrustedCertificateEntry another)
+       {
+               int diff = mSubjectPrimary.compareToIgnoreCase(another.mSubjectPrimary);
+               if (diff == 0)
+               {
+                       diff = mSubjectSecondary.compareToIgnoreCase(another.mSubjectSecondary);
+               }
+               return diff;
+       }
+}
index 4e8e0dd..2f07b96 100644 (file)
@@ -23,8 +23,8 @@ import java.util.List;
 import java.util.Map.Entry;
 
 import org.strongswan.android.R;
-import org.strongswan.android.data.TrustedCertificateEntry;
 import org.strongswan.android.logic.TrustedCertificateManager;
+import org.strongswan.android.security.TrustedCertificateEntry;
 import org.strongswan.android.ui.adapter.TrustedCertificateAdapter;
 
 import android.app.Activity;
index 967d25a..2874207 100644 (file)
@@ -16,8 +16,8 @@
 package org.strongswan.android.ui;
 
 import org.strongswan.android.R;
-import org.strongswan.android.data.TrustedCertificateEntry;
 import org.strongswan.android.data.VpnProfileDataSource;
+import org.strongswan.android.security.TrustedCertificateEntry;
 
 import android.app.ActionBar;
 import android.app.ActionBar.Tab;
index baad961..6cc6b0c 100644 (file)
@@ -20,11 +20,11 @@ package org.strongswan.android.ui;
 import java.security.cert.X509Certificate;
 
 import org.strongswan.android.R;
-import org.strongswan.android.data.TrustedCertificateEntry;
 import org.strongswan.android.data.VpnProfile;
 import org.strongswan.android.data.VpnProfileDataSource;
 import org.strongswan.android.data.VpnType;
 import org.strongswan.android.logic.TrustedCertificateManager;
+import org.strongswan.android.security.TrustedCertificateEntry;
 
 import android.app.Activity;
 import android.app.AlertDialog;
index a97360d..3795bb1 100644 (file)
@@ -18,7 +18,7 @@ package org.strongswan.android.ui.adapter;
 import java.util.List;
 
 import org.strongswan.android.R;
-import org.strongswan.android.data.TrustedCertificateEntry;
+import org.strongswan.android.security.TrustedCertificateEntry;
 
 import android.content.Context;
 import android.view.LayoutInflater;