~ubuntu-branches/ubuntu/saucy/resiprocate/saucy-proposed

« back to all changes in this revision

Viewing changes to repro/UserAuthGrabber.hxx

  • Committer: Package Import Robot
  • Author(s): Daniel Pocock
  • Date: 2012-05-17 19:29:59 UTC
  • Revision ID: package-import@ubuntu.com-20120517192959-vv00m77isztdy64q
Tags: upstream-1.8.2
ImportĀ upstreamĀ versionĀ 1.8.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef USER_AUTH_GRABBER
 
2
#define USER_AUTH_GRABBER 1
 
3
 
 
4
#include "repro/Worker.hxx"
 
5
#include "repro/AbstractDb.hxx"
 
6
#include "repro/UserStore.hxx"
 
7
#include "resip/stack/Message.hxx"
 
8
#include "repro/UserInfoMessage.hxx"
 
9
#include "resip/dum/UserAuthInfo.hxx"
 
10
 
 
11
#define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
 
12
 
 
13
 
 
14
namespace repro
 
15
{
 
16
 
 
17
class UserAuthGrabber : public Worker
 
18
{
 
19
   public:
 
20
      UserAuthGrabber(repro::UserStore& userStore ):
 
21
         mUserStore(userStore)
 
22
      {}
 
23
      
 
24
      virtual ~UserAuthGrabber(){}
 
25
      
 
26
      virtual bool process(resip::ApplicationMessage* msg)
 
27
      {
 
28
         repro::UserInfoMessage* uinf = dynamic_cast<UserInfoMessage*>(msg);    // auth for repro's DigestAuthenticator
 
29
         resip::UserAuthInfo* uainf = dynamic_cast<resip::UserAuthInfo*>(msg);  // auth for DUM's ServerAuthManager
 
30
         if(uinf)
 
31
         {
 
32
            uinf->mRec.passwordHash = mUserStore.getUserAuthInfo(uinf->user(), uinf->realm());
 
33
            DebugLog(<<"Grabbed user info for " 
 
34
                           << uinf->user() <<"@"<<uinf->realm()
 
35
                           << " : " << uinf->A1());
 
36
            return true;
 
37
         }
 
38
         else if(uainf)
 
39
         {
 
40
            uainf->setA1(mUserStore.getUserAuthInfo(uainf->getUser(), uainf->getRealm()));
 
41
            if(uainf->getA1().empty())
 
42
            {
 
43
               uainf->setMode(resip::UserAuthInfo::UserUnknown);
 
44
            }
 
45
            DebugLog(<<"Grabbed user info for " 
 
46
                           << uainf->getUser() <<"@"<<uainf->getRealm()
 
47
                           << " : " << uainf->getA1());
 
48
            return true;
 
49
         }
 
50
         else
 
51
         {
 
52
            WarningLog(<<"Did not recognize message type...");
 
53
         }
 
54
         return false;
 
55
      }
 
56
      
 
57
      virtual UserAuthGrabber* clone() const
 
58
      {
 
59
         return new UserAuthGrabber(mUserStore);
 
60
      }
 
61
      
 
62
   protected:
 
63
      UserStore& mUserStore;
 
64
};
 
65
 
 
66
}
 
67
#endif
 
68
 
 
69
/* ====================================================================
 
70
 * The Vovida Software License, Version 1.0 
 
71
 * 
 
72
 * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
 
73
 * 
 
74
 * Redistribution and use in source and binary forms, with or without
 
75
 * modification, are permitted provided that the following conditions
 
76
 * are met:
 
77
 * 
 
78
 * 1. Redistributions of source code must retain the above copyright
 
79
 *    notice, this list of conditions and the following disclaimer.
 
80
 * 
 
81
 * 2. Redistributions in binary form must reproduce the above copyright
 
82
 *    notice, this list of conditions and the following disclaimer in
 
83
 *    the documentation and/or other materials provided with the
 
84
 *    distribution.
 
85
 * 
 
86
 * 3. The names "VOCAL", "Vovida Open Communication Application Library",
 
87
 *    and "Vovida Open Communication Application Library (VOCAL)" must
 
88
 *    not be used to endorse or promote products derived from this
 
89
 *    software without prior written permission. For written
 
90
 *    permission, please contact vocal@vovida.org.
 
91
 *
 
92
 * 4. Products derived from this software may not be called "VOCAL", nor
 
93
 *    may "VOCAL" appear in their name, without prior written
 
94
 *    permission of Vovida Networks, Inc.
 
95
 * 
 
96
 * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
 
97
 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 
98
 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
 
99
 * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
 
100
 * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
 
101
 * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
 
102
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 
103
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 
104
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 
105
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 
106
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
 
107
 * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 
108
 * DAMAGE.
 
109
 * 
 
110
 * ====================================================================
 
111
 * 
 
112
 * This software consists of voluntary contributions made by Vovida
 
113
 * Networks, Inc. and many individuals on behalf of Vovida Networks,
 
114
 * Inc.  For more information on Vovida Networks, Inc., please see
 
115
 * <http://www.vovida.org/>.
 
116
 *
 
117
 */