-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
634 additions
and
284 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -222,3 +222,9 @@ $RECYCLE.BIN/ | |
target/ | ||
nbactions*.xml | ||
src/core/iTextSharp.xml | ||
|
||
# JetBrains Rider | ||
.idea/ | ||
|
||
#Linux files | ||
.directory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
This file is part of the iText (R) project. | ||
Copyright (c) 1998-2018 iText Group NV | ||
Authors: iText Software. | ||
This program is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU Affero General Public License version 3 | ||
as published by the Free Software Foundation 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 | ||
ITEXT GROUP. ITEXT GROUP DISCLAIMS THE WARRANTY OF NON INFRINGEMENT | ||
OF THIRD PARTY RIGHTS | ||
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 or write to | ||
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
Boston, MA, 02110-1301 USA, or download the license from the following URL: | ||
http://itextpdf.com/terms-of-use/ | ||
The interactive user interfaces in modified source and object code versions | ||
of this program must display Appropriate Legal Notices, as required under | ||
Section 5 of the GNU Affero General Public License. | ||
In accordance with Section 7(b) of the GNU Affero General Public License, | ||
a covered work must retain the producer line in every PDF that is created | ||
or manipulated using iText. | ||
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 commercial activities involving the iText software without | ||
disclosing the source code of your own applications. | ||
These activities include: offering paid services to customers as an ASP, | ||
serving PDFs on the fly in a web application, shipping iText with a closed | ||
source product. | ||
For more information, please contact iText Software Corp. at this | ||
address: [email protected] | ||
*/ | ||
using System; | ||
|
||
namespace Versions.Attributes { | ||
[AttributeUsage(AttributeTargets.Assembly)] | ||
internal class KeyVersionAttribute : Attribute { | ||
private string keyVersion; | ||
|
||
internal string KeyVersion { | ||
get { return keyVersion; } | ||
private set { keyVersion = value; } | ||
} | ||
|
||
internal KeyVersionAttribute(string keyVersion) { | ||
this.KeyVersion = keyVersion; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,7 +41,10 @@ source product. | |
address: [email protected] | ||
*/ | ||
using System; | ||
using System.IO; | ||
using System.Reflection; | ||
using iTextSharp.text.log; | ||
using Versions.Attributes; | ||
|
||
namespace iTextSharp.text { | ||
|
||
|
@@ -72,22 +75,60 @@ public sealed class Version { | |
* This String contains the version number of this iText release. | ||
* For debugging purposes, we request you NOT to change this constant. | ||
*/ | ||
static private String release = "5.5.12"; | ||
static private String release = "5.5.13"; | ||
|
||
/** | ||
* This String contains the iText version as shown in the producer line. | ||
* iText is a product developed by iText Group NV. | ||
* iText Group requests that you retain the iText producer line | ||
* in every PDF that is created or manipulated using iText. | ||
*/ | ||
private String iTextVersion = iText + " " + release + " \u00a92000-2017 iText Group NV"; | ||
private String iTextVersion = iText + " " + release + " \u00a92000-2018 iText Group NV"; | ||
|
||
/** | ||
* The license key. | ||
*/ | ||
private String key = null; | ||
|
||
/** | ||
|
||
private static Type GetLicenseKeyClass() { | ||
String licenseKeyClassPartialName = "iText.License.LicenseKey, itext.licensekey"; | ||
String licenseKeyClassFullName = null; | ||
|
||
object[] keyVersionAttrs = typeof(Version).Assembly.GetCustomAttributes(typeof(KeyVersionAttribute), false); | ||
object keyVersionAttr = keyVersionAttrs.Length > 0 ? keyVersionAttrs[0] : null; | ||
if (keyVersionAttr is KeyVersionAttribute) { | ||
String keyVersion = ((KeyVersionAttribute) keyVersionAttr).KeyVersion; | ||
String format = "{0}, Version={1}, Culture=neutral, PublicKeyToken=8354ae6d2174ddca"; | ||
licenseKeyClassFullName = String.Format(format, licenseKeyClassPartialName, keyVersion); | ||
} | ||
|
||
Type type = null; | ||
if (licenseKeyClassFullName != null) { | ||
String fileLoadExceptionMessage = null; | ||
try { | ||
type = System.Type.GetType(licenseKeyClassFullName); | ||
} | ||
catch (FileLoadException fileLoadException) { | ||
fileLoadExceptionMessage = fileLoadException.Message; | ||
} | ||
|
||
if (fileLoadExceptionMessage != null) { | ||
ILogger logger = LoggerFactory.GetLogger(typeof(Version)); | ||
try { | ||
type = System.Type.GetType(licenseKeyClassPartialName); | ||
} | ||
catch { | ||
// ignore | ||
} | ||
if (type == null) { | ||
logger.Error(fileLoadExceptionMessage); | ||
} | ||
} | ||
} | ||
return type; | ||
} | ||
|
||
/** | ||
* Gets an instance of the iText version that is currently used. | ||
* Note that iText Group requests that you retain the iText producer line | ||
* in every PDF that is created or manipulated using iText. | ||
|
@@ -97,41 +138,44 @@ public static Version GetInstance() { | |
version = new Version(); | ||
lock (version) { | ||
try { | ||
Type type = Type.GetType("iTextSharp.license.LicenseKey, itextsharp.LicenseKey"); | ||
MethodInfo m = type.GetMethod("GetLicenseeInfo"); | ||
String[] info = (String[]) m.Invoke(Activator.CreateInstance(type), null); | ||
if (info[3] != null && info[3].Trim().Length > 0) { | ||
version.key = info[3]; | ||
} else { | ||
version.key = "Trial version "; | ||
if (info[5] == null) { | ||
version.key += "unauthorised"; | ||
} else { | ||
version.key += info[5]; | ||
} | ||
} | ||
if (info[4] != null && info[4].Trim().Length > 0) { | ||
version.iTextVersion = info[4]; | ||
} else if (info[2] != null && info[2].Trim().Length > 0) { | ||
version.iTextVersion += " (" + info[2]; | ||
if (!version.key.ToLower().StartsWith("trial")) { | ||
version.iTextVersion += "; licensed version)"; | ||
} else { | ||
version.iTextVersion += "; " + version.key + ")"; | ||
} | ||
} else if (info[0] != null && info[0].Trim().Length > 0) { | ||
// fall back to contact name, if company name is unavailable | ||
version.iTextVersion += " (" + info[0]; | ||
if (!version.key.ToLower().StartsWith("trial")) { | ||
// we shouldn't have a licensed version without company name, | ||
// but let's account for it anyway | ||
version.iTextVersion += "; licensed version)"; | ||
} else { | ||
version.iTextVersion += "; " + version.key + ")"; | ||
} | ||
} else { | ||
throw new Exception(); | ||
} | ||
Type type = GetLicenseKeyClass(); | ||
Type[] cArg = new Type[] {typeof(String)}; | ||
MethodInfo m = type.GetMethod("GetLicenseeInfoForVersion", cArg); | ||
String coreVersion = release; | ||
Object[] args = new Object[] {coreVersion}; | ||
String[] info = (String[]) m.Invoke(Activator.CreateInstance(type), args); | ||
if (info[3] != null && info[3].Trim().Length > 0) { | ||
version.key = info[3]; | ||
} else { | ||
version.key = "Trial version "; | ||
if (info[5] == null) { | ||
version.key += "unauthorised"; | ||
} else { | ||
version.key += info[5]; | ||
} | ||
} | ||
if (info[4] != null && info[4].Trim().Length > 0) { | ||
version.iTextVersion = info[4]; | ||
} else if (info[2] != null && info[2].Trim().Length > 0) { | ||
version.iTextVersion += " (" + info[2]; | ||
if (!version.key.ToLower().StartsWith("trial")) { | ||
version.iTextVersion += "; licensed version)"; | ||
} else { | ||
version.iTextVersion += "; " + version.key + ")"; | ||
} | ||
} else if (info[0] != null && info[0].Trim().Length > 0) { | ||
// fall back to contact name, if company name is unavailable | ||
version.iTextVersion += " (" + info[0]; | ||
if (!version.key.ToLower().StartsWith("trial")) { | ||
// we shouldn't have a licensed version without company name, | ||
// but let's account for it anyway | ||
version.iTextVersion += "; licensed version)"; | ||
} else { | ||
version.iTextVersion += "; " + version.key + ")"; | ||
} | ||
} else { | ||
throw new Exception(); | ||
} | ||
} catch (Exception) { | ||
version.iTextVersion += AGPL; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.