summaryrefslogtreecommitdiffstats
path: root/base/util/src/com/netscape/cmsutil/radius
diff options
context:
space:
mode:
Diffstat (limited to 'base/util/src/com/netscape/cmsutil/radius')
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/AccessAccept.java27
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/AccessChallenge.java27
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/AccessReject.java27
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/AccessRequest.java25
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/Attribute.java97
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/AttributeFactory.java154
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/AttributeSet.java56
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/Authenticator.java24
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/CHAPChallengeAttribute.java38
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/CHAPPasswordAttribute.java55
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/CallbackIdAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/CallbackNumberAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/CallerStationIdAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/CallingStationIdAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/ChallengeException.java43
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FilterIdAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkLinkAttribute.java51
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkNetworkAttribute.java49
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkZoneAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FramedCompressionAttribute.java54
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FramedIPAddressAttribute.java39
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FramedIPNetmaskAttribute.java39
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FramedIPXNetworkAttribute.java39
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FramedMTUAttribute.java49
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FramedProtocolAttribute.java56
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FramedRouteAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/FramedRoutingAttribute.java54
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/GenericAttribute.java35
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/IdleTimeoutAttribute.java52
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/LoginIPHostAttribute.java52
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/LoginLATGroupAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/LoginLATNodeAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/LoginLATPortAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/LoginLATServiceAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/LoginServiceAttribute.java58
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/LoginTCPPortAttribute.java52
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/NASClassAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/NASIPAddressAttribute.java41
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/NASIdentifierAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/NASPacket.java52
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/NASPortAttribute.java48
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/NASPortTypeAttribute.java53
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/Packet.java70
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/PacketFactory.java39
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/PortLimitAttribute.java51
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/ProxyStateAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/RadiusConn.java230
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/RejectException.java39
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/ReplyMessageAttribute.java40
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/RequestAuthenticator.java44
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/ResponseAuthenticator.java32
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/ServerPacket.java47
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/ServiceTypeAttribute.java61
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/SessionTimeoutAttribute.java48
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/StateAttribute.java45
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/TerminationActionAttribute.java55
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/UserNameAttribute.java39
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/UserPasswordAttribute.java73
-rw-r--r--base/util/src/com/netscape/cmsutil/radius/VendorSpecificAttribute.java52
59 files changed, 2971 insertions, 0 deletions
diff --git a/base/util/src/com/netscape/cmsutil/radius/AccessAccept.java b/base/util/src/com/netscape/cmsutil/radius/AccessAccept.java
new file mode 100644
index 000000000..4824c885f
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/AccessAccept.java
@@ -0,0 +1,27 @@
+// --- 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 AccessAccept extends ServerPacket {
+ public AccessAccept(byte data[]) throws IOException {
+ super(data);
+ }
+
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/AccessChallenge.java b/base/util/src/com/netscape/cmsutil/radius/AccessChallenge.java
new file mode 100644
index 000000000..c06f809b1
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/AccessChallenge.java
@@ -0,0 +1,27 @@
+// --- 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 AccessChallenge extends ServerPacket {
+ public AccessChallenge(byte data[]) throws IOException {
+ super(data);
+ }
+
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/AccessReject.java b/base/util/src/com/netscape/cmsutil/radius/AccessReject.java
new file mode 100644
index 000000000..5f32ef349
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/AccessReject.java
@@ -0,0 +1,27 @@
+// --- 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 AccessReject extends ServerPacket {
+ public AccessReject(byte data[]) throws IOException {
+ super(data);
+ }
+
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/AccessRequest.java b/base/util/src/com/netscape/cmsutil/radius/AccessRequest.java
new file mode 100644
index 000000000..7856b0cc8
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/AccessRequest.java
@@ -0,0 +1,25 @@
+// --- 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;
+
+public class AccessRequest extends NASPacket {
+ public AccessRequest(short id, Authenticator auth) {
+ super(ACCESS_REQUEST, id, auth);
+ }
+
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/Attribute.java b/base/util/src/com/netscape/cmsutil/radius/Attribute.java
new file mode 100644
index 000000000..5e79816e4
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/Attribute.java
@@ -0,0 +1,97 @@
+// --- 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.ByteArrayOutputStream;
+import java.io.IOException;
+
+public abstract class Attribute {
+ public static final int USER_NAME = 1;
+ public static final int USER_PASSWORD = 2;
+ public static final int CHAP_PASSWORD = 3;
+ public static final int NAS_IP_ADDRESS = 4;
+ public static final int NAS_PORT = 5;
+ public static final int SERVICE_TYPE = 6;
+ public static final int FRAMED_PROTOCOL = 7;
+ public static final int FRAMED_IP_ADDRESS = 8;
+ public static final int FRAMED_IP_NETMASK = 9;
+ public static final int FRAMED_ROUTING = 10;
+ public static final int FILTER_ID = 11;
+ public static final int FRAMED_MTU = 12;
+ public static final int FRAMED_COMPRESSION = 13;
+ public static final int LOGIN_IP_HOST = 14;
+ public static final int LOGIN_SERVICE = 15;
+ public static final int LOGIN_TCP_PORT = 16;
+ // 17 HAS NOT BEEN ASSIGNED
+ public static final int REPLY_MESSAGE = 18;
+ public static final int CALLBACK_NUMBER = 19;
+ public static final int CALLBACK_ID = 20;
+ // 21 HAS NOT BEEN ASSIGNED
+ public static final int FRAMED_ROUTE = 22;
+ public static final int FRAMED_IPX_NETWORK = 23;
+ public static final int STATE = 24;
+ public static final int NAS_CLASS = 25;
+ public static final int VENDOR_SPECIFIC = 26;
+ public static final int SESSION_TIMEOUT = 27;
+ public static final int IDLE_TIMEOUT = 28;
+ public static final int TERMINATION_ACTION = 29;
+ public static final int CALLER_STATION_ID = 30;
+ public static final int CALLING_STATION_ID = 31;
+ public static final int NAS_IDENTIFIER = 32;
+ public static final int PROXY_STATE = 33;
+ public static final int LOGIN_LAT_SERVICE = 34;
+ public static final int LOGIN_LAT_NODE = 35;
+ public static final int LOGIN_LAT_GROUP = 36;
+ public static final int FRAMED_APPLETALK_LINK = 37;
+ public static final int FRAMED_APPLETALK_NETWORK = 38;
+ public static final int FRAMED_APPLETALK_ZONE = 39;
+ // 40-59 HAS NOT BEEN ASSIGNED
+ public static final int CHAP_CHALLENGE = 60;
+ public static final int NAS_PORT_TYPE = 61;
+ public static final int PORT_LIMIT = 62;
+ public static final int LOGIN_LAT_PORT = 63;
+
+ protected int _t = 0;
+
+ public Attribute() {
+ }
+
+ public Attribute(int t) {
+ _t = t;
+ }
+
+ public int getType() {
+ return _t;
+ }
+
+ public abstract byte[] getValue()
+ throws IOException;
+
+ public byte[] getData()
+ throws IOException {
+ ByteArrayOutputStream attrOS = new ByteArrayOutputStream();
+
+ attrOS.write(_t); // type
+ byte value[] = getValue();
+
+ attrOS.write(value.length + 2); // length
+ attrOS.write(value);
+
+ return attrOS.toByteArray();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/AttributeFactory.java b/base/util/src/com/netscape/cmsutil/radius/AttributeFactory.java
new file mode 100644
index 000000000..021c06720
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/AttributeFactory.java
@@ -0,0 +1,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));
+ }
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/AttributeSet.java b/base/util/src/com/netscape/cmsutil/radius/AttributeSet.java
new file mode 100644
index 000000000..d6974d371
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/AttributeSet.java
@@ -0,0 +1,56 @@
+// --- 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.util.Enumeration;
+import java.util.Vector;
+
+public class AttributeSet {
+ private Vector<Attribute> _attrs = new Vector<Attribute>();
+
+ public AttributeSet() {
+ }
+
+ public void addAttribute(Attribute attr) {
+ _attrs.addElement(attr);
+ }
+
+ public int size() {
+ return _attrs.size();
+ }
+
+ public Enumeration<Attribute> getAttributes() {
+ return _attrs.elements();
+ }
+
+ public Attribute getAttributeByType(int type) {
+ int l = _attrs.size();
+
+ for (int i = 0; i < l; i++) {
+ Attribute attr = getAttributeAt(i);
+
+ if (attr.getType() == type)
+ return attr;
+ }
+ return null;
+ }
+
+ public Attribute getAttributeAt(int pos) {
+ return _attrs.elementAt(pos);
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/Authenticator.java b/base/util/src/com/netscape/cmsutil/radius/Authenticator.java
new file mode 100644
index 000000000..008af489a
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/Authenticator.java
@@ -0,0 +1,24 @@
+// --- 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 abstract class Authenticator {
+ public abstract byte[] getData() throws IOException;
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/CHAPChallengeAttribute.java b/base/util/src/com/netscape/cmsutil/radius/CHAPChallengeAttribute.java
new file mode 100644
index 000000000..cd715a031
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/CHAPChallengeAttribute.java
@@ -0,0 +1,38 @@
+// --- 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 CHAPChallengeAttribute extends Attribute {
+ private String _str = null;
+
+ public CHAPChallengeAttribute(byte value[]) {
+ super();
+ _t = CHAP_CHALLENGE;
+ _str = new String(value, 2, value.length - 2);
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/CHAPPasswordAttribute.java b/base/util/src/com/netscape/cmsutil/radius/CHAPPasswordAttribute.java
new file mode 100644
index 000000000..3f0ef1793
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/CHAPPasswordAttribute.java
@@ -0,0 +1,55 @@
+// --- 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 CHAPPasswordAttribute extends Attribute {
+ private byte _value[] = null;
+ private int _ident = 0;
+ private String _str = null;
+
+ public CHAPPasswordAttribute(String s) {
+ _str = s;
+ }
+
+ public CHAPPasswordAttribute(byte value[]) {
+ super();
+ _t = CHAP_PASSWORD;
+ _ident = value[2];
+ _str = new String(value, 2, 16);
+ _value = value;
+ }
+
+ public int getIdent() {
+ return _ident;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte val[] = new byte[1 + _str.length()];
+ byte s[] = _str.getBytes();
+
+ val[0] = (byte) _ident;
+ System.arraycopy(s, 0, val, 1, s.length);
+ return val;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/CallbackIdAttribute.java b/base/util/src/com/netscape/cmsutil/radius/CallbackIdAttribute.java
new file mode 100644
index 000000000..5fd806003
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/CallbackIdAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 CallbackIdAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public CallbackIdAttribute(byte value[]) {
+ super();
+ _t = CALLBACK_ID;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/CallbackNumberAttribute.java b/base/util/src/com/netscape/cmsutil/radius/CallbackNumberAttribute.java
new file mode 100644
index 000000000..d6e45cecd
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/CallbackNumberAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 CallbackNumberAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public CallbackNumberAttribute(byte value[]) {
+ super();
+ _t = CALLBACK_NUMBER;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/CallerStationIdAttribute.java b/base/util/src/com/netscape/cmsutil/radius/CallerStationIdAttribute.java
new file mode 100644
index 000000000..3b5eec804
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/CallerStationIdAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 CallerStationIdAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public CallerStationIdAttribute(byte value[]) {
+ super();
+ _t = CALLER_STATION_ID;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/CallingStationIdAttribute.java b/base/util/src/com/netscape/cmsutil/radius/CallingStationIdAttribute.java
new file mode 100644
index 000000000..9a57f8089
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/CallingStationIdAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 CallingStationIdAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public CallingStationIdAttribute(byte value[]) {
+ super();
+ _t = CALLING_STATION_ID;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/ChallengeException.java b/base/util/src/com/netscape/cmsutil/radius/ChallengeException.java
new file mode 100644
index 000000000..972f7f084
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/ChallengeException.java
@@ -0,0 +1,43 @@
+// --- 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;
+
+public class ChallengeException extends Exception {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3496050461777520369L;
+ private AccessChallenge _res = null;
+
+ public ChallengeException(AccessChallenge res) {
+ _res = res;
+ }
+
+ public AttributeSet getAttributeSet() {
+ return _res.getAttributeSet();
+ }
+
+ public String getState() {
+ return ((StateAttribute) (_res.getAttributeSet().getAttributeByType(Attribute.STATE))).getString();
+ }
+
+ public String getReplyMessage() {
+ return ((ReplyMessageAttribute) (_res.getAttributeSet().getAttributeByType(Attribute.REPLY_MESSAGE)))
+ .getString();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FilterIdAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FilterIdAttribute.java
new file mode 100644
index 000000000..879d7d5c7
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FilterIdAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 FilterIdAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public FilterIdAttribute(byte value[]) {
+ super();
+ _t = CHAP_PASSWORD;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkLinkAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkLinkAttribute.java
new file mode 100644
index 000000000..05273780f
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkLinkAttribute.java
@@ -0,0 +1,51 @@
+// --- 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 FramedAppleTalkLinkAttribute extends Attribute {
+ public static int UN_NUMBERED = 0;
+
+ private byte _value[] = null;
+ private int _type = 0;
+
+ public FramedAppleTalkLinkAttribute(byte value[]) {
+ super();
+ _t = FRAMED_APPLETALK_LINK;
+ _value = value;
+ _type = value[5] & 0xFF;
+ _type |= ((value[4] << 8) & 0xFF00);
+ _type |= ((value[3] << 16) & 0xFF0000);
+ _type |= ((value[2] << 24) & 0xFF000000);
+ }
+
+ public int getType() {
+ return _type;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_type >>> 24) & 0xFF);
+ p[1] = (byte) ((_type >>> 16) & 0xFF);
+ p[2] = (byte) ((_type >>> 8) & 0xFF);
+ p[3] = (byte) (_type & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkNetworkAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkNetworkAttribute.java
new file mode 100644
index 000000000..cea0d936a
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkNetworkAttribute.java
@@ -0,0 +1,49 @@
+// --- 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 FramedAppleTalkNetworkAttribute extends Attribute {
+ private byte _value[] = null;
+ private int _type = 0;
+
+ public FramedAppleTalkNetworkAttribute(byte value[]) {
+ super();
+ _t = FRAMED_APPLETALK_NETWORK;
+ _value = value;
+ _type = value[5] & 0xFF;
+ _type |= ((value[4] << 8) & 0xFF00);
+ _type |= ((value[3] << 16) & 0xFF0000);
+ _type |= ((value[2] << 24) & 0xFF000000);
+ }
+
+ public int getType() {
+ return _type;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_type >>> 24) & 0xFF);
+ p[1] = (byte) ((_type >>> 16) & 0xFF);
+ p[2] = (byte) ((_type >>> 8) & 0xFF);
+ p[3] = (byte) (_type & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkZoneAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkZoneAttribute.java
new file mode 100644
index 000000000..54ee47c45
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FramedAppleTalkZoneAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 FramedAppleTalkZoneAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public FramedAppleTalkZoneAttribute(byte value[]) {
+ super();
+ _t = FRAMED_APPLETALK_ZONE;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FramedCompressionAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FramedCompressionAttribute.java
new file mode 100644
index 000000000..b57c030b5
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FramedCompressionAttribute.java
@@ -0,0 +1,54 @@
+// --- 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 FramedCompressionAttribute extends Attribute {
+ public static final int NONE = 1;
+ public static final int VJ_TCP_IP_HEADER = 2;
+ public static final int IPX_HEADER = 2;
+ public static final int STAC_LZS = 3;
+
+ private byte _value[] = null;
+ private int _type = 0;
+
+ public FramedCompressionAttribute(byte value[]) {
+ super();
+ _t = FRAMED_COMPRESSION;
+ _type = value[5] & 0xFF;
+ _type |= ((value[4] << 8) & 0xFF00);
+ _type |= ((value[3] << 16) & 0xFF0000);
+ _type |= ((value[2] << 24) & 0xFF000000);
+ _value = value;
+ }
+
+ public int getType() {
+ return _type;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_type >>> 24) & 0xFF);
+ p[1] = (byte) ((_type >>> 16) & 0xFF);
+ p[2] = (byte) ((_type >>> 8) & 0xFF);
+ p[3] = (byte) (_type & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FramedIPAddressAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FramedIPAddressAttribute.java
new file mode 100644
index 000000000..2f66ee8c2
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FramedIPAddressAttribute.java
@@ -0,0 +1,39 @@
+// --- 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 FramedIPAddressAttribute extends Attribute {
+ private byte _value[] = null;
+ private byte _addr[] = new byte[4];
+
+ public FramedIPAddressAttribute(byte value[]) {
+ super();
+ _t = FRAMED_IP_ADDRESS;
+ _addr[0] = value[2];
+ _addr[1] = value[3];
+ _addr[2] = value[4];
+ _addr[3] = value[5];
+ _value = value;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _addr;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FramedIPNetmaskAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FramedIPNetmaskAttribute.java
new file mode 100644
index 000000000..f8e1980c7
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FramedIPNetmaskAttribute.java
@@ -0,0 +1,39 @@
+// --- 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 FramedIPNetmaskAttribute extends Attribute {
+ private byte _value[] = null;
+ private byte _mask[] = new byte[4];
+
+ public FramedIPNetmaskAttribute(byte value[]) {
+ super();
+ _t = FRAMED_IP_NETMASK;
+ _mask[0] = value[2];
+ _mask[1] = value[3];
+ _mask[2] = value[4];
+ _mask[3] = value[5];
+ _value = value;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _mask;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FramedIPXNetworkAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FramedIPXNetworkAttribute.java
new file mode 100644
index 000000000..92f47eec1
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FramedIPXNetworkAttribute.java
@@ -0,0 +1,39 @@
+// --- 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 FramedIPXNetworkAttribute extends Attribute {
+ private byte _value[] = null;
+ private byte _net[] = new byte[4];
+
+ public FramedIPXNetworkAttribute(byte value[]) {
+ super();
+ _t = FRAMED_IPX_NETWORK;
+ _net[0] = value[2];
+ _net[1] = value[3];
+ _net[2] = value[4];
+ _net[3] = value[5];
+ _value = value;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _net;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FramedMTUAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FramedMTUAttribute.java
new file mode 100644
index 000000000..5cd9551a2
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FramedMTUAttribute.java
@@ -0,0 +1,49 @@
+// --- 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 FramedMTUAttribute extends Attribute {
+ private byte _value[] = null;
+ private int _type = 0;
+
+ public FramedMTUAttribute(byte value[]) {
+ super();
+ _t = FRAMED_IP_ADDRESS;
+ _value = value;
+ _type = value[5] & 0xFF;
+ _type |= ((value[4] << 8) & 0xFF00);
+ _type |= ((value[3] << 16) & 0xFF0000);
+ _type |= ((value[2] << 24) & 0xFF000000);
+ }
+
+ public int getType() {
+ return _type;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_type >>> 24) & 0xFF);
+ p[1] = (byte) ((_type >>> 16) & 0xFF);
+ p[2] = (byte) ((_type >>> 8) & 0xFF);
+ p[3] = (byte) (_type & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FramedProtocolAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FramedProtocolAttribute.java
new file mode 100644
index 000000000..5af219b9a
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FramedProtocolAttribute.java
@@ -0,0 +1,56 @@
+// --- 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 FramedProtocolAttribute extends Attribute {
+ public static final int PPP = 1;
+ public static final int SLIP = 2;
+ public static final int ARAP = 3;
+ public static final int GANDALF = 4;
+ public static final int XYLOGICS = 5;
+ public static final int X_75 = 6;
+
+ private byte _value[] = null;
+ private int _type = 0;
+
+ public FramedProtocolAttribute(byte value[]) {
+ super();
+ _t = SERVICE_TYPE;
+ _type = value[5] & 0xFF;
+ _type |= ((value[4] << 8) & 0xFF00);
+ _type |= ((value[3] << 16) & 0xFF0000);
+ _type |= ((value[2] << 24) & 0xFF000000);
+ _value = value;
+ }
+
+ public int getType() {
+ return _type;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_type >>> 24) & 0xFF);
+ p[1] = (byte) ((_type >>> 16) & 0xFF);
+ p[2] = (byte) ((_type >>> 8) & 0xFF);
+ p[3] = (byte) (_type & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FramedRouteAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FramedRouteAttribute.java
new file mode 100644
index 000000000..9b123fe2a
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FramedRouteAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 FramedRouteAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public FramedRouteAttribute(byte value[]) {
+ super();
+ _t = FRAMED_ROUTE;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/FramedRoutingAttribute.java b/base/util/src/com/netscape/cmsutil/radius/FramedRoutingAttribute.java
new file mode 100644
index 000000000..14d2b0cc8
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/FramedRoutingAttribute.java
@@ -0,0 +1,54 @@
+// --- 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 FramedRoutingAttribute extends Attribute {
+ public static final int NONE = 0;
+ public static final int SEND_ROUTING_PACKETS = 1;
+ public static final int LISTEN_FOR_ROUTING_PACKETS = 2;
+ public static final int SEND_AND_LISTEN = 3;
+
+ private byte _value[] = null;
+ private int _type = 0;
+
+ public FramedRoutingAttribute(byte value[]) {
+ super();
+ _t = FRAMED_ROUTING;
+ _type = value[5] & 0xFF;
+ _type |= ((value[4] << 8) & 0xFF00);
+ _type |= ((value[3] << 16) & 0xFF0000);
+ _type |= ((value[2] << 24) & 0xFF000000);
+ _value = value;
+ }
+
+ public int getType() {
+ return _type;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_type >>> 24) & 0xFF);
+ p[1] = (byte) ((_type >>> 16) & 0xFF);
+ p[2] = (byte) ((_type >>> 8) & 0xFF);
+ p[3] = (byte) (_type & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/GenericAttribute.java b/base/util/src/com/netscape/cmsutil/radius/GenericAttribute.java
new file mode 100644
index 000000000..ac1798ae3
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/GenericAttribute.java
@@ -0,0 +1,35 @@
+// --- 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 GenericAttribute extends Attribute {
+ private byte _value[] = null;
+
+ public GenericAttribute(byte value[]) {
+ super();
+ _t = value[0];
+ _value = new byte[value.length - 2];
+ System.arraycopy(value, 2, _value, 0, _value.length);
+ }
+
+ public byte[] getValue() throws IOException {
+ return _value;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/IdleTimeoutAttribute.java b/base/util/src/com/netscape/cmsutil/radius/IdleTimeoutAttribute.java
new file mode 100644
index 000000000..44b0c5087
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/IdleTimeoutAttribute.java
@@ -0,0 +1,52 @@
+// --- 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 IdleTimeoutAttribute extends Attribute {
+ private int _timeout = 0;
+
+ public IdleTimeoutAttribute(byte value[]) {
+ super();
+ _t = IDLE_TIMEOUT;
+ _timeout = value[5] & 0xFF;
+ _timeout |= ((value[4] << 8) & 0xFF00);
+ _timeout |= ((value[3] << 16) & 0xFF0000);
+ _timeout |= ((value[2] << 24) & 0xFF000000);
+ }
+
+ public IdleTimeoutAttribute(int timeout) {
+ super(IDLE_TIMEOUT);
+ _timeout = timeout;
+ }
+
+ public int getTimeout() {
+ return _timeout;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_timeout >>> 24) & 0xFF);
+ p[1] = (byte) ((_timeout >>> 16) & 0xFF);
+ p[2] = (byte) ((_timeout >>> 8) & 0xFF);
+ p[3] = (byte) (_timeout & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/LoginIPHostAttribute.java b/base/util/src/com/netscape/cmsutil/radius/LoginIPHostAttribute.java
new file mode 100644
index 000000000..0d1c0565a
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/LoginIPHostAttribute.java
@@ -0,0 +1,52 @@
+// --- 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 LoginIPHostAttribute extends Attribute {
+ public static final int NAS_ALLOW_SELECT = 0xFFFFFFFF;
+ public static final int NAS_SELECT = 0;
+
+ private byte _value[] = null;
+ private int _type = 0;
+
+ public LoginIPHostAttribute(byte value[]) {
+ super();
+ _t = LOGIN_IP_HOST;
+ _type = value[5] & 0xFF;
+ _type |= ((value[4] << 8) & 0xFF00);
+ _type |= ((value[3] << 16) & 0xFF0000);
+ _type |= ((value[2] << 24) & 0xFF000000);
+ _value = value;
+ }
+
+ public int getType() {
+ return _type;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_type >>> 24) & 0xFF);
+ p[1] = (byte) ((_type >>> 16) & 0xFF);
+ p[2] = (byte) ((_type >>> 8) & 0xFF);
+ p[3] = (byte) (_type & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/LoginLATGroupAttribute.java b/base/util/src/com/netscape/cmsutil/radius/LoginLATGroupAttribute.java
new file mode 100644
index 000000000..4cee6bc3a
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/LoginLATGroupAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 LoginLATGroupAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public LoginLATGroupAttribute(byte value[]) {
+ super();
+ _t = LOGIN_LAT_GROUP;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/LoginLATNodeAttribute.java b/base/util/src/com/netscape/cmsutil/radius/LoginLATNodeAttribute.java
new file mode 100644
index 000000000..2c2d3411e
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/LoginLATNodeAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 LoginLATNodeAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public LoginLATNodeAttribute(byte value[]) {
+ super();
+ _t = LOGIN_LAT_NODE;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/LoginLATPortAttribute.java b/base/util/src/com/netscape/cmsutil/radius/LoginLATPortAttribute.java
new file mode 100644
index 000000000..330161ec8
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/LoginLATPortAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 LoginLATPortAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public LoginLATPortAttribute(byte value[]) {
+ super();
+ _t = PROXY_STATE;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/LoginLATServiceAttribute.java b/base/util/src/com/netscape/cmsutil/radius/LoginLATServiceAttribute.java
new file mode 100644
index 000000000..158630d27
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/LoginLATServiceAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 LoginLATServiceAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public LoginLATServiceAttribute(byte value[]) {
+ super();
+ _t = LOGIN_LAT_SERVICE;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/LoginServiceAttribute.java b/base/util/src/com/netscape/cmsutil/radius/LoginServiceAttribute.java
new file mode 100644
index 000000000..73f49d39f
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/LoginServiceAttribute.java
@@ -0,0 +1,58 @@
+// --- 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 LoginServiceAttribute extends Attribute {
+ public static final int TELNET = 0;
+ public static final int RLOGIN = 1;
+ public static final int TCP_CLEAR = 2;
+ public static final int PORTMASTER = 3;
+ public static final int LAT = 4;
+ public static final int X25_PAD = 5;
+ public static final int X25_T3POS = 6;
+ public static final int TCP_CLEAR_QUIET = 8;
+
+ private byte _value[] = null;
+ private int _type = 0;
+
+ public LoginServiceAttribute(byte value[]) {
+ super();
+ _t = LOGIN_SERVICE;
+ _type = value[5] & 0xFF;
+ _type |= ((value[4] << 8) & 0xFF00);
+ _type |= ((value[3] << 16) & 0xFF0000);
+ _type |= ((value[2] << 24) & 0xFF000000);
+ _value = value;
+ }
+
+ public int getType() {
+ return _type;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_type >>> 24) & 0xFF);
+ p[1] = (byte) ((_type >>> 16) & 0xFF);
+ p[2] = (byte) ((_type >>> 8) & 0xFF);
+ p[3] = (byte) (_type & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/LoginTCPPortAttribute.java b/base/util/src/com/netscape/cmsutil/radius/LoginTCPPortAttribute.java
new file mode 100644
index 000000000..6b44f50c6
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/LoginTCPPortAttribute.java
@@ -0,0 +1,52 @@
+// --- 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 LoginTCPPortAttribute extends Attribute {
+ private int _port = 0;
+
+ public LoginTCPPortAttribute(byte value[]) {
+ super();
+ _t = LOGIN_TCP_PORT;
+ _port = value[5] & 0xFF;
+ _port |= ((value[4] << 8) & 0xFF00);
+ _port |= ((value[3] << 16) & 0xFF0000);
+ _port |= ((value[2] << 24) & 0xFF000000);
+ }
+
+ public LoginTCPPortAttribute(int port) {
+ super(LOGIN_TCP_PORT);
+ _port = port;
+ }
+
+ public int getPort() {
+ return _port;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_port >>> 24) & 0xFF);
+ p[1] = (byte) ((_port >>> 16) & 0xFF);
+ p[2] = (byte) ((_port >>> 8) & 0xFF);
+ p[3] = (byte) (_port & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/NASClassAttribute.java b/base/util/src/com/netscape/cmsutil/radius/NASClassAttribute.java
new file mode 100644
index 000000000..57b983028
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/NASClassAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 NASClassAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public NASClassAttribute(byte value[]) {
+ super();
+ _t = NAS_CLASS;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/NASIPAddressAttribute.java b/base/util/src/com/netscape/cmsutil/radius/NASIPAddressAttribute.java
new file mode 100644
index 000000000..d4022b3dd
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/NASIPAddressAttribute.java
@@ -0,0 +1,41 @@
+// --- 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;
+import java.net.InetAddress;
+
+public class NASIPAddressAttribute extends Attribute {
+ private InetAddress _ip = null;
+ private byte _value[] = null;
+
+ public NASIPAddressAttribute(byte value[]) {
+ super();
+ _t = NAS_IP_ADDRESS;
+ _value = value;
+ }
+
+ public NASIPAddressAttribute(InetAddress ip) {
+ super(NAS_IP_ADDRESS);
+ _ip = ip;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _ip.getAddress();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/NASIdentifierAttribute.java b/base/util/src/com/netscape/cmsutil/radius/NASIdentifierAttribute.java
new file mode 100644
index 000000000..0a3a62cd8
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/NASIdentifierAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 NASIdentifierAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public NASIdentifierAttribute(byte value[]) {
+ super();
+ _t = NAS_IDENTIFIER;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/NASPacket.java b/base/util/src/com/netscape/cmsutil/radius/NASPacket.java
new file mode 100644
index 000000000..70d143989
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/NASPacket.java
@@ -0,0 +1,52 @@
+// --- 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.ByteArrayOutputStream;
+import java.io.IOException;
+
+public abstract class NASPacket extends Packet {
+ public NASPacket(int c, short id, Authenticator auth) {
+ super(c, id, auth);
+ }
+
+ public byte[] getData() throws IOException {
+ // prepare the attributes first
+ ByteArrayOutputStream attrsOS = new ByteArrayOutputStream();
+
+ for (int i = 0; i < _attrs.size(); i++) {
+ Attribute attr = (Attribute) getAttributeAt(i);
+
+ attrsOS.write(attr.getData());
+ }
+ byte attrsData[] = attrsOS.toByteArray();
+
+ ByteArrayOutputStream dataOS = new ByteArrayOutputStream();
+
+ dataOS.write(_c); // code
+ dataOS.write(_id); // identifier
+ int len = attrsData.length + 20;
+
+ dataOS.write((len >>> 8) & 0xFF);
+ dataOS.write(len & 0xFF);
+ dataOS.write(_auth.getData());
+ dataOS.write(attrsData);
+
+ return dataOS.toByteArray();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/NASPortAttribute.java b/base/util/src/com/netscape/cmsutil/radius/NASPortAttribute.java
new file mode 100644
index 000000000..0f7b31e75
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/NASPortAttribute.java
@@ -0,0 +1,48 @@
+// --- 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 NASPortAttribute extends Attribute {
+ private int _port = 0;
+
+ public NASPortAttribute(byte value[]) {
+ super();
+ _t = NAS_PORT;
+ _port = value[5] & 0xFF;
+ _port |= ((value[4] << 8) & 0xFF00);
+ _port |= ((value[3] << 16) & 0xFF0000);
+ _port |= ((value[2] << 24) & 0xFF000000);
+ }
+
+ public NASPortAttribute(int port) {
+ super(NAS_PORT);
+ _port = port;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_port >>> 24) & 0xFF);
+ p[1] = (byte) ((_port >>> 16) & 0xFF);
+ p[2] = (byte) ((_port >>> 8) & 0xFF);
+ p[3] = (byte) (_port & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/NASPortTypeAttribute.java b/base/util/src/com/netscape/cmsutil/radius/NASPortTypeAttribute.java
new file mode 100644
index 000000000..84ccc3ae1
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/NASPortTypeAttribute.java
@@ -0,0 +1,53 @@
+// --- 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 NASPortTypeAttribute extends Attribute {
+ public static final int ASYNC = 0;
+ public static final int SYNC = 1;
+ public static final int ISDN_SYNC = 2;
+ public static final int ISDN_ASYNC_V120 = 3;
+ public static final int ISDN_ASYNC_V110 = 4;
+ public static final int VIRTUAL = 5;
+ public static final int PIAFS = 6;
+ public static final int HDLC = 7;
+ public static final int X_25 = 8;
+ public static final int X_75 = 9;
+ public static final int G3_FAX = 10;
+ public static final int SDSL = 11;
+ public static final int ADSL_CAP = 12;
+ public static final int ADSL_DMT = 13;
+ public static final int IDSL = 14;
+ public static final int ETHERNET = 15;
+ public static final int XDSL = 16;
+ public static final int CABLE = 17;
+
+ private byte _value[] = null;
+
+ public NASPortTypeAttribute(byte value[]) {
+ super();
+ _t = NAS_PORT_TYPE;
+ _value = value;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _value;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/Packet.java b/base/util/src/com/netscape/cmsutil/radius/Packet.java
new file mode 100644
index 000000000..4fad0ba79
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/Packet.java
@@ -0,0 +1,70 @@
+// --- 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;
+
+public abstract class Packet {
+ public static final int ACCESS_REQUEST = 1;
+ public static final int ACCESS_ACCEPT = 2;
+ public static final int ACCESS_REJECT = 3;
+ // public static final int ACCOUNTING_REQUEST = 4;
+ // public static final int ACCOUNTING_RESPONSE = 5;
+ public static final int ACCESS_CHALLENGE = 11;
+ public static final int RESERVED = 255;
+
+ protected int _c = 0;
+ protected short _id = 0;
+ protected Authenticator _auth = null;
+ protected AttributeSet _attrs = new AttributeSet();
+
+ public Packet() {
+ }
+
+ public Packet(int c, short id, Authenticator auth) {
+ _c = c;
+ _id = id;
+ _auth = auth;
+ }
+
+ public int getCode() {
+ return _c;
+ }
+
+ public short getIdentifier() {
+ return _id;
+ }
+
+ public Authenticator getAuthenticator() {
+ return _auth;
+ }
+
+ public void addAttribute(Attribute attr) {
+ _attrs.addAttribute(attr);
+ }
+
+ public AttributeSet getAttributeSet() {
+ return _attrs;
+ }
+
+ public Attribute getAttributeAt(int pos) {
+ return _attrs.getAttributeAt(pos);
+ }
+
+ public String toString() {
+ return "Packet [code=" + _c + ",id=" + (_id & 0xFF) + "]";
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/PacketFactory.java b/base/util/src/com/netscape/cmsutil/radius/PacketFactory.java
new file mode 100644
index 000000000..8d2e20e74
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/PacketFactory.java
@@ -0,0 +1,39 @@
+// --- 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 PacketFactory {
+ public static ServerPacket createServerPacket(byte data[])
+ throws IOException {
+ switch (data[0] & 0xFF) {
+ case Packet.ACCESS_ACCEPT:
+ return new AccessAccept(data);
+
+ case Packet.ACCESS_REJECT:
+ return new AccessReject(data);
+
+ case Packet.ACCESS_CHALLENGE:
+ return new AccessChallenge(data);
+
+ default:
+ throw new IOException("Unknown server packet " + (data[0] & 0xFF));
+ }
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/PortLimitAttribute.java b/base/util/src/com/netscape/cmsutil/radius/PortLimitAttribute.java
new file mode 100644
index 000000000..7903bb1fd
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/PortLimitAttribute.java
@@ -0,0 +1,51 @@
+// --- 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 PortLimitAttribute extends Attribute {
+ private int _port = 0;
+
+ private byte _value[] = null;
+
+ public PortLimitAttribute(byte value[]) {
+ super();
+ _t = FRAMED_IP_ADDRESS;
+ _value = value;
+ _port = value[5] & 0xFF;
+ _port |= ((value[4] << 8) & 0xFF00);
+ _port |= ((value[3] << 16) & 0xFF0000);
+ _port |= ((value[2] << 24) & 0xFF000000);
+
+ }
+
+ public int getPort() {
+ return _port;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_port >>> 24) & 0xFF);
+ p[1] = (byte) ((_port >>> 16) & 0xFF);
+ p[2] = (byte) ((_port >>> 8) & 0xFF);
+ p[3] = (byte) (_port & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/ProxyStateAttribute.java b/base/util/src/com/netscape/cmsutil/radius/ProxyStateAttribute.java
new file mode 100644
index 000000000..83831b652
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/ProxyStateAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 ProxyStateAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public ProxyStateAttribute(byte value[]) {
+ super();
+ _t = PROXY_STATE;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/RadiusConn.java b/base/util/src/com/netscape/cmsutil/radius/RadiusConn.java
new file mode 100644
index 000000000..b22807a5d
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/RadiusConn.java
@@ -0,0 +1,230 @@
+// --- 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;
+import java.io.InterruptedIOException;
+import java.net.DatagramPacket;
+import java.net.DatagramSocket;
+import java.net.InetAddress;
+import java.net.SocketException;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+import java.util.Properties;
+
+/**
+ * This class implements RFC2865 - Remote Authentication Dial In
+ * User Service (RADIUS), June 2000.
+ */
+public class RadiusConn {
+ public static int MAX_RETRIES = 10;
+ public static int OFFICAL_PORT = 1812;
+ public static int DEFAULT_PORT = 1645;
+ public static int DEFAULT_TIMEOUT = 5;
+
+ public static String OPTION_DEBUG = "OPTION_DEBUG";
+
+ private Properties _options = null;
+ private boolean _traceOn = true;
+ private String _host[] = new String[2];
+ private int _port[] = new int[2];
+ private int _selected = 0;
+ private String _secret = null;
+ private DatagramSocket _socket = null;
+ private short _id = (short) System.currentTimeMillis();
+ private int _maxRetries = MAX_RETRIES;
+ private SecureRandom _rand = null;
+
+ public RadiusConn(String host1, String host2, int port, String secret,
+ int timeout) throws SocketException {
+ this(host1, port, host2, port, secret, timeout, null, null);
+ }
+
+ public RadiusConn(String host, int port, String secret, byte seed[],
+ Properties options)
+ throws SocketException {
+ this(host, port, host, port, secret, DEFAULT_TIMEOUT, seed, options);
+ }
+
+ public RadiusConn(String host1, int port1, String host2, int port2,
+ String secret, int timeout, byte seed[], Properties options)
+ throws SocketException {
+ _host[0] = host1;
+ _port[0] = port1;
+ _host[1] = host2;
+ _port[1] = port2;
+ _selected = 0;
+ _secret = secret;
+ _options = options;
+ _socket = new DatagramSocket();
+ _socket.setSoTimeout(timeout * 1000);
+ if (seed == null) {
+ _rand = new SecureRandom();
+ } else {
+ _rand = new SecureRandom(seed);
+ }
+ }
+
+ public void disconnect() throws IOException {
+ _socket.disconnect();
+ }
+
+ public void authenticate(String name, String password)
+ throws IOException, NoSuchAlgorithmException,
+ RejectException, ChallengeException {
+ int retries = 0;
+ Packet res = null;
+
+ do {
+ AccessRequest req = createAccessRequest();
+
+ req.addAttribute(new UserNameAttribute(name));
+ req.addAttribute(new UserPasswordAttribute(req.getAuthenticator(),
+ _secret, password));
+ req.addAttribute(new NASIPAddressAttribute(InetAddress.getLocalHost()));
+ req.addAttribute(new NASPortAttribute(_socket.getLocalPort()));
+
+ send(req, _host[_selected], _port[_selected]);
+ try {
+ retries++;
+ res = receive();
+ if (res instanceof AccessReject) {
+ throw new RejectException((AccessReject) res);
+ } else if (res instanceof AccessChallenge) {
+ throw new ChallengeException((AccessChallenge) res);
+ }
+ } catch (InterruptedIOException e) {
+ if (retries >= _maxRetries) {
+ // switch server if maxRetries reaches limit
+ retries = 0;
+ if (_selected == 0) {
+ _selected = 1;
+ } else {
+ _selected = 0;
+ }
+ // throw e;
+ }
+
+ }
+ } while (res == null);
+ }
+
+ public void replyChallenge(String password, ChallengeException ce)
+ throws IOException, NoSuchAlgorithmException,
+ RejectException, ChallengeException {
+ replyChallenge(null, password, ce);
+ }
+
+ public void replyChallenge(String name, String password,
+ ChallengeException ce)
+ throws IOException, NoSuchAlgorithmException,
+ RejectException, ChallengeException {
+ StateAttribute state = (StateAttribute)
+ ce.getAttributeSet().getAttributeByType(Attribute.STATE);
+
+ if (state == null)
+ throw new IOException("State not found in challenge");
+ AccessRequest req = createAccessRequest();
+
+ req.addAttribute(state); // needed in challenge
+ if (name != null) {
+ req.addAttribute(new UserNameAttribute(name));
+ }
+ req.addAttribute(new UserPasswordAttribute(req.getAuthenticator(),
+ _secret, password));
+ req.addAttribute(new NASIPAddressAttribute(InetAddress.getLocalHost()));
+ req.addAttribute(new NASPortAttribute(_socket.getLocalPort()));
+
+ send(req, _host[_selected], _port[_selected]);
+ Packet res = receive();
+
+ if (res instanceof AccessReject) {
+ throw new RejectException((AccessReject) res);
+ } else if (res instanceof AccessChallenge) {
+ throw new ChallengeException((AccessChallenge) res);
+ }
+ }
+
+ public void replyChallenge(String name, String password, String state)
+ throws IOException, NoSuchAlgorithmException,
+ RejectException, ChallengeException {
+ if (state == null)
+ throw new IOException("State not found in challenge");
+ AccessRequest req = createAccessRequest();
+
+ req.addAttribute(new StateAttribute(state)); // needed in challenge
+ req.addAttribute(new UserNameAttribute(name));
+ req.addAttribute(new UserPasswordAttribute(req.getAuthenticator(),
+ _secret, password));
+ req.addAttribute(new NASIPAddressAttribute(InetAddress.getLocalHost()));
+ req.addAttribute(new NASPortAttribute(_socket.getLocalPort()));
+
+ send(req, _host[_selected], _port[_selected]);
+ Packet res = receive();
+
+ if (res instanceof AccessReject) {
+ throw new RejectException((AccessReject) res);
+ } else if (res instanceof AccessChallenge) {
+ throw new ChallengeException((AccessChallenge) res);
+ }
+ }
+
+ private short getIdentifier() {
+ return _id++;
+ }
+
+ private void send(NASPacket packet, String host, int port)
+ throws IOException {
+ DatagramPacket dp = new DatagramPacket(new byte[4096], 4096);
+
+ dp.setPort(port);
+ dp.setAddress(InetAddress.getByName(host));
+ byte data[] = packet.getData();
+
+ dp.setLength(data.length);
+ dp.setData(data);
+ _socket.send(dp);
+ if (_traceOn)
+ trace("Sent " + packet);
+ }
+
+ private ServerPacket receive()
+ throws IOException {
+ DatagramPacket dp = new DatagramPacket(new byte[4096], 4096);
+
+ _socket.receive(dp);
+ byte data[] = dp.getData();
+ ServerPacket p = PacketFactory.createServerPacket(data);
+
+ if (_traceOn)
+ trace("Received " + p + " size=" + p.getAttributeSet().size());
+ return p;
+ }
+
+ private AccessRequest createAccessRequest() throws NoSuchAlgorithmException {
+ RequestAuthenticator ra = new RequestAuthenticator(_rand, _secret);
+ AccessRequest req = new AccessRequest(getIdentifier(), ra);
+
+ return req;
+ }
+
+ private void trace(String msg) {
+ System.out.println("TRACE: " + msg);
+ System.out.flush();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/RejectException.java b/base/util/src/com/netscape/cmsutil/radius/RejectException.java
new file mode 100644
index 000000000..f312ef2a4
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/RejectException.java
@@ -0,0 +1,39 @@
+// --- 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;
+
+public class RejectException extends Exception {
+ /**
+ *
+ */
+ private static final long serialVersionUID = -6410697638175895003L;
+ private AccessReject _res = null;
+
+ public RejectException(AccessReject res) {
+ _res = res;
+ }
+
+ public AttributeSet getAttributeSet() {
+ return _res.getAttributeSet();
+ }
+
+ public String getReplyMessage() {
+ return ((ReplyMessageAttribute) (_res.getAttributeSet().getAttributeByType(Attribute.REPLY_MESSAGE)))
+ .getString();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/ReplyMessageAttribute.java b/base/util/src/com/netscape/cmsutil/radius/ReplyMessageAttribute.java
new file mode 100644
index 000000000..5ec4ea052
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/ReplyMessageAttribute.java
@@ -0,0 +1,40 @@
+// --- 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 ReplyMessageAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public ReplyMessageAttribute(byte value[]) {
+ super();
+ _t = REPLY_MESSAGE;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/RequestAuthenticator.java b/base/util/src/com/netscape/cmsutil/radius/RequestAuthenticator.java
new file mode 100644
index 000000000..5d82752dd
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/RequestAuthenticator.java
@@ -0,0 +1,44 @@
+// --- 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;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+import java.security.SecureRandom;
+
+public class RequestAuthenticator extends Authenticator {
+ private byte _ra[] = null;
+
+ public RequestAuthenticator(SecureRandom rand, String secret)
+ throws NoSuchAlgorithmException {
+ byte[] authenticator = new byte[16];
+
+ rand.nextBytes(authenticator);
+
+ MessageDigest md5 = MessageDigest.getInstance("MD5");
+
+ md5.update(authenticator);
+ md5.update(secret.getBytes());
+ _ra = md5.digest();
+ }
+
+ public byte[] getData() throws IOException {
+ return _ra;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/ResponseAuthenticator.java b/base/util/src/com/netscape/cmsutil/radius/ResponseAuthenticator.java
new file mode 100644
index 000000000..3c3de33c4
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/ResponseAuthenticator.java
@@ -0,0 +1,32 @@
+// --- 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 ResponseAuthenticator extends Authenticator {
+ private byte _data[] = null;
+
+ public ResponseAuthenticator(byte data[]) {
+ _data = data;
+ }
+
+ public byte[] getData() throws IOException {
+ return _data;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/ServerPacket.java b/base/util/src/com/netscape/cmsutil/radius/ServerPacket.java
new file mode 100644
index 000000000..f7d7fa302
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/ServerPacket.java
@@ -0,0 +1,47 @@
+// --- 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 abstract class ServerPacket extends Packet {
+ public ServerPacket(byte data[]) throws IOException {
+ super();
+ _c = data[0];
+ _id = data[1];
+ int datalen = data[3] & 0xFF;
+
+ datalen |= ((data[2] << 8) & 0xFF00);
+ byte authData[] = new byte[16];
+
+ System.arraycopy(data, 4, authData, 0, 16);
+ _auth = new ResponseAuthenticator(authData);
+
+ // building attributes
+ int startp = 20;
+
+ while (startp != datalen) {
+ int attrLen = (data[startp + 1] & 0xFF);
+ byte attrData[] = new byte[attrLen];
+
+ System.arraycopy(data, startp, attrData, 0, attrData.length);
+ addAttribute(AttributeFactory.createAttribute(attrData));
+ startp += attrData.length;
+ }
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/ServiceTypeAttribute.java b/base/util/src/com/netscape/cmsutil/radius/ServiceTypeAttribute.java
new file mode 100644
index 000000000..f31c74f9a
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/ServiceTypeAttribute.java
@@ -0,0 +1,61 @@
+// --- 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 ServiceTypeAttribute extends Attribute {
+ public static final int LOGIN = 1;
+ public static final int FRAMED = 2;
+ public static final int CALLBACK_LOGIN = 3;
+ public static final int CALLBACK_FRAMED = 4;
+ public static final int OUTBOUND = 5;
+ public static final int ADMINSITRATIVE = 6;
+ public static final int NAS_PROMPT = 7;
+ public static final int AUTHENTICATE_ONLY = 8;
+ public static final int CALLBACK_NAS_PROMPT = 9;
+ public static final int CALL_CHECK = 10;
+ public static final int CALLBACK_ADMINISTRATIVE = 11;
+
+ private byte _value[] = null;
+ private int _type = 0;
+
+ public ServiceTypeAttribute(byte value[]) {
+ super();
+ _t = SERVICE_TYPE;
+ _type = value[5] & 0xFF;
+ _type |= ((value[4] << 8) & 0xFF00);
+ _type |= ((value[3] << 16) & 0xFF0000);
+ _type |= ((value[2] << 24) & 0xFF000000);
+ _value = value;
+ }
+
+ public int getType() {
+ return _type;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_type >>> 24) & 0xFF);
+ p[1] = (byte) ((_type >>> 16) & 0xFF);
+ p[2] = (byte) ((_type >>> 8) & 0xFF);
+ p[3] = (byte) (_type & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/SessionTimeoutAttribute.java b/base/util/src/com/netscape/cmsutil/radius/SessionTimeoutAttribute.java
new file mode 100644
index 000000000..2809aee4b
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/SessionTimeoutAttribute.java
@@ -0,0 +1,48 @@
+// --- 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 SessionTimeoutAttribute extends Attribute {
+ private int _timeout = 0;
+
+ public SessionTimeoutAttribute(byte value[]) {
+ super();
+ _t = SESSION_TIMEOUT;
+ _timeout = value[5] & 0xFF;
+ _timeout |= ((value[4] << 8) & 0xFF00);
+ _timeout |= ((value[3] << 16) & 0xFF0000);
+ _timeout |= ((value[2] << 24) & 0xFF000000);
+ }
+
+ public SessionTimeoutAttribute(int timeout) {
+ super(SESSION_TIMEOUT);
+ _timeout = timeout;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_timeout >>> 24) & 0xFF);
+ p[1] = (byte) ((_timeout >>> 16) & 0xFF);
+ p[2] = (byte) ((_timeout >>> 8) & 0xFF);
+ p[3] = (byte) (_timeout & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/StateAttribute.java b/base/util/src/com/netscape/cmsutil/radius/StateAttribute.java
new file mode 100644
index 000000000..027f95620
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/StateAttribute.java
@@ -0,0 +1,45 @@
+// --- 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 StateAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _str = null;
+
+ public StateAttribute(String str) {
+ _t = STATE;
+ _str = str;
+ }
+
+ public StateAttribute(byte value[]) {
+ super();
+ _t = STATE;
+ _str = new String(value, 2, value.length - 2);
+ _value = value;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _str.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/TerminationActionAttribute.java b/base/util/src/com/netscape/cmsutil/radius/TerminationActionAttribute.java
new file mode 100644
index 000000000..b47a70d8c
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/TerminationActionAttribute.java
@@ -0,0 +1,55 @@
+// --- 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 TerminationActionAttribute extends Attribute {
+ public static final int DEFAULT = 0;
+ public static final int RADIUS_REQUEST = 1;
+
+ private int _action = 0;
+
+ public TerminationActionAttribute(byte value[]) {
+ super();
+ _t = TERMINATION_ACTION;
+ _action = value[5] & 0xFF;
+ _action |= ((value[4] << 8) & 0xFF00);
+ _action |= ((value[3] << 16) & 0xFF0000);
+ _action |= ((value[2] << 24) & 0xFF000000);
+ }
+
+ public TerminationActionAttribute(int action) {
+ super(TERMINATION_ACTION);
+ _action = action;
+ }
+
+ public int getAction() {
+ return _action;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte[] p = new byte[4];
+
+ p[0] = (byte) ((_action >>> 24) & 0xFF);
+ p[1] = (byte) ((_action >>> 16) & 0xFF);
+ p[2] = (byte) ((_action >>> 8) & 0xFF);
+ p[3] = (byte) (_action & 0xFF);
+ return p;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/UserNameAttribute.java b/base/util/src/com/netscape/cmsutil/radius/UserNameAttribute.java
new file mode 100644
index 000000000..af7ce6bbe
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/UserNameAttribute.java
@@ -0,0 +1,39 @@
+// --- 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 UserNameAttribute extends Attribute {
+ private String _name = null;
+
+ public UserNameAttribute(byte value[]) {
+ super();
+ _t = USER_NAME;
+ _name = new String(value, 2, value.length - 2);
+ }
+
+ public UserNameAttribute(String name) {
+ super(USER_NAME);
+ _name = name;
+ }
+
+ public byte[] getValue() throws IOException {
+ return _name.getBytes();
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/UserPasswordAttribute.java b/base/util/src/com/netscape/cmsutil/radius/UserPasswordAttribute.java
new file mode 100644
index 000000000..31c27cdfd
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/UserPasswordAttribute.java
@@ -0,0 +1,73 @@
+// --- 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;
+import java.security.MessageDigest;
+import java.security.NoSuchAlgorithmException;
+
+public class UserPasswordAttribute extends Attribute {
+ private Authenticator _ra = null;
+ private String _secret = null;
+ private String _password = null;
+
+ public UserPasswordAttribute(byte value[]) {
+ //
+ }
+
+ public UserPasswordAttribute(Authenticator ra, String secret, String password) {
+ super(USER_PASSWORD);
+ _ra = ra;
+ _secret = secret;
+ _password = password;
+ }
+
+ public byte[] getValue() throws IOException {
+ MessageDigest md5 = null;
+
+ try {
+ md5 = MessageDigest.getInstance("MD5");
+ } catch (NoSuchAlgorithmException e) {
+ throw new IOException(e.getMessage());
+ }
+ md5.update(_secret.getBytes());
+ md5.update(_ra.getData());
+ byte sum[] = md5.digest();
+
+ byte up[] = _password.getBytes();
+ int oglen = (up.length / 16) + 1;
+ byte ret[] = new byte[oglen * 16];
+
+ for (int i = 0; i < ret.length; i++) {
+ if ((i % 16) == 0) {
+ md5.reset();
+ md5.update(_secret.getBytes());
+ }
+ if (i < up.length) {
+ ret[i] = (byte) (sum[i % 16] ^ up[i]);
+ } else {
+ ret[i] = (byte) (sum[i % 16] ^ 0);
+ }
+ md5.update(ret[i]);
+ if ((i % 16) == 15) {
+ sum = md5.digest();
+ }
+ }
+ return ret;
+ }
+}
diff --git a/base/util/src/com/netscape/cmsutil/radius/VendorSpecificAttribute.java b/base/util/src/com/netscape/cmsutil/radius/VendorSpecificAttribute.java
new file mode 100644
index 000000000..5f3d9f170
--- /dev/null
+++ b/base/util/src/com/netscape/cmsutil/radius/VendorSpecificAttribute.java
@@ -0,0 +1,52 @@
+// --- 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 VendorSpecificAttribute extends Attribute {
+ private byte _value[] = null;
+ private String _id = null;
+ private String _str = null;
+
+ public VendorSpecificAttribute(byte value[]) {
+ super();
+ _t = VENDOR_SPECIFIC;
+ _id = new String(value, 2, 4);
+ _str = new String(value, 6, value.length - 6);
+ _value = value;
+ }
+
+ public String getId() {
+ return _id;
+ }
+
+ public String getString() {
+ return _str;
+ }
+
+ public byte[] getValue() throws IOException {
+ byte v[] = new byte[_id.length() + _str.length()];
+ byte idData[] = _id.getBytes();
+ byte strData[] = _str.getBytes();
+
+ System.arraycopy(idData, 0, v, 0, _id.length());
+ System.arraycopy(strData, 0, v, _id.length(), _str.length());
+ return v;
+ }
+}