2 * Copyright (C) 2012-2014 Tobias Brunner
3 * 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
.data
;
18 import java
.util
.EnumSet
;
22 /* the order here must match the items in R.array.vpn_types */
23 IKEV2_EAP("ikev2-eap", EnumSet
.of(VpnTypeFeature
.USER_PASS
)),
24 IKEV2_CERT("ikev2-cert", EnumSet
.of(VpnTypeFeature
.CERTIFICATE
)),
25 IKEV2_CERT_EAP("ikev2-cert-eap", EnumSet
.of(VpnTypeFeature
.USER_PASS
, VpnTypeFeature
.CERTIFICATE
)),
26 IKEV2_EAP_TLS("ikev2-eap-tls", EnumSet
.of(VpnTypeFeature
.CERTIFICATE
)),
27 IKEV2_BYOD_EAP("ikev2-byod-eap", EnumSet
.of(VpnTypeFeature
.USER_PASS
, VpnTypeFeature
.BYOD
));
30 * Features of a VPN type.
32 public enum VpnTypeFeature
34 /** client certificate is required */
36 /** username and password are required */
38 /** enable BYOD features */
42 private String mIdentifier
;
43 private EnumSet
<VpnTypeFeature
> mFeatures
;
46 * Enum which provides additional information about the supported VPN types.
48 * @param id identifier used to store and transmit this specific type
49 * @param features of the given VPN type
50 * @param certificate true if a client certificate is required
52 VpnType(String id
, EnumSet
<VpnTypeFeature
> features
)
59 * The identifier used to store this value in the database
62 public String
getIdentifier()
68 * Checks whether a feature is supported/required by this type of VPN.
70 * @return true if the feature is supported/required
72 public boolean has(VpnTypeFeature feature
)
74 return mFeatures
.contains(feature
);
78 * Get the enum entry with the given identifier.
80 * @param identifier get the enum entry with this identifier
81 * @return the enum entry, or the default if not found
83 public static VpnType
fromIdentifier(String identifier
)
85 for (VpnType type
: VpnType
.values())
87 if (identifier
.equals(type
.mIdentifier
))
92 return VpnType
.IKEV2_EAP
;