UniOTP Agent APIs: Difference between revisions

From SecuTech Wiki
Jump to navigationJump to search
Created page with "== Chapter 1: C/C++ == ==== Installation and usage ==== 1. Please copy the Securepass_auth.h header file and the radclt.lib library file into your project.<br> 2. Please p..."
 
Bao (talk | contribs)
mNo edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
[[Category:UniOTP_API]]
== Chapter 1: C/C++  ==
== Chapter 1: C/C++  ==


==== Installation and usage  ====
=== Installation and usage  ===
 
1. Please copy the Securepass_auth.h header file and the radclt.lib library file into your project.<br> 2. Please perform authentication through the SecuAuth interface. For detailed instructions, please see the demo project. <br>
 
<br>
 
'''How to integrate with the C++ environment'''<br><br>
 
1. Please add the RadiusClt1.h header file and radclt.lib library file to the project. <br>
 
2. When you need to perform authentication, instantiate the RadiusClt class.<br> 3. Use the initrad member function inside the RadiusClt class to initialize authentication information. <br> 4. 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. <br><br>


# 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'''


<br>
# 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  ====
=== API  ===


int secuauth ( char *phost,<br> char *pshare, <br> int nsharelen, <br> char *pszusername, <br> int nusernamelen, <br> char *pszpassword, <br> int npasswordlen, <br> int *pnchallenge, <br> int *pbvalidresponse, <br> char *presponse/* = NULL*/, <br> int nmaxbuflen/* = 0*/, <br> unsigned short uport/* = 1812*/, <br> int nwaittime/* = 3*/ <br> ); <br>  
<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'''  
'''Parameters'''


{| cellspacing="1" cellpadding="1" border="1" width="500"
{| class="wikitable"
|-
|-
| '''Parameters<br>'''
! Parameters
| '''Description'''<br>
! Description
|-
|-
| Char *phost<br>
| Char *phost
| [IN] authentication server main address (IP <br>address)<br>
| [IN] authentication server main address (IP address)
|-
|-
| Char *pshare<br>
| Char *pshare
| [IN] shared key used by authentication <br>server and dynamic password token<br>
| [IN] shared key used by authentication server and dynamic password token
|-
|-
| Int nsharelen <br>
| Int nsharelen
| [IN] shared key length <br>
| [IN] shared key length
|-
|-
| char *pszusername<br>
| char *pszusername
| [IN] The username waiting for Authentication<br>
| [IN] The username waiting for authentication
|-
|-
| int nusernamelen <br>
| int nusernamelen
| [IN] username length<br>
| [IN] username length
|-
|-
| char *pszpassword<br>
| char *pszpassword
| [IN] Password for this time (OTP[PIN] PIN is optional, but it is compulsory to choose a PIN for challenge/response type.) <br>
| [IN] Password for this time (OTP[PIN] PIN is optional, but it is compulsory to choose a PIN for challenge/response type)
|-
|-
| int npasswordlen<br>
| int npasswordlen
| [IN] password length <br>
| [IN] password length
|-
|-
| int *pnchallenge<br>
| int *pnchallenge
| [OUT] The challenge code returned from the <br>server. If the function return value is <br>RD_ERROR_CHALLENGENEED, <br>pnchallenge will be used as the challenge <br>code.<br>
| [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<br>
| int *pbvalidresponse
| [OUT] whether Challenge information <br>returned or not(please don’t try to set this <br>parameter to NULL) <br>
| [OUT] whether Challenge information returned or not(please don’t try to set this parameter to NULL)
|-
|-
| char *presponse<br>
| 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.<br>
| [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<br>
| int nmaxbuflen
| [IN] response buffer maximum size(byte)<br>
| [IN] response buffer maximum size (byte)
|-
|-
| unsigned short uport <br>
| unsigned short uport
| [IN] Authentication server port number, the default port for standard Radius is 1812.<br>
| [IN] Authentication server port number, the default port for standard Radius is 1812
|-
|-
| int nwaittime<br>
| int nwaittime
| [IN] Maximum waiting time (second), if waiting time exceeds this value, the client will stop waiting for server response.<br>
| [IN] Maximum waiting time (second), if waiting time exceeds this value, the client will stop waiting for server response
|}
|}


<br>
'''Return value'''


{| cellspacing="1" cellpadding="1" border="1" width="500"
{| class="wikitable"
|-
|-
| '''Return value'''<br>
! Return value
| '''Description'''<br>
! Description
|-
|-
| RD_ERROR_SUCCESS<br>
| RD_ERROR_SUCCESS
| Authentication succeeded <br>
| Authentication succeeded
|-
|-
| RD_ERROR_CHALLENGENEED<br>
| RD_ERROR_CHALLENGENEED
| The function received successfully the challenge information returned from the server<br>
| The function received successfully the challenge information returned from the server
|-
|-
| RD_ERROR_INVALID_USERNAMERD_ERROR_INVALID<br>
| RD_ERROR_INVALID_USERNAMERD_ERROR_INVALID
| Cannot use this username <br>
| Cannot use this username
|-
|-
| RD_ERROR_INVALID_PWD<br>
| RD_ERROR_INVALID_PWD
| Cannot use this password (wrong format etc.) <br>
| Cannot use this password (wrong format, etc.)
|-
|-
| RD_ERROR_INVALIDHOST<br>
| RD_ERROR_INVALIDHOST
| Cannot use this authentication server (this error is also returned when the IP address field is empty)<br>
| Cannot use this authentication server (this error is also returned when the IP address field is empty)
|-
|-
| RD_ERROR_INVALIDPCNAME<br>
| RD_ERROR_INVALIDPCNAME
| Cannot read Computer name<br>
| Cannot read Computer name
|-
|-
| RD_ERROR_GENRAFAILED<br>
| RD_ERROR_GENRAFAILED
| Failed to generate authenticator request, an error might have occurred when requesting certification package.<br>
| Failed to generate authenticator request, an error might have occurred when requesting certification package
|-
|-
| RD_ERROR_GENPWDFAILED<br>
| RD_ERROR_GENPWDFAILED
| Failed to encrypt the password submitted by the user, this error might have occurred when organizing the packets<br>
| Failed to encrypt the password submitted by the user, this error might have occurred when organizing the packets
|-
|-
| RD_ERROR_CREATEPKTFAILED<br>
| RD_ERROR_CREATEPKTFAILED
| Failed to generate the authentication packets<br>
| Failed to generate the authentication packets
|-
|-
| RD_ERROR_CREATESOCKETFAILED<br>
| RD_ERROR_CREATESOCKETFAILED
| Socket initialization failed<br>
| Socket initialization failed
|-
|-
| RD_ERROR_SENDDATAFAILED<br>
| RD_ERROR_SENDDATAFAILED
| Failed to send packets<br>
| Failed to send packets
|-
|-
| RD_ERROR_RECVDATAFAILED<br>
| RD_ERROR_RECVDATAFAILED
| Failed to receive data<br>
| Failed to receive data
|-
|-
| RD_ERROR_INVALIDPKT<br>
| RD_ERROR_INVALIDPKT
| Data received are invalid<br>
| Data received are invalid
|-
|-
| RD_ERROR_NORESPONSE<br>
| RD_ERROR_NORESPONSE
| The server doesn’t respond <br>
| The server doesn’t respond
|-
|-
| RD_ERROR_AUTHFAILED<br>
| RD_ERROR_AUTHFAILED
| Authentication failed (wrong password, etc.)<br>
| Authentication failed (wrong password, etc)
|-
|-
| RD_ERROR_GETCHALLENGEFAILED <br>
| RD_ERROR_GETCHALLENGEFAILED
| The server sent challenge information but an error occurred when receiving data.<br>
| The server sent challenge information but an error occurred when receiving data
|-
|-
| RD_ERROR_REMOTESOCKETCLOSED <br>
| RD_ERROR_REMOTESOCKETCLOSED
| Server socket closed<br>
| Server socket closed
|-
|-
| RD_ERROR_INITSOCKFAILED <br>
| RD_ERROR_INITSOCKFAILED
| Under Windows, error when executing WSAStartup function<br>
| Under Windows, error when executing WSAStartup function
|}
|}


<br>


== Chapter 2: C# ==
== Chapter 2: C# ==


==== Installation and usage  ====
=== Installation and usage  ===


1. Please add the UniOTP_Clt.dll dynamic library to your project. <br> 2. Instantiate the SecuRadClts_Client constructor class in your source code where you want to authenticate the user. <br> 3. Use the “Authenticate” method inside the SecuRadClts_Client class to perform the authentication<br><br>
# 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.


SecuRadClts_Client class performs Radius client functions. By calling the member class function interfaces below, you can perform standard Radius authentication.
=== API: SECURADCLTS_CLIENT()  ===


==== API: SECURADCLTS_CLIENT()  ====
'''Prototype'''


'''Prototype'''<br>  
<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>


SecuRadClts_Client (
'''Description'''
string Server,
 
string SharedSecret, 
string Username, 
string Password, 
int nport
);


'''Description'''<br>
Class object instantiation, completes the initialization process


Class object instantiation, completes the initialization process
'''Parameters'''


'''Parameters'''<br>
{| class="wikitable"
 
{| cellspacing="1" cellpadding="1" border="1" width="500"
|-
|-
| '''Parameters<br>'''
! Parameters
| '''Description '''<br>
! Description
|-
|-
| String Server <br>
| String Server
| Authentication server address <br>
| Authentication server address
|-
|-
| String SharedSecret<br>
| String SharedSecret
| Shared key<br>
| Shared key
|-
|-
| String Username<br>
| String Username
| Username for the authentication<br>
| Username for the authentication
|-
|-
| String Password <br>
| String Password
| Password for the authentication<br>
| Password for the authentication
|-
|-
| Int nport <br>
| Int nport
| Authentication server port <br>
| Authentication server port
|}
|}


'''Return value '''<br>
'''Return value '''


{| cellspacing="1" cellpadding="1" border="1" width="500"
{| class="wikitable"
|-
|-
| '''Return Value'''<br>
! Return Value
| '''Description '''<br>
! Description  
|-
|-
| 0<br>
| 0
| Authentication Succeeded<br>
| Authentication Succeeded
|-
|-
| 1<br>
| 1
| Authentication request failed (impossible to connect to the server or wrong shared key)<br>
| Authentication request failed (impossible to connect to the server or wrong shared key)
|-
|-
| 2<br>
| 2
| authentication server response time out <br>
| authentication server response time out
|-
|-
| 3<br>
| 3
| returned packets are invalid (length shorter than the packet shortest length)<br>
| returned packets are invalid (length shorter than the packet shortest length)
|-
|-
| 4<br>
| 4
| Authentication failed (password error) <br>
| Authentication failed (password error)
|-
|-
| 5<br>
| 5
| Invalid packets (Identification code error)<br>
| Invalid packets (Identification code error)
|-
|-
| 6<br>
| 6
| packet length error<br>
| packet length error
|-
|-
| 7<br>
| 7
| invalid challenge information<br>
| invalid challenge information
|-
|-
| 8<br>
| 8
| invalid packets<br>
| invalid packets
|-
|-
| 100<br>
| 100
| The server sent a challenge<br>
| The server sent a challenge
|}
|}


<br>
'''Properties'''


'''Properties'''<br>
{| class="wikitable"
 
{| cellspacing="1" cellpadding="1" border="1" width="500"
|-
|-
| '''Property <br>'''
! Property
| '''Type'''<br>
! Type
| '''Meaning'''<br>
! Meaning
| '''Performing method'''<br>
! Performing method
|-
|-
| Shared Secret<br>
| Shared Secret
| String<br>
| String
| Shared Key<br>
| Shared Key
| Set get<br>
| Set get
|-
|-
| UserName <br>
| UserName
| String<br>
| String
| Username waiting to <br>be authenticated<br>
| Username waiting to be authenticated
| Set get<br>
| Set get
|-
|-
| Password<br>
| Password
| String<br>
| String
| Authentication password<br>
| Authentication password
| Set get<br>
| Set get
|-
|-
| Server<br>
| Server
| String<br>
| String
| Authentication server address<br>
| Authentication server address
| Set get<br>
| Set get
|-
|-
| Port <br>
| Port
| String<br>
| String
| Authentication server port <br>(Standard Radius authentication <br>protocol users 1812 for <br>authentication)<br>
| Authentication server port (Standard Radius authentication protocol users 1812 for authentication)
| Set get<br>
| Set get
|-
|-
| UDPTimeout <br>
| UDPTimeout
| String<br>
| String
| Server longest waiting time<br>
| Server longest waiting time
| Set get<br>
| Set get
|-
|-
| pChallenge<br>
| pChallenge
| String<br>
| String
| Server Challenge message <br>
| Server Challenge message
| Set get<br>
| Set get
|}
|}


<br>


== Chapter 3: Java  ==
== Chapter 3: Java  ==


==== Installation and Usage  ====
=== Installation and Usage  ===


1. Add the secuotp_jradiust.jar file inside your project. <br> 2. When you need to authenticate, Use RadientClient to create a client instance. <br> 3. Use “authenticate” to complete the authentication. <br> For further details about the source code, please see the sample folder. <br> <br>
# 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.


==== API: RADIUSCLIENT()  ====
For further details about the source code, please see the sample folder.


'''Prototype'''<br>
=== API: RadiusCLIENT()  ===


RadiusClient (
'''Prototype'''
String hostname,
String sharedSecret,
String username
);


<br>  
<source lang="java" collapse="true" first-line="2" highlight="[4,6]" title="title">
RadiusClient (
    String hostname,
    String sharedSecret,
    String username
);
</source>


'''Description'''<br>
'''Description'''


Create an object from the RadiusClient class  
Create an object from the RadiusClient class


'''Parameters'''<br>
'''Parameters'''


{| cellspacing="1" cellpadding="1" border="1" width="500"
{| class="wikitable"
|-
|-
| '''Parameters '''<br>
! Parameters  
| '''Description '''<br>
! Description  
|-
|-
| String hostname<br>
| String hostname
| Authentication server address <br>
| Authentication server address
|-
|-
| String shareSecret<br>
| String shareSecret
| Shared key<br>
| Shared key
|-
|-
| String username<br>
| String username
| Username for user waiting to be authenticated<br>
| Username for user waiting to be authenticated
|}
|}


<br>
'''Prototype 2'''


'''Prototype 2'''<br>  
<source lang="java" collapse="true" first-line="2" highlight="[4,6]" title="title">
RadiusClient (
    String hostname,
    int authPort,
    String sharedSecret,
    String username
);
</source>


RadiusClient(
'''Parameters'''
String hostname,
int authPort, 
String sharedSecret,
String username
);


'''Parameters'''<br>
{| class="wikitable"
 
{| cellspacing="1" cellpadding="1" border="1" width="500"
|-
|-
| '''Parameters'''<br>
! Parameters
| '''Description''' <br>
! Description
|-
|-
| String hostname<br>
| String hostname
| Authentication server address <br>
| Authentication server address
|-
|-
| Int authPort <br>
| int authPort
| Authentication service port (standard Radius authentication port is 1812) <br>
| Authentication service port (standard Radius authentication port is 1812)
|-
|-
| String shareSecret<br>
| String shareSecret
| Shared key<br>
| Shared key
|-
|-
| String username<br>
| String username
| Username for user waiting to be authenticated <br>
| Username for user waiting to be authenticated
|}
|}


<br>
'''Prototype 3'''
 
<br> '''Prototype 3'''<br>


RadiusClient(  
<source lang="java" collapse="true" first-line="2" highlight="[4,6]" title="title">
RadiusClient (
String hostname,  
    String hostname,
    int authPort,
int authPort,  
    String sharedSecret,
    String userName,
String sharedSecret,  
    int sockTimeout
);
String userName,  
</source>
int sockTimeout  
);  


<br> '''Description'''<br>
'''Description'''


Create an object from the RadiusClient class.  
Create an object from the RadiusClient class.


'''Parameters'''<br>
'''Parameters'''


{| cellspacing="1" cellpadding="1" border="1" width="500"
{| class="wikitable"
|-
|-
| '''Parameters '''<br>
! Parameters  
| '''Description'''<br>
! Description
|-
|-
| String hostname<br>
| String hostname
| Authentication server address <br>
| Authentication server address
|-
|-
| Int authPort<br>
| int authPort
| Authentication service port (standard <br>Radius authentication port is 1812) <br>
| Authentication service port (standard Radius authentication port is 1812)
|-
|-
| String shareSecret<br>
| String shareSecret
| Shared key<br>
| Shared key
|-
|-
| String username<br>
| String username
| Username for user waiting to be authenticated<br>
| Username for user waiting to be authenticated
|-
|-
| Int sockTimeout<br>
| int sockTimeout
| Longest waiting time for the server response<br>
| Longest waiting time for the server response
|}
|}


<br>
=== API: AUTHENTICATE() ===
 
==== API: AUTHENTICATE() ====


'''Prototype'''<br>
'''Prototype'''


int authenticate(  
<source lang="java" collapse="true" first-line="2" highlight="[4,6]" title="title">
int authenticate (
String userPass  
    String userPass
);
);
</source>


<br>
'''Description'''


'''Description'''<br>
Perform authentication


Perform authentication
'''Parameters'''


<br>
{| class="wikitable"
 
'''Parameters'''<br>
 
{| cellspacing="1" cellpadding="1" border="1" width="500"
|-
|-
| '''Parameters '''<br>
! Parameters  
| '''Description'''<br>
! Description
|-
|-
| Sting userPass<br>
| Sting userPass
| User authentication password for this time <br>(OTP only or OTP + PIN) <br>
| User authentication password for this time (OTP only or OTP + PIN)
|}
|}


<br>
'''Return Value'''


'''Return Value'''<br>
{| class="wikitable"
 
{| cellspacing="1" cellpadding="1" border="1" width="500"
|-
|-
| '''Return Value'''<br>
! Return Value
| '''Description '''<br>
! Description  
|-
|-
| ACCESS_ACCEPT <br>
| ACCESS_ACCEPT
| Authentication succeeded<br>
| Authentication succeeded
|-
|-
| ACCESS_REJECT <br>
| ACCESS_REJECT
| Authentication failed<br>
| Authentication failed
|-
|-
| ACCESS_CHALLENGE <br>
| ACCESS_CHALLENGE
| The server sent challenge information <br>
| The server sent challenge information
|}
|}


<br>
=== API: GETCHALLENGEMESSAGE()  ===
 
==== API: GETCHALLENGEMESSAGE()  ====


'''Prototype'''<br>
'''Prototype'''


String getChallengeMessage();
<code>String getChallengeMessage();</code>


<br> '''Description'''<br>
'''Description'''


When the authentication server sends a challenge, this function is used to retrieve the challenge information returned by the authentication service.  
When the authentication server sends a challenge, this function is used to retrieve the challenge information returned by the authentication service.


'''Parameters'''<br>
'''Parameters'''


N/A  
N/A


'''Return value'''<br>
'''Return value'''


N/A Challenge information returned by the server  
N/A Challenge information returned by the server


'''Static data definition'''<br>
'''Static data definition'''


{| cellspacing="1" cellpadding="1" border="1" width="500"
{| class="wikitable"
|-
|-
| '''Static data'''<br>
! Static data
| '''Value''' <br>
! Value
| '''Meaning '''<br>
! Meaning  
|-
|-
| ACCESS_ACCEPT<br>
| ACCESS_ACCEPT
| 2<br>
| 2
| Radius packet type, this packet shows <br>that the authentication succeeded<br>
| Radius packet type, this packet shows that the authentication succeeded
|-
|-
| ACCESS_REJECT<br>
| ACCESS_REJECT
| 3<br>
| 3
| Radius packet type, this packet shows <br>that the authentication failed<br>
| Radius packet type, this packet shows that the authentication failed
|-
|-
| ACCESS_CHALLENGE<br>
| ACCESS_CHALLENGE
| 11<br>
| 11
| Radius packet type, this packet shows<br>that the authentication emitted a challenge<br>
| Radius packet type, this packet showsthat the authentication emitted a challenge
|}
|}


<br>
== Chapter 4: PHP  ==


== Chapter 4: PHP  ==
=== Installation and Usage ===


1. Copy the 2 files, radius.class.php and radius_config.php into the project directory. <br> 2. Change the radius_config.php file contents so that it matches your authentication server parameters. <br> 3. When you need to authenticate, create an instance of Radius class <br> 4. Use the AccessRequest member function to complete the authentication procedure.<br><br>
# 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&nbsp;: RADIUS()  ====
=== API: RADIUS()  ===


'''Prototype:'''<br>
'''Prototype:'''


Radius(  
<source lang="php" collapse="true" first-line="2" highlight="[4,6]" title="title">
$ip_radius_server = '127.0.0.1',  
Radius (
$shared_secret = &lt;i&gt;, &lt;/i&gt;
    $ip_radius_server = '127.0.0.1',
$udp_timeout = 5,  
    $shared_secret = &lt;i&gt;, &lt;/i&gt;
$authentication_port = 1812  
    $udp_timeout = 5,
);
    $authentication_port = 1812
);
</source>


'''Description'''<br>
'''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'''<br>
'''Parameters'''


{| cellspacing="1" cellpadding="1" border="1" width="500"
{| class="wikitable"
|-
|-
| '''Parameters'''<br>
! Parameters
| '''Description'''<br>
! Description
|-
|-
| $ip_radius_server <br>
| $ip_radius_server
| Authentication server address or server domain name, if empty, local computer will be chosen as default. <br>
| Authentication server address or server domain name, if empty, local computer will be chosen as default.
|-
|-
| $shared_secret<br>
| $shared_secret
| shared key, if empty, no shared key will be used<br>
| shared key, if empty, no shared key will be used
|-
|-
| $udp_timeout <br>
| $udp_timeout
| Server response waiting time, if empty, time out will be 5 <br>
| Server response waiting time, if empty, time out will be 5
|-
|-
| $authentication_port<br>
| $authentication_port
| Authentication server port, if empty, the value will be 1812<br>
| Authentication server port, if empty, the value will be 1812
|}
|}


'''Return Value'''<br>
'''Return Value'''


N/A  
N/A


<br>
=== API:ACCESSREQUEST() ===


==== API:ACCESSREQUEST()  ====
'''Prototype'''


'''Prototype'''<br>  
<source lang="php" collapse="true" first-line="2" highlight="[4,6]" title="title">
AccessRequest (
    $username = &lt;i&gt;, &lt;/i&gt;
    $password = &lt;i&gt;, &lt;/i&gt;
    $udp_timeout = 0
);
</source>


AccessRequest(
'''Description'''
$username = &lt;i&gt;,&lt;/i&gt;
$password = &lt;i&gt;, &lt;/i&gt;
$udp_timeout = 0
);


<br>'''Description'''<br>
Perform user authentication


Perform user authentication
'''Parameters'''


'''Parameters'''<br>
{| class="wikitable"
 
{| cellspacing="1" cellpadding="1" border="1" width="500"
|-
|-
| '''Parameters'''<br>
! Parameters
| '''Description'''<br>
! Description
|-
|-
| width="120" | $username<br>
| width="120" | $username
| Username for the user waiting to be authenticated<br>
| Username for the user waiting to be authenticated
|-
|-
| $password<br>
| $password
| Authentication password for this time’s authentication, depending on the authentication method, this can either be OTP or OTP+PIN<br>
| Authentication password for this time’s authentication, depending on the authentication method, this can either be OTP or OTP+PIN
|-
|-
| $udp_timeout <br>
| $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. <br>
| 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.
|}
|}


<br>
'''Return value '''


'''Return value '''<br>
{| class="wikitable"
 
{| cellspacing="1" cellpadding="1" border="1" width="500"
|-
|-
| '''Return Value''' <br>
! Return Value
| '''Description'''<br>
! Description
|-
|-
| width="120" | ACCESS_ACCEPT <br>
| width="120" | ACCESS_ACCEPT
| Authentication succeeded <br>
| Authentication succeeded
|-
|-
| ACCESS_REJECT<br>
| ACCESS_REJECT
| Authentication failed<br>
| Authentication failed
|-
|-
| ACCESS_CHALLENGE<br>
| ACCESS_CHALLENGE
| Challenge sent by the authentication server for this time’s authentication <br>
| Challenge sent by the authentication server for this time’s authentication
|}
|}


==== API: GETCHALLENGEMSG()  ====
=== API: GETCHALLENGEMSG()  ===


'''Prototype'''<br>
'''Prototype'''


GetChallengeMsg();
<code>GetChallengeMsg();</code>


'''Description'''<br>
'''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'''<br>
'''Parameters'''


N/A  
N/A


'''Return Value'''<br>
'''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() ====
=== API:GETLASTERROR() ===


'''Prototype'''<br>
'''Prototype'''


GetLastError()
<code>GetLastError();</code>


'''Description'''<br>
'''Description'''


Get information about last error  
Get information about last error


'''Parameters'''<br>
'''Parameters'''


N/A  
N/A


'''Return Value'''<br>
'''Return Value'''


Character string, last abnormal error message  
Character string, last abnormal error message


==== API:CLEARLASTERROR() ====
=== API:CLEARLASTERROR() ===


'''Prototype'''<br>
'''Prototype'''


ClearLastError()
<code>ClearLastError();</code>


'''Description'''<br>
'''Description'''


Clears error information  
Clears error information


'''Parameters'''<br>
'''Parameters'''


N/A  
N/A


'''Return Value'''<br>
'''Return Value'''


N/A  
N/A


'''Static data definition'''<br>
'''Static data definition'''


{| cellspacing="1" cellpadding="1" border="1" width="500"
{| class="wikitable"
|-
|-
| Static data<br>
! Static data
| Value<br>
! Value
| Meaning <br>
! Meaning
|-
|-
| ACCESS_ACCEPT<br>
| ACCESS_ACCEPT
| 2<br>
| 2
| Radius packet type, this packet shows that the authentication succeeded <br>
| Radius packet type, this packet shows that the authentication succeeded
|-
|-
| ACCESS_REJECT<br>
| ACCESS_REJECT
| 3<br>
| 3
| Radius packet type, this packet shows that the authentication failed <br>
| Radius packet type, this packet shows that the authentication failed
|-
|-
| ACCESS_CHALLENGE<br>
| ACCESS_CHALLENGE
| 11<br>
| 11
| Radius packet type, this packet shows that the authentication emitted a challenge<br>
| Radius packet type, this packet shows that the authentication emitted a challenge
|}
|}
<br> <br>

Latest revision as of 15:49, 17 August 2016


Chapter 1: C/C++

Installation and usage

  1. Please copy the Securepass_auth.h header file and the radclt.lib library file into your project.
  2. Please perform authentication through the SecuAuth interface. For detailed instructions, please see the demo project.

How to integrate with the C++ environment

  1. Please add the RadiusClt1.h header file and radclt.lib library file to the project.
  2. When you need to perform authentication, instantiate the RadiusClt class.
  3. Use the initrad member function inside the RadiusClt class to initialize authentication information.
  4. 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

  1. Please add the UniOTP_Clt.dll dynamic library to your project.
  2. Instantiate the SecuRadClts_Client constructor class in your source code where you want to authenticate the user.
  3. 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

  1. Add the secuotp_jradiust.jar file inside your project.
  2. When you need to authenticate, Use RadientClient to create a client instance.
  3. 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

  1. Copy the 2 files, radius.class.php and radius_config.php into the project directory.
  2. Change the radius_config.php file contents so that it matches your authentication server parameters.
  3. When you need to authenticate, create an instance of Radius class
  4. 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 = &lt;i&gt;, &lt;/i&gt;
    $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 = &lt;i&gt;, &lt;/i&gt;
    $password = &lt;i&gt;, &lt;/i&gt;
    $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