\section{KDESasl Class Reference}
\label{classKDESasl}\index{KDESasl@{KDESasl}}
This library can create responses for SASL authentication for a given challenge and a given secret.  


{\tt \#include $<$kdesasl.h$>$}

Collaboration diagram for KDESasl:\begin{figure}[H]
\begin{center}
\leavevmode
\includegraphics[width=93pt]{classKDESasl__coll__graph}
\end{center}
\end{figure}
\subsection*{Public Member Functions}
\begin{CompactItemize}
\item 
{\bf KDESasl} (const {\bf KURL} \&a\-Url)
\item 
{\bf KDESasl} (const {\bf QString} \&a\-User, const {\bf QString} \&a\-Pass, const {\bf QString} \&a\-Protocol)
\item 
virtual {\bf QCString} {\bf choose\-Method} (const {\bf QStr\-IList} a\-Methods)
\item 
virtual void {\bf set\-Method} (const {\bf QCString} \&a\-Method)
\item 
{\bf QCString} {\bf method} () const 
\item 
bool {\bf dialog\-Complete} (int num\-Calls) const 
\item 
bool {\bf is\-Clear\-Text\-Method} () const 
\item 
{\bf QCString} {\bf get\-Response} (const {\bf QByte\-Array} \&a\-Challenge={\bf QByte\-Array}(), bool a\-Base64=true)
\item 
{\bf QByte\-Array} {\bf get\-Binary\-Response} (const {\bf QByte\-Array} \&a\-Challenge={\bf QByte\-Array}(), bool a\-Base64=true)
\item 
bool {\bf client\-Starts} () const 
\end{CompactItemize}
\subsection*{Protected Member Functions}
\begin{CompactItemize}
\item 
virtual {\bf QByte\-Array} {\bf get\-Plain\-Response} ()
\item 
virtual {\bf QByte\-Array} {\bf get\-Login\-Response} ()
\item 
virtual {\bf QByte\-Array} {\bf get\-Cram\-Md5Response} (const {\bf QByte\-Array} \&a\-Challenge)
\item 
virtual {\bf QByte\-Array} {\bf get\-Digest\-Md5Response} (const {\bf QByte\-Array} \&a\-Challenge)
\end{CompactItemize}


\subsection{Detailed Description}
This library can create responses for SASL authentication for a given challenge and a given secret. 

This way of authentication is common for SMTP, POP3, IMAP and LDAP.

SASL is one way strong encryption and therefore useful for authentication, but not for secret information transfer. It is possibly to prove with SASL to know a shared secret like a password. It is not possible with SASL to transfer any other information in an encrypted way. For that purpose Open\-PGP or SSL are useful.

Currently PLAIN (RFC 2595), LOGIN (not really a SASL mechanism, but used like that in IMAP and SMTP), CRAM-MD5 (RFC 2195) and DIGEST-MD5 (RFC 2831) authentication are supported. PLAIN and LOGIN transmit the credentials in the clear (apart from a possible base64 encoding).

For {\bf KDE} 3.2, the API has been extended to allow transparent use of all currently supported SASL mechanisms. Example: 

\footnotesize\begin{verbatim} KDESasl sasl( myUser, myPass, myProtocol );
 if ( !sasl.chooseMethod( myMechanismsSupportedByServer ) )
   return false; // couldn't agree on a method

 int numResponses = 0;
 if ( sasl.clientStarts() ) { // check whether we're supposed to start the dialog
   ++numResponses;
   mySendAuthCommand( sasl.method(), sasl.getResponse() );
 } else {
   mySendAuthCommand( sasl.method() );
 }
 for ( ; !sasl.dialogComplete( numResponses ) ; ++numResponses ) {
   QByteArray challenge = myRecvChallenge();
   mySendResponse( sasl.getResponse( challenge ) );
 }
 return myCheckSuccess();
\end{verbatim}
\normalsize


\begin{Desc}
\item[Author:]Michael H\"{a}ckel $<${\tt haeckel@kde.org}$>$ \end{Desc}
\begin{Desc}
\item[Version:]\begin{Desc}
\item[Id]{\bf kdesasl.h}{\rm (p.\,\pageref{kdesasl_8h})} 370277 2004-12-13 01:41:12Z mueller \end{Desc}
\end{Desc}




Definition at line 72 of file kdesasl.h.

\subsection{Constructor \& Destructor Documentation}
\index{KDESasl@{KDESasl}!KDESasl@{KDESasl}}
\index{KDESasl@{KDESasl}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KDESasl::KDESasl (const {\bf KURL} \& {\em a\-Url})}\label{classKDESasl_a0}


Construct a sasl object and initialize it with the username and password passed via the url. 



Definition at line 30 of file kdesasl.cpp.\index{KDESasl@{KDESasl}!KDESasl@{KDESasl}}
\index{KDESasl@{KDESasl}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}KDESasl::KDESasl (const {\bf QString} \& {\em a\-User}, const {\bf QString} \& {\em a\-Pass}, const {\bf QString} \& {\em a\-Protocol})}\label{classKDESasl_a1}


This is a conveniece function and differs from the above function only by what arguments it accepts. 



Definition at line 38 of file kdesasl.cpp.

\subsection{Member Function Documentation}
\index{KDESasl@{KDESasl}!chooseMethod@{chooseMethod}}
\index{chooseMethod@{chooseMethod}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QCString} KDESasl::choose\-Method (const {\bf QStr\-IList} {\em a\-Methods})\hspace{0.3cm}{\tt  [virtual]}}\label{classKDESasl_a3}


\begin{Desc}
\item[Returns:]the most secure method from the given methods and use it for further operations. \end{Desc}


Definition at line 50 of file kdesasl.cpp.\index{KDESasl@{KDESasl}!setMethod@{setMethod}}
\index{setMethod@{setMethod}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}void KDESasl::set\-Method (const {\bf QCString} \& {\em a\-Method})\hspace{0.3cm}{\tt  [virtual]}}\label{classKDESasl_a4}


Explicitely set the SASL method used. 



Definition at line 60 of file kdesasl.cpp.

References QCString::upper().\index{KDESasl@{KDESasl}!method@{method}}
\index{method@{method}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QCString} KDESasl::method () const}\label{classKDESasl_a5}


\begin{Desc}
\item[Returns:]the SASL method used. \end{Desc}
\begin{Desc}
\item[Since:]3.2 \end{Desc}


Definition at line 267 of file kdesasl.cpp.

Referenced by client\-Starts(), dialog\-Complete(), and is\-Clear\-Text\-Method().\index{KDESasl@{KDESasl}!dialogComplete@{dialogComplete}}
\index{dialogComplete@{dialogComplete}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KDESasl::dialog\-Complete (int {\em num\-Calls}) const}\label{classKDESasl_a6}


\begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em num\-Calls}]number of times {\bf get\-Response()}{\rm (p.\,\pageref{classKDESasl_a8})} has been called. \end{description}
\end{Desc}
\begin{Desc}
\item[Returns:]whether the challenge/response dialog has completed\end{Desc}
\begin{Desc}
\item[Since:]3.2 \end{Desc}


Definition at line 275 of file kdesasl.cpp.

References method().\index{KDESasl@{KDESasl}!isClearTextMethod@{isClearTextMethod}}
\index{isClearTextMethod@{isClearTextMethod}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KDESasl::is\-Clear\-Text\-Method () const}\label{classKDESasl_a7}


\begin{Desc}
\item[Returns:]whether the currently selected mechanism results in cleartext passwords being sent over the network and thus should be used only under TLS/SSL cover or for legacy servers.\end{Desc}
\begin{Desc}
\item[Since:]3.2 \end{Desc}


Definition at line 283 of file kdesasl.cpp.

References method().\index{KDESasl@{KDESasl}!getResponse@{getResponse}}
\index{getResponse@{getResponse}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QCString} KDESasl::get\-Response (const {\bf QByte\-Array} \& {\em a\-Challenge} = {\tt {\bf QByte\-Array}()}, bool {\em a\-Base64} = {\tt true})}\label{classKDESasl_a8}


Creates a response using the formerly chosen SASL method. 

For LOGIN authentication you have to call this function twice. KDESasl realizes on its own, if you are calling it for the first or for the second time. \begin{Desc}
\item[Parameters:]
\begin{description}
\item[{\em a\-Challenge}]is the challenge sent to create a response for \item[{\em a\-Base64}]specifies, whether the authentication protocol uses base64 encoding. The challenge is decoded from base64 and the response is encoded base64 if set to true. \end{description}
\end{Desc}


Definition at line 261 of file kdesasl.cpp.

References get\-Binary\-Response().\index{KDESasl@{KDESasl}!getBinaryResponse@{getBinaryResponse}}
\index{getBinaryResponse@{getBinaryResponse}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KDESasl::get\-Binary\-Response (const {\bf QByte\-Array} \& {\em a\-Challenge} = {\tt {\bf QByte\-Array}()}, bool {\em a\-Base64} = {\tt true})}\label{classKDESasl_a9}


Create a response as above but place it in a {\bf QByte\-Array}. 



Definition at line 242 of file kdesasl.cpp.

References KCodecs::base64Decode(), KCodecs::base64Encode(), get\-Cram\-Md5Response(), get\-Digest\-Md5Response(), get\-Login\-Response(), and get\-Plain\-Response().

Referenced by get\-Response().\index{KDESasl@{KDESasl}!clientStarts@{clientStarts}}
\index{clientStarts@{clientStarts}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}bool KDESasl::client\-Starts () const}\label{classKDESasl_a10}


Returns true if the client is supposed to initiate the challenge-respinse dialog with an initial response (which most protocols can transfer alongside the authentication command as an optional second parameter). 

This method relieves the sasl user from knowing details about the mechanism. If true, use {\bf get\-Response()}{\rm (p.\,\pageref{classKDESasl_a8})} with a null challenge.

\begin{Desc}
\item[Since:]3.2 \end{Desc}


Definition at line 271 of file kdesasl.cpp.

References method().\index{KDESasl@{KDESasl}!getPlainResponse@{getPlainResponse}}
\index{getPlainResponse@{getPlainResponse}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KDESasl::get\-Plain\-Response ()\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKDESasl_b0}


PLAIN authentication as described in RFC 2595. 



Definition at line 65 of file kdesasl.cpp.

References QCString::length(), and QString::utf8().

Referenced by get\-Binary\-Response().\index{KDESasl@{KDESasl}!getLoginResponse@{getLoginResponse}}
\index{getLoginResponse@{getLoginResponse}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KDESasl::get\-Login\-Response ()\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKDESasl_b1}


LOGIN authentication. 



Definition at line 83 of file kdesasl.cpp.

References QString::utf8().

Referenced by get\-Binary\-Response().\index{KDESasl@{KDESasl}!getCramMd5Response@{getCramMd5Response}}
\index{getCramMd5Response@{getCramMd5Response}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KDESasl::get\-Cram\-Md5Response (const {\bf QByte\-Array} \& {\em a\-Challenge})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKDESasl_b2}


CRAM-MD5 authentication as described in RFC 2195. 



Definition at line 91 of file kdesasl.cpp.

References KMD5::hex\-Digest(), QString::length(), KMD5::raw\-Digest(), KMD5::update(), and QString::utf8().

Referenced by get\-Binary\-Response().\index{KDESasl@{KDESasl}!getDigestMd5Response@{getDigestMd5Response}}
\index{getDigestMd5Response@{getDigestMd5Response}!KDESasl@{KDESasl}}
\subsubsection{\setlength{\rightskip}{0pt plus 5cm}{\bf QByte\-Array} KDESasl::get\-Digest\-Md5Response (const {\bf QByte\-Array} \& {\em a\-Challenge})\hspace{0.3cm}{\tt  [protected, virtual]}}\label{classKDESasl_b3}


DIGEST-MD5 authentication as described in RFC 2831. 



Definition at line 124 of file kdesasl.cpp.

References KCodecs::base64Encode(), KMD5::hex\-Digest(), QCString::is\-Empty(), QString::latin1(), QCString::length(), KMD5::raw\-Digest(), KMD5::reset(), QCString::set\-Num(), KMD5::update(), and QString::utf8().

Referenced by get\-Binary\-Response().

The documentation for this class was generated from the following files:\begin{CompactItemize}
\item 
kdesasl.h\item 
kdesasl.cpp\end{CompactItemize}
