KeyChain.h

00001 //           ///          //                                  C++ Cross Platform
00002 //          /////        ////
00003 //         /// XXX     XXX ///            ///////////   /////////     ///   ///
00004 //        ///    XXX XXX    ///         ///             ///    ///   ///  ///
00005 //       ///       XXX       ///         /////////     ///      //  //////
00006 //      ///      XXX XXX      ///               ///   ///    ///   ///  ///
00007 //     ////    XXX     XXX    ////    ////////////  //////////    ///   ///
00008 //    ////                     ////
00009 //   ////  M  O  B  O  T  I  X  ////////////////////////////////////////////////
00010 //  //// Security Vision Systems //////////////////////////////////////////////
00011 //
00012 //  $Author: khe_admin $
00013 //  $LastChangedBy: khe_admin $
00014 //  $LastChangedDate: 2007-06-29 15:34:53 +0200 (Fri, 29 Jun 2007) $
00015 //  $HeadURL: http://svn.mobotix.net/svn/mxsdk/src/IOKitComponent/trunk/include/KeyChain.h $
00016 //
00018      //
00019      //  MOBOTIX MxPEG SDK
00020      //
00021      //  This file belongs to the C++ library released as part of the MxPEG SDK.
00022      //
00023      //  This software is licensed under the BSD licence,
00024      //  http://www.opensource.org/licenses/bsd-license.php
00025      //
00026      //  Copyright (c) 2005 - 2007, MOBOTIX AG
00027      //  All rights reserved.
00028      //
00029      //  Redistribution and use in source and binary forms, with or without
00030      //  modification, are permitted provided that the following conditions are
00031      //  met:
00032      //
00033      //  - Redistributions of source code must retain the above copyright
00034      //    notice, this list of conditions and the following disclaimer.
00035      //
00036      //  - Redistributions in binary form must reproduce the above copyright
00037      //    notice, this list of conditions and the following disclaimer in the
00038      //    documentation and/or other materials provided with the distribution.
00039      //
00040      //  - Neither the name of MOBOTIX AG nor the names of its contributors may
00041      //    be used to endorse or promote products derived from this software
00042      //    without specific prior written permission.
00043      //
00044      //  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
00045      //  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
00046      //  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
00047      //  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
00048      //  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
00049      //  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
00050      //  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
00051      //  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
00052      //  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
00053      //  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
00054      //  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00055      //
00057 
00058 
00059 
00060 #ifndef __MX_KEYCHAIN_H__
00061 #define __MX_KEYCHAIN_H__
00062 
00063 
00064 
00065 #include <interfaces/IKeyChain.h>
00066 #include <interfaces/IComponent.h>
00067 #include <interfaces/IComponentInvoker.h>
00068 
00069 #include <Framework/Framework.h>
00070 
00071 #include <mxm/core/mxmPerlStyleHash.h>
00072 
00073 #include <QObject>
00074 
00075 
00076 
00077 #define MX_KEYCHAIN_ID "KeyChain"
00078 
00079 
00080 
00081 namespace mx {
00082    
00084 
00089    class KeyChain : public QObject,
00090                     public mxmObject,
00091                     public virtual IComponent,
00092                     public virtual IKeyChain {
00093       
00094       Q_OBJECT
00095       
00099     private:
00100       static mxm::smart<mxmStringList> _enumerateInterfaces() {
00101          return(new mxmStringList((mxmString(MX_KEYCHAIN_ID),
00102                                    MX_ICOMPONENT_ID,
00103                                    MX_IKEYCHAIN_ID,
00104                                    MX_IREQUIRESEXTERNALAUTHENTICATOR_ID,
00105                                    MX_IEXTERNALAUTHENTICATOR_ID)));
00106       }
00107       static mxm::smart<mxmStringList> _enumerateCapabilities(
00108                                           const mxmString &interface) {
00109          if(interface == mx::Framework::IdHintKey)
00110           return(new mxmStringList(MX_KEYCHAIN_ID));
00111          else
00112           return(new mxmStringList());
00113       }
00114       
00115     private:
00116       class Invoker : public mxmObject, public virtual IComponentInvoker {
00117        public:
00118          mxm::smart<mxmStringList> enumerateInterfaces() {
00119             return(_enumerateInterfaces());
00120          }
00121          mxm::smart<mxmStringList> enumerateCapabilities(
00122                                      const mxmString &interface) {
00123             return(_enumerateCapabilities(interface));
00124          }
00125          IComponent *newComponent() {
00126             return(new KeyChain());
00127          }
00128       };
00129     public:
00131       static IComponentInvoker *newInvoker() {
00132          return(new Invoker());
00133       }
00134       
00135     private:
00136       mxmPerlStyleHash ChainKeys;
00137       int CurrentKey;
00138       bool ForwardingEnabled;
00139       bool Forwarding;
00140       bool AwaitingAuthentication,
00141            WasAwaitingAuthentication;
00142       
00143     public:
00144       KeyChain();
00145       
00146     public:
00148       mxm::smart<mxmStringList> enumerateInterfaces() {
00149          return(_enumerateInterfaces());
00150       }
00152       mxm::smart<mxmStringList> enumerateCapabilities(
00153                                    const mxmString &interface) {
00154          return(_enumerateCapabilities(interface));
00155       }
00156       
00158       mxmPerlStyleHash &chainKeys();
00160       void enableKeyForwarding(bool enabled);
00161       
00163       mxmQtSlot acceptAuthenticationRequestSlot() const;
00165       mxmQtSignal authenticationCommittedSignal() const;
00167       mxmQtSignal authenticationCancelledSignal() const;
00168     public slots:
00170       void slotAcceptAuthenticationRequest(const QString &msg,
00171                                            bool first_try);
00172     signals:
00174       void signalAuthenticationCommitted(const QString &username,
00175                                          const QString &password);
00177       void signalAuthenticationCancelled();
00178       
00179     public:
00181       mxmQtSignal authenticationRequestSignal() const;
00183       mxmQtSlot processAuthenticationSlot() const;
00185       mxmQtSlot processAuthenticationCancellationSlot() const;
00186     signals:
00188       void signalAuthenticationRequest(const QString &msg,
00189                                        bool first_try);
00190     public slots:
00192       void processAuthentication(const QString &user,
00193                                  const QString &password);
00195       void processAuthenticationCancellation();
00196     public:
00198       bool awaitingAuthentication();
00200       bool wasAwaitingAuthentication();
00201    };
00202 };
00203 
00204 
00205 #endif   // __MX_KEYCHAIN_H__

Generated on Fri Jun 29 17:21:04 2007 for MxPEG SDK by  doxygen 1.4.6