LicenseManagerActive.hh 5.55 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3
*                                                                            *
*                              OpenFlipper                                   *
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Jan Möbius's avatar
Jan Möbius committed
39
*                                                                            *
40 41
\*===========================================================================*/

42

43 44 45 46

#ifndef LICENSEMANAGER_HH
#define LICENSEMANAGER_HH

Jan Möbius's avatar
Jan Möbius committed
47 48
#include <OpenFlipper/BasePlugin/SecurityInterface.hh>

49 50 51 52 53 54
/** \file LicenseManager.hh
*
* This interface is used to add copy protection to plugins. \ref securityInterfacePage
*
*/

55 56 57 58 59
/* The salt file has to be provided for each plugin. It can be the same
  for all plugins. See example for details on how this file has to be setup
*/
#include "salt.hh"

60 61 62 63 64 65 66 67
/** \brief License management base class
 *
 * See \ref securityInterfacePage for Details on how to use it.
 *
 * The class is used by plugins to integrate license management. It will check the license,
 * generate license requests and prevent the plugin from loading if an invalid license or no license
 * is found.
 */
Jan Möbius's avatar
Jan Möbius committed
68
class LicenseManager : public QObject, SecurityInterface  {
69 70 71 72 73 74 75 76 77 78 79

Q_OBJECT
Q_INTERFACES(SecurityInterface)

  public:

    virtual ~LicenseManager();
    LicenseManager();

  public :

Jan Möbius's avatar
Jan Möbius committed
80
    /** This function is overloaded and will not allow to unblock signals
81
        if the plugin is not authenticated.
Jan Möbius's avatar
Jan Möbius committed
82
    */
83
    void blockSignals( bool _state);
Jan Möbius's avatar
Jan Möbius committed
84
    
85
    /** Return if the plugin has successfully passed the authentication.
Jan Möbius's avatar
Jan Möbius committed
86
    */
87 88 89
    bool authenticated();

  public slots:
Jan Möbius's avatar
Jan Möbius committed
90
    /** Call this function for plugin authentication. If it returns true,
91
        the authentication has been successful. Otherwise the core will
Jan Möbius's avatar
Jan Möbius committed
92 93
        stop loading the plugin. Additionally the plugin will make itself
        unusable by not allowing any signal slot connections.
94

Jan Möbius's avatar
Jan Möbius committed
95
    */
96 97
    bool authenticate();
    
98 99
    /** if authenticate returns false, this string will contain the license information required
     *  to generate a license request and the error that caused the failure.
100 101
    */
    QString licenseError();
102 103

  private:
104 105 106 107


    bool timestampOk();

Jan Möbius's avatar
Jan Möbius committed
108
    /** This is used to get the plugins Name from derived classes
109
        The plugin name is the usual name of the plugin
Jan Möbius's avatar
Jan Möbius committed
110 111
    */
    virtual QString name() = 0;
112

Jan Möbius's avatar
Jan Möbius committed
113
    /** This function is special to the LicenseManager. It is used to
114
        find the plugin when checking its hash value.
Jan Möbius's avatar
Jan Möbius committed
115
    */
116 117
    virtual QString pluginFileName();

118
    /// This flag is true if authentication was successful
Jan Möbius's avatar
Jan Möbius committed
119
    bool authenticated_;
120 121 122
    
    /// License information string
    QString authstring_;
Jan Möbius's avatar
Jan Möbius committed
123

124 125

  protected :
Jan Möbius's avatar
Jan Möbius committed
126 127 128 129
    /** This function is overloaded in the security interface. If the
        plugin is not authenticated, all connections will be automatically
        removed again.
    */
130
    void connectNotify ( const char * signal );
131 132 133

};

134
#endif // LICENSEMANAGER_HH