1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222
|
/*
* RadiusClass -- An C++-Library for radius authentication
* and accounting.
*
* Copyright (C) 2005 EWE TEL GmbH/Ralf Luebben <ralfluebben@gmx.de>
*
* 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; either version 2 of the License, or
* any later version.
*
* 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 St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include "RadiusServer.h"
#include <string.h>
/** The constructer of the class.
* @param char * name : Represents the name or the ip address. The default is 127.0.0.1.
* @param char * secret : The sharedsecret in plaintext.
* @param int authport : The UDP port for authentication, the default is 1812.
* @param int acctport : The UDP port for accounting, the default is 1813.
* @param int retry : How many times the client should try to send a packet if he doesn't get an answer.
* @param int wait : The time (in seconds) to wait on a response of the radius server.
*/
RadiusServer::RadiusServer(string name, string secret,
int authport, int acctport, int retry, int wait, int requirema)
{
this->acctport=acctport;
this->authport=authport;
this->name=name;
this->retry=retry;
this->wait=wait;
this->requirema=requirema;
this->sharedsecret=secret;
}
/** The destructur of the class.
* It does nothing.
*/
RadiusServer::~RadiusServer()
{
}
/** The allocation operator.
* @param const RadiusServer &s : A reference to a RadiusServer.
*/
RadiusServer &RadiusServer::operator=(const RadiusServer &s)
{
this->name=s.name;
this->wait=s.wait;
this->retry=s.retry;
this->acctport=s.acctport;
this->authport=s.authport;
this->requirema=s.requirema;
this->sharedsecret=s.sharedsecret;
return (*this);
}
/** The setter method for the authport.
* There is no correctness checking.
*@param port The number of the UDP port.
*/
void RadiusServer::setAuthPort(short int port)
{
this->authport=port;
}
/** The getter method for the authport.
* @return A integer of the authport.
*/
int RadiusServer::getAuthPort()
{
return (this->authport);
}
/** The setter method for the acctport.
* There is no correctness checking.
* @param port The number of the UDP port.
*/
void RadiusServer::setAcctPort(short int port)
{
this->acctport=port;
}
/** The getter method for the acctport.
* @return A integer of the acctport.
*/
int RadiusServer::getAcctPort()
{
return (this->acctport);
}
/**The setter method for the server name.
* There is no correctness checking. The name could be a name or an ip address.
* @param name : The name or ip address of the radius server.
*/
void RadiusServer::setName(string name)
{
this->name=name;
}
/** The getter method for the server name.
* @return A string with the server name.
*/
string RadiusServer::getName()
{
return (this->name);
}
/** The setter method for the retries.
* Is the value less or equal 0 it ist set to 1.
* @param retry The number of retries the client should try to send a radius packet to the server, if the doesn't get an answer.
*/
void RadiusServer::setRetry(int retry)
{
if (retry<=0)
{
retry=1;
}
this->retry=retry;
}
/** The getter method for the retry.
* @return A integer of the retries.
*/
int RadiusServer::getRetry()
{
return (this->retry);
}
/** The setter method for the sharedsecret
* @param secret The sharedsecret in plaintext.
*/
void RadiusServer::setSharedSecret(string secret)
{
this->sharedsecret=secret;
}
/** The getter method for the sharedsecret
* @return A string with the plaintext shared secret.
*/
string RadiusServer::getSharedSecret(void)
{
return this->sharedsecret;
}
/** The getter method for the private member wait*
* @return A interger of the time to wait for a resopnse.
*/
int RadiusServer::getWait(void)
{
return this->wait;
}
/** The setter method for the private member wait
* @param w The seconds to wait for response of the server. If w is less or equal 0 it is set to 1.
*/
void RadiusServer::setWait(int w)
{
if (w>0)
{
this->wait=w;
}
else
{
this->wait=1;
}
}
/** The getter method for the private member requirema
* @return A integer 0 when MA Message-Authenticator is not required, 1 if it
* is required, -1 if automatically determined from first answer.
*/
int RadiusServer::getRequireMA(void)
{
return this->requirema;
}
/** The setter method for the private member requirema
* @param ma integer 0 when MA Message-Authenticator is not required, 1 if it
*/
void RadiusServer::setRequireMA(int ma)
{
this->requirema=ma;
}
ostream& operator << (ostream& os, RadiusServer& server)
{
os << "\n\nRadiusServer:";
os << "\nName: " << server.name;
os << "\nAuthentication-Port: " << server.authport;
os << "\nAccounting-Port: " << server.acctport;
os << "\nRetries: " << server.retry;
os << "\nWait: " << server.wait;
os << "\nRequireMA: " << server.requirema;
os << "\nSharedSecret: *******";
return os;
}
|