|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.sourceforge.jradiusclient.RadiusClient
This class provides basic functionality required to implement a NAS as defined by the RADIUS protocol as specified in RFC 2865 and RFC 2866. This implementation is stateless and not thread safe, i.e. since the user name could be changed by the current thread or any other thread, it is difficult to ensure that the responseAttributes correlate to the request we think we are dealing with. It is up to the user of this class to ensure these things at this point. A future release may change this class to a stateful, threadsafe object, but it works for now. Users of this class must also manage building their own request attributes and submitting them with their call to authenticate. For example a programmer using this library, wanting to do chap authentication needs to generate the random challenge, send it to the user, who generates the MD5 of
Field Summary |
Constructor Summary | |
RadiusClient(java.lang.String hostname,
int authPort,
int acctPort,
java.lang.String sharedSecret,
java.lang.String userName)
Constructor allows the user to specify an alternate port for the radius server |
|
RadiusClient(java.lang.String hostname,
int authPort,
int acctPort,
java.lang.String sharedSecret,
java.lang.String userName,
int sockTimeout)
Constructor allows the user to specify an alternate port for the radius server |
|
RadiusClient(java.lang.String hostname,
java.lang.String sharedSecret,
java.lang.String userName)
Constructor - uses the default port 1812 for authentication and 1813 for accounting |
Method Summary | |
int |
authenticate(java.lang.String userPass)
This method performs the job of authenticating the specified user against the radius server. |
int |
authenticate(java.lang.String userPass,
java.io.ByteArrayOutputStream requestAttributes)
This method performs the job of authenticating the specified user against the radius server. |
int |
authenticate(java.lang.String userPass,
java.io.ByteArrayOutputStream requestAttributes,
int retries)
This method performs the job of authenticating the specified user against the radius server. |
protected void |
closeSocket()
closes the socket |
boolean |
disableAccounting(java.lang.String sessionID)
|
boolean |
disableAccounting(java.lang.String sessionID,
java.io.ByteArrayOutputStream requestAttributes)
|
boolean |
enableAccounting(java.lang.String sessionID)
|
boolean |
enableAccounting(java.lang.String sessionID,
java.io.ByteArrayOutputStream requestAttributes)
|
boolean |
equals(java.lang.Object object)
Compares the specified Object with this RadiusClient
for equality. |
void |
finalize()
overrides finalize to close socket and then normal finalize on super class |
int |
getAcctPort()
This method returns the current port to be used for accounting |
int |
getAuthPort()
This method returns the current port to be used for authentication |
java.lang.String |
getChallengeMessage()
This method extracts the Challenge message returned by a RADIUS Server and supplies it to the user, who should them use it to build a new password and re-authenticate. |
java.lang.String |
getFramedIPAddress()
This method extracts the Framed IP Address returned by a RADIUS Server |
java.lang.String |
getHostname()
This method returns the current Host Name to be used for RADIUS authentication or accounting |
java.lang.String |
getReplyMessage()
This method extracts the reply message returned by a RADIUS Server and supplies it to the user, who should them use it to build a new password and re-authenticate. |
java.lang.Integer |
getSessionTimeout()
This method extracts the SessionTimeout returned by a RADIUS Server |
java.lang.String |
getSharedSecret()
This method returns the current secret value that the Radius Client shares with the RADIUS Server. |
int |
getTimeout()
This method returns the current timeout period on a recieve of a response from the RADIUS Server. |
java.lang.String |
getUserName()
This method returns the current user name to be used for authentication |
int |
hashCode()
|
void |
setAcctPort(int port)
This method sets the port to be used for accounting |
void |
setAuthPort(int port)
This method sets the port to be used for authentication |
void |
setUserAttribute(int type,
byte[] attribute,
java.io.ByteArrayOutputStream requestAttributes)
This method is used to set a byte array attribute in a Request Attributes ByteArrayOutputStream that can be passed in to the authenticate method. |
void |
setUserName(java.lang.String username)
This method sets the user name to be used for authentication |
void |
setUserSubAttribute(int type,
int subType,
byte[] attribute,
java.io.ByteArrayOutputStream requestAttributes)
This method is used to set a byte array attribute in a Request Attributes ByteArrayOutputStream that can be passed in to the authenticate method. |
boolean |
startAccounting(java.lang.String sessionID)
|
boolean |
startAccounting(java.lang.String sessionID,
java.io.ByteArrayOutputStream requestAttributes)
|
boolean |
stopAccounting(java.lang.String sessionID)
|
boolean |
stopAccounting(java.lang.String sessionID,
java.io.ByteArrayOutputStream requestAttributes)
|
java.lang.String |
toString()
This method returns a string representation of this RadiusClient . |
boolean |
updateAccounting(java.lang.String sessionID)
|
boolean |
updateAccounting(java.lang.String sessionID,
java.io.ByteArrayOutputStream requestAttributes)
|
Methods inherited from class java.lang.Object |
clone, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
public RadiusClient(java.lang.String hostname, java.lang.String sharedSecret, java.lang.String userName) throws java.net.SocketException, java.security.NoSuchAlgorithmException, InvalidParameterException
hostname
- java.lang.StringsharedSecret
- java.lang.StringuserName
- java.lang.String
java.net.SocketException
- If we could not create the necessary socket
java.security.NoSuchAlgorithmException
- If we could not get an
instance of the MD5 algorithm.
InvalidParameterException
- If an invalid hostname
(null or empty string), an invalid port
(port < 0 or port > 65536) or an invalid
shared secret (null, shared secret can be
empty string) is passed in.public RadiusClient(java.lang.String hostname, int authPort, int acctPort, java.lang.String sharedSecret, java.lang.String userName) throws java.net.SocketException, java.security.NoSuchAlgorithmException, InvalidParameterException
hostname
- java.lang.StringauthPort
- int the port to use for authentication requestsacctPort
- int the port to use for accounting requestssharedSecret
- java.lang.StringuserName
- java.lang.String
java.net.SocketException
- If we could not create the necessary socket
java.security.NoSuchAlgorithmException
- If we could not get an
instance of the MD5 algorithm.
InvalidParameterException
- If an invalid hostname
(null or empty string), an invalid
port ( port < 0 or port > 65536)
or an invalid shared secret (null, shared
secret can be empty string) is passed in.public RadiusClient(java.lang.String hostname, int authPort, int acctPort, java.lang.String sharedSecret, java.lang.String userName, int sockTimeout) throws java.net.SocketException, java.security.NoSuchAlgorithmException, InvalidParameterException
hostname
- java.lang.StringauthPort
- int the port to use for authentication requestsacctPort
- int the port to use for accounting requestssharedSecret
- java.lang.StringuserName
- java.lang.String
java.net.SocketException
- If we could not create the necessary socket
java.security.NoSuchAlgorithmException
- If we could not get an
instance of the MD5 algorithm.
InvalidParameterException
- If an invalid hostname
(null or empty string), an invalid
port ( port < 0 or port > 65536)
or an invalid shared secret (null, shared
secret can be empty string) is passed in.Method Detail |
public int authenticate(java.lang.String userPass) throws java.io.IOException, java.net.UnknownHostException, RadiusException, InvalidParameterException
userPass
- java.lang.String
java.io.IOException
java.net.UnknownHostException
RadiusException
InvalidParameterException
public int authenticate(java.lang.String userPass, java.io.ByteArrayOutputStream requestAttributes) throws java.io.IOException, java.net.UnknownHostException, RadiusException, InvalidParameterException
userPass
- java.lang.StringrequestAttributes
- ByteArrayOutputStream
java.io.IOException
java.net.UnknownHostException
RadiusException
InvalidParameterException
public int authenticate(java.lang.String userPass, java.io.ByteArrayOutputStream requestAttributes, int retries) throws java.io.IOException, java.net.UnknownHostException, RadiusException, InvalidParameterException
userPass
- java.lang.String plaintext userPass to be encrypted using PAP algorithmrequestAttributes
- ByteArrayOutputStream
java.io.IOException
java.net.UnknownHostException
RadiusException
InvalidParameterException
public boolean startAccounting(java.lang.String sessionID) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
public boolean updateAccounting(java.lang.String sessionID) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
public boolean stopAccounting(java.lang.String sessionID) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
public boolean enableAccounting(java.lang.String sessionID) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
public boolean disableAccounting(java.lang.String sessionID) throws java.io.IOException, java.net.UnknownHostException
java.io.IOException
java.net.UnknownHostException
public boolean startAccounting(java.lang.String sessionID, java.io.ByteArrayOutputStream requestAttributes) throws java.io.IOException, java.net.UnknownHostException
sessionID
- the session identifier we are accounting
against for this userrequestAttributes
- Any additional attributes you might require to add to the accounting packet. (J.B. 25/08/2003)
java.io.IOException
java.net.UnknownHostException
public boolean updateAccounting(java.lang.String sessionID, java.io.ByteArrayOutputStream requestAttributes) throws java.io.IOException, java.net.UnknownHostException
sessionID
- the session identifier we are accounting
against for this userrequestAttributes
- Any additional attributes you might require to add to the accounting packet. (J.B. 25/08/2003)
java.io.IOException
java.net.UnknownHostException
public boolean stopAccounting(java.lang.String sessionID, java.io.ByteArrayOutputStream requestAttributes) throws java.io.IOException, java.net.UnknownHostException
sessionID
- the session identifier we are accounting
against for this userrequestAttributes
- Any additional attributes you might require to add to the accounting packet. (J.B. 25/08/2003)
java.io.IOException
java.net.UnknownHostException
public boolean enableAccounting(java.lang.String sessionID, java.io.ByteArrayOutputStream requestAttributes) throws java.io.IOException, java.net.UnknownHostException
sessionID
- the session identifier we are accounting
against for this user
java.io.IOException
java.net.UnknownHostException
public boolean disableAccounting(java.lang.String sessionID, java.io.ByteArrayOutputStream requestAttributes) throws java.io.IOException, java.net.UnknownHostException
sessionID
- the session identifier we are accounting
against for this user
java.io.IOException
java.net.UnknownHostException
public java.lang.String getHostname()
public int getAuthPort()
public void setAuthPort(int port) throws InvalidParameterException
port
- int
InvalidParameterException
- If the port is less
than 0 or greater than 65535public int getAcctPort()
public void setAcctPort(int port) throws InvalidParameterException
port
- int
InvalidParameterException
- If the port is less
than 0 or greater than 65535public java.lang.String getUserName()
public void setUserName(java.lang.String username) throws InvalidParameterException
InvalidParameterException
- If the username is null,
empty or all blankspublic java.lang.String getSharedSecret()
public int getTimeout()
public java.lang.String getReplyMessage() throws RadiusException
RadiusException
public java.lang.String getChallengeMessage() throws RadiusException
RadiusException
public java.lang.Integer getSessionTimeout() throws RadiusException
RadiusException
public java.lang.String getFramedIPAddress() throws RadiusException
RadiusException
public void setUserAttribute(int type, byte[] attribute, java.io.ByteArrayOutputStream requestAttributes) throws InvalidParameterException
type
- int attribute typeattribute
- byte[] the actual attribute byte arrayrequestAttributes
- ByteArrayOutputStream the ByteArrayOutputStreamto write the attribute to
InvalidParameterException
public void setUserSubAttribute(int type, int subType, byte[] attribute, java.io.ByteArrayOutputStream requestAttributes) throws InvalidParameterException
type
- int attribute typesubType
- int sub attribute typeattribute
- byte[] the actual attribute byte arrayrequestAttributes
- ByteArrayOutputStream the ByteArrayOutputStreamto write the attribute to
InvalidParameterException
- author kay michael koehler koehler@remwave.com, koehler@buddy4mac.com, koehler@econo.depublic java.lang.String toString()
RadiusClient
.
toString
in class java.lang.Object
public boolean equals(java.lang.Object object)
RadiusClient
for equality. Returns true if the given object is also a
RadiusClient
and the two RadiusClient
have the same host, port, sharedSecret & username.
equals
in class java.lang.Object
object
- Object to be compared for equality with this
RadiusClient
.
RadiusClient
.public int hashCode()
hashCode
in class java.lang.Object
RadiusClient
protected void closeSocket()
public void finalize() throws java.lang.Throwable
finalize
in class java.lang.Object
java.lang.Throwable
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |