/* * CERT_License.h * * Created by Andrew Salamon on 9/15/08. * Copyright 2008 Machine Perception Laboratory, University of California San Diego. All rights reserved. * */ #ifndef __CERT_LICENSE_H__ #define __CERT_LICENSE_H__ #include #include #include #include #include namespace bg = boost::gregorian; #include "CERT_LicenseVerifier.h" namespace CERT { class License { public: static bg::date stringToDate( const std::string &dtStr ); static const int invalid; static const int internal; static const int evaluation; static const int licensed; public: License(); License( const std::string &filepath ); void clear(); int getType(); void setType( int _type ); std::string getName(); void setName( const std::string &name ); bg::date getStartDate(); void setStartDate( const bg::date &dt ); bg::date getEndDate(); void setEndDate( const bg::date &dt ); ///< Will adjust duration to match. unsigned int getDuration(); void setDuration( unsigned int dur ); ///< Will adjust end date to match. std::string toString(); ///< Newline delimited. Primarily for use by encryption code to verify a license hasn't been tampered with. void fromStream( std::istream &is ); void toStream( std::ostream &os ); void setPrivateKeyPath( const std::string &path ); int daysLeft(); ///< <= 0 means the license has expired. private: int type; std::string name; bg::date start; unsigned int duration; LicenseVerifier verifier; }; } // end namespace CERT std::istream &operator>>( std::istream &is, CERT::License &license ); std::ostream &operator<<( std::ostream &os, CERT::License &license ); #endif