52eef97f8998fd14b7cb8f2518e17e4b5da2e841
[strongswan.git] / src / frontends / android / src / org / strongswan / android / logic / imc / attributes / AttributeType.java
1 /*
2 * Copyright (C) 2013 Tobias Brunner
3 * Copyright (C) 2012 Christoph Buehler
4 * Copyright (C) 2012 Patrick Loetscher
5 * Hochschule fuer Technik Rapperswil
6 *
7 * This program is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation; either version 2 of the License, or (at your
10 * option) any later version. See <http://www.fsf.org/copyleft/gpl.txt>.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * for more details.
16 */
17
18 package org.strongswan.android.logic.imc.attributes;
19
20 public enum AttributeType
21 {
22 /* IETF standard PA-TNC attribute types defined by RFC 5792 */
23 IETF_TESTING(PrivateEnterpriseNumber.IETF, 0),
24 IETF_ATTRIBUTE_REQUEST(PrivateEnterpriseNumber.IETF, 1),
25 IETF_PRODUCT_INFORMATION(PrivateEnterpriseNumber.IETF, 2),
26 IETF_NUMERIC_VERSION(PrivateEnterpriseNumber.IETF, 3),
27 IETF_STRING_VERSION(PrivateEnterpriseNumber.IETF, 4),
28 IETF_OPERATIONAL_STATUS(PrivateEnterpriseNumber.IETF, 5),
29 IETF_PORT_FILTER(PrivateEnterpriseNumber.IETF, 6),
30 IETF_INSTALLED_PACKAGES(PrivateEnterpriseNumber.IETF, 7),
31 IETF_PA_TNC_ERROR(PrivateEnterpriseNumber.IETF, 8),
32 IETF_ASSESSMENT_RESULT(PrivateEnterpriseNumber.IETF, 9),
33 IETF_REMEDIATION_INSTRUCTIONS(PrivateEnterpriseNumber.IETF, 10),
34 IETF_FORWARDING_ENABLED(PrivateEnterpriseNumber.IETF, 11),
35 IETF_FACTORY_DEFAULT_PWD_ENABLED(PrivateEnterpriseNumber.IETF, 12),
36 IETF_RESERVED(PrivateEnterpriseNumber.IETF, 0xffffffff),
37 /* ITA attributes */
38 ITA_SETTINGS(PrivateEnterpriseNumber.ITA, 4);
39
40 private PrivateEnterpriseNumber mVendor;
41 private int mType;
42
43 /**
44 * Enum type for vendor specific attributes (defined in their namespace)
45 *
46 * @param vendor private enterprise number of vendor
47 * @param type vendor specific attribute type
48 */
49 private AttributeType(PrivateEnterpriseNumber vendor, int type)
50 {
51 mVendor = vendor;
52 mType = type;
53 }
54
55 /**
56 * Get private enterprise number of vendor
57 *
58 * @return PEN
59 */
60 public PrivateEnterpriseNumber getVendor()
61 {
62 return mVendor;
63 }
64
65 /**
66 * Get vendor specific type
67 *
68 * @return type
69 */
70 public int getType()
71 {
72 return mType;
73 }
74
75 /**
76 * Get the enum entry from the given numeric values, if defined
77 *
78 * @param vendor vendor id
79 * @param type vendor specific type
80 * @return enum entry or null
81 */
82 public static AttributeType fromValues(int vendor, int type)
83 {
84 PrivateEnterpriseNumber pen = PrivateEnterpriseNumber.fromValue(vendor);
85
86 if (pen == null)
87 {
88 return null;
89 }
90 for (AttributeType attr : AttributeType.values())
91 {
92 if (attr.mVendor == pen && attr.mType == type)
93 {
94 return attr;
95 }
96 }
97 return null;
98 }
99 }