UniOTP Agent APIs: Difference between revisions
mNo edit summary |
mNo edit summary |
||
| Line 3: | Line 3: | ||
== Chapter 1: C/C++ == | == Chapter 1: C/C++ == | ||
=== Installation and usage === | |||
# Please copy the Securepass_auth.h header file and the radclt.lib library file into your project. | |||
# Please perform authentication through the SecuAuth interface. For detailed instructions, please see the demo project. | |||
'''How to integrate with the C++ environment''' | |||
# Please add the RadiusClt1.h header file and radclt.lib library file to the project. | |||
# When you need to perform authentication, instantiate the RadiusClt class. | |||
# Use the initrad member function inside the RadiusClt class to initialize authentication information. | |||
# Use the “parase” member function inside the RadiusClt class in order to set the username and OTP PIN for authentication. Use the “auth” member function inside the RadiusClt class to terminate the authentication process. | |||
=== API === | |||
2 | <source lang="C" collapse="true" first-line="2" highlight="[4,6]" title="title"> | ||
int secuauth( | |||
char *phost, | |||
char *pshare, | |||
int nsharelen, | |||
char *pszusername, | |||
int nusernamelen, | |||
char *pszpassword, | |||
int npasswordlen, | |||
int *pnchallenge, | |||
int *pbvalidresponse, | |||
char *presponse /* = NULL*/, | |||
int nmaxbuflen /* = 0*/, | |||
unsigned short uport /* = 1812*/, | |||
int nwaittime /* = 3*/ | |||
); | |||
</source> | |||
'''Parameters''' | |||
{| class="wikitable" | |||
{| | |||
|- | |- | ||
! Parameters | |||
! Description | |||
|- | |- | ||
| Char *phost | | Char *phost | ||
| [IN] authentication server main address (IP | | [IN] authentication server main address (IP address) | ||
|- | |- | ||
| Char *pshare | | Char *pshare | ||
| [IN] shared key used by authentication | | [IN] shared key used by authentication server and dynamic password token | ||
|- | |- | ||
| Int nsharelen | | Int nsharelen | ||
| [IN] shared key length | | [IN] shared key length | ||
|- | |- | ||
| char *pszusername | | char *pszusername | ||
| [IN] The username waiting for | | [IN] The username waiting for authentication | ||
|- | |- | ||
| int nusernamelen | | int nusernamelen | ||
| [IN] username length | | [IN] username length | ||
|- | |- | ||
| char *pszpassword | | char *pszpassword | ||
| [IN] Password for this time (OTP[PIN] PIN is optional, but it is compulsory to choose a PIN for challenge/response type | | [IN] Password for this time (OTP[PIN] PIN is optional, but it is compulsory to choose a PIN for challenge/response type) | ||
|- | |- | ||
| int npasswordlen | | int npasswordlen | ||
| [IN] password length | | [IN] password length | ||
|- | |- | ||
| int *pnchallenge | | int *pnchallenge | ||
| [OUT] The challenge code returned from the | | [OUT] The challenge code returned from the server. If the function return value is RD_ERROR_CHALLENGENEED, pnchallenge will be used as the challenge code | ||
|- | |- | ||
| int *pbvalidresponse | | int *pbvalidresponse | ||
| [OUT] whether Challenge information | | [OUT] whether Challenge information returned or not(please don’t try to set this parameter to NULL) | ||
|- | |- | ||
| char *presponse | | char *presponse | ||
| [OUT] Buffer used for receiving challenge information. If the buffer length is smaller than the challenge information length, challenge information will not be returned. Challenge information length cannot exceed 256 bytes | | [OUT] Buffer used for receiving challenge information. If the buffer length is smaller than the challenge information length, challenge information will not be returned. Challenge information length cannot exceed 256 bytes | ||
|- | |- | ||
| int nmaxbuflen | | int nmaxbuflen | ||
| [IN] response buffer maximum | | [IN] response buffer maximum size (byte) | ||
|- | |- | ||
| unsigned short uport | | unsigned short uport | ||
| [IN] Authentication server port number, the default port for standard Radius is 1812 | | [IN] Authentication server port number, the default port for standard Radius is 1812 | ||
|- | |- | ||
| int nwaittime | | int nwaittime | ||
| [IN] Maximum waiting time (second), if waiting time exceeds this value, the client will stop waiting for server response | | [IN] Maximum waiting time (second), if waiting time exceeds this value, the client will stop waiting for server response | ||
|} | |} | ||
'''Return value''' | |||
{| | {| class="wikitable" | ||
|- | |- | ||
! Return value | |||
! Description | |||
|- | |- | ||
| RD_ERROR_SUCCESS | | RD_ERROR_SUCCESS | ||
| Authentication succeeded | | Authentication succeeded | ||
|- | |- | ||
| RD_ERROR_CHALLENGENEED | | RD_ERROR_CHALLENGENEED | ||
| The function received successfully the challenge information returned from the server | | The function received successfully the challenge information returned from the server | ||
|- | |- | ||
| RD_ERROR_INVALID_USERNAMERD_ERROR_INVALID | | RD_ERROR_INVALID_USERNAMERD_ERROR_INVALID | ||
| Cannot use this username | | Cannot use this username | ||
|- | |- | ||
| RD_ERROR_INVALID_PWD | | RD_ERROR_INVALID_PWD | ||
| Cannot use this password (wrong format etc.) | | Cannot use this password (wrong format, etc.) | ||
|- | |- | ||
| RD_ERROR_INVALIDHOST | | RD_ERROR_INVALIDHOST | ||
| Cannot use this authentication server (this error is also returned when the IP address field is empty) | | Cannot use this authentication server (this error is also returned when the IP address field is empty) | ||
|- | |- | ||
| RD_ERROR_INVALIDPCNAME | | RD_ERROR_INVALIDPCNAME | ||
| Cannot read Computer name | | Cannot read Computer name | ||
|- | |- | ||
| RD_ERROR_GENRAFAILED | | RD_ERROR_GENRAFAILED | ||
| Failed to generate authenticator request, an error might have occurred when requesting certification package | | Failed to generate authenticator request, an error might have occurred when requesting certification package | ||
|- | |- | ||
| RD_ERROR_GENPWDFAILED | | RD_ERROR_GENPWDFAILED | ||
| Failed to encrypt the password submitted by the user, this error might have occurred when organizing the packets | | Failed to encrypt the password submitted by the user, this error might have occurred when organizing the packets | ||
|- | |- | ||
| RD_ERROR_CREATEPKTFAILED | | RD_ERROR_CREATEPKTFAILED | ||
| Failed to generate the authentication packets | | Failed to generate the authentication packets | ||
|- | |- | ||
| RD_ERROR_CREATESOCKETFAILED | | RD_ERROR_CREATESOCKETFAILED | ||
| Socket initialization failed | | Socket initialization failed | ||
|- | |- | ||
| RD_ERROR_SENDDATAFAILED | | RD_ERROR_SENDDATAFAILED | ||
| Failed to send packets | | Failed to send packets | ||
|- | |- | ||
| RD_ERROR_RECVDATAFAILED | | RD_ERROR_RECVDATAFAILED | ||
| Failed to receive data | | Failed to receive data | ||
|- | |- | ||
| RD_ERROR_INVALIDPKT | | RD_ERROR_INVALIDPKT | ||
| Data received are invalid | | Data received are invalid | ||
|- | |- | ||
| RD_ERROR_NORESPONSE | | RD_ERROR_NORESPONSE | ||
| The server doesn’t respond | | The server doesn’t respond | ||
|- | |- | ||
| RD_ERROR_AUTHFAILED | | RD_ERROR_AUTHFAILED | ||
| Authentication failed (wrong password, etc | | Authentication failed (wrong password, etc) | ||
|- | |- | ||
| RD_ERROR_GETCHALLENGEFAILED | | RD_ERROR_GETCHALLENGEFAILED | ||
| The server sent challenge information but an error occurred when receiving data | | The server sent challenge information but an error occurred when receiving data | ||
|- | |- | ||
| RD_ERROR_REMOTESOCKETCLOSED | | RD_ERROR_REMOTESOCKETCLOSED | ||
| Server socket closed | | Server socket closed | ||
|- | |- | ||
| RD_ERROR_INITSOCKFAILED | | RD_ERROR_INITSOCKFAILED | ||
| Under Windows, error when executing WSAStartup function | | Under Windows, error when executing WSAStartup function | ||
|} | |} | ||
== Chapter 2: C# | == Chapter 2: C# == | ||
=== Installation and usage === | |||
# Please add the UniOTP_Clt.dll dynamic library to your project. | |||
# Instantiate the SecuRadClts_Client constructor class in your source code where you want to authenticate the user. | |||
# Use the Authenticate method inside the SecuRadClts_Client class to perform the authentication | |||
For further details about the source code, please see the sample folder. | For further details about the source code, please see the sample folder. SecuRadClts_Client class performs Radius client functions. By calling the member class function interfaces below, you can perform standard Radius authentication. | ||
=== API: SECURADCLTS_CLIENT() === | |||
'''Prototype''' | |||
<source lang="C#" collapse="true" first-line="2" highlight="[4,6]" title="title"> | |||
SecuRadClts_Client ( | |||
string Server, | |||
string SharedSecret, | |||
string Username, | |||
string Password, | |||
int nport | |||
); | |||
</source> | |||
'''Description''' | |||
Class object instantiation, completes the initialization process | |||
'''Parameters''' | |||
{| class="wikitable" | |||
{| | |||
|- | |- | ||
! Parameters | |||
! Description | |||
|- | |- | ||
| String Server | | String Server | ||
| Authentication server address | | Authentication server address | ||
|- | |- | ||
| String SharedSecret | | String SharedSecret | ||
| Shared key | | Shared key | ||
|- | |- | ||
| String Username | | String Username | ||
| Username for the authentication | | Username for the authentication | ||
|- | |- | ||
| String Password | | String Password | ||
| Password for the authentication | | Password for the authentication | ||
|- | |- | ||
| Int nport | | Int nport | ||
| Authentication server port | | Authentication server port | ||
|} | |} | ||
'''Return value ''' | '''Return value ''' | ||
{| | {| class="wikitable" | ||
|- | |- | ||
! Return Value | |||
! Description | |||
|- | |- | ||
| 0 | | 0 | ||
| Authentication Succeeded | | Authentication Succeeded | ||
|- | |- | ||
| 1 | | 1 | ||
| Authentication request failed (impossible to connect to the server or wrong shared key) | | Authentication request failed (impossible to connect to the server or wrong shared key) | ||
|- | |- | ||
| 2 | | 2 | ||
| authentication server response time out | | authentication server response time out | ||
|- | |- | ||
| 3 | | 3 | ||
| returned packets are invalid (length shorter than the packet shortest length) | | returned packets are invalid (length shorter than the packet shortest length) | ||
|- | |- | ||
| 4 | | 4 | ||
| Authentication failed (password error) | | Authentication failed (password error) | ||
|- | |- | ||
| 5 | | 5 | ||
| Invalid packets (Identification code error) | | Invalid packets (Identification code error) | ||
|- | |- | ||
| 6 | | 6 | ||
| packet length error | | packet length error | ||
|- | |- | ||
| 7 | | 7 | ||
| invalid challenge information | | invalid challenge information | ||
|- | |- | ||
| 8 | | 8 | ||
| invalid packets | | invalid packets | ||
|- | |- | ||
| 100 | | 100 | ||
| The server sent a challenge | | The server sent a challenge | ||
|} | |} | ||
'''Properties''' | |||
'''Properties''' | |||
{| | {| class="wikitable" | ||
|- | |- | ||
! Property | |||
! Type | |||
! Meaning | |||
! Performing method | |||
|- | |- | ||
| Shared Secret | | Shared Secret | ||
| String | | String | ||
| Shared Key | | Shared Key | ||
| Set get | | Set get | ||
|- | |- | ||
| UserName | | UserName | ||
| String | | String | ||
| Username waiting to | | Username waiting to be authenticated | ||
| Set get | | Set get | ||
|- | |- | ||
| Password | | Password | ||
| String | | String | ||
| Authentication password | | Authentication password | ||
| Set get | | Set get | ||
|- | |- | ||
| Server | | Server | ||
| String | | String | ||
| Authentication server address | | Authentication server address | ||
| Set get | | Set get | ||
|- | |- | ||
| Port | | Port | ||
| String | | String | ||
| Authentication server port | | Authentication server port (Standard Radius authentication protocol users 1812 for authentication) | ||
| Set get | | Set get | ||
|- | |- | ||
| UDPTimeout | | UDPTimeout | ||
| String | | String | ||
| Server longest waiting time | | Server longest waiting time | ||
| Set get | | Set get | ||
|- | |- | ||
| pChallenge | | pChallenge | ||
| String | | String | ||
| Server Challenge message | | Server Challenge message | ||
| Set get | | Set get | ||
|} | |} | ||
== Chapter 3: Java == | == Chapter 3: Java == | ||
=== Installation and Usage === | |||
# Add the secuotp_jradiust.jar file inside your project. | |||
# When you need to authenticate, Use RadientClient to create a client instance. | |||
# Use “authenticate” to complete the authentication. | |||
For further details about the source code, please see the sample folder. | |||
=== API: RadiusCLIENT() === | |||
'''Prototype''' | |||
< | <source lang="java" collapse="true" first-line="2" highlight="[4,6]" title="title"> | ||
RadiusClient ( | |||
String hostname, | |||
String sharedSecret, | |||
String username | |||
); | |||
</source> | |||
'''Description''' | '''Description''' | ||
Create an object from the RadiusClient class | Create an object from the RadiusClient class | ||
'''Parameters''' | '''Parameters''' | ||
{| | {| class="wikitable" | ||
|- | |- | ||
! Parameters | |||
! Description | |||
|- | |- | ||
| String hostname | | String hostname | ||
| Authentication server address | | Authentication server address | ||
|- | |- | ||
| String shareSecret | | String shareSecret | ||
| Shared key | | Shared key | ||
|- | |- | ||
| String username | | String username | ||
| Username for user waiting to be authenticated | | Username for user waiting to be authenticated | ||
|} | |} | ||
'''Prototype 2''' | |||
'''Prototype 2''' | |||
<source lang="java" collapse="true" first-line="2" highlight="[4,6]" title="title"> | |||
RadiusClient ( | |||
String hostname, | |||
int authPort, | |||
String sharedSecret, | |||
String username | |||
); | |||
</source> | |||
'''Parameters''' | '''Parameters''' | ||
{| | {| class="wikitable" | ||
|- | |- | ||
! Parameters | |||
! Description | |||
|- | |- | ||
| String hostname | | String hostname | ||
| Authentication server address | | Authentication server address | ||
|- | |- | ||
| | | int authPort | ||
| Authentication service port (standard Radius authentication port is 1812) | | Authentication service port (standard Radius authentication port is 1812) | ||
|- | |- | ||
| String shareSecret | | String shareSecret | ||
| Shared key | | Shared key | ||
|- | |- | ||
| String username | | String username | ||
| Username for user waiting to be authenticated | | Username for user waiting to be authenticated | ||
|} | |} | ||
'''Prototype 3''' | |||
<source lang="java" collapse="true" first-line="2" highlight="[4,6]" title="title"> | |||
RadiusClient ( | |||
String hostname, | |||
int authPort, | |||
String sharedSecret, | |||
String userName, | |||
int sockTimeout | |||
); | |||
</source> | |||
'''Description''' | |||
Create an object from the RadiusClient class. | Create an object from the RadiusClient class. | ||
'''Parameters''' | '''Parameters''' | ||
{| | {| class="wikitable" | ||
|- | |- | ||
! Parameters | |||
! Description | |||
|- | |- | ||
| String hostname | | String hostname | ||
| Authentication server address | | Authentication server address | ||
|- | |- | ||
| | | int authPort | ||
| Authentication service port (standard | | Authentication service port (standard Radius authentication port is 1812) | ||
|- | |- | ||
| String shareSecret | | String shareSecret | ||
| Shared key | | Shared key | ||
|- | |- | ||
| String username | | String username | ||
| Username for user waiting to be authenticated | | Username for user waiting to be authenticated | ||
|- | |- | ||
| | | int sockTimeout | ||
| Longest waiting time for the server response | | Longest waiting time for the server response | ||
|} | |} | ||
=== API: AUTHENTICATE() === | |||
'''Prototype''' | '''Prototype''' | ||
<source lang="java" collapse="true" first-line="2" highlight="[4,6]" title="title"> | |||
int authenticate ( | |||
String userPass | |||
); | |||
</source> | |||
'''Description''' | |||
Perform authentication | |||
'''Parameters''' | |||
{| class="wikitable" | |||
{| | |||
|- | |- | ||
! Parameters | |||
! Description | |||
|- | |- | ||
| Sting userPass | | Sting userPass | ||
| User authentication password for this time | | User authentication password for this time (OTP only or OTP + PIN) | ||
|} | |} | ||
'''Return Value''' | |||
{| class="wikitable" | |||
{| | |||
|- | |- | ||
! Return Value | |||
! Description | |||
|- | |- | ||
| ACCESS_ACCEPT | | ACCESS_ACCEPT | ||
| Authentication succeeded | | Authentication succeeded | ||
|- | |- | ||
| ACCESS_REJECT | | ACCESS_REJECT | ||
| Authentication failed | | Authentication failed | ||
|- | |- | ||
| ACCESS_CHALLENGE | | ACCESS_CHALLENGE | ||
| The server sent challenge information | | The server sent challenge information | ||
|} | |} | ||
=== API: GETCHALLENGEMESSAGE() === | |||
'''Prototype''' | |||
<code>String getChallengeMessage();</code> | |||
'''Description''' | |||
When the authentication server sends a challenge, this function is used to retrieve the challenge information returned by the authentication service. | |||
'''Parameters''' | |||
N/A | |||
'''Return value''' | |||
N/A Challenge information returned by the server | |||
'''Static data definition''' | |||
{| class="wikitable" | |||
{| | |||
|- | |- | ||
! Static data | |||
! Value | |||
! Meaning | |||
|- | |- | ||
| ACCESS_ACCEPT | | ACCESS_ACCEPT | ||
| 2 | | 2 | ||
| Radius packet type, this packet shows | | Radius packet type, this packet shows that the authentication succeeded | ||
|- | |- | ||
| ACCESS_REJECT | | ACCESS_REJECT | ||
| 3 | | 3 | ||
| Radius packet type, this packet shows | | Radius packet type, this packet shows that the authentication failed | ||
|- | |- | ||
| ACCESS_CHALLENGE | | ACCESS_CHALLENGE | ||
| 11 | | 11 | ||
| Radius packet type, this packet | | Radius packet type, this packet showsthat the authentication emitted a challenge | ||
|} | |} | ||
== Chapter 4: PHP == | == Chapter 4: PHP == | ||
=== Installation and Usage === | |||
# Copy the 2 files, radius.class.php and radius_config.php into the project directory. | |||
# Change the radius_config.php file contents so that it matches your authentication server parameters. | |||
# When you need to authenticate, create an instance of Radius class | |||
# Use the AccessRequest member function to complete the authentication procedure. | |||
For further details about the source code, please see the sample folder. | For further details about the source code, please see the sample folder. | ||
Class Radius is used for Radius on the client side, by using the following functions of the class, you can get the configuration data from the authentication server, the authentication information configuration data of the authentication user, user ID authentication, the server additional information, etc. | Class Radius is used for Radius on the client side, by using the following functions of the class, you can get the configuration data from the authentication server, the authentication information configuration data of the authentication user, user ID authentication, the server additional information, etc. | ||
=== API: RADIUS() === | |||
'''Prototype:''' | '''Prototype:''' | ||
<source lang="php" collapse="true" first-line="2" highlight="[4,6]" title="title"> | |||
Radius ( | |||
$ip_radius_server = '127.0.0.1', | |||
$shared_secret = <i>, </i> | |||
$udp_timeout = 5, | |||
$authentication_port = 1812 | |||
); | |||
</source> | |||
'''Description''' | '''Description''' | ||
Function to create an object from Radius class. Call this function to instantiate Radius class and in the same time configure server address, shared key and longest waiting time for server response. | Function to create an object from Radius class. Call this function to instantiate Radius class and in the same time configure server address, shared key and longest waiting time for server response. | ||
'''Parameters''' | '''Parameters''' | ||
{| | {| class="wikitable" | ||
|- | |- | ||
! Parameters | |||
! Description | |||
|- | |- | ||
| $ip_radius_server | | $ip_radius_server | ||
| Authentication server address or server domain name, if empty, local computer will be chosen as default. | | Authentication server address or server domain name, if empty, local computer will be chosen as default. | ||
|- | |- | ||
| $shared_secret | | $shared_secret | ||
| shared key, if empty, no shared key will be used | | shared key, if empty, no shared key will be used | ||
|- | |- | ||
| $udp_timeout | | $udp_timeout | ||
| Server response waiting time, if empty, time out will be 5 | | Server response waiting time, if empty, time out will be 5 | ||
|- | |- | ||
| $authentication_port | | $authentication_port | ||
| Authentication server port, if empty, the value will be 1812 | | Authentication server port, if empty, the value will be 1812 | ||
|} | |} | ||
'''Return Value''' | '''Return Value''' | ||
N/A | |||
=== API:ACCESSREQUEST() === | |||
'''Prototype''' | '''Prototype''' | ||
<source lang="php" collapse="true" first-line="2" highlight="[4,6]" title="title"> | |||
AccessRequest ( | |||
$username = <i>, </i> | |||
$password = <i>, </i> | |||
$udp_timeout = 0 | |||
); | |||
</source> | |||
'''Description''' | |||
Perform user authentication | Perform user authentication | ||
'''Parameters''' | '''Parameters''' | ||
{| | {| class="wikitable" | ||
|- | |- | ||
! Parameters | |||
! Description | |||
|- | |- | ||
| width="120" | $username | | width="120" | $username | ||
| Username for the user waiting to be authenticated | | Username for the user waiting to be authenticated | ||
|- | |- | ||
| $password | | $password | ||
| Authentication password for this time’s authentication, depending on the authentication method, this can either be OTP or OTP+PIN | | Authentication password for this time’s authentication, depending on the authentication method, this can either be OTP or OTP+PIN | ||
|- | |- | ||
| $udp_timeout | | $udp_timeout | ||
| Longest server response waiting time. If you don’t set this parameter, the value will be the default value defined in the class when instantiating. | | Longest server response waiting time. If you don’t set this parameter, the value will be the default value defined in the class when instantiating. | ||
|} | |} | ||
'''Return value ''' | |||
'''Return value ''' | |||
{| | {| class="wikitable" | ||
|- | |- | ||
! Return Value | |||
! Description | |||
|- | |- | ||
| width="120" | ACCESS_ACCEPT | | width="120" | ACCESS_ACCEPT | ||
| Authentication succeeded | | Authentication succeeded | ||
|- | |- | ||
| ACCESS_REJECT | | ACCESS_REJECT | ||
| Authentication failed | | Authentication failed | ||
|- | |- | ||
| ACCESS_CHALLENGE | | ACCESS_CHALLENGE | ||
| Challenge sent by the authentication server for this time’s authentication | | Challenge sent by the authentication server for this time’s authentication | ||
|} | |} | ||
=== API: GETCHALLENGEMSG() === | |||
'''Prototype''' | '''Prototype''' | ||
<code>GetChallengeMsg();</code> | |||
'''Description''' | '''Description''' | ||
When the AccessRequest function returns ACCESS_CHALLENGE, call this function to get the challenge code returned by the authentication server, which is used for the current ID authentication. | When the AccessRequest function returns ACCESS_CHALLENGE, call this function to get the challenge code returned by the authentication server, which is used for the current ID authentication. | ||
'''Parameters''' | '''Parameters''' | ||
N/A | N/A | ||
'''Return Value''' | '''Return Value''' | ||
Challenge information returned by the authentication server for this time’s authentication | Challenge information returned by the authentication server for this time’s authentication | ||
=== API:GETLASTERROR() === | |||
'''Prototype''' | '''Prototype''' | ||
<code>GetLastError();</code> | |||
'''Description''' | '''Description''' | ||
Get information about last error | Get information about last error | ||
'''Parameters''' | '''Parameters''' | ||
N/A | N/A | ||
'''Return Value''' | '''Return Value''' | ||
Character string, last abnormal error message | Character string, last abnormal error message | ||
=== API:CLEARLASTERROR() === | |||
'''Prototype''' | '''Prototype''' | ||
<code>ClearLastError();</code> | |||
'''Description''' | '''Description''' | ||
Clears error information | Clears error information | ||
'''Parameters''' | '''Parameters''' | ||
N/A | N/A | ||
'''Return Value''' | '''Return Value''' | ||
N/A | N/A | ||
'''Static data definition''' | '''Static data definition''' | ||
{| | {| class="wikitable" | ||
|- | |- | ||
! Static data | |||
! Value | |||
! Meaning | |||
|- | |- | ||
| ACCESS_ACCEPT | | ACCESS_ACCEPT | ||
| 2 | | 2 | ||
| Radius packet type, this packet shows that the authentication succeeded | | Radius packet type, this packet shows that the authentication succeeded | ||
|- | |- | ||
| ACCESS_REJECT | | ACCESS_REJECT | ||
| 3 | | 3 | ||
| Radius packet type, this packet shows that the authentication failed | | Radius packet type, this packet shows that the authentication failed | ||
|- | |- | ||
| ACCESS_CHALLENGE | | ACCESS_CHALLENGE | ||
| 11 | | 11 | ||
| Radius packet type, this packet shows that the authentication emitted a challenge | | Radius packet type, this packet shows that the authentication emitted a challenge | ||
|} | |} | ||
Latest revision as of 15:49, 17 August 2016
Chapter 1: C/C++
Installation and usage
- Please copy the Securepass_auth.h header file and the radclt.lib library file into your project.
- Please perform authentication through the SecuAuth interface. For detailed instructions, please see the demo project.
How to integrate with the C++ environment
- Please add the RadiusClt1.h header file and radclt.lib library file to the project.
- When you need to perform authentication, instantiate the RadiusClt class.
- Use the initrad member function inside the RadiusClt class to initialize authentication information.
- Use the “parase” member function inside the RadiusClt class in order to set the username and OTP PIN for authentication. Use the “auth” member function inside the RadiusClt class to terminate the authentication process.
API
int secuauth(
char *phost,
char *pshare,
int nsharelen,
char *pszusername,
int nusernamelen,
char *pszpassword,
int npasswordlen,
int *pnchallenge,
int *pbvalidresponse,
char *presponse /* = NULL*/,
int nmaxbuflen /* = 0*/,
unsigned short uport /* = 1812*/,
int nwaittime /* = 3*/
);
Parameters
| Parameters | Description |
|---|---|
| Char *phost | [IN] authentication server main address (IP address) |
| Char *pshare | [IN] shared key used by authentication server and dynamic password token |
| Int nsharelen | [IN] shared key length |
| char *pszusername | [IN] The username waiting for authentication |
| int nusernamelen | [IN] username length |
| char *pszpassword | [IN] Password for this time (OTP[PIN] PIN is optional, but it is compulsory to choose a PIN for challenge/response type) |
| int npasswordlen | [IN] password length |
| int *pnchallenge | [OUT] The challenge code returned from the server. If the function return value is RD_ERROR_CHALLENGENEED, pnchallenge will be used as the challenge code |
| int *pbvalidresponse | [OUT] whether Challenge information returned or not(please don’t try to set this parameter to NULL) |
| char *presponse | [OUT] Buffer used for receiving challenge information. If the buffer length is smaller than the challenge information length, challenge information will not be returned. Challenge information length cannot exceed 256 bytes |
| int nmaxbuflen | [IN] response buffer maximum size (byte) |
| unsigned short uport | [IN] Authentication server port number, the default port for standard Radius is 1812 |
| int nwaittime | [IN] Maximum waiting time (second), if waiting time exceeds this value, the client will stop waiting for server response |
Return value
| Return value | Description |
|---|---|
| RD_ERROR_SUCCESS | Authentication succeeded |
| RD_ERROR_CHALLENGENEED | The function received successfully the challenge information returned from the server |
| RD_ERROR_INVALID_USERNAMERD_ERROR_INVALID | Cannot use this username |
| RD_ERROR_INVALID_PWD | Cannot use this password (wrong format, etc.) |
| RD_ERROR_INVALIDHOST | Cannot use this authentication server (this error is also returned when the IP address field is empty) |
| RD_ERROR_INVALIDPCNAME | Cannot read Computer name |
| RD_ERROR_GENRAFAILED | Failed to generate authenticator request, an error might have occurred when requesting certification package |
| RD_ERROR_GENPWDFAILED | Failed to encrypt the password submitted by the user, this error might have occurred when organizing the packets |
| RD_ERROR_CREATEPKTFAILED | Failed to generate the authentication packets |
| RD_ERROR_CREATESOCKETFAILED | Socket initialization failed |
| RD_ERROR_SENDDATAFAILED | Failed to send packets |
| RD_ERROR_RECVDATAFAILED | Failed to receive data |
| RD_ERROR_INVALIDPKT | Data received are invalid |
| RD_ERROR_NORESPONSE | The server doesn’t respond |
| RD_ERROR_AUTHFAILED | Authentication failed (wrong password, etc) |
| RD_ERROR_GETCHALLENGEFAILED | The server sent challenge information but an error occurred when receiving data |
| RD_ERROR_REMOTESOCKETCLOSED | Server socket closed |
| RD_ERROR_INITSOCKFAILED | Under Windows, error when executing WSAStartup function |
Chapter 2: C#
Installation and usage
- Please add the UniOTP_Clt.dll dynamic library to your project.
- Instantiate the SecuRadClts_Client constructor class in your source code where you want to authenticate the user.
- Use the Authenticate method inside the SecuRadClts_Client class to perform the authentication
For further details about the source code, please see the sample folder. SecuRadClts_Client class performs Radius client functions. By calling the member class function interfaces below, you can perform standard Radius authentication.
API: SECURADCLTS_CLIENT()
Prototype
SecuRadClts_Client (
string Server,
string SharedSecret,
string Username,
string Password,
int nport
);
Description
Class object instantiation, completes the initialization process
Parameters
| Parameters | Description |
|---|---|
| String Server | Authentication server address |
| String SharedSecret | Shared key |
| String Username | Username for the authentication |
| String Password | Password for the authentication |
| Int nport | Authentication server port |
Return value
| Return Value | Description |
|---|---|
| 0 | Authentication Succeeded |
| 1 | Authentication request failed (impossible to connect to the server or wrong shared key) |
| 2 | authentication server response time out |
| 3 | returned packets are invalid (length shorter than the packet shortest length) |
| 4 | Authentication failed (password error) |
| 5 | Invalid packets (Identification code error) |
| 6 | packet length error |
| 7 | invalid challenge information |
| 8 | invalid packets |
| 100 | The server sent a challenge |
Properties
| Property | Type | Meaning | Performing method |
|---|---|---|---|
| Shared Secret | String | Shared Key | Set get |
| UserName | String | Username waiting to be authenticated | Set get |
| Password | String | Authentication password | Set get |
| Server | String | Authentication server address | Set get |
| Port | String | Authentication server port (Standard Radius authentication protocol users 1812 for authentication) | Set get |
| UDPTimeout | String | Server longest waiting time | Set get |
| pChallenge | String | Server Challenge message | Set get |
Chapter 3: Java
Installation and Usage
- Add the secuotp_jradiust.jar file inside your project.
- When you need to authenticate, Use RadientClient to create a client instance.
- Use “authenticate” to complete the authentication.
For further details about the source code, please see the sample folder.
API: RadiusCLIENT()
Prototype
RadiusClient (
String hostname,
String sharedSecret,
String username
);
Description
Create an object from the RadiusClient class
Parameters
| Parameters | Description |
|---|---|
| String hostname | Authentication server address |
| String shareSecret | Shared key |
| String username | Username for user waiting to be authenticated |
Prototype 2
RadiusClient (
String hostname,
int authPort,
String sharedSecret,
String username
);
Parameters
| Parameters | Description |
|---|---|
| String hostname | Authentication server address |
| int authPort | Authentication service port (standard Radius authentication port is 1812) |
| String shareSecret | Shared key |
| String username | Username for user waiting to be authenticated |
Prototype 3
RadiusClient (
String hostname,
int authPort,
String sharedSecret,
String userName,
int sockTimeout
);
Description
Create an object from the RadiusClient class.
Parameters
| Parameters | Description |
|---|---|
| String hostname | Authentication server address |
| int authPort | Authentication service port (standard Radius authentication port is 1812) |
| String shareSecret | Shared key |
| String username | Username for user waiting to be authenticated |
| int sockTimeout | Longest waiting time for the server response |
API: AUTHENTICATE()
Prototype
int authenticate (
String userPass
);
Description
Perform authentication
Parameters
| Parameters | Description |
|---|---|
| Sting userPass | User authentication password for this time (OTP only or OTP + PIN) |
Return Value
| Return Value | Description |
|---|---|
| ACCESS_ACCEPT | Authentication succeeded |
| ACCESS_REJECT | Authentication failed |
| ACCESS_CHALLENGE | The server sent challenge information |
API: GETCHALLENGEMESSAGE()
Prototype
String getChallengeMessage();
Description
When the authentication server sends a challenge, this function is used to retrieve the challenge information returned by the authentication service.
Parameters
N/A
Return value
N/A Challenge information returned by the server
Static data definition
| Static data | Value | Meaning |
|---|---|---|
| ACCESS_ACCEPT | 2 | Radius packet type, this packet shows that the authentication succeeded |
| ACCESS_REJECT | 3 | Radius packet type, this packet shows that the authentication failed |
| ACCESS_CHALLENGE | 11 | Radius packet type, this packet showsthat the authentication emitted a challenge |
Chapter 4: PHP
Installation and Usage
- Copy the 2 files, radius.class.php and radius_config.php into the project directory.
- Change the radius_config.php file contents so that it matches your authentication server parameters.
- When you need to authenticate, create an instance of Radius class
- Use the AccessRequest member function to complete the authentication procedure.
For further details about the source code, please see the sample folder.
Class Radius is used for Radius on the client side, by using the following functions of the class, you can get the configuration data from the authentication server, the authentication information configuration data of the authentication user, user ID authentication, the server additional information, etc.
API: RADIUS()
Prototype:
Radius (
$ip_radius_server = '127.0.0.1',
$shared_secret = <i>, </i>
$udp_timeout = 5,
$authentication_port = 1812
);
Description
Function to create an object from Radius class. Call this function to instantiate Radius class and in the same time configure server address, shared key and longest waiting time for server response.
Parameters
| Parameters | Description |
|---|---|
| $ip_radius_server | Authentication server address or server domain name, if empty, local computer will be chosen as default. |
| $shared_secret | shared key, if empty, no shared key will be used |
| $udp_timeout | Server response waiting time, if empty, time out will be 5 |
| $authentication_port | Authentication server port, if empty, the value will be 1812 |
Return Value
N/A
API:ACCESSREQUEST()
Prototype
AccessRequest (
$username = <i>, </i>
$password = <i>, </i>
$udp_timeout = 0
);
Description
Perform user authentication
Parameters
| Parameters | Description |
|---|---|
| $username | Username for the user waiting to be authenticated |
| $password | Authentication password for this time’s authentication, depending on the authentication method, this can either be OTP or OTP+PIN |
| $udp_timeout | Longest server response waiting time. If you don’t set this parameter, the value will be the default value defined in the class when instantiating. |
Return value
| Return Value | Description |
|---|---|
| ACCESS_ACCEPT | Authentication succeeded |
| ACCESS_REJECT | Authentication failed |
| ACCESS_CHALLENGE | Challenge sent by the authentication server for this time’s authentication |
API: GETCHALLENGEMSG()
Prototype
GetChallengeMsg();
Description
When the AccessRequest function returns ACCESS_CHALLENGE, call this function to get the challenge code returned by the authentication server, which is used for the current ID authentication.
Parameters
N/A
Return Value
Challenge information returned by the authentication server for this time’s authentication
API:GETLASTERROR()
Prototype
GetLastError();
Description
Get information about last error
Parameters
N/A
Return Value
Character string, last abnormal error message
API:CLEARLASTERROR()
Prototype
ClearLastError();
Description
Clears error information
Parameters
N/A
Return Value
N/A
Static data definition
| Static data | Value | Meaning |
|---|---|---|
| ACCESS_ACCEPT | 2 | Radius packet type, this packet shows that the authentication succeeded |
| ACCESS_REJECT | 3 | Radius packet type, this packet shows that the authentication failed |
| ACCESS_CHALLENGE | 11 | Radius packet type, this packet shows that the authentication emitted a challenge |