Qt 4.8
Public Functions | Static Public Functions | Private Functions | Properties | Static Private Attributes | List of all members
FAREnforcer Class Reference

Enforces the False Authentication Rate. More...

#include <qtransportauth_qws_p.h>

Public Functions

void logAuthAttempt (QDateTime time=QDateTime::currentDateTime())
 
void reset ()
 

Static Public Functions

static FAREnforcergetInstance ()
 

Private Functions

 FAREnforcer ()
 
 FAREnforcer (const FAREnforcer &)
 
FAREnforceroperator= (FAREnforcer const &)
 

Properties

QList< QDateTimeauthAttempts
 

Static Private Attributes

static const QString FARMessage = QLatin1String("FAR_Exceeded")
 
static const int minute = 60
 
static const int minutelyRate = 4
 
static const QString SxeTag = QLatin1String("<SXE Breach>")
 

Detailed Description

Enforces the False Authentication Rate.

Warning
This function is not part of the public interface. If more than 4 authentications are received per minute the sxemonitor is notified that the FAR has been exceeded

Definition at line 169 of file qtransportauth_qws_p.h.

Constructors and Destructors

◆ FAREnforcer() [1/2]

FAREnforcer::FAREnforcer ( )
private

Definition at line 1518 of file qtransportauth_qws.cpp.

1518  :authAttempts()
1519 {
1520  QDateTime nullDateTime = QDateTime();
1521  for (int i = 0; i < minutelyRate; i++ )
1522  authAttempts << nullDateTime;
1523 }
QList< QDateTime > authAttempts
static const int minutelyRate
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

◆ FAREnforcer() [2/2]

FAREnforcer::FAREnforcer ( const FAREnforcer )
private

Functions

◆ getInstance()

FAREnforcer * FAREnforcer::getInstance ( )
static

Definition at line 1526 of file qtransportauth_qws.cpp.

Referenced by QTransportAuth::authFromMessage().

1527 {
1528  static FAREnforcer theInstance;
1529  return &theInstance;
1530 }
Enforces the False Authentication Rate.

◆ logAuthAttempt()

void FAREnforcer::logAuthAttempt ( QDateTime  time = QDateTime::currentDateTime())

Definition at line 1532 of file qtransportauth_qws.cpp.

Referenced by QTransportAuth::authFromMessage().

1533 {
1535 
1536  authAttempts.append( time );
1537  if ( dt.secsTo( authAttempts.last() ) <= minute )
1538  {
1539 #if defined(SXE_DISCOVERY)
1541  static QBasicAtomicInt reported = Q_BASIC_ATOMIC_INITIALIZER(0);
1542  if ( reported.testAndSetRelaxed(0,1) ) {
1543 #ifndef QT_NO_TEXTSTREAM
1544  QString logFilePath = QTransportAuth::getInstance()->logFilePath();
1545  if ( !logFilePath.isEmpty() ) {
1546  QFile log( logFilePath );
1547  if ( !log.open(QIODevice::WriteOnly | QIODevice::Append) ) {
1548  qWarning("Could not write to log in discovery mode: %s",
1549  qPrintable(logFilePath) );
1550  } else {
1551  QTextStream ts( &log );
1552  ts << "\t\tWarning: False Authentication Rate of " << minutelyRate << "\n"
1553  << "\t\tserver connections/authentications per minute has been exceeded,\n"
1554  << "\t\tno further warnings will be issued\n";
1555  }
1556  }
1557  }
1558 #endif
1559  reset();
1560  return;
1561  }
1562 #endif
1563  syslog( LOG_ERR | LOG_LOCAL6, "%s %s",
1566  reset();
1567  }
1568 }
static const QString SxeTag
The QString class provides a Unicode character string.
Definition: qstring.h:83
#define Q_BASIC_ATOMIC_INITIALIZER(a)
Definition: qbasicatomic.h:218
QList< QDateTime > authAttempts
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
bool testAndSetRelaxed(int expectedValue, int newValue)
T takeFirst()
Removes the first item in the list and returns it.
Definition: qlist.h:489
static const int minutelyRate
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
int secsTo(const QDateTime &) const
Returns the number of seconds from this datetime to the other datetime.
Definition: qdatetime.cpp:2914
Q_CORE_EXPORT void qWarning(const char *,...)
static const QString FARMessage
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216
The QFile class provides an interface for reading from and writing to files.
Definition: qfile.h:65
The QTextStream class provides a convenient interface for reading and writing text.
Definition: qtextstream.h:73
QString logFilePath() const
static const int minute
T & last()
Returns a reference to the last item in the list.
Definition: qlist.h:284
#define qPrintable(string)
Definition: qglobal.h:1750
static QTransportAuth * getInstance()
Return a pointer to the instance of this process&#39;s QTransportAuth object.
bool isDiscoveryMode() const

◆ operator=()

FAREnforcer& FAREnforcer::operator= ( FAREnforcer const &  )
private

◆ reset()

void FAREnforcer::reset ( )

Definition at line 1570 of file qtransportauth_qws.cpp.

Referenced by logAuthAttempt().

1571 {
1572  QDateTime nullDateTime = QDateTime();
1573  for (int i = 0; i < minutelyRate; i++ )
1574  authAttempts[i] = nullDateTime;
1575 }
QList< QDateTime > authAttempts
static const int minutelyRate
The QDateTime class provides date and time functions.
Definition: qdatetime.h:216

Properties

◆ authAttempts

QList<QDateTime> FAREnforcer::authAttempts
private

Definition at line 188 of file qtransportauth_qws_p.h.

Referenced by FAREnforcer(), logAuthAttempt(), and reset().

◆ FARMessage

const QString FAREnforcer::FARMessage = QLatin1String("FAR_Exceeded")
staticprivate

Definition at line 183 of file qtransportauth_qws_p.h.

Referenced by hmac_md5().

◆ minute

const int FAREnforcer::minute = 60
staticprivate

Definition at line 186 of file qtransportauth_qws_p.h.

Referenced by hmac_md5(), and logAuthAttempt().

◆ minutelyRate

const int FAREnforcer::minutelyRate = 4
staticprivate

Definition at line 184 of file qtransportauth_qws_p.h.

Referenced by FAREnforcer(), hmac_md5(), logAuthAttempt(), and reset().

◆ SxeTag

const QString FAREnforcer::SxeTag = QLatin1String("<SXE Breach>")
staticprivate

Definition at line 185 of file qtransportauth_qws_p.h.

Referenced by hmac_md5().


The documentation for this class was generated from the following files: