Skip to content

Commit 7802f9a

Browse files
committed
Merge branch 'develop' into devsecops
2 parents e945eeb + 66efba4 commit 7802f9a

File tree

8 files changed

+236
-56
lines changed

8 files changed

+236
-56
lines changed

itext.tests/itext.sign.tests/itext/signatures/validation/CertificateChainValidatorTest.cs

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ public virtual void ChainWithAiaTest() {
137137
IX509Certificate[] certificateChain = PemFileHelper.ReadFirstChain(chainName);
138138
IX509Certificate signingCert = (IX509Certificate)certificateChain[0];
139139
IX509Certificate rootCert = (IX509Certificate)certificateChain[2];
140-
IssuingCertificateRetriever customRetriever = new _IssuingCertificateRetriever_190();
140+
IssuingCertificateRetriever customRetriever = new _IssuingCertificateRetriever_191();
141141
ValidatorChainBuilder validatorChainBuilder = SetUpValidatorChain(certificateRetriever, properties, mockRevocationDataValidator
142142
);
143143
validatorChainBuilder.WithIssuingCertificateRetrieverFactory(() => customRetriever);
@@ -150,8 +150,8 @@ public virtual void ChainWithAiaTest() {
150150
AssertValidationReport.AssertThat(report, (a) => a.HasStatus(ValidationReport.ValidationResult.VALID));
151151
}
152152

153-
private sealed class _IssuingCertificateRetriever_190 : IssuingCertificateRetriever {
154-
public _IssuingCertificateRetriever_190() {
153+
private sealed class _IssuingCertificateRetriever_191 : IssuingCertificateRetriever {
154+
public _IssuingCertificateRetriever_191() {
155155
}
156156

157157
protected internal override Stream GetIssuerCertByURI(String uri) {
@@ -170,7 +170,7 @@ public virtual void ChainWithAiaWhichPointsToRandomCertTest() {
170170
IX509Certificate signingCert = (IX509Certificate)certificateChain[0];
171171
IX509Certificate intermediateCert = (IX509Certificate)certificateChain[1];
172172
IX509Certificate rootCert = (IX509Certificate)certificateChain[2];
173-
IssuingCertificateRetriever customRetriever = new _IssuingCertificateRetriever_218();
173+
IssuingCertificateRetriever customRetriever = new _IssuingCertificateRetriever_219();
174174
ValidatorChainBuilder validatorChainBuilder = SetUpValidatorChain(certificateRetriever, properties, mockRevocationDataValidator
175175
);
176176
validatorChainBuilder.WithIssuingCertificateRetrieverFactory(() => customRetriever);
@@ -185,8 +185,8 @@ public virtual void ChainWithAiaWhichPointsToRandomCertTest() {
185185
AssertValidationReport.AssertThat(report, (a) => a.HasStatus(ValidationReport.ValidationResult.VALID));
186186
}
187187

188-
private sealed class _IssuingCertificateRetriever_218 : IssuingCertificateRetriever {
189-
public _IssuingCertificateRetriever_218() {
188+
private sealed class _IssuingCertificateRetriever_219 : IssuingCertificateRetriever {
189+
public _IssuingCertificateRetriever_219() {
190190
}
191191

192192
protected internal override Stream GetIssuerCertByURI(String uri) {
@@ -801,5 +801,25 @@ private String BuildKeyUsageWrongMessagePart(KeyUsage expectedKeyUsage, params K
801801
.EXPECTED_VALUE, expectedKeyUsage) + MessageFormatUtil.Format(KeyUsageExtension.ACTUAL_VALUE, stringBuilder
802802
.ToString()));
803803
}
804+
805+
[NUnit.Framework.Test]
806+
public virtual void ValidityPeriodCheckTrustedCertificateTest() {
807+
MockRevocationDataValidator mockRevocationDataValidator = new MockRevocationDataValidator();
808+
IssuingCertificateRetriever certificateRetriever = new IssuingCertificateRetriever();
809+
SignatureValidationProperties properties = new SignatureValidationProperties();
810+
String chainName = CERTS_SRC + "chain.pem";
811+
//certificate expiration date year 2400
812+
IX509Certificate rootCert = (IX509Certificate)PemFileHelper.ReadFirstChain(chainName)[0];
813+
ValidatorChainBuilder validatorChainBuilder = SetUpValidatorChain(certificateRetriever, properties, mockRevocationDataValidator
814+
);
815+
CertificateChainValidator validator = validatorChainBuilder.BuildCertificateChainValidator();
816+
certificateRetriever.SetTrustedCertificates(JavaCollectionsUtil.SingletonList<IX509Certificate>(rootCert));
817+
//validation year 2405
818+
DateTime validationDate = new DateTime(13750537642000L);
819+
ValidationReport report = validator.ValidateCertificate(baseContext, rootCert, validationDate);
820+
AssertValidationReport.AssertThat(report, (a) => a.HasStatus(ValidationReport.ValidationResult.VALID).HasNumberOfFailures
821+
(0).HasNumberOfLogs(1).HasLogItem((l) => l.WithCheckName("Certificate check.").WithMessage(CertificateChainValidator
822+
.CERTIFICATE_TRUSTED, (i) => rootCert.GetSubjectDN()).WithCertificate(rootCert)));
823+
}
804824
}
805825
}

itext/itext.kernel/itext/kernel/geom/AffineTransform.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,16 @@ namespace iText.Kernel.Geom {
3131
/// which is a combination of linear transformations such as translation,
3232
/// scaling, rotation, and shearing which allows preservation of the straightness of lines.
3333
/// </summary>
34+
/// <remarks>
35+
/// The
36+
/// <see cref="AffineTransform"/>
37+
/// class represents an affine transformation,
38+
/// which is a combination of linear transformations such as translation,
39+
/// scaling, rotation, and shearing which allows preservation of the straightness of lines.
40+
/// <para />
41+
/// Note: this class is a special case of a 3 by 3
42+
/// <see cref="Matrix"/>.
43+
/// </remarks>
3444
public class AffineTransform {
3545
/// <summary>The type of affine transformation.</summary>
3646
/// <remarks>
@@ -190,6 +200,9 @@ public AffineTransform(iText.Kernel.Geom.AffineTransform t) {
190200
/// instance with the values provided.
191201
/// The default type is for the transformation is
192202
/// <c>TYPE_UNKNOWN</c>
203+
/// Detailed explanation of parameters can be found in
204+
/// <see cref="Matrix"/>
205+
/// documentation.
193206
/// </remarks>
194207
/// <param name="m00">The value of the first row and first column of the matrix.</param>
195208
/// <param name="m10">The value of the second row and first column of the matrix.</param>
@@ -218,6 +231,9 @@ public AffineTransform(double m00, double m10, double m01, double m11, double m0
218231
/// instance with the values provided.
219232
/// The default type is for the transformation is
220233
/// <c>TYPE_UNKNOWN</c>
234+
/// Detailed explanation of parameters can be found in
235+
/// <see cref="Matrix"/>
236+
/// documentation.
221237
/// </remarks>
222238
/// <param name="matrix">The array of values to be used for the transformation matrix.</param>
223239
public AffineTransform(float[] matrix) {
@@ -243,6 +259,9 @@ public AffineTransform(float[] matrix) {
243259
/// instance with the values provided.
244260
/// The default type is for the transformation is
245261
/// <c>TYPE_UNKNOWN</c>
262+
/// Detailed explanation of parameters can be found in
263+
/// <see cref="Matrix"/>
264+
/// documentation.
246265
/// </remarks>
247266
/// <param name="matrix">The array of values to be used for the transformation matrix.</param>
248267
public AffineTransform(double[] matrix) {

itext/itext.kernel/itext/kernel/geom/Matrix.cs

Lines changed: 75 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -24,50 +24,109 @@ You should have received a copy of the GNU Affero General Public License
2424
using iText.Commons.Utils;
2525

2626
namespace iText.Kernel.Geom {
27-
/// <summary>
28-
/// Keeps all the values of a 3 by 3 matrix and allows you to
29-
/// do some math with matrices.
30-
/// </summary>
27+
/// <summary>Keeps all the values of a 3 by 3 matrix and allows you to do some math with matrices.</summary>
28+
/// <remarks>
29+
/// Keeps all the values of a 3 by 3 matrix and allows you to do some math with matrices.
30+
/// <para />
31+
/// Transformation matrix in PDF is a special case of a 3 by 3 matrix
32+
/// <br />
33+
/// <c>[a b 0]</c>
34+
/// <br />
35+
/// <c>[c d 0]</c>
36+
/// <br />
37+
/// <c>[e f 1]</c>
38+
/// <para />
39+
/// In its most general form, this matrix is specified by six numbers, usually in the form of an array containing six
40+
/// elements
41+
/// <c>[a b c d e f]</c>
42+
/// . It can represent any linear transformation from one coordinate system to
43+
/// another. Here the most common transformations:
44+
/// <list type="bullet">
45+
/// <item><description>Translations shall be specified as
46+
/// <c>[1 0 0 1 Tx Ty]</c>
47+
/// , where
48+
/// <c>Tx</c>
49+
/// and
50+
/// <c>Ty</c>
51+
/// shall be the
52+
/// distances to translate the origin of the coordinate system in the horizontal and vertical dimensions, respectively.
53+
/// </description></item>
54+
/// <item><description>Scaling shall be obtained by
55+
/// <c>[Sx 0 0 Sy 0 0]</c>
56+
/// . This scales the coordinates so that 1 unit in the
57+
/// horizontal and vertical dimensions of the new coordinate system is the same size as
58+
/// <c>Sx</c>
59+
/// and
60+
/// <c>Sy</c>
61+
/// units,
62+
/// respectively, in the previous coordinate system.
63+
/// </description></item>
64+
/// <item><description>Rotations shall be produced by
65+
/// <c>[Rc Rs -Rs Rc 0 0]</c>
66+
/// , where
67+
/// <c>Rc = cos(q)</c>
68+
/// and
69+
/// <c>Rs = sin(q)</c>
70+
/// which has the effect of rotating the coordinate system axes by an angle
71+
/// <c>q</c>
72+
/// counterclockwise.
73+
/// </description></item>
74+
/// <item><description>Skew shall be specified by
75+
/// <c>[1 Wx Wy 1 0 0]</c>
76+
/// , where
77+
/// <c>Wx = tan(a)</c>
78+
/// and
79+
/// <c>Wy = tan(b)</c>
80+
/// which
81+
/// skews the x-axis by an angle
82+
/// <c>a</c>
83+
/// and the y-axis by an angle
84+
/// <c>b</c>.
85+
/// </description></item>
86+
/// </list>
87+
/// <para />
88+
/// For more information see PDF Specification ISO 32000-1 section 8.3.
89+
/// </remarks>
3190
public class Matrix {
32-
/// <summary>the row=1, col=1 position ('a') in the matrix.</summary>
91+
/// <summary>The row=1, col=1 position ('a') in the matrix.</summary>
3392
public const int I11 = 0;
3493

35-
/// <summary>the row=1, col=2 position ('b') in the matrix.</summary>
94+
/// <summary>The row=1, col=2 position ('b') in the matrix.</summary>
3695
public const int I12 = 1;
3796

38-
/// <summary>the row=1, col=3 position (always 0 for 2-D) in the matrix.</summary>
97+
/// <summary>The row=1, col=3 position (always 0 for 2D) in the matrix.</summary>
3998
public const int I13 = 2;
4099

41-
/// <summary>the row=2, col=1 position ('c') in the matrix.</summary>
100+
/// <summary>The row=2, col=1 position ('c') in the matrix.</summary>
42101
public const int I21 = 3;
43102

44-
/// <summary>the row=2, col=2 position ('d') in the matrix.</summary>
103+
/// <summary>The row=2, col=2 position ('d') in the matrix.</summary>
45104
public const int I22 = 4;
46105

47-
/// <summary>the row=2, col=3 position (always 0 for 2-D) in the matrix.</summary>
106+
/// <summary>The row=2, col=3 position (always 0 for 2D) in the matrix.</summary>
48107
public const int I23 = 5;
49108

50-
/// <summary>the row=3, col=1 ('e', or X translation) position in the matrix.</summary>
109+
/// <summary>The row=3, col=1 ('e', or X translation) position in the matrix.</summary>
51110
public const int I31 = 6;
52111

53-
/// <summary>the row=3, col=2 ('f', or Y translation) position in the matrix.</summary>
112+
/// <summary>The row=3, col=2 ('f', or Y translation) position in the matrix.</summary>
54113
public const int I32 = 7;
55114

56-
/// <summary>the row=3, col=3 position (always 1 for 2-D) in the matrix.</summary>
115+
/// <summary>The row=3, col=3 position (always 1 for 2D) in the matrix.</summary>
57116
public const int I33 = 8;
58117

59118
/// <summary>The values inside the matrix (the identity matrix by default).</summary>
60119
/// <remarks>
61120
/// The values inside the matrix (the identity matrix by default).
62121
/// <para />
63-
/// For reference, the indeces are as follows:
122+
/// For reference, the indexes are as follows:
64123
/// <br />I11 I12 I13
65124
/// <br />I21 I22 I23
66125
/// <br />I31 I32 I33
67126
/// </remarks>
68127
private readonly float[] vals = new float[] { 1, 0, 0, 0, 1, 0, 0, 0, 1 };
69128

70-
/// <summary>constructs a new Matrix with identity.</summary>
129+
/// <summary>Constructs a new Matrix with identity.</summary>
71130
public Matrix() {
72131
}
73132

@@ -144,7 +203,7 @@ public virtual float Get(int index) {
144203
/// <summary>multiplies this matrix by 'b' and returns the result.</summary>
145204
/// <remarks>
146205
/// multiplies this matrix by 'b' and returns the result.
147-
/// See http://en.wikipedia.org/wiki/Matrix_multiplication
206+
/// See <a href="http://en.wikipedia.org/wiki/matrix_multiplication">Matrix_multiplication</a>
148207
/// </remarks>
149208
/// <param name="by">The matrix to multiply by</param>
150209
/// <returns>the resulting matrix</returns>

itext/itext.kernel/itext/kernel/pdf/canvas/CanvasGraphicsState.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,13 @@ public virtual Matrix GetCtm() {
157157
/// <summary>Updates current transformation matrix.</summary>
158158
/// <remarks>
159159
/// Updates current transformation matrix.
160-
/// The third column will always be [0 0 1]
160+
/// <para />
161+
/// Detailed explanation of
162+
/// <c>[a b c d e f]</c>
163+
/// parameters of transformation
164+
/// matrix can be found in
165+
/// <see cref="iText.Kernel.Geom.Matrix"/>
166+
/// documentation.
161167
/// </remarks>
162168
/// <param name="a">element at (1,1) of the transformation matrix</param>
163169
/// <param name="b">element at (1,2) of the transformation matrix</param>

0 commit comments

Comments
 (0)