Skip to main content

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.

ValueDescription
NormalConnectionnormal TCP socket connection - Deprecated
SecureConnectionA secure (TLS) connection
SSLMutualConnectionA TLS connection with mutual authentication and PKCS 11,12 authentication. Certificate chain and private key are needed

Protected Attributes

TypeNameDescription
void *m_pConn
te_oidm_nPrincipalID
_TESTD string *m_pstrServer
uint32_tm_nPort
_TESTD string *m_pstrCookie
uint32_tm_nConnType

Protected Member Functions

MemberDescription
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

MemberDescription
~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)=0The 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() constThe 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() constThe 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) constThe 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() constThe 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() constThe getCipherAlgorithm method retrieves the current cipher algorithm.

Static Public Member Functions

MemberDescription
_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

ParameterDescription
serverA constant string representing the name or IP of the Key Server.
portAn integer representing the Key Service port number.

void authenticate(TEAuthenticationContext &ctx)

The authenticate method authenticates a principal.

Parameters

ParameterDescription
ctxA 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

ParameterDescription
serverA constant string representing the name or IP of the Key Server.
portAn integer representing the Key Service port number.
userA constant string representing a username.
passwdA 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

ParameterDescription
serverA constant string representing the name or IP of the Key Server.
portAn unsigned long integer representing the Key Service port number.
ctxA TEAuthenticationContext object.

void open(TEAuthenticationContext &ctx)

The open method opens a connection having an authentication context.

Parameters

ParameterDescription
ctxA 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

ParameterDescription
serverA 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

ParameterDescription
portAn 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

ParameterDescription
encodeA 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

ParameterDescription
delayAn 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

ParameterDescription
cipherA 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

ParameterDescription
connTypeAn 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

ParameterDescription
handleAn integer representing a connection handle for an existing connection.
connTypeAn integer representing a connection type.