35b32da53120785a4057c882032d3a8cd06320b8
[strongswan.git] / src / frontends / android / src / org / strongswan / android / data / VpnType.java
1 /*
2 * Copyright (C) 2012 Tobias Brunner
3 * Hochschule fuer Technik Rapperswil
4 *
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>.
9 *
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
13 * for more details.
14 */
15
16 package org.strongswan.android.data;
17
18 public enum VpnType
19 {
20 IKEV2_EAP("ikev2-eap", true, false),
21 IKEV2_CERT("ikev2-cert", false, true);
22
23 private String mIdentifier;
24 private boolean mCertificate;
25 private boolean mUsernamePassword;
26
27 /**
28 * Enum which provides additional information about the supported VPN types.
29 *
30 * @param id identifier used to store and transmit this specific type
31 * @param userpass true if username and password are required
32 * @param certificate true if a client certificate is required
33 */
34 VpnType(String id, boolean userpass, boolean certificate)
35 {
36 mIdentifier = id;
37 mUsernamePassword = userpass;
38 mCertificate = certificate;
39 }
40
41 /**
42 * The identifier used to store this value in the database
43 * @return identifier
44 */
45 public String getIdentifier()
46 {
47 return mIdentifier;
48 }
49
50 /**
51 * Whether username and password are required for this type of VPN.
52 *
53 * @return true if username and password are required
54 */
55 public boolean getRequiresUsernamePassword()
56 {
57 return mUsernamePassword;
58 }
59
60 /**
61 * Whether a certificate is required for this type of VPN.
62 *
63 * @return true if a certificate is required
64 */
65 public boolean getRequiresCertificate()
66 {
67 return mCertificate;
68 }
69
70 /**
71 * Get the enum entry with the given identifier.
72 *
73 * @param identifier get the enum entry with this identifier
74 * @return the enum entry, or the default if not found
75 */
76 public static VpnType fromIdentifier(String identifier)
77 {
78 for (VpnType type : VpnType.values())
79 {
80 if (identifier.equals(type.mIdentifier))
81 {
82 return type;
83 }
84 }
85 return VpnType.IKEV2_EAP;
86 }
87 }