reSIProcate/DialogUsageManager  9694
Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes
resip::ClientAuthManager::RealmState Class Reference
Collaboration diagram for resip::ClientAuthManager::RealmState:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RealmState ()
void clear ()
bool handleAuth (UserProfile &userProfile, const Auth &auth, bool isProxyCredential)
void authSucceeded ()
void addAuthentication (SipMessage &origRequest)

Private Types

enum  State {
  Invalid, Cached, Current, TryOnce,
  Failed
}

Private Member Functions

void transition (State s)
bool findCredential (UserProfile &userProfile, const Auth &auth)

Static Private Member Functions

static const DatagetStateString (State s)

Private Attributes

UserProfile::DigestCredential mCredential
bool mIsProxyCredential
State mState
unsigned int mNonceCount
Auth mAuth
AuthmAuthPtr

Detailed Description

Definition at line 46 of file ClientAuthManager.hxx.


Member Enumeration Documentation

Enumerator:
Invalid 
Cached 
Current 
TryOnce 
Failed 

Definition at line 58 of file ClientAuthManager.hxx.


Constructor & Destructor Documentation

ClientAuthManager::RealmState::RealmState ( )

Definition at line 265 of file ClientAuthManager.cxx.


Member Function Documentation

void ClientAuthManager::RealmState::addAuthentication ( SipMessage origRequest)

Definition at line 402 of file ClientAuthManager.cxx.

References resip::SipMessage::addOutboundDecorator(), resip::Data::empty(), resip::Helper::qopOption(), and resip::Helper::updateNonceCount().

{
   assert(mState != Failed);
   if (mState == Failed) return;

   Data nonceCountString;
   Data authQop = Helper::qopOption(mAuth);
   if(!authQop.empty())
   {
       Helper::updateNonceCount(mNonceCount, nonceCountString);
   }
   
   // Add client auth decorator so that we ensure any body hashes are calcuated after user defined outbound decorators that
   // may be modifying the message body
   std::auto_ptr<MessageDecorator> clientAuthDecorator(new ClientAuthDecorator(mIsProxyCredential, mAuth, mCredential, authQop, nonceCountString));
   request.addOutboundDecorator(clientAuthDecorator);
}

Here is the call graph for this function:

void ClientAuthManager::RealmState::authSucceeded ( )

Definition at line 296 of file ClientAuthManager.cxx.

{
   switch(mState)
   {
      case Invalid:
         assert(0);
         break;
      case Current:
      case Cached:
      case TryOnce:
         transition(Cached);
         break;
      case Failed:
         assert(0);
         break;         
   };
}
void ClientAuthManager::RealmState::clear ( void  )

Definition at line 373 of file ClientAuthManager.cxx.

{
   mNonceCount = 0;
}
bool ClientAuthManager::RealmState::findCredential ( UserProfile userProfile,
const Auth auth 
) [private]

dcm! -- icky, expose static empty soon...ptr instead of reference?

Definition at line 379 of file ClientAuthManager.cxx.

References resip::Helper::algorithmAndQopSupported(), DebugLog, resip::UserProfile::getDigestCredential(), resip::ClientAuthExtension::instance(), and resip::ParserCategory::param().

{
   if (!(Helper::algorithmAndQopSupported(auth) 
         || (ClientAuthExtension::instance().algorithmAndQopSupported(auth))))
   {
      DebugLog(<<"Unsupported algorithm or qop: " << auth);
      return false;
   }

   const Data& realm = auth.param(p_realm);                   
   mCredential = userProfile.getDigestCredential(realm);
   if ( mCredential.realm.empty() )                       
   {                                        
      DebugLog( << "Got a 401 or 407 but could not find credentials for realm: " << realm);
//      DebugLog (<< auth);
//      DebugLog (<< response);
      return false;
   }                     
   return true;   
}

Here is the call graph for this function:

const Data & ClientAuthManager::RealmState::getStateString ( State  s) [static, private]

Definition at line 283 of file ClientAuthManager.cxx.

References RealmStates.

{
   return RealmStates[s];
}
bool ClientAuthManager::RealmState::handleAuth ( UserProfile userProfile,
const Auth auth,
bool  isProxyCredential 
)

Definition at line 315 of file ClientAuthManager.cxx.

References DebugLog, resip::Auth::exists(), and resip::ParserCategory::param().

{   
   DebugLog( << "ClientAuthManager::RealmState::handleAuth: " << this << " " << auth << " is proxy: " << isProxyCredential);
   mIsProxyCredential = isProxyCredential;   //this changing dynamically would
                                             //be very bizarre..should trap w/ enum
   switch(mState)
   {
      case Invalid:
         mAuth = auth;
         transition(Current);
         break;         
      case Current:
         if (auth.exists(p_stale) && auth.param(p_stale) == "true")
         {
            DebugLog (<< "Stale nonce:" <<  auth);
            mAuth = auth;
            clear();
         }
         else if(auth.exists(p_nonce) && auth.param(p_nonce) != mAuth.param(p_nonce))
         {
            DebugLog (<< "Different nonce, was: " << mAuth.param(p_nonce) << " now " << auth.param(p_nonce));
            mAuth = auth;
            clear();
            transition(TryOnce);            
         }
         else
         {
            DebugLog( << "Challenge response already failed for: " << auth);
            transition(Failed);            
            return false;
         }
         break;         
      case TryOnce:
         DebugLog( << "Extra chance still failed: " << auth);
         transition(Failed);
         return false;
      case Cached: //basically 1 free chance, here for interop, may not be
                   //required w/ nonce check in current
         mAuth = auth;
         clear();
         transition(Current);
         break;         
      case Failed:
         return false;
   }

   if (findCredential(userProfile, auth))
   {
      return true;
   }
   else
   {
      transition(Failed);
      return false;
   }
}

Here is the call graph for this function:

void ClientAuthManager::RealmState::transition ( State  s) [private]

Definition at line 289 of file ClientAuthManager.cxx.

References DebugLog.

{
   DebugLog(<< "ClientAuthManager::RealmState::transition from " << getStateString(mState) << " to " << getStateString(s));
   mState = s;
}

Member Data Documentation

Definition at line 75 of file ClientAuthManager.hxx.

Definition at line 78 of file ClientAuthManager.hxx.

Definition at line 70 of file ClientAuthManager.hxx.

Definition at line 71 of file ClientAuthManager.hxx.

Definition at line 74 of file ClientAuthManager.hxx.

Definition at line 73 of file ClientAuthManager.hxx.


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