reSIProcate/stack  9694
Public Types | Public Member Functions | Private Attributes | Static Private Attributes
resip::Auth Class Reference

Represents the "credentials" and "challenge" elements in the SIP grammar. More...

#include <Auth.hxx>

Inheritance diagram for resip::Auth:
Inheritance graph
[legend]
Collaboration diagram for resip::Auth:
Collaboration graph
[legend]

List of all members.

Public Types

enum  { commaHandling = NoCommaTokenizing }

Public Member Functions

 Auth ()
 Auth (const HeaderFieldValue &hfv, Headers::Type type, PoolBase *pool=0)
 Auth (const Auth &orig, PoolBase *pool=0)
Authoperator= (const Auth &)
virtual void parse (ParseBuffer &pb)
virtual EncodeStreamencodeParsed (EncodeStream &str) const
virtual ParserCategoryclone () const
virtual ParserCategoryclone (void *location) const
virtual ParserCategoryclone (PoolBase *pool) const
void parseAuthParameters (ParseBuffer &pb)
EncodeStreamencodeAuthParameters (EncodeStream &str) const
Datascheme ()
const Datascheme () const
virtual ParametercreateParam (ParameterTypes::Type type, ParseBuffer &pb, const std::bitset< 256 > &terminators, PoolBase *pool)
bool exists (const Param< Auth > &paramType) const
void remove (const Param< Auth > &paramType)
 defineParam (algorithm,"algorithm", DataParameter,"RFC 2617")
 defineParam (cnonce,"cnonce", QuotedDataParameter,"RFC 2617")
 defineParam (domain,"domain", QuotedDataParameter,"RFC 3261")
 defineParam (nc,"nc", DataParameter,"RFC 2617")
 defineParam (nonce,"nonce", QuotedDataParameter,"RFC 2617")
 defineParam (opaque,"opaque", QuotedDataParameter,"RFC 2617")
 defineParam (realm,"realm", QuotedDataParameter,"RFC 2617")
 defineParam (response,"response", QuotedDataParameter,"RFC 3261")
 defineParam (stale,"stale", DataParameter,"RFC 2617")
 defineParam (uri,"uri", QuotedDataParameter,"RFC 3261")
 defineParam (username,"username", QuotedDataParameter,"RFC 3261")
 defineParam (qop,"qop", DataParameter,"RFC 3261")
 defineParam (qopOptions,"qop", DataParameter,"RFC 3261")

Private Attributes

Data mScheme

Static Private Attributes

static ParameterTypes::Factory ParameterFactories [ParameterTypes::MAX_PARAMETER] = {0}

Detailed Description

Represents the "credentials" and "challenge" elements in the SIP grammar.

Definition at line 17 of file Auth.hxx.


Member Enumeration Documentation

anonymous enum
Enumerator:
commaHandling 

Definition at line 20 of file Auth.hxx.


Constructor & Destructor Documentation

Auth::Auth ( )

Definition at line 21 of file Auth.cxx.

Referenced by clone().

Auth::Auth ( const HeaderFieldValue hfv,
Headers::Type  type,
PoolBase pool = 0 
)

Definition at line 25 of file Auth.cxx.

   : ParserCategory(hfv, type, pool) 
{}
Auth::Auth ( const Auth orig,
PoolBase pool = 0 
)

Definition at line 29 of file Auth.cxx.

   : ParserCategory(rhs, pool),
   mScheme(rhs.mScheme)
{}

Member Function Documentation

ParserCategory * Auth::clone ( ) const [virtual]

Implements resip::ParserCategory.

Definition at line 98 of file Auth.cxx.

References Auth().

{
   return new Auth(*this);
}

Here is the call graph for this function:

ParserCategory * Auth::clone ( void *  location) const [virtual]

Implements resip::ParserCategory.

Definition at line 104 of file Auth.cxx.

References Auth().

{
   return new (location) Auth(*this);
}

Here is the call graph for this function:

ParserCategory * Auth::clone ( PoolBase pool) const [virtual]

Implements resip::ParserCategory.

Definition at line 110 of file Auth.cxx.

References Auth().

{
   return new (pool) Auth(*this, pool);
}

Here is the call graph for this function:

Parameter * Auth::createParam ( ParameterTypes::Type  type,
ParseBuffer pb,
const std::bitset< 256 > &  terminators,
PoolBase pool 
) [virtual]

Reimplemented from resip::ParserCategory.

Definition at line 181 of file Auth.cxx.

References resip::ParameterTypes::MAX_PARAMETER, resip::ParserCategory::mHeaderType, ParameterFactories, resip::DataParameter::setQuoted(), type, and resip::ParameterTypes::UNKNOWN.

Referenced by parseAuthParameters().

{
   if(type==ParameterTypes::qop)
   {
      DataParameter* qop = 0;
      switch(mHeaderType)
      {
         case Headers::ProxyAuthenticate:
         case Headers::WWWAuthenticate:
            qop = new (pool) DataParameter(ParameterTypes::qopOptions,pb,terminators);
            qop->setQuoted(true);
            break;
         case Headers::ProxyAuthorization:
         case Headers::Authorization:
         case Headers::AuthenticationInfo:
         default:
            qop = new (pool) DataParameter(ParameterTypes::qop,pb,terminators);
            qop->setQuoted(false);
      }
      return qop;
   }

   if(type > ParameterTypes::UNKNOWN && type < ParameterTypes::MAX_PARAMETER && ParameterFactories[type])
   {
      return ParameterFactories[type](type, pb, terminators, pool);
   }
   return 0;
}

Here is the call graph for this function:

resip::Auth::defineParam ( algorithm  ,
"algorithm"  ,
DataParameter  ,
"RFC 2617"   
)
resip::Auth::defineParam ( cnonce  ,
"cnonce"  ,
QuotedDataParameter  ,
"RFC 2617"   
)
resip::Auth::defineParam ( domain  ,
"domain"  ,
QuotedDataParameter  ,
"RFC 3261"   
)
resip::Auth::defineParam ( nc  ,
"nc"  ,
DataParameter  ,
"RFC 2617"   
)
resip::Auth::defineParam ( nonce  ,
"nonce"  ,
QuotedDataParameter  ,
"RFC 2617"   
)
resip::Auth::defineParam ( opaque  ,
"opaque"  ,
QuotedDataParameter  ,
"RFC 2617"   
)
resip::Auth::defineParam ( realm  ,
"realm"  ,
QuotedDataParameter  ,
"RFC 2617"   
)
resip::Auth::defineParam ( response  ,
"response"  ,
QuotedDataParameter  ,
"RFC 3261"   
)
resip::Auth::defineParam ( stale  ,
"stale"  ,
DataParameter  ,
"RFC 2617"   
)
resip::Auth::defineParam ( uri  ,
"uri"  ,
QuotedDataParameter  ,
"RFC 3261"   
)
resip::Auth::defineParam ( username  ,
"username"  ,
QuotedDataParameter  ,
"RFC 3261"   
)
resip::Auth::defineParam ( qop  ,
"qop"  ,
DataParameter  ,
"RFC 3261"   
)
resip::Auth::defineParam ( qopOptions  ,
"qop"  ,
DataParameter  ,
"RFC 3261"   
)
EncodeStream & Auth::encodeAuthParameters ( EncodeStream str) const

Definition at line 151 of file Auth.cxx.

References resip::Symbols::COMMA, resip::ParserCategory::mParameters, and resip::ParserCategory::mUnknownParameters.

Referenced by encodeParsed().

{
   bool first = true;
   for (ParameterList::const_iterator it = mParameters.begin();
        it != mParameters.end(); it++)
   {
      if (!first)
      {
         str << Symbols::COMMA;
      }
      first = false;
      (*it)->encode(str);
   }

   for (ParameterList::const_iterator it = mUnknownParameters.begin();
        it != mUnknownParameters.end(); it++)
   {
      if (!first)
      {
         str << Symbols::COMMA;
      }
      first = false;
      (*it)->encode(str);
   }
   return str;
}
EncodeStream & Auth::encodeParsed ( EncodeStream str) const [virtual]

Implements resip::LazyParser.

Definition at line 85 of file Auth.cxx.

References resip::Data::empty(), encodeAuthParameters(), mScheme, and resip::Symbols::SPACE.

{
   if (!mScheme.empty())
   {
      str << mScheme << Symbols::SPACE;
   }

   encodeAuthParameters(str);

   return str;
}

Here is the call graph for this function:

bool Auth::exists ( const Param< Auth > &  paramType) const
Auth & Auth::operator= ( const Auth rhs)

Definition at line 35 of file Auth.cxx.

References mScheme.

{
   if (this != &rhs)
   {
      ParserCategory::operator=(rhs);
      mScheme = rhs.mScheme;
   }
   return *this;
}
void Auth::parse ( ParseBuffer pb) [virtual]

Implements resip::LazyParser.

Definition at line 60 of file Auth.cxx.

References resip::ParseBuffer::data(), resip::ParseBuffer::eof(), resip::Symbols::EQUALS, mScheme, parseAuthParameters(), resip::ParseBuffer::position(), resip::ParseBuffer::reset(), resip::ParseBuffer::skipToOneOf(), resip::ParseBuffer::skipWhitespace(), and resip::Data::toBitset().

{
   const char* start;
   start = pb.skipWhitespace();
   static const std::bitset<256> schemeDelimiter(Data::toBitset("\r\n\t ="));
   pb.skipToOneOf(schemeDelimiter);

   if (!pb.eof() && *pb.position() == Symbols::EQUALS[0])
   {
      // Authentication-Info only
      // back up, and then parse
      pb.reset(start);
      parseAuthParameters(pb);
   }
   else
   {
      // everything else
      pb.data(mScheme, start);

      pb.skipWhitespace();
      parseAuthParameters(pb);
   }
}

Here is the call graph for this function:

void Auth::parseAuthParameters ( ParseBuffer pb)

Definition at line 116 of file Auth.cxx.

References resip::Symbols::COMMA, createParam(), resip::ParseBuffer::eof(), resip::ParserCategory::getPool(), resip::ParameterTypes::getType(), resip::ParserCategory::mParameters, resip::ParserCategory::mUnknownParameters, resip::ParseBuffer::position(), resip::ParseBuffer::skipChar(), resip::ParseBuffer::skipToOneOf(), resip::ParseBuffer::skipWhitespace(), resip::Data::toBitset(), and type.

Referenced by parse().

{
   while (!pb.eof())
   {
      const char* keyStart = pb.position();
      static std::bitset<256> paramBegin=Data::toBitset(" \t\r\n=");
      static std::bitset<256> terminators=Data::toBitset(" \t\r\n,");
      const char* keyEnd = pb.skipToOneOf(paramBegin);
      if((int)(keyEnd-keyStart) != 0)
      {
         ParameterTypes::Type type = ParameterTypes::getType(keyStart, (unsigned int)(keyEnd - keyStart));
         Parameter* p=createParam(type, pb, terminators, getPool());
         if (!p)
         {
            mUnknownParameters.push_back(new UnknownParameter(keyStart, 
                                                              int((keyEnd - keyStart)), pb, 
                                                              terminators));
         }
         else
         {
            // invoke the particular factory
            mParameters.push_back(p);
         }
         pb.skipWhitespace();
         if (pb.eof() || *pb.position() != Symbols::COMMA[0])
         {
            break;
         }
         pb.skipChar();
         pb.skipWhitespace();
      }
   }
}

Here is the call graph for this function:

void Auth::remove ( const Param< Auth > &  paramType)

Definition at line 219 of file Auth.cxx.

References resip::LazyParser::checkParsed(), resip::ParamBase::getTypeNum(), and resip::ParserCategory::removeParameterByEnum().

Here is the call graph for this function:

Data & Auth::scheme ( )

Definition at line 46 of file Auth.cxx.

References resip::LazyParser::checkParsed(), and mScheme.

Referenced by main(), resip::Helper::makeChallenge(), resip::Helper::makeChallengeResponseAuth(), and resip::Helper::makeChallengeResponseAuthWithA1().

{
   checkParsed(); 
   return mScheme;
}

Here is the call graph for this function:

const Data & Auth::scheme ( ) const

Definition at line 53 of file Auth.cxx.

References resip::LazyParser::checkParsed(), and mScheme.

{
   checkParsed(); 
   return mScheme;
}

Here is the call graph for this function:


Member Data Documentation

Definition at line 72 of file Auth.hxx.

Referenced by encodeParsed(), operator=(), parse(), and scheme().

Definition at line 74 of file Auth.hxx.

Referenced by createParam().


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