summaryrefslogtreecommitdiffstats
path: root/base/util/src/com/netscape/cmsutil/radius/AttributeFactory.java
blob: 021c067204667e8cbab07974c4b467e25381a3c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
// --- BEGIN COPYRIGHT BLOCK ---
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; version 2 of the License.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along
// with this program; if not, write to the Free Software Foundation, Inc.,
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
//
// (C) 2007 Red Hat, Inc.
// All rights reserved.
// --- END COPYRIGHT BLOCK ---
package com.netscape.cmsutil.radius;

import java.io.IOException;

public class AttributeFactory {
    public static Attribute createAttribute(byte data[])
            throws IOException {
        switch (data[0] & 0xFF) {
        case Attribute.USER_NAME: // 1
            return new UserNameAttribute(data);

        case Attribute.USER_PASSWORD: // 2
            return new UserPasswordAttribute(data);

        case Attribute.NAS_IP_ADDRESS: // 4
            return new NASIPAddressAttribute(data);

        case Attribute.NAS_PORT: // 5
            return new NASPortAttribute(data);

        case Attribute.CHAP_PASSWORD: // 3
            return new CHAPPasswordAttribute(data);

        case Attribute.SERVICE_TYPE: // 6
            return new ServiceTypeAttribute(data);

        case Attribute.FRAMED_PROTOCOL: // 7
            return new FramedProtocolAttribute(data);

        case Attribute.FRAMED_IP_ADDRESS: // 8
            return new FramedIPAddressAttribute(data);

        case Attribute.FRAMED_IP_NETMASK: // 9
            return new FramedIPNetmaskAttribute(data);

        case Attribute.FRAMED_ROUTING: // 10 
            return new FramedRoutingAttribute(data);

        case Attribute.FILTER_ID: // 11 
            return new FilterIdAttribute(data);

        case Attribute.FRAMED_MTU: // 12 
            return new FramedMTUAttribute(data);

        case Attribute.FRAMED_COMPRESSION: // 13
            return new FramedCompressionAttribute(data);

        case Attribute.LOGIN_IP_HOST: // 14
            return new LoginIPHostAttribute(data);

        case Attribute.LOGIN_SERVICE: // 15
            return new LoginServiceAttribute(data);

        case Attribute.LOGIN_TCP_PORT: // 16
            return new LoginTCPPortAttribute(data);

        case Attribute.REPLY_MESSAGE: // 18
            return new ReplyMessageAttribute(data);

        case Attribute.CALLBACK_NUMBER: // 19
            return new CallbackNumberAttribute(data);

        case Attribute.CALLBACK_ID: // 20 
            return new CallbackIdAttribute(data);

        case Attribute.FRAMED_ROUTE: // 22 
            return new FramedRouteAttribute(data);

        case Attribute.FRAMED_IPX_NETWORK: // 23 
            return new FramedIPXNetworkAttribute(data);

        case Attribute.STATE: // 24 
            return new StateAttribute(data);

        case Attribute.NAS_CLASS: // 25 
            return new NASClassAttribute(data);

        case Attribute.VENDOR_SPECIFIC: // 26 
            return new VendorSpecificAttribute(data);

        case Attribute.SESSION_TIMEOUT: // 27 
            return new SessionTimeoutAttribute(data);

        case Attribute.IDLE_TIMEOUT: // 28 
            return new IdleTimeoutAttribute(data);

        case Attribute.TERMINATION_ACTION: // 29 
            return new TerminationActionAttribute(data);

        case Attribute.CALLER_STATION_ID: // 30 
            return new CallerStationIdAttribute(data);

        case Attribute.CALLING_STATION_ID: // 31 
            return new CallingStationIdAttribute(data);

        case Attribute.NAS_IDENTIFIER: // 32 
            return new NASIdentifierAttribute(data);

        case Attribute.PROXY_STATE: // 33 
            return new ProxyStateAttribute(data);

        case Attribute.LOGIN_LAT_SERVICE: // 34 
            return new LoginLATServiceAttribute(data);

        case Attribute.LOGIN_LAT_NODE: // 35 
            return new LoginLATNodeAttribute(data);

        case Attribute.LOGIN_LAT_GROUP: // 36 
            return new LoginLATGroupAttribute(data);

        case Attribute.FRAMED_APPLETALK_LINK: // 37 
            return new FramedAppleTalkLinkAttribute(data);

        case Attribute.FRAMED_APPLETALK_NETWORK: // 38 
            return new FramedAppleTalkNetworkAttribute(data);

        case Attribute.FRAMED_APPLETALK_ZONE: // 39 
            return new FramedAppleTalkZoneAttribute(data);

        case Attribute.CHAP_CHALLENGE: // 60 
            return new CHAPChallengeAttribute(data);

        case Attribute.NAS_PORT_TYPE: // 61 
            return new NASPortTypeAttribute(data);

        case Attribute.PORT_LIMIT: // 62 
            return new PortLimitAttribute(data);

        case Attribute.LOGIN_LAT_PORT: // 63 
            return new LoginLATPortAttribute(data);

        default:
            return new GenericAttribute(data);
            // throw new IOException("Unknown attribute " + (data[0] & 0xFF));
        }
    }
}