reSIProcate/repro  9694
IsTrustedNode.cxx
Go to the documentation of this file.
00001 #if defined(HAVE_CONFIG_H)
00002 #include "config.h"
00003 #endif
00004 
00005 #include "resip/stack/SipMessage.hxx"
00006 #include "resip/stack/Transport.hxx"
00007 #include "resip/stack/Helper.hxx"
00008 #include "repro/monkeys/IsTrustedNode.hxx"
00009 #include "repro/RequestContext.hxx"
00010 #include "repro/Proxy.hxx"
00011 #include "repro/ProxyConfig.hxx"
00012 #include "repro/AclStore.hxx"
00013 #include <ostream>
00014 
00015 #include "rutil/Logger.hxx"
00016 #define RESIPROCATE_SUBSYSTEM resip::Subsystem::REPRO
00017 
00018 using namespace resip;
00019 using namespace repro;
00020 using namespace std;
00021 
00022 KeyValueStore::Key IsTrustedNode::mFromTrustedNodeKey = Proxy::allocateRequestKeyValueStoreKey();
00023 
00024 IsTrustedNode::IsTrustedNode(ProxyConfig& config) :
00025    Processor("IsTrustedNode"),
00026    mAclStore(config.getDataStore()->mAclStore)
00027 {}
00028 
00029 IsTrustedNode::~IsTrustedNode()
00030 {}
00031 
00032 Processor::processor_action_t
00033 IsTrustedNode::process(RequestContext& context)
00034 {
00035    DebugLog(<< "Monkey handling request: " << *this 
00036             << "; reqcontext = " << context);
00037 
00038    resip::SipMessage& request = context.getOriginalRequest();
00039 
00040    if(mAclStore.isRequestTrusted(request))
00041    {
00042       context.getKeyValueStore().setBoolValue(mFromTrustedNodeKey, true);
00043    }
00044    else
00045    {
00046       context.getKeyValueStore().setBoolValue(mFromTrustedNodeKey, false);
00047 
00048       // strip PAI headers that we don't trust
00049       if(request.exists(h_PAssertedIdentities))
00050       {
00051          request.remove(h_PAssertedIdentities);
00052       }
00053    }
00054       
00055    return Processor::Continue;
00056 }
00057 
00058 
00059 /* ====================================================================
00060  * The Vovida Software License, Version 1.0 
00061  * 
00062  * Copyright (c) 2000 Vovida Networks, Inc.  All rights reserved.
00063  * 
00064  * Redistribution and use in source and binary forms, with or without
00065  * modification, are permitted provided that the following conditions
00066  * are met:
00067  * 
00068  * 1. Redistributions of source code must retain the above copyright
00069  *    notice, this list of conditions and the following disclaimer.
00070  * 
00071  * 2. Redistributions in binary form must reproduce the above copyright
00072  *    notice, this list of conditions and the following disclaimer in
00073  *    the documentation and/or other materials provided with the
00074  *    distribution.
00075  * 
00076  * 3. The names "VOCAL", "Vovida Open Communication Application Library",
00077  *    and "Vovida Open Communication Application Library (VOCAL)" must
00078  *    not be used to endorse or promote products derived from this
00079  *    software without prior written permission. For written
00080  *    permission, please contact vocal@vovida.org.
00081  *
00082  * 4. Products derived from this software may not be called "VOCAL", nor
00083  *    may "VOCAL" appear in their name, without prior written
00084  *    permission of Vovida Networks, Inc.
00085  * 
00086  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED
00087  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
00088  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND
00089  * NON-INFRINGEMENT ARE DISCLAIMED.  IN NO EVENT SHALL VOVIDA
00090  * NETWORKS, INC. OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT DAMAGES
00091  * IN EXCESS OF $1,000, NOR FOR ANY INDIRECT, INCIDENTAL, SPECIAL,
00092  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
00093  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
00094  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
00095  * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00096  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
00097  * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
00098  * DAMAGE.
00099  * 
00100  * ====================================================================
00101  * 
00102  * This software consists of voluntary contributions made by Vovida
00103  * Networks, Inc. and many individuals on behalf of Vovida Networks,
00104  * Inc.  For more information on Vovida Networks, Inc., please see
00105  * <http://www.vovida.org/>.
00106  *
00107  */