~ubuntu-branches/ubuntu/utopic/strongswan/utopic

« back to all changes in this revision

Viewing changes to src/frontends/android/src/org/strongswan/android/logic/imc/attributes/AttributeType.java

  • Committer: Package Import Robot
  • Author(s): Jonathan Davies
  • Date: 2014-01-20 19:00:59 UTC
  • mfrom: (1.2.6)
  • Revision ID: package-import@ubuntu.com-20140120190059-z8e4dl3g8cd09yi5
Tags: 5.1.2~dr3+git20130120-0ubuntu1
* Upstream Git snapshot for build fixes with regards to entropy.
* debian/rules:
  - Enforcing DEB_BUILD_OPTIONS=nostrip for library integrity checking.
  - Set TESTS_REDUCED_KEYLENGTHS to one generate smallest key-lengths in
    tests.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
        ITA_DEVICE_ID(PrivateEnterpriseNumber.ITA, 8);
 
40
 
 
41
        private PrivateEnterpriseNumber mVendor;
 
42
        private int mType;
 
43
 
 
44
        /**
 
45
         * Enum type for vendor specific attributes (defined in their namespace)
 
46
         *
 
47
         * @param vendor private enterprise number of vendor
 
48
         * @param type vendor specific attribute type
 
49
         */
 
50
        private AttributeType(PrivateEnterpriseNumber vendor, int type)
 
51
        {
 
52
                mVendor = vendor;
 
53
                mType = type;
 
54
        }
 
55
 
 
56
        /**
 
57
         * Get private enterprise number of vendor
 
58
         *
 
59
         * @return PEN
 
60
         */
 
61
        public PrivateEnterpriseNumber getVendor()
 
62
        {
 
63
                return mVendor;
 
64
        }
 
65
 
 
66
        /**
 
67
         * Get vendor specific type
 
68
         *
 
69
         * @return type
 
70
         */
 
71
        public int getType()
 
72
        {
 
73
                return mType;
 
74
        }
 
75
 
 
76
        /**
 
77
         * Get the enum entry from the given numeric values, if defined
 
78
         *
 
79
         * @param vendor vendor id
 
80
         * @param type vendor specific type
 
81
         * @return enum entry or null
 
82
         */
 
83
        public static AttributeType fromValues(int vendor, int type)
 
84
        {
 
85
                PrivateEnterpriseNumber pen = PrivateEnterpriseNumber.fromValue(vendor);
 
86
 
 
87
                if (pen == null)
 
88
                {
 
89
                        return null;
 
90
                }
 
91
                for (AttributeType attr : AttributeType.values())
 
92
                {
 
93
                        if (attr.mVendor == pen && attr.mType == type)
 
94
                        {
 
95
                                return attr;
 
96
                        }
 
97
                }
 
98
                return null;
 
99
        }
 
100
}