2 * Copyright (C) 2016 Tobias Brunner
3 * HSR Hochschule fuer Technik Rapperswil
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License as published by the
7 * Free Software Foundation; either version 2 of the License, or (at your
8 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 package org.strongswan.android.ui.adapter;
18 import android.content.Context;
19 import android.view.LayoutInflater;
20 import android.view.View;
21 import android.view.ViewGroup;
22 import android.widget.ArrayAdapter;
23 import android.widget.TextView;
25 import org.strongswan.android.R;
26 import org.strongswan.android.security.TrustedCertificateEntry;
28 import java.util.List;
30 public class CertificateIdentitiesAdapter extends ArrayAdapter<String>
32 TrustedCertificateEntry mCertificate;
34 public CertificateIdentitiesAdapter(Context context)
36 super(context, android.R.layout.simple_dropdown_item_1line);
41 * Set a new certificate for this adapter.
43 * @param certificate the certificate to extract identities from (null to clear)
45 public void setCertificate(TrustedCertificateEntry certificate)
47 mCertificate = certificate;
52 private void extractIdentities()
54 if (mCertificate == null)
56 add(getContext().getString(R.string.profile_user_select_id_init));
60 add(String.format(getContext().getString(R.string.profile_user_select_id_default),
61 mCertificate.getCertificate().getSubjectDN().getName()));
62 addAll(mCertificate.getSubjectAltNames());