mirror of
https://github.com/unidoc/unioffice.git
synced 2025-04-25 13:48:53 +08:00
New license based on the unidoc model (#294)
* Style fixes. Fixes for tests. Should not fail with version updates in the future.
This commit is contained in:
parent
1783b652de
commit
2e7943e809
@ -1,3 +1,37 @@
|
||||
UniDoc unioffice - Office library for golang
|
||||
Copyright (C) 2016-2019 FoxyUtils ehf.
|
||||
|
||||
This program provided by FoxyUtils ehf ("Company") is free software ("covered
|
||||
work"). You can redistribute it and/or modify it under the terms of the GNU
|
||||
Affero General Public License, Version 3 ("License") which is currently located
|
||||
here ?http://www.gnu.org/licenses/agpl.html (and listed in full below), with
|
||||
the addition of the following permission added to Section 15 as permitted in
|
||||
Section 7(a): FOR ANY PART OF THE COVERED WORK IN WHICH THE COPYRIGHT IS
|
||||
OWNED BY THE COMPANY, THE COMPANY DISCLAIMS THE WARRANTY OF NON INFRINGEMENT
|
||||
OF THIRD PARTY RIGHTS. YOU USE THIS WORK AT YOUR OWN RISK.
|
||||
|
||||
This covered work is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||
FOR A PARTICULAR PURPOSE. See the License for further details.
|
||||
|
||||
The interactive user interfaces in modified source and object code versions of
|
||||
this covered work must display Appropriate Legal Notices, as required under
|
||||
Section 5 of the License.
|
||||
|
||||
You can be released from the requirements of the license by purchasing a
|
||||
commercial license. Buying such a license is mandatory as soon as you develop
|
||||
activities involving unioffice without disclosing the source code of your own
|
||||
applications under the AGPL license. These activities include offering services
|
||||
as an application service provider or providing an over-network based
|
||||
application programming interface (API), creating or manipulating documents for
|
||||
users in a web/server/cloud application, incorporating unioffice into a closed
|
||||
source product.
|
||||
|
||||
For more information, please contact the Company by emailing sales@unidoc.io.
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
AGPLv3 LICENSE
|
||||
-------------------------------------------------------------------------------
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
@ -615,3 +649,47 @@ reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU Affero General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU Affero General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Affero General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If your software can interact with users remotely through a computer
|
||||
network, you should also make sure that it provides a way for users to
|
||||
get its source. For example, if your program is a web application, its
|
||||
interface could display a "Source" link that leads users to an archive
|
||||
of the code. There are many ways you could offer source, and different
|
||||
solutions will be better for different programs; see section 13 for the
|
||||
specific requirements.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU AGPL, see
|
||||
<http://www.gnu.org/licenses/>.
|
@ -1,118 +1,426 @@
|
||||
END USER LICENSE AGREEMENT
|
||||
|
||||
This copy of gooxml ("the Software Product") and accompanying documentation is
|
||||
licensed and not sold. This Software Product is protected by copyright laws and
|
||||
treaties, as well as laws and treaties related to other forms of intellectual
|
||||
property. Baliance LLC or its subsidiaries, affiliates, and suppliers
|
||||
(collectively "Baliance") own intellectual property rights in the Software
|
||||
Product. The Licensee's ("you" or "your") license to download, use, copy, or
|
||||
change the Software Product is subject to these rights and to all the terms and
|
||||
conditions of this End User License Agreement ("Agreement").
|
||||
|
||||
Acceptance
|
||||
Software License Agreement for UniDoc unioffice (Commercial License)
|
||||
Terms of Use
|
||||
|
||||
YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS COMMERCIAL AGREEMENT BY
|
||||
PURCHASING THE THE SOFTWARE PRODUCT. YOU MUST AGREE TO ALL OF THE TERMS OF THIS
|
||||
AGREEMENT BEFORE YOU WILL BE ALLOWED TO DOWNLOAD THE SOFTWARE PRODUCT. IF YOU DO
|
||||
NOT AGREE TO ALL OF THE TERMS OF THIS AGREEMENT, YOU MUST NOT PURCHASE THE
|
||||
SOFTWARE AND WILL BE BOUND BY THE TERMS OF THE AGPL LICENSE.
|
||||
|
||||
License Grant
|
||||
also available on our website https://unidoc.io/eula/
|
||||
for different packages under this license see https://unidoc.io/pricing/
|
||||
|
||||
Development with Licensed Software
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
Subject to the terms of this Agreement, Baliance grants to Licensee a personal,
|
||||
worldwide, non-exclusive, non-transferable license, valid for the Term, to use,
|
||||
modify and copy the Licensed Software by Designated Users for the sole purposes
|
||||
of designing, developing, demonstrating and testing Application(s), and to
|
||||
provide thereto related support and other services to end-user Customers.
|
||||
This Software Package is operated and owned by FoxyUtils ehf ("Provider"). Your
|
||||
access to and use of the Software Package is subject to this End User License
|
||||
Agreement and Terms of Use ("Terms of Use"). Use of the Software Package
|
||||
indicates your acceptance of these Terms of Use. We may update these Terms of
|
||||
Use from time to time, and your continued use of the Software Package
|
||||
constitutes acceptance by you of any updates. Please read these Terms of Use
|
||||
carefully before using the Software Package.
|
||||
|
||||
Licensee may install copies of the Licensed Software on an unlimited number of
|
||||
computers provided that (i) only the Designated Users may use the Licensed
|
||||
Software, and (ii) all Designated Users must have a valid Development License to
|
||||
use Licensed Software.
|
||||
1. DEFINITIONS
|
||||
In these Terms of Use the following words and phrases shall have the following
|
||||
meanings, unless the context otherwise requires:
|
||||
|
||||
Licensee may at any time designate another Designated User to replace a
|
||||
then-current Designated User by notifying Baliance in writing.
|
||||
(a) "Client" means the person or entity who purchases a licence to use the
|
||||
Software Package;
|
||||
|
||||
Restrictions on Transfer
|
||||
(b) "Content" means any information or data that you convey to us;
|
||||
|
||||
Without first obtaining the express written consent of Baliance, you may not
|
||||
otherwise assign your rights and obligations under this Agreement, or
|
||||
redistribute, encumber, sell, rent, lease, sublicense, or otherwise transfer
|
||||
your rights to the Software Product except
|
||||
|
||||
Updates
|
||||
(c) "Intellectual Property Rights" means all intellectual property rights
|
||||
wherever in the world, whether registrable or unregistrable, registered or
|
||||
unregistered, including any application or right of application for such rights
|
||||
(and these "intellectual property rights" include copyright and related rights,
|
||||
database rights, confidential information, trade secrets, know-how, systems and
|
||||
the source code for those systems, business names, trade names, trade marks,
|
||||
service marks, passing off rights, unfair competition rights, patents, petty
|
||||
patents, utility models, semi-conductor topography rights and rights in
|
||||
designs);
|
||||
|
||||
Licensee will be eligible for software updates for the duration of the support
|
||||
period of the license (12 months). Upon expiry of the support term, the Licensee
|
||||
will not be authorized to use further updates of the software until a new
|
||||
license has been purchased. However, licensees shall be allowed to continue the
|
||||
software as it existed at the expiration of the license term in perpetuity.
|
||||
|
||||
Unless otherwise agreed, Baliance shall not be responsible for providing any
|
||||
service or support to the Customers.
|
||||
(d) "Provider" means FoxyUtils ehf;
|
||||
|
||||
Disclaimer of Warranties and Limitation of Liability
|
||||
(e) "Service" means the licence of the Software Package and any other services
|
||||
provided by the Provider;
|
||||
|
||||
UNLESS OTHERWISE EXPLICITLY AGREED TO IN WRITING BY BALIANCE, BALIANCE MAKES NO
|
||||
OTHER WARRANTIES, EXPRESS OR IMPLIED, IN FACT OR IN LAW, INCLUDING, BUT NOT
|
||||
LIMITED TO, ANY IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
|
||||
PARTICULAR PURPOSE OTHER THAN AS SET FORTH IN THIS AGREEMENT OR IN THE LIMITED
|
||||
WARRANTY DOCUMENTS PROVIDED WITH THE SOFTWARE PRODUCT.
|
||||
|
||||
Baliance makes no warranty that the Software Product will meet your requirements
|
||||
or operate under your specific conditions of use. Baliance makes no warranty
|
||||
that operation of the Software Product will be secure, error free, or free from
|
||||
interruption. YOU MUST DETERMINE WHETHER THE SOFTWARE PRODUCT SUFFICIENTLY MEETS
|
||||
YOUR REQUIREMENTS FOR SECURITY AND UNINTERRUPTABILITY. YOU BEAR SOLE
|
||||
RESPONSIBILITY AND ALL LIABILITY FOR ANY LOSS INCURRED DUE TO FAILURE OF THE
|
||||
SOFTWARE PRODUCT TO MEET YOUR REQUIREMENTS. BALIANCE WILL NOT, UNDER ANY
|
||||
CIRCUMSTANCES, BE RESPONSIBLE OR LIABLE FOR THE LOSS OF DATA ON ANY COMPUTER OR
|
||||
INFORMATION STORAGE DEVICE.
|
||||
|
||||
UNDER NO CIRCUMSTANCES SHALL BALIANCE, ITS DIRECTORS, OFFICERS, EMPLOYEES OR
|
||||
AGENTS BE LIABLE TO YOU OR ANY OTHER PARTY FOR INDIRECT, CONSEQUENTIAL, SPECIAL,
|
||||
INCIDENTAL, PUNITIVE, OR EXEMPLARY DAMAGES OF ANY KIND (INCLUDING LOST REVENUES
|
||||
OR PROFITS OR LOSS OF BUSINESS) RESULTING FROM THIS AGREEMENT, OR FROM THE
|
||||
FURNISHING, PERFORMANCE, INSTALLATION, OR USE OF THE SOFTWARE PRODUCT, WHETHER
|
||||
DUE TO A BREACH OF CONTRACT, BREACH OF WARRANTY, OR THE NEGLIGENCE OF BALIANCE
|
||||
OR ANY OTHER PARTY, EVEN IF BALIANCE IS ADVISED BEFOREHAND OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES. TO THE EXTENT THAT THE APPLICABLE JURISDICTION LIMITS BALIANCE'S
|
||||
ABILITY TO DISCLAIM ANY IMPLIED WARRANTIES, THIS DISCLAIMER SHALL BE EFFECTIVE
|
||||
TO THE MAXIMUM EXTENT PERMITTED.
|
||||
|
||||
Limitation of Remedies and Damages
|
||||
(f) "Software" means the software source codes/document library located on the
|
||||
Website and any other software owned or licensed by Provider;
|
||||
|
||||
Your remedy for a breach of this Agreement or of any warranty included in this
|
||||
Agreement is the correction or replacement of the Software Product. Selection of
|
||||
whether to correct or replace shall be solely at the discretion of Baliance.
|
||||
Baliance reserves the right to substitute a functionally equivalent copy of the
|
||||
Software Product as a replacement. If Baliance is unable to provide a
|
||||
replacement or substitute Software Product or corrections to the Software
|
||||
Product, your sole alternate remedy shall be a refund of the purchase price for
|
||||
the Software Product exclusive of any costs for shipping and handling.
|
||||
|
||||
Any claim must be made within the applicable warranty period. All warranties
|
||||
cover only defects arising under normal use and do not include malfunctions or
|
||||
failure resulting from misuse, abuse, neglect, alteration, problems with
|
||||
electrical power, acts of nature, unusual temperatures or humidity, improper
|
||||
installation, or damage determined by Baliance to have been caused by you. All
|
||||
limited warranties on the Software Product are granted only to you and are
|
||||
non-transferable. You agree to indemnify and hold Baliance harmless from all
|
||||
claims, judgments, liabilities, expenses, or costs arising from your breach of
|
||||
this Agreement and/or acts or omissions.
|
||||
|
||||
Governing Law, Jurisdiction and Costs
|
||||
(g) "Software Package" means the Software licenced to you by the Provider;
|
||||
|
||||
This Agreement is governed by the laws of Alabama, without regard to Alabama's
|
||||
conflict or choice of law provisions.
|
||||
|
||||
Severability
|
||||
(h) "Term" means the period of 12 months from the date the Service is purchased;
|
||||
|
||||
If any provision of this Agreement shall be held to be invalid or unenforceable,
|
||||
the remainder of this Agreement shall remain in full force and effect. To the
|
||||
extent any express or implied restrictions are not permitted by applicable laws,
|
||||
these express or implied restrictions shall remain in force and effect to the
|
||||
maximum extent permitted by such applicable laws.
|
||||
|
||||
(i) "us" means Provider and 'we' or 'our' shall be interpreted accordingly;
|
||||
|
||||
(j) "Website" means the website located at unidoc.io;
|
||||
|
||||
(k) "you" means the person or entity that accesses the Software Package and
|
||||
'your' shall be interpreted accordingly.
|
||||
|
||||
2. ACCESS
|
||||
(a) Your use of the Software Package is by non-exclusive sub-licence granted by
|
||||
the Client strictly in accordance with these Terms of Use. You must also only
|
||||
use the Software Package purchased by you in accordance with the terms for
|
||||
that particular Software Package as stated on the Website. For example, if you
|
||||
purchase a Software Package that allows you to have one Developer, you must not
|
||||
allow more than one Developer use the Software Package.
|
||||
|
||||
(b) You acknowledge and agree with Provider that you will not, as a result of
|
||||
being granted a non-exclusive licence, acquire any rights (including without
|
||||
limitation Intellectual Property Rights) in the Software or the Software Package
|
||||
other than the non-exclusive rights granted in accordance with these Terms of
|
||||
Use.
|
||||
|
||||
(c) The Software Package is available only to, and may only be used by,
|
||||
individuals who can form legally binding contracts under their applicable law.
|
||||
Without limiting the foregoing, our services are not available to and may not be
|
||||
used by persons under 18 years of age. If you do not qualify, please do not use
|
||||
our services.
|
||||
|
||||
(d) In order to use this Software Package, you require the equipment and
|
||||
connections necessary to access the World Wide Web. Without limitation, you are
|
||||
responsible for:
|
||||
|
||||
(i) the provision of any such connection or access to the World Wide Web;
|
||||
|
||||
(ii) the payment of any fees associated with such connection or access (such as
|
||||
those charged by an internet service provider or other online service); and
|
||||
|
||||
(iii) the provision of all equipment necessary for you to make any such
|
||||
connection to the World Wide Web, including a computer and a modem.
|
||||
|
||||
3. LICENSE
|
||||
(a) On purchasing a licence to access a Software Package, we hereby
|
||||
grant to you a perpetual non-exclusive royalty free licence to access the
|
||||
Software Package and to use the Software Package for all commercial purposes
|
||||
(subject to clause 3(b)).
|
||||
|
||||
(b) The Software Package or any part of it may not be used by you or any of your
|
||||
related entities, nor can you allow the Software Package or any part of it to be
|
||||
used by any other entity, in any way connected to any business/products which
|
||||
directly or indirectly could be considered to be competing with the Company's
|
||||
business/products to any extent, or otherwise in any way that the Company
|
||||
considers to be detrimental to it acting reasonably.
|
||||
|
||||
(c) During the Term, you shall have access to all updated versions of the
|
||||
Software Package, however following conclusion of the Term you will only be able
|
||||
to access the Software Package as it existed during the Term. You will not have
|
||||
access to any further updates, unless you purchase a further licence.
|
||||
|
||||
4. REGISTRATION
|
||||
(a) This registration clause is only applicable if Provider requires you to
|
||||
register use the Services from time to time.
|
||||
|
||||
(i) You must not use false or misleading information in registering or using the
|
||||
Service and you must update your details should they have changed from the last
|
||||
time you used the Service. We are not responsible for any loss or damage
|
||||
(including misdirected deliveries or notifications) which may occur because you
|
||||
have not provided us with up to date, accurate or complete information.
|
||||
|
||||
(ii) You must choose a username and password when registering your Account. You
|
||||
are responsible for the security of your username and password and we will
|
||||
assume that anyone using your Account is authorised by you. Under no
|
||||
circumstances will unauthorised access and use of your Account reduce your
|
||||
liability in connection with the Service. This includes your obligation to
|
||||
purchase Services which may result from use of your username and password.
|
||||
|
||||
(iii) You must notify us immediately if you become aware of any unauthorised use
|
||||
of your Account or other security breach which we may consider relevant.
|
||||
|
||||
(iv) You permit us to send you notifications by email including marketing
|
||||
related materials.
|
||||
|
||||
(v) We accept no liability for any loss or damage incurred if you do not receive
|
||||
any notifications by us to you, for whatever reason.
|
||||
|
||||
(vi) You may request that your account be closed by emailing us. Your account
|
||||
will be closed if you have paid everything you owe to us in cleared funds and
|
||||
all transactions have been completed.
|
||||
|
||||
(b) Transmissions to Website * (i) You are solely responsible for transmissions
|
||||
to our Website when using your account or when the Software Package is accessed
|
||||
by someone using your Account.
|
||||
|
||||
5. SYSTEM INTEGRITY & USER CONDUCT
|
||||
(a) You must not use the Software Package to:
|
||||
|
||||
(i) input, upload, post, disclose or transmit any material which is subject to
|
||||
Intellectual Property Rights of Provider or any third party or breaches any duty
|
||||
of confidence or contractual obligation owed to Provider or any third party;
|
||||
|
||||
(ii) input, upload, post, disclose or transmit any material that is unlawful or
|
||||
violates any law;
|
||||
|
||||
(iii) upload any files that contain viruses, Trojan horses, worms, time bombs,
|
||||
corrupted files or any other similar software or programs that may damage the
|
||||
operation of the Software Package or another's computer or property of another;
|
||||
|
||||
(iv) sub-license, rent, lease, transfer or attempt to assign the rights in the
|
||||
Software Package or the Software to any other person and any dealing in
|
||||
contravention of this sub-clause shall be ineffective;
|
||||
|
||||
(v) falsify or delete any attributions, legends, or other proprietary
|
||||
designations of origin or source of any content of the Software Package;
|
||||
|
||||
(vi) interfere with or disrupt the Software Package or servers or networks
|
||||
connected to the Software Package, or disobey any requirements, procedures,
|
||||
policies, or regulations of networks connected to the Software Package;
|
||||
|
||||
(vii) attempt to gain unauthorised access to the Software Package or computer
|
||||
systems or networks connected to the Software Package through any means;
|
||||
|
||||
(viii) breach any privacy legislation.
|
||||
|
||||
(b) You acknowledge and agree that you must not:
|
||||
|
||||
(i) use the Software Package for any purpose other than the purpose for which it
|
||||
was designed and intended;
|
||||
|
||||
(ii) use the Software Package for any purpose other than for the purposes of
|
||||
your business;
|
||||
|
||||
(iii) commit or permit any act which may interfere with the use of the Software
|
||||
Package by any other user;
|
||||
|
||||
(iv) tamper with, hinder the operation of or make unauthorised modifications to
|
||||
the Software Package or any part thereof;
|
||||
|
||||
(v) damage or modify the Software or the Software Package or any part thereof;
|
||||
|
||||
(vi) reverse engineer, decompile or disassemble the Software or the Software
|
||||
Package or any part thereof;
|
||||
|
||||
(vii) conduct any systematic or automated data scraping, data mining, data
|
||||
extraction or data harvesting, or other systematic or automated data collection
|
||||
activity, by means of or in relation to the Services.
|
||||
|
||||
|
||||
6. LINKS & ADVERTISING
|
||||
(a) Neither Provider nor its officers, directors, employees, agents, or related
|
||||
bodies corporate recommend or endorse the content or advertisements of any
|
||||
third parties which may be linked to or from the Website.
|
||||
|
||||
7. INTELLECTUAL PROPERTY RIGHTS
|
||||
(a) The Software and the Software Package are protected by Intellectual
|
||||
Property Rights. You acknowledge that Provider is the owner of these rights,
|
||||
with our affiliates or other third party licensors. (b) The Provider logo and
|
||||
name are owned by us, and may not be used as part of your business or in
|
||||
connection with any goods or services without the prior written consent of
|
||||
Provider which shall be given, given with conditions or withheld at
|
||||
Provider's absolute discretion.
|
||||
|
||||
8. INFORMATION PROVIDED AND PRIVACY
|
||||
(a) You authorise us to use, store or otherwise process any information
|
||||
including personal information which relates to and/or identifies you,
|
||||
including, but not limited to, your name, company or business name,
|
||||
email address and postal address, all details of your use of the
|
||||
Services such as your access times ('the Personal Information'), for all
|
||||
purposes we consider necessary in our discretion, including research and
|
||||
marketing purposes. You grant us an irrevocable royalty free non-exclusive
|
||||
licence to use your Personal Information in accordance with this clause.
|
||||
|
||||
9. WARRANTIES
|
||||
(a) Provider does not warrant that:
|
||||
|
||||
(i) The Software or the Software Package will provide any function for which it
|
||||
is not specifically designed;
|
||||
|
||||
(ii) The Software or the Software Package will provide any minimum level of
|
||||
performance;
|
||||
|
||||
(iii) The Software or the Software Package will be virus free or free of
|
||||
performance anomalies or be operational without interruption.
|
||||
|
||||
(b) You warrant to us that at the time of entering the Software Package, you
|
||||
were not relying on any representation made by us.
|
||||
|
||||
(c) Except as expressly provided to the contrary, and to the extent permitted by
|
||||
law, we make no representations or warranties of any kind, express or implied as
|
||||
to the operation of your access to or the results of your access to the Software
|
||||
or the Software Package (including any related or linked Software Packages) or
|
||||
the correctness, accuracy, timeliness, or completeness or reliability of the
|
||||
information, content, materials or Services included on the Software Package.
|
||||
|
||||
10. DISCLAIMER AND LIMITATION OF LIABILITY
|
||||
(a) To the extent permitted by law, the Software Package is provided by
|
||||
Provider on an "as is" basis without any express or implied warranty of
|
||||
any kind. You acknowledge and agree that any claim you may have in
|
||||
relation to the Software Package is a claim against the Client, not us.
|
||||
|
||||
(b) The Software or the Software Package may contain inaccuracies or
|
||||
typographical errors.
|
||||
|
||||
(c) The World Wide Web exists across open public networks that are neither
|
||||
secure nor private. Accordingly, you acknowledge and accept the risk that any
|
||||
communication to or from the Software Package may be intercepted, used or
|
||||
modified by third parties.
|
||||
|
||||
(d) Provider may change any of the material on the Software Package at any time
|
||||
without notice.
|
||||
|
||||
(e) Provider makes no commitment to update any material on the Software Package.
|
||||
|
||||
(f) You are responsible for assessing the reliability, accuracy, completeness,
|
||||
timeliness, suitability, quality, physical state or for a particular purpose of
|
||||
the material on or accessible through the Software Package.
|
||||
|
||||
(g) You accept all risks and responsibility for all loss, damage, costs and
|
||||
other consequences resulting from your use of the Software Package or the
|
||||
material on or accessible through the Software Package.
|
||||
|
||||
(h) Where the laws of any country or state in which these Terms of Use are
|
||||
effective implies into these Terms of Use any term, condition or warranty, and
|
||||
those laws avoid or prohibit provisions in a contract excluding or modifying
|
||||
them, then the term, condition or warranty shall be deemed to be included in
|
||||
these Terms of Use provided that the liability of Provider, its officers,
|
||||
directors, employees, agents and related bodies corporate for a breach of any
|
||||
such term, condition or warranty, including any economic or consequential loss
|
||||
which you may sustain shall be limited to the supply of the Services again or
|
||||
$10.00, whichever is the lesser.
|
||||
|
||||
(i) You release Provider and its officers, directors, employees, agents or
|
||||
related bodies corporate from its liability for any loss or damage including
|
||||
without limitation, losses or damages for loss of profits, business
|
||||
interruption, loss of information, indirect, special, punitive or consequential
|
||||
losses or damages arising out of the use or inability to use or reliance on the
|
||||
material or information available on or accessible through the Software Package,
|
||||
even if Provider has been advised of the likelihood of such damages and whether
|
||||
or not caused by any negligent act or omission.
|
||||
|
||||
(j) Without limiting the aforementioned clause you release us from any loss or
|
||||
damage (including indirect, special or consequential loss or damage) arising
|
||||
from the use of, or reliance on, the Software or the Software Package, whether
|
||||
or not caused by any negligent act or omission including but not limited to:-
|
||||
|
||||
(i) loss of use, data or profits on any theory of liability arising out of or in
|
||||
connection with the use of or the inability to use the Software or the Software
|
||||
Package;
|
||||
|
||||
(ii) your reliance on the Software or the Software Package;
|
||||
|
||||
(iii) the statements or actions of any employee or agent of the Provider;
|
||||
|
||||
(iv) any unauthorised access to or alteration of your transmissions or data;
|
||||
|
||||
(v) any information that is sent or received or not sent or received;
|
||||
|
||||
(vi) any failure to store or loss of data or files or other content;
|
||||
|
||||
(vii) your fraudulent, negligent or otherwise unlawful behaviour;
|
||||
|
||||
(viii) any delay or interruption of the Software or the Software Package;
|
||||
|
||||
(ix) any loss incurred as a result of a third party obtaining your access
|
||||
details, either with or without your knowledge;
|
||||
|
||||
(x) any loss or damages in relation to the supply of services on or in relation
|
||||
to this Software Package and any advertisement placed on the Software Package or
|
||||
information made available on the Software Package.
|
||||
|
||||
11. INDEMNITY
|
||||
(a) You agree to indemnify and hold harmless Provider, and its
|
||||
officers, directors, shareholders, employees, consultants, agents, and related
|
||||
bodies corporate from and against all losses, damages, expenses and costs
|
||||
(including solicitor client costs on a full indemnity basis) and all third-party
|
||||
claims, liability, losses, damages, expenses and costs arising from any claim,
|
||||
demand, suit, action or proceeding by any person against any of those
|
||||
indemnified in relation to or in connection with your use of the Software
|
||||
Package or the Software or your failure to comply with these Terms of Use, or
|
||||
from your violation of any applicable law.
|
||||
|
||||
12. UPGRADES
|
||||
(a) You acknowledge and agree that these Terms of Use apply to
|
||||
updates, supplements, add on components, or internet based services components
|
||||
of the Software and the Software Package together with any other terms along
|
||||
with the update, supplement, add on component or internet based services
|
||||
components which Provider provides.
|
||||
|
||||
(b) Provider reserves the right to discontinue any internet based services
|
||||
provided to you or made available to you through the use of the Software and the
|
||||
Software Package at any time.
|
||||
|
||||
13. BREACH AND TERMINATION
|
||||
(a) Provider reserves the right to deny you access to, or use of, all or part
|
||||
of the Software Package, without prior notice, if you engage in any conduct
|
||||
that Provider believes, in its sole discretion:
|
||||
|
||||
(i) violates any term or provision of these Terms of Use or any other terms or
|
||||
policies of Provider in place from time to time; or
|
||||
|
||||
(ii) violates the rights of Provider or any third party; or
|
||||
|
||||
(iii) is otherwise inappropriate for continued access and use of the Software
|
||||
Package.
|
||||
|
||||
(b) Provider may terminate your right to access to, or use of, all or part of
|
||||
the Software Package, immediately on written notice to you if you:
|
||||
|
||||
(i) commit a material breach of these Terms of Use, which is capable of remedy,
|
||||
and you fail to remedy the breach within a reasonable time of a written notice
|
||||
to do so; or
|
||||
|
||||
(ii) commit a material breach of these Terms of Use which cannot be remedied; or
|
||||
|
||||
(iii) are repeatedly in breach of these Terms of Use; or
|
||||
|
||||
(iv) are the subject of a bankruptcy order, or become insolvent, or make any
|
||||
arrangement or composition with or assignment for the benefit of your creditors,
|
||||
or if you go into voluntary (otherwise than for reconstruction or amalgamation)
|
||||
or compulsory liquidation, or a receiver or administrator is appointed over your
|
||||
assets.
|
||||
|
||||
(c) On termination of this Agreement your right to use the Software Package
|
||||
shall cease.
|
||||
|
||||
(d) Termination of your access to the Software Package shall be without
|
||||
prejudice to the rights of the parties accrued before termination. All
|
||||
restrictions imposed on you, disclaimers and limitations of liability set out in
|
||||
these Terms of Use will survive termination.
|
||||
|
||||
14. GENERAL
|
||||
(a) Provider may from time to time amend, update, or change the Software
|
||||
Package, including these Terms of Use, without prior notice.
|
||||
|
||||
(b) These Terms of Use constitute the entire agreement between you and Provider
|
||||
with respect to this Software Package, and the Terms of Use replace all prior or
|
||||
contemporaneous understandings or agreements, written or oral, regarding the
|
||||
Software Package.
|
||||
|
||||
(c) No oral explanation or information provided by a party to another affects
|
||||
the meaning or interpretation of this Agreement or constitutes any collateral
|
||||
agreement, warranty or understanding.
|
||||
|
||||
(d) If any provision of these Terms of Use is found to be invalid or
|
||||
unenforceable, that provision shall be enforced to the maximum extent possible
|
||||
and will be deemed deleted to the extent that it is not enforceable, and the
|
||||
remaining provisions of the Terms of Use shall remain in full force and effect.
|
||||
|
||||
(e) The failure by Provider to insist upon or enforce strict performance of any
|
||||
of these Terms of Use will not be construed as a waiver of any right or remedy
|
||||
of Provider in respect of any existing or subsequent breach of these Terms of
|
||||
Use.
|
||||
|
||||
(f) No waiver by a party of a provision of this Agreement is binding unless made
|
||||
in writing.
|
||||
|
||||
(g) The law of Iceland govern these Terms of Use. You hereby consent and submit
|
||||
to the non-exclusive jurisdiction and venue of the Courts of Iceland for any
|
||||
cause of action relating to or arising under these Terms of Use.
|
||||
|
||||
(h) Provider operates the Software Package in Iceland. Information contained on
|
||||
the Software Package may not be appropriate or available for use in other
|
||||
locations. If you access the Software Package from other locations, you do so at
|
||||
your own initiative and you are solely responsible for compliance with local
|
||||
laws.
|
||||
|
||||
(i) Where possible, the obligations of the parties under this Agreement will
|
||||
indefinitely survive the finalisation or discontinuance of this Agreement.
|
||||
|
||||
(j) This Agreement shall be for the benefit of and binding upon the parties and
|
||||
their heirs, executors, successors and permitted assigns.
|
||||
|
||||
(k) The parties must execute and deliver all documents and must do all things as
|
||||
are necessary for the complete performance of their respective obligations under
|
||||
this Agreement.
|
||||
|
||||
(l) The rights and remedies of a party to this Agreement are in addition to the
|
||||
rights or remedies conferred on the party at law or in equity.
|
||||
|
||||
(m) Rules of construction will not apply to disadvantage a party whether that
|
||||
party put the clause forward, was responsible for drafting all or part of it or
|
||||
would otherwise benefit from it.
|
||||
|
21
LICENSE.md
Normal file
21
LICENSE.md
Normal file
@ -0,0 +1,21 @@
|
||||
## Licensing Information
|
||||
|
||||
This library (UniDoc unioffice) has a dual license, a commercial one suitable for closed source projects and an
|
||||
AGPL license that can be used in open source software.
|
||||
|
||||
Depending on your needs, you must choose one of them and follow its policies. A detail of the policies
|
||||
and agreements for each license type are available in the [LICENSE.COMMERCIAL](LICENSE.COMMERCIAL)
|
||||
and [LICENSE.AGPL](LICENSE.AGPL) files.
|
||||
|
||||
In brief, purchasing a license is mandatory as soon as you develop activities
|
||||
distributing the unioffice software inside your product or deploying it on a network
|
||||
without disclosing the source code of your own applications under the AGPL license.
|
||||
These activities include:
|
||||
|
||||
* offering services as an application service provider or over-network application programming interface (API)
|
||||
* creating/manipulating documents for users in a web/server/cloud application
|
||||
* shipping unioffice with a closed source product
|
||||
|
||||
Please see [pricing](http://unidoc.io/pricing) to purchase a commercial license or contact sales at sales@unidoc.io
|
||||
for more info.
|
||||
|
@ -9,8 +9,6 @@ package common
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/unidoc/unioffice"
|
||||
"github.com/unidoc/unioffice/schema/soo/ofc/extended_properties"
|
||||
@ -25,13 +23,14 @@ type AppProperties struct {
|
||||
// NewAppProperties constructs a new AppProperties.
|
||||
func NewAppProperties() AppProperties {
|
||||
p := AppProperties{x: extended_properties.NewProperties()}
|
||||
p.SetCompany("Baliance LLC")
|
||||
p.SetCompany("FoxyUtils ehf")
|
||||
p.SetApplication("github.com/unidoc/unioffice")
|
||||
p.SetDocSecurity(0)
|
||||
p.SetLinksUpToDate(false)
|
||||
// trim the 'v'
|
||||
ver := strings.Replace(unioffice.ReleaseVersion, "v", "", -1)
|
||||
f, _ := strconv.ParseFloat(ver, 64)
|
||||
|
||||
var major, minor, patch int64
|
||||
fmt.Sscanf(Version, "%d.%d.%d", &major, &minor, &patch)
|
||||
f := float64(major) + float64(minor)/10000.0
|
||||
p.SetApplicationVersion(fmt.Sprintf("%07.4f", f))
|
||||
return p
|
||||
}
|
||||
|
@ -9,12 +9,8 @@ package common_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/unidoc/unioffice"
|
||||
|
||||
"github.com/unidoc/unioffice/common"
|
||||
)
|
||||
|
||||
@ -32,7 +28,9 @@ func TestNewAppDefaultProperties(t *testing.T) {
|
||||
t.Errorf("unexpected application: %s", got)
|
||||
}
|
||||
|
||||
fv, _ := strconv.ParseFloat(strings.Replace(unioffice.ReleaseVersion, "v", "", -1), 64)
|
||||
var major, minor, patch int64
|
||||
fmt.Sscanf(common.Version, "%d.%d.%d", &major, &minor, &patch)
|
||||
fv := float64(major) + float64(minor)/10000.0
|
||||
if got := ap.ApplicationVersion(); got != fmt.Sprintf("%07.4f", fv) {
|
||||
t.Errorf("unexpected application version: %s", got)
|
||||
}
|
||||
|
161
common/license/crypto.go
Normal file
161
common/license/crypto.go
Normal file
@ -0,0 +1,161 @@
|
||||
/*
|
||||
* This file is subject to the terms and conditions defined in
|
||||
* file 'LICENSE.md', which is part of this source code package.
|
||||
*/
|
||||
|
||||
package license
|
||||
|
||||
import (
|
||||
"crypto"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/sha512"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
licenseKeyHeader = "-----BEGIN UNIDOC LICENSE KEY-----"
|
||||
licenseKeyFooter = "-----END UNIDOC LICENSE KEY-----"
|
||||
)
|
||||
|
||||
// Returns signed content in a base64 format which is in format:
|
||||
//
|
||||
// Base64OriginalContent
|
||||
// +
|
||||
// Base64Signature
|
||||
func signContent(privKey string, content []byte) (string, error) {
|
||||
privBlock, _ := pem.Decode([]byte(privKey))
|
||||
if privBlock == nil {
|
||||
return "", fmt.Errorf("PrivKey failed")
|
||||
}
|
||||
|
||||
priv, err := x509.ParsePKCS1PrivateKey(privBlock.Bytes)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
hash := sha512.New()
|
||||
hash.Write(content)
|
||||
digest := hash.Sum(nil)
|
||||
|
||||
signature, err := rsa.SignPKCS1v15(rand.Reader, priv, crypto.SHA512, digest)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
ret := base64.StdEncoding.EncodeToString(content)
|
||||
ret += "\n+\n"
|
||||
ret += base64.StdEncoding.EncodeToString(signature)
|
||||
|
||||
return ret, nil
|
||||
}
|
||||
|
||||
// Verifies and reconstructs the original content
|
||||
func verifyContent(pubKey string, content string) ([]byte, error) {
|
||||
// Empty + line is the delimiter between content and signature.
|
||||
// We need to cope with both unix and windows newline, default to unix
|
||||
// one and try Windows one as fallback.
|
||||
separator := "\n+\n"
|
||||
separatorFallback := "\r\n+\r\n"
|
||||
|
||||
sepIdx := strings.Index(content, separator)
|
||||
if sepIdx == -1 {
|
||||
sepIdx = strings.Index(content, separatorFallback)
|
||||
if sepIdx == -1 {
|
||||
return nil, fmt.Errorf("invalid input, signature separator")
|
||||
}
|
||||
}
|
||||
|
||||
// Original is from start until the separator - 1
|
||||
original := content[:sepIdx]
|
||||
|
||||
// Signature is from after the separator until the end of file.
|
||||
signatureStarts := sepIdx + len(separator)
|
||||
signature := content[signatureStarts:]
|
||||
|
||||
if original == "" || signature == "" {
|
||||
return nil, fmt.Errorf("invalid input, missing original or signature")
|
||||
}
|
||||
|
||||
originalBytes, err := base64.StdEncoding.DecodeString(original)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid input original")
|
||||
}
|
||||
|
||||
signatureBytes, err := base64.StdEncoding.DecodeString(signature)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("invalid input signature")
|
||||
}
|
||||
|
||||
pubBlock, _ := pem.Decode([]byte(pubKey))
|
||||
if pubBlock == nil {
|
||||
return nil, fmt.Errorf("PubKey failed")
|
||||
}
|
||||
|
||||
tempPub, err := x509.ParsePKIXPublicKey(pubBlock.Bytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
pub := tempPub.(*rsa.PublicKey)
|
||||
if pub == nil {
|
||||
return nil, fmt.Errorf("PubKey conversion failed")
|
||||
}
|
||||
|
||||
hash := sha512.New()
|
||||
hash.Write(originalBytes)
|
||||
digest := hash.Sum(nil)
|
||||
|
||||
err = rsa.VerifyPKCS1v15(pub, crypto.SHA512, digest, signatureBytes)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return originalBytes, nil
|
||||
}
|
||||
|
||||
// Returns the content wrap around the headers
|
||||
func getWrappedContent(header string, footer string, content string) (string, error) {
|
||||
// Find all content between header and footer.
|
||||
headerIdx := strings.Index(content, header)
|
||||
if headerIdx == -1 {
|
||||
return "", fmt.Errorf("header not found")
|
||||
}
|
||||
|
||||
footerIdx := strings.Index(content, footer)
|
||||
if footerIdx == -1 {
|
||||
return "", fmt.Errorf("footer not found")
|
||||
}
|
||||
|
||||
start := headerIdx + len(header) + 1
|
||||
return content[start : footerIdx-1], nil
|
||||
}
|
||||
|
||||
func licenseKeyDecode(content string) (LicenseKey, error) {
|
||||
var ret LicenseKey
|
||||
|
||||
data, err := getWrappedContent(licenseKeyHeader, licenseKeyFooter, content)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
verifiedRet, err := verifyContent(pubKey, data)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
err = json.Unmarshal(verifiedRet, &ret)
|
||||
if err != nil {
|
||||
return ret, err
|
||||
}
|
||||
|
||||
ret.CreatedAt = time.Unix(ret.CreatedAtInt, 0)
|
||||
ret.ExpiresAt = time.Unix(ret.ExpiresAtInt, 0)
|
||||
return ret, nil
|
||||
}
|
140
common/license/key.go
Normal file
140
common/license/key.go
Normal file
@ -0,0 +1,140 @@
|
||||
/*
|
||||
* This file is subject to the terms and conditions defined in
|
||||
* file 'LICENSE.md', which is part of this source code package.
|
||||
*/
|
||||
|
||||
package license
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/unidoc/unioffice/common"
|
||||
)
|
||||
|
||||
// License tiers.
|
||||
const (
|
||||
LicenseTierUnlicensed = "unlicensed"
|
||||
LicenseTierCommunity = "community"
|
||||
LicenseTierIndividual = "individual"
|
||||
LicenseTierBusiness = "business"
|
||||
)
|
||||
|
||||
// Make sure all time is at least after this for sanity check.
|
||||
var testTime = time.Date(2010, 1, 1, 0, 0, 0, 0, time.UTC)
|
||||
|
||||
// LicenseKey represents a license key for UniOffice.
|
||||
type LicenseKey struct {
|
||||
LicenseId string `json:"license_id"`
|
||||
CustomerId string `json:"customer_id"`
|
||||
CustomerName string `json:"customer_name"`
|
||||
Tier string `json:"tier"`
|
||||
CreatedAt time.Time `json:"-"`
|
||||
CreatedAtInt int64 `json:"created_at"`
|
||||
ExpiresAt time.Time `json:"-"`
|
||||
ExpiresAtInt int64 `json:"expires_at"`
|
||||
CreatorName string `json:"creator_name"`
|
||||
CreatorEmail string `json:"creator_email"`
|
||||
UniPDF bool `json:"unipdf"`
|
||||
UniOffice bool `json:"unioffice"`
|
||||
Trial bool `json:"trial"` // For trial licenses.
|
||||
}
|
||||
|
||||
// Returns the date to compare against, for trial licenses it is the current time,
|
||||
// but for production it is the current release date.
|
||||
func (k *LicenseKey) getExpiryDateToCompare() time.Time {
|
||||
if k.Trial {
|
||||
return time.Now().UTC()
|
||||
}
|
||||
|
||||
return common.ReleasedAt
|
||||
}
|
||||
|
||||
func (k *LicenseKey) isExpired() bool {
|
||||
return k.getExpiryDateToCompare().After(k.ExpiresAt)
|
||||
}
|
||||
|
||||
// Validate returns an error if the licenseis invalid, nil otherwise.
|
||||
func (k *LicenseKey) Validate() error {
|
||||
if len(k.LicenseId) < 10 {
|
||||
return fmt.Errorf("invalid license: License Id")
|
||||
}
|
||||
|
||||
if len(k.CustomerId) < 10 {
|
||||
return fmt.Errorf("invalid license: Customer Id")
|
||||
}
|
||||
|
||||
if len(k.CustomerName) < 1 {
|
||||
return fmt.Errorf("invalid license: Customer Name")
|
||||
}
|
||||
|
||||
if testTime.After(k.CreatedAt) {
|
||||
return fmt.Errorf("invalid license: Created At is invalid")
|
||||
}
|
||||
|
||||
if k.CreatedAt.After(k.ExpiresAt) {
|
||||
return fmt.Errorf("invalid license: Created At cannot be Greater than Expires At")
|
||||
}
|
||||
|
||||
if k.isExpired() {
|
||||
return fmt.Errorf("invalid license: The license has already expired")
|
||||
}
|
||||
|
||||
if len(k.CreatorName) < 1 {
|
||||
return fmt.Errorf("invalid license: Creator name")
|
||||
}
|
||||
|
||||
if len(k.CreatorEmail) < 1 {
|
||||
return fmt.Errorf("invalid license: Creator email")
|
||||
}
|
||||
|
||||
if !k.UniOffice {
|
||||
return fmt.Errorf("invalid license: This UniDoc key is invalid for UniOffice.")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// TypeToString returns a string representation of the license type.
|
||||
func (k *LicenseKey) TypeToString() string {
|
||||
if k.Tier == LicenseTierUnlicensed {
|
||||
return "Unlicensed"
|
||||
}
|
||||
|
||||
if k.Tier == LicenseTierCommunity {
|
||||
return "AGPLv3 Open Source Community License"
|
||||
}
|
||||
|
||||
if k.Tier == LicenseTierIndividual || k.Tier == "indie" {
|
||||
return "Commercial License - Individual"
|
||||
}
|
||||
|
||||
return "Commercial License - Business"
|
||||
}
|
||||
|
||||
// ToString returns a string representing the license information.
|
||||
func (k *LicenseKey) ToString() string {
|
||||
str := fmt.Sprintf("License Id: %s\n", k.LicenseId)
|
||||
str += fmt.Sprintf("Customer Id: %s\n", k.CustomerId)
|
||||
str += fmt.Sprintf("Customer Name: %s\n", k.CustomerName)
|
||||
str += fmt.Sprintf("Tier: %s\n", k.Tier)
|
||||
str += fmt.Sprintf("Created At: %s\n", common.UtcTimeFormat(k.CreatedAt))
|
||||
str += fmt.Sprintf("Expires At: %s\n", common.UtcTimeFormat(k.ExpiresAt))
|
||||
str += fmt.Sprintf("Creator: %s <%s>\n", k.CreatorName, k.CreatorEmail)
|
||||
return str
|
||||
}
|
||||
|
||||
// IsLicensed returns true if the package is licensed.
|
||||
func (k *LicenseKey) IsLicensed() bool {
|
||||
return k.Tier != LicenseTierUnlicensed
|
||||
}
|
||||
|
||||
// MakeUnlicensedKey returns an unlicensed key.
|
||||
func MakeUnlicensedKey() *LicenseKey {
|
||||
lk := LicenseKey{}
|
||||
lk.CustomerName = "Unlicensed"
|
||||
lk.Tier = LicenseTierUnlicensed
|
||||
lk.CreatedAt = time.Now().UTC()
|
||||
lk.CreatedAtInt = lk.CreatedAt.Unix()
|
||||
return &lk
|
||||
}
|
64
common/license/license_legacy.go
Normal file
64
common/license/license_legacy.go
Normal file
@ -0,0 +1,64 @@
|
||||
/*
|
||||
* This file is subject to the terms and conditions defined in
|
||||
* file 'LICENSE.md', which is part of this source code package.
|
||||
*/
|
||||
|
||||
package license
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"crypto"
|
||||
"crypto/rsa"
|
||||
"crypto/sha256"
|
||||
"crypto/x509"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
const legacyPubKeyHex = `305c300d06092a864886f70d0101010500034b003048024100b87eafb6c07499eb97cc9d3565ecf3168196301907c841addc665086bb3ed8eb12d9da26cafa96450146da8bd0ccf155fcacc686955ef0302fa44aa3ec89417b0203010001`
|
||||
|
||||
var legacyPubKey *rsa.PublicKey
|
||||
|
||||
// LegacyLicenseType is the type of license
|
||||
type LegacyLicenseType byte
|
||||
|
||||
func init() {
|
||||
pubKeyBytes, err := hex.DecodeString(legacyPubKeyHex)
|
||||
if err != nil {
|
||||
log.Fatalf("error reading key: %s", err)
|
||||
}
|
||||
pkRaw, err := x509.ParsePKIXPublicKey(pubKeyBytes)
|
||||
if err != nil {
|
||||
log.Fatalf("error reading key: %s", err)
|
||||
}
|
||||
legacyPubKey = pkRaw.(*rsa.PublicKey)
|
||||
}
|
||||
|
||||
// LegacyLicense holds the old-style unioffice license information.
|
||||
type LegacyLicense struct {
|
||||
Name string
|
||||
Signature string `json:",omitempty"`
|
||||
Expiration time.Time
|
||||
LicenseType LegacyLicenseType
|
||||
}
|
||||
|
||||
// Verify verifies a license by checking the license content and signature
|
||||
// against a public key.
|
||||
func (l LegacyLicense) Verify(pubKey *rsa.PublicKey) error {
|
||||
cp := l
|
||||
cp.Signature = ""
|
||||
buf := bytes.Buffer{}
|
||||
enc := json.NewEncoder(&buf)
|
||||
if err := enc.Encode(cp); err != nil {
|
||||
return err
|
||||
}
|
||||
sig, err := hex.DecodeString(l.Signature)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hashed := sha256.Sum256(buf.Bytes())
|
||||
err = rsa.VerifyPKCS1v15(pubKey, crypto.SHA256, hashed[:], sig)
|
||||
return err
|
||||
}
|
19
common/license/pubkeys.go
Normal file
19
common/license/pubkeys.go
Normal file
@ -0,0 +1,19 @@
|
||||
/*
|
||||
* This file is subject to the terms and conditions defined in
|
||||
* file 'LICENSE.md', which is part of this source code package.
|
||||
*/
|
||||
|
||||
package license
|
||||
|
||||
// Public key
|
||||
const pubKey = `
|
||||
-----BEGIN PUBLIC KEY-----
|
||||
MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAmFUiyd7b5XjpkP5Rap4w
|
||||
Dc1dyzIQ4LekxrvytnEMpNUbo6iA74V8ruZOvrScsf2QeN9/qrUG8qEbUWdoEYq+
|
||||
otFNAFNxlGbxbDHcdGVaM0OXdXgDyL5aIEagL0c5pwjIdPGIn46f78eMJ+JkdcpD
|
||||
DJaqYXdrz5KeshjSiIaa7menBIAXS4UFxNfHhN0HCYZYqQG7bK+s5rRHonydNWEG
|
||||
H8Myvr2pya2KrMumfmAxUB6fenC/4O0Wr8gfPOU8RitmbDvQPIRXOL4vTBrBdbaA
|
||||
9nwNP+i//20MT2bxmeWB+gpcEhGpXZ733azQxrC3J4v3CZmENStDK/KDSPKUGfu6
|
||||
fwIDAQAB
|
||||
-----END PUBLIC KEY-----
|
||||
`
|
100
common/license/util.go
Normal file
100
common/license/util.go
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* This file is subject to the terms and conditions defined in
|
||||
* file 'LICENSE.md', which is part of this source code package.
|
||||
*/
|
||||
|
||||
// Package license helps manage commercial licenses and check if they are valid for the version of unidoc used.
|
||||
package license
|
||||
|
||||
import (
|
||||
"compress/gzip"
|
||||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/unidoc/unioffice/common"
|
||||
)
|
||||
|
||||
// Defaults to the open source license.
|
||||
var licenseKey = MakeUnlicensedKey()
|
||||
|
||||
// SetLicenseKey sets and validates the license key.
|
||||
func SetLicenseKey(content string, customerName string) error {
|
||||
lk, err := licenseKeyDecode(content)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if strings.ToLower(lk.CustomerName) != strings.ToLower(customerName) {
|
||||
return fmt.Errorf("customer name mismatch, expected '%s', but got '%s'", customerName, lk.CustomerName)
|
||||
}
|
||||
|
||||
err = lk.Validate()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
licenseKey = &lk
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SetLegacyLicenseKey installs a legacy license code. License codes issued prior to June 2019.
|
||||
// Will be removed at some point in a future major version.
|
||||
func SetLegacyLicenseKey(s string) error {
|
||||
re := regexp.MustCompile("\\s")
|
||||
s = re.ReplaceAllString(s, "")
|
||||
|
||||
var r io.Reader
|
||||
r = strings.NewReader(s)
|
||||
r = base64.NewDecoder(base64.RawURLEncoding, r)
|
||||
r, err := gzip.NewReader(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dec := json.NewDecoder(r)
|
||||
l := &LegacyLicense{}
|
||||
if err := dec.Decode(l); err != nil {
|
||||
return err
|
||||
}
|
||||
// check signature
|
||||
if err := l.Verify(legacyPubKey); err != nil {
|
||||
return errors.New("license validatin error")
|
||||
}
|
||||
|
||||
if l.Expiration.Before(common.ReleasedAt) {
|
||||
return errors.New("license expired")
|
||||
}
|
||||
|
||||
utcNow := time.Now().UTC()
|
||||
|
||||
newLicense := LicenseKey{}
|
||||
newLicense.CreatedAt = utcNow
|
||||
newLicense.CustomerId = "Legacy"
|
||||
newLicense.CustomerName = l.Name
|
||||
newLicense.Tier = LicenseTierBusiness
|
||||
newLicense.ExpiresAt = l.Expiration
|
||||
newLicense.CreatorName = "UniDoc support"
|
||||
newLicense.CreatorEmail = "support@unidoc.io"
|
||||
newLicense.UniOffice = true
|
||||
|
||||
licenseKey = &newLicense
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetLicenseKey() *LicenseKey {
|
||||
if licenseKey == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Copy.
|
||||
lk2 := *licenseKey
|
||||
return &lk2
|
||||
}
|
16
common/time.go
Normal file
16
common/time.go
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
* This file is subject to the terms and conditions defined in
|
||||
* file 'LICENSE.md', which is part of this source code package.
|
||||
*/
|
||||
|
||||
package common
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const timeFormat = "2 January 2006 at 15:04"
|
||||
|
||||
func UtcTimeFormat(t time.Time) string {
|
||||
return t.Format(timeFormat) + " UTC"
|
||||
}
|
22
common/version.go
Normal file
22
common/version.go
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* This file is subject to the terms and conditions defined in
|
||||
* file 'LICENSE.md', which is part of this source code package.
|
||||
*/
|
||||
|
||||
// Package common contains common properties used by the subpackages.
|
||||
package common
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
const releaseYear = 2019
|
||||
const releaseMonth = 6
|
||||
const releaseDay = 6
|
||||
const releaseHour = 11
|
||||
const releaseMin = 30
|
||||
|
||||
// Version holds version information, when bumping this make sure to bump the released at stamp also.
|
||||
const Version = "1.2.0"
|
||||
|
||||
var ReleasedAt = time.Date(releaseYear, releaseMonth, releaseDay, releaseHour, releaseMin, 0, 0, time.UTC)
|
@ -10,6 +10,7 @@ package document
|
||||
import (
|
||||
"archive/zip"
|
||||
"errors"
|
||||
"flag"
|
||||
"fmt"
|
||||
"image"
|
||||
"image/jpeg"
|
||||
@ -20,7 +21,10 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/unidoc/unioffice"
|
||||
"github.com/unidoc/unioffice/color"
|
||||
"github.com/unidoc/unioffice/common"
|
||||
"github.com/unidoc/unioffice/common/license"
|
||||
"github.com/unidoc/unioffice/measurement"
|
||||
"github.com/unidoc/unioffice/zippkg"
|
||||
|
||||
"github.com/unidoc/unioffice/schema/soo/dml"
|
||||
@ -158,6 +162,21 @@ func (d *Document) Save(w io.Writer) error {
|
||||
}
|
||||
dt := unioffice.DocTypeDocument
|
||||
|
||||
if !license.GetLicenseKey().IsLicensed() && flag.Lookup("test.v") == nil {
|
||||
fmt.Println("Unlicensed version of UniOffice")
|
||||
fmt.Println("- Get a license on https://unidoc.io")
|
||||
hdr := d.AddHeader()
|
||||
para := hdr.AddParagraph()
|
||||
para.Properties().AddTabStop(2.5*measurement.Inch, wml.ST_TabJcCenter, wml.ST_TabTlcNone)
|
||||
run := para.AddRun()
|
||||
run.AddTab()
|
||||
run.AddText("Unlicensed version of UniOffice - Get a license on https://unidoc.io")
|
||||
run.Properties().SetBold(true)
|
||||
run.Properties().SetSize(14)
|
||||
run.Properties().SetColor(color.Red)
|
||||
d.BodySection().SetHeader(hdr, wml.ST_HdrFtrDefault)
|
||||
}
|
||||
|
||||
z := zip.NewWriter(w)
|
||||
defer z.Close()
|
||||
if err := zippkg.MarshalXML(z, unioffice.BaseRelsFilename, d.Rels.X()); err != nil {
|
||||
|
@ -21,6 +21,8 @@ import (
|
||||
|
||||
func TestSimpleDoc(t *testing.T) {
|
||||
doc := document.New()
|
||||
testVersion := "00.8000"
|
||||
doc.AppProperties.X().AppVersion = &testVersion
|
||||
para := doc.AddParagraph()
|
||||
run := para.AddRun()
|
||||
run.AddText("foo")
|
||||
|
BIN
document/testdata/simple-1.docx
vendored
BIN
document/testdata/simple-1.docx
vendored
Binary file not shown.
186
license.go
186
license.go
@ -1,186 +0,0 @@
|
||||
// Copyright 2017 Baliance. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by the terms of the Affero GNU General
|
||||
// Public License version 3.0 as published by the Free Software Foundation and
|
||||
// appearing in the file LICENSE included in the packaging of this file. A
|
||||
// commercial license can be purchased by contacting sales@baliance.com.
|
||||
|
||||
package unioffice
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"compress/gzip"
|
||||
"crypto"
|
||||
"crypto/rand"
|
||||
"crypto/rsa"
|
||||
"crypto/sha256"
|
||||
"crypto/x509"
|
||||
"encoding/base64"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"log"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
// OpenSourceLicense is the AGPL open source license. It is installed by default
|
||||
// if no license has previously been installed.
|
||||
const OpenSourceLicense = `
|
||||
H4sIAAAAAAAC_xzJsU7DQAwA0J2vqDynks--y9nZ
|
||||
2RAMLQubfeegDKRR2kogxL8jkN72vuHZPgImeNli
|
||||
PZwu973F4fUaOwxwWt5Xu933v86Fqjfnlq1mKWzU
|
||||
SXzEwCKoqWc0sREtvCYlsdlV2b12CwqyntVk7orZ
|
||||
eTQRtMhMoonHaDh3DMsYVEir10JzbV3CW1FmyrM4
|
||||
wQCPn9uy2225rDABI-Ix0ZHTGXH69wYDPC0t1muc
|
||||
v7aAKf08_AYAAP__z2E3oN8A`
|
||||
|
||||
var license *License
|
||||
|
||||
const pubKeyHex = `305c300d06092a864886f70d0101010500034b003048024100b87eafb6c07499eb97cc9d3565ecf3168196301907c841addc665086bb3ed8eb12d9da26cafa96450146da8bd0ccf155fcacc686955ef0302fa44aa3ec89417b0203010001`
|
||||
|
||||
var pubKey *rsa.PublicKey
|
||||
|
||||
func init() {
|
||||
pubKeyBytes, err := hex.DecodeString(pubKeyHex)
|
||||
if err != nil {
|
||||
log.Fatalf("error reading key: %s", err)
|
||||
}
|
||||
pkRaw, err := x509.ParsePKIXPublicKey(pubKeyBytes)
|
||||
if err != nil {
|
||||
log.Fatalf("error reading key: %s", err)
|
||||
}
|
||||
pubKey = pkRaw.(*rsa.PublicKey)
|
||||
}
|
||||
|
||||
// LicenseType is the type of license
|
||||
//go:generate stringer -type=LicenseType
|
||||
type LicenseType byte
|
||||
|
||||
// LicenseType constants
|
||||
const (
|
||||
LicenseTypeInvalid LicenseType = iota
|
||||
LicenseTypeAGPL
|
||||
LicenseTypeCommercial
|
||||
)
|
||||
|
||||
// License holds the unioffice license information.
|
||||
type License struct {
|
||||
Name string
|
||||
Signature string `json:",omitempty"`
|
||||
Expiration time.Time
|
||||
LicenseType LicenseType
|
||||
}
|
||||
|
||||
// Sign signs a license with a private key, setting the license's signature
|
||||
// value
|
||||
func (l *License) Sign(privKey *rsa.PrivateKey) error {
|
||||
l.Signature = ""
|
||||
buf := bytes.Buffer{}
|
||||
enc := json.NewEncoder(&buf)
|
||||
if err := enc.Encode(l); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
hashed := sha256.Sum256(buf.Bytes())
|
||||
signature, err := rsa.SignPKCS1v15(rand.Reader, privKey, crypto.SHA256, hashed[:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
l.Signature = hex.EncodeToString(signature)
|
||||
return nil
|
||||
}
|
||||
|
||||
// Verify verifies a license by checking the license content and signature
|
||||
// against a public key.
|
||||
func (l License) Verify(pubKey *rsa.PublicKey) error {
|
||||
cp := l
|
||||
cp.Signature = ""
|
||||
buf := bytes.Buffer{}
|
||||
enc := json.NewEncoder(&buf)
|
||||
if err := enc.Encode(cp); err != nil {
|
||||
return err
|
||||
}
|
||||
sig, err := hex.DecodeString(l.Signature)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
hashed := sha256.Sum256(buf.Bytes())
|
||||
err = rsa.VerifyPKCS1v15(pubKey, crypto.SHA256, hashed[:], sig)
|
||||
return err
|
||||
}
|
||||
|
||||
func (l License) String() string {
|
||||
buf := bytes.Buffer{}
|
||||
enc := json.NewEncoder(&buf)
|
||||
enc.Encode(l)
|
||||
return buf.String()
|
||||
}
|
||||
|
||||
// Encoded returns a base64 encoded version of the license for use with
|
||||
// InstallLicense.
|
||||
func (l License) Encoded() string {
|
||||
buf := bytes.Buffer{}
|
||||
w := base64.NewEncoder(base64.RawURLEncoding, &buf)
|
||||
gz, _ := gzip.NewWriterLevel(w, gzip.BestCompression)
|
||||
enc := json.NewEncoder(gz)
|
||||
enc.Encode(l)
|
||||
gz.Close()
|
||||
|
||||
rsp := bytes.Buffer{}
|
||||
const maxLen = 40
|
||||
raw := buf.Bytes()
|
||||
for i := 0; i < buf.Len(); i += maxLen {
|
||||
rsp.Write(raw[i : i+maxLen])
|
||||
rsp.WriteByte('\r')
|
||||
rsp.WriteByte('\n')
|
||||
}
|
||||
return rsp.String()
|
||||
}
|
||||
|
||||
// InstallLicense installs a license, returning an error if the license is
|
||||
// invalid or expired. Expiration checks the ReleaseDate variable in version.go.
|
||||
func InstallLicense(s string) error {
|
||||
re := regexp.MustCompile("\\s")
|
||||
s = re.ReplaceAllString(s, "")
|
||||
|
||||
var r io.Reader
|
||||
r = strings.NewReader(s)
|
||||
r = base64.NewDecoder(base64.RawURLEncoding, r)
|
||||
r, err := gzip.NewReader(r)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
dec := json.NewDecoder(r)
|
||||
l := &License{}
|
||||
if err := dec.Decode(l); err != nil {
|
||||
return err
|
||||
}
|
||||
// check signature
|
||||
if err := l.Verify(pubKey); err != nil {
|
||||
return errors.New("license validatin error")
|
||||
}
|
||||
|
||||
if l.Expiration.Before(ReleaseDate) {
|
||||
return errors.New("license expired")
|
||||
}
|
||||
license = l
|
||||
return nil
|
||||
}
|
||||
|
||||
// GetLicense returns the current license. This can be used by commercial
|
||||
// customers to assist in ensuring that their license hasn't expired.
|
||||
func GetLicense() License {
|
||||
if license == nil {
|
||||
if err := InstallLicense(OpenSourceLicense); err != nil {
|
||||
log.Printf("open source license error: %s", err)
|
||||
}
|
||||
}
|
||||
if license != nil {
|
||||
return *license
|
||||
}
|
||||
return License{}
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
// Copyright 2017 Baliance. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by the terms of the Affero GNU General
|
||||
// Public License version 3.0 as published by the Free Software Foundation and
|
||||
// appearing in the file LICENSE included in the packaging of this file. A
|
||||
// commercial license can be purchased by contacting sales@baliance.com.
|
||||
|
||||
package unioffice_test
|
||||
|
||||
import "testing"
|
||||
import "github.com/unidoc/unioffice"
|
||||
|
||||
func TestOpenSourceLicense(t *testing.T) {
|
||||
unioffice.GetLicense()
|
||||
}
|
@ -1,16 +0,0 @@
|
||||
// Code generated by "stringer -type=LicenseType"; DO NOT EDIT.
|
||||
|
||||
package unioffice
|
||||
|
||||
import "fmt"
|
||||
|
||||
const _LicenseType_name = "LicenseTypeInvalidLicenseTypeAGPLLicenseTypeCommercial"
|
||||
|
||||
var _LicenseType_index = [...]uint8{0, 18, 33, 54}
|
||||
|
||||
func (i LicenseType) String() string {
|
||||
if i >= LicenseType(len(_LicenseType_index)-1) {
|
||||
return fmt.Sprintf("LicenseType(%d)", i)
|
||||
}
|
||||
return _LicenseType_name[_LicenseType_index[i]:_LicenseType_index[i+1]]
|
||||
}
|
BIN
spreadsheet/testdata/simple-1.xlsx
vendored
BIN
spreadsheet/testdata/simple-1.xlsx
vendored
Binary file not shown.
BIN
spreadsheet/testdata/simple-2.xlsx
vendored
BIN
spreadsheet/testdata/simple-2.xlsx
vendored
Binary file not shown.
@ -24,6 +24,8 @@ import (
|
||||
func TestSimpleWorkbook(t *testing.T) {
|
||||
wb := spreadsheet.New()
|
||||
defer wb.Close()
|
||||
testVersion := "00.8000"
|
||||
wb.AppProperties.X().AppVersion = &testVersion
|
||||
sheet := wb.AddSheet()
|
||||
sheet.Cell("A1").SetString("Hello World!")
|
||||
|
||||
@ -83,6 +85,8 @@ func TestWorkbookUnmarshal(t *testing.T) {
|
||||
func TestSimpleSheet(t *testing.T) {
|
||||
wb := spreadsheet.New()
|
||||
defer wb.Close()
|
||||
testVersion := "00.8000"
|
||||
wb.AppProperties.X().AppVersion = &testVersion
|
||||
sheet := wb.AddSheet()
|
||||
row := sheet.AddRow()
|
||||
cell := row.AddCell()
|
||||
|
@ -1,23 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
|
||||
cat << __EOF > version.go
|
||||
// Copyright `date +%Y` Baliance. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by the terms of the Affero GNU General
|
||||
// Public License version 3.0 as published by the Free Software Foundation and
|
||||
// appearing in the file LICENSE included in the packaging of this file. A
|
||||
// commercial license can be purchased by contacting sales@baliance.com.
|
||||
|
||||
package unioffice
|
||||
|
||||
import "time"
|
||||
|
||||
// Release is the last release version of the software.
|
||||
var ReleaseVersion = "v0.8000"
|
||||
|
||||
// ReleaseDate is the release date of the source code for licensing purposes.
|
||||
var ReleaseDate = time.Date(`date +%Y`,`date +%_m`,`date +%_d`,0,0,0,0,time.UTC)
|
||||
|
||||
__EOF
|
||||
goimports -w version.go
|
16
version.go
16
version.go
@ -1,16 +0,0 @@
|
||||
// Copyright 2018 Baliance. All rights reserved.
|
||||
//
|
||||
// Use of this source code is governed by the terms of the Affero GNU General
|
||||
// Public License version 3.0 as published by the Free Software Foundation and
|
||||
// appearing in the file LICENSE included in the packaging of this file. A
|
||||
// commercial license can be purchased by contacting sales@baliance.com.
|
||||
|
||||
package unioffice
|
||||
|
||||
import "time"
|
||||
|
||||
// Release is the last release version of the software.
|
||||
var ReleaseVersion = "v0.8000"
|
||||
|
||||
// ReleaseDate is the release date of the source code for licensing purposes.
|
||||
var ReleaseDate = time.Date(2018, 9, 14, 0, 0, 0, 0, time.UTC)
|
Loading…
x
Reference in New Issue
Block a user