ERUCES::TEConnection
#include <teagent.h>
The TEConnection class represents connections to the Key Service.
The TEConnection class representing connections to the Key Server.
The TEConnection class is an abstract class representing a connection to a Key Server. The first step in working with the TEAgent package is creating a TEConnection object by calling the static createInstance method and then connecting that object to a Key Server by calling the open method.
Public Types
enum @066036215336124020322037301252240025056105240242
Connection type enumation.
| Value | Description |
|---|---|
NormalConnection | normal TCP socket connection - Deprecated |
SecureConnection | A secure (TLS) connection |
SSLMutualConnection | A TLS connection with mutual authentication and PKCS 11,12 authentication. Certificate chain and private key are needed |
Protected Attributes
| Type | Name | Description |
|---|---|---|
| void * | m_pConn | |
| te_oid | m_nPrincipalID | |
| _TESTD string * | m_pstrServer | |
| uint32_t | m_nPort | |
| _TESTD string * | m_pstrCookie | |
| uint32_t | m_nConnType |
Protected Member Functions
| Member | Description |
|---|---|
TEConnection() | The TEConnection constructor is the default class constructor. |
TEConnection(const TEConnection &) | The TEConnection constructor copies a TEConnection object. |
void open(const _TESTD string &server, uint32_t port) | The open method opens a TCP socket connection. |
void authenticate(TEAuthenticationContext &ctx) | The authenticate method authenticates a principal. |
Public Member Functions
| Member | Description |
|---|---|
~TEConnection() | The TEConnection destructor is the class destructor. |
void open(const _TESTD string &server, uint32_t port, const _TESTD string &user, const _TESTD string &passwd)=0 | The open method opens a connection with username and password authentication. |
void open(const _TESTD string &server, uint32_t port, TEAuthenticationContext &ctx) | The open method opens a connection using the specified type of authentication context. |
void open(TEAuthenticationContext &ctx) | The open method opens a connection having an authentication context. |
void close() | The close method closes a connection to the Key Service. |
uint32_t getConnectionHandle() | The getConnectionHandle method gets a connection handle which can be used to build another connection object that will share the same connection. |
_TESTD string getServer() const | The getServer method gets a server name or IP address. |
void setServer(const _TESTD string &server) | The setServer method sets a server name or IP address. |
uint32_t getPort() const | The getPort method gets a communication port number. |
void setPort(const uint32_t port) | The setPort method sets a port number. |
bool isValid() | The isValid method checks whether a connection is valid. |
te_oid getPrincipalID() | The getPrincipalId method gets a principal identifier used to connect to a server. |
const _TESTD string getCookie(bool encode=true) const | The getCookie method retrieves the cookie for the connection from the Key Service. |
void clearTokenSession(uint32_t delay) | The clearTokenSession method clears the currrent token session from the Key Service. |
uint32_t getConnectionType() const | The getConnectionType method retrieves the current type of connection. |
void setCipherAlgorithm(const _TESTD string &cipher) | The setCipherAlgorithm method sets the cipher algorithm. |
void setDefaultCipherAlgorithm() | The setDefaultCipherAlgorithm method sets the default cipher algorithm. |
const _TESTD string getCipherAlgorithm() const | The getCipherAlgorithm method retrieves the current cipher algorithm. |
Static Public Member Functions
| Member | Description |
|---|---|
_TESTD auto_ptr< TEConnection > createInstance(uint32_t connType) | The createInstance method creates a connection object with a specific connection type. |
_TESTD auto_ptr< TEConnection > getInstance(uint32_t handle, uint32_t connType=NormalConnection) | The getInstance method gets an existing socket connection and creates a new connection object. |
Member Function Documentation
TEConnection()
The TEConnection constructor is the default class constructor.
TEConnection(const TEConnection &)
The TEConnection constructor copies a TEConnection object.
void open(const _TESTD string &server, uint32_t port)
The open method opens a TCP socket connection.
Parameters
| Parameter | Description |
|---|---|
server | A constant string representing the name or IP of the Key Server. |
port | An integer representing the Key Service port number. |
void authenticate(TEAuthenticationContext &ctx)
The authenticate method authenticates a principal.
Parameters
| Parameter | Description |
|---|---|
ctx | A TEAuthenticationContext object that keeps the principal's credentials. |
~TEConnection()
The TEConnection destructor is the class destructor.
void open(const _TESTD string &server, uint32_t port, const _TESTD string &user, const _TESTD string &passwd)=0
The open method opens a connection with username and password authentication.
Parameters
| Parameter | Description |
|---|---|
server | A constant string representing the name or IP of the Key Server. |
port | An integer representing the Key Service port number. |
user | A constant string representing a username. |
passwd | A constant string representing a password. |
void open(const _TESTD string &server, uint32_t port, TEAuthenticationContext &ctx)
The open method opens a connection using the specified type of authentication context.
Parameters
| Parameter | Description |
|---|---|
server | A constant string representing the name or IP of the Key Server. |
port | An unsigned long integer representing the Key Service port number. |
ctx | A TEAuthenticationContext object. |
void open(TEAuthenticationContext &ctx)
The open method opens a connection having an authentication context.
Parameters
| Parameter | Description |
|---|---|
ctx | A TEAuthenticationContext object. |
Remark: Server name and port must be set before calling this method.
void close()
The close method closes a connection to the Key Service.
uint32_t getConnectionHandle()
The getConnectionHandle method gets a connection handle which can be used to build another connection object that will share the same connection.
Remark: The connection handle cannot be used to build another secure connection object because secure connection cannot be shared.
Returns: Returns a connection handle for an existing connection.
_TESTD string getServer() const
The getServer method gets a server name or IP address.
Returns: Returns a string representing a server name or IP address.
void setServer(const _TESTD string &server)
The setServer method sets a server name or IP address.
Parameters
| Parameter | Description |
|---|---|
server | A string representing a server name or IP address. |
uint32_t getPort() const
The getPort method gets a communication port number.
Returns: Returns an integer representing a port number.
void setPort(const uint32_t port)
The setPort method sets a port number.
Parameters
| Parameter | Description |
|---|---|
port | An integer representing the port number to be set. |
bool isValid()
The isValid method checks whether a connection is valid.
Returns: Returns a boolean value representing the connection validity; True = connection valid, False = connection invalid.
te_oid getPrincipalID()
The getPrincipalId method gets a principal identifier used to connect to a server.
Returns: Returns an integer representing the principal ID of the connection's current owner.
const _TESTD string getCookie(bool encode=true) const
The getCookie method retrieves the cookie for the connection from the Key Service.
Parameters
| Parameter | Description |
|---|---|
encode | A boolean value representing whether or not to Base64 encode the cookie. |
Returns: Returns a string representing the cookie returned from the Key Service. May be Base64 encoded.
void clearTokenSession(uint32_t delay)
The clearTokenSession method clears the currrent token session from the Key Service.
Parameters
| Parameter | Description |
|---|---|
delay | An integer representing the amount of time to delay clearing the token session. In seconds. |
uint32_t getConnectionType() const
The getConnectionType method retrieves the current type of connection.
Returns: Returns the type of connection.
void setCipherAlgorithm(const _TESTD string &cipher)
The setCipherAlgorithm method sets the cipher algorithm.
Parameters
| Parameter | Description |
|---|---|
cipher | A String of cipher algorithm (case sensitive) |
void setDefaultCipherAlgorithm()
The setDefaultCipherAlgorithm method sets the default cipher algorithm.
const _TESTD string getCipherAlgorithm() const
The getCipherAlgorithm method retrieves the current cipher algorithm.
Returns: Returns a string of cipher algorithm.
_TESTD auto_ptr< TEConnection > createInstance(uint32_t connType)
The createInstance method creates a connection object with a specific connection type.
Parameters
| Parameter | Description |
|---|---|
connType | An integer representing a connection type. |
_TESTD auto_ptr< TEConnection > getInstance(uint32_t handle, uint32_t connType=NormalConnection)
The getInstance method gets an existing socket connection and creates a new connection object.
Parameters
| Parameter | Description |
|---|---|
handle | An integer representing a connection handle for an existing connection. |
connType | An integer representing a connection type. |