diff --git a/src/main/java/com/itextpdf/rups/model/oid/builder/OidJointIsoItuTTreeBuilder.java b/src/main/java/com/itextpdf/rups/model/oid/builder/OidJointIsoItuTTreeBuilder.java index 5821d90f..d38f74f8 100644 --- a/src/main/java/com/itextpdf/rups/model/oid/builder/OidJointIsoItuTTreeBuilder.java +++ b/src/main/java/com/itextpdf/rups/model/oid/builder/OidJointIsoItuTTreeBuilder.java @@ -299,6 +299,7 @@ private static OidTreeNode createDsCertificateExtensionTree() { entry("22", "expirationDate"), entry("23", "instructionCode"), entry("24", "invalidityDate"), + entry("27", "deltaCRLIndicator"), entry("28", "issuingDistributionPoint"), entry("29", "certificateIssuer"), entry("30", "nameConstraints"), diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/OidCorrectorMapper.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/OidCorrectorMapper.java index 8f5a7589..e69db1b3 100644 --- a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/OidCorrectorMapper.java +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/OidCorrectorMapper.java @@ -70,9 +70,17 @@ This file is part of the iText (R) project. import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.AuthorityInfoAccessCorrector; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.AuthorityKeyIdentifierCorrector; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.BasicConstraintsCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.CertificateIssuerCorrector; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.CertificatePoliciesCorrector; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.CrlDistributionPointsCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.CrlNumberCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.CrlReasonCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.DeltaCrlIndicatorCorrector; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.ExtKeyUsageCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.FreshestCrlCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.InvalidityDateCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.IssuerAltNameCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.IssuingDistributionPointCorrector; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.KeyUsageCorrector; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.SubjectKeyIdentifierCorrector; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.TimeStampCorrector; @@ -221,6 +229,10 @@ public final class OidCorrectorMapper { BasicConstraintsCorrector.OID, BasicConstraintsCorrector.INSTANCE ), + Map.entry( + CertificateIssuerCorrector.OID, + CertificateIssuerCorrector.INSTANCE + ), Map.entry( CertificatePoliciesCorrector.OID, CertificatePoliciesCorrector.INSTANCE @@ -229,10 +241,38 @@ public final class OidCorrectorMapper { CrlDistributionPointsCorrector.OID, CrlDistributionPointsCorrector.INSTANCE ), + Map.entry( + CrlNumberCorrector.OID, + CrlNumberCorrector.INSTANCE + ), + Map.entry( + CrlReasonCorrector.OID, + CrlReasonCorrector.INSTANCE + ), + Map.entry( + DeltaCrlIndicatorCorrector.OID, + DeltaCrlIndicatorCorrector.INSTANCE + ), Map.entry( ExtKeyUsageCorrector.OID, ExtKeyUsageCorrector.INSTANCE ), + Map.entry( + FreshestCrlCorrector.OID, + FreshestCrlCorrector.INSTANCE + ), + Map.entry( + InvalidityDateCorrector.OID, + InvalidityDateCorrector.INSTANCE + ), + Map.entry( + IssuerAltNameCorrector.OID, + IssuerAltNameCorrector.INSTANCE + ), + Map.entry( + IssuingDistributionPointCorrector.OID, + IssuingDistributionPointCorrector.INSTANCE + ), Map.entry( KeyUsageCorrector.OID, KeyUsageCorrector.INSTANCE diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/BasicOcspResponseCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/BasicOcspResponseCorrector.java index f190a8c5..5ae899a4 100644 --- a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/BasicOcspResponseCorrector.java +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/BasicOcspResponseCorrector.java @@ -45,6 +45,7 @@ This file is part of the iText (R) project. import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TaggedObjectTreeNode; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.CrlReasonCorrector; import org.bouncycastle.asn1.ASN1BitString; import org.bouncycastle.asn1.ASN1GeneralizedTime; diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/NameCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/NameCorrector.java index e1c8b4ed..501ac680 100644 --- a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/NameCorrector.java +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/NameCorrector.java @@ -44,6 +44,7 @@ This file is part of the iText (R) project. import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.types.RelativeDistinguishedNameCorrector; import org.bouncycastle.asn1.ASN1Primitive; import org.bouncycastle.asn1.ASN1Sequence; diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CertificateIssuerCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CertificateIssuerCorrector.java new file mode 100644 index 00000000..861398eb --- /dev/null +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CertificateIssuerCorrector.java @@ -0,0 +1,88 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.GeneralNamesCorrector; + +import org.bouncycastle.asn1.ASN1Primitive; + +/** + * Corrector for the certificateIssuer extension, as it is defined in RFC 5280. + * + *
+ * CertificateIssuer ::= GeneralNames
+ * 
+ */ +public final class CertificateIssuerCorrector extends AbstractCorrector { + /** + * Singleton instance of the corrector. + */ + public static final CertificateIssuerCorrector INSTANCE = new CertificateIssuerCorrector(); + + private CertificateIssuerCorrector() { + // singleton class + } + + /** + * OBJECT IDENTIFIER for the type, which is handled by the corrector. + */ + public static final String OID = "2.5.29.29"; + + /** + * {@inheritDoc} + */ + @Override + public String getDefaultVariableName() { + return "certificateIssuer"; + } + + /** + * {@inheritDoc} + */ + @Override + public void correct(AbstractAsn1TreeNode node, ASN1Primitive obj, String variableName) { + GeneralNamesCorrector.INSTANCE.correct(node, obj, variableName); + } +} diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlDistributionPointsCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlDistributionPointsCorrector.java index 5d8c57f2..06eb4196 100644 --- a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlDistributionPointsCorrector.java +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlDistributionPointsCorrector.java @@ -43,16 +43,15 @@ This file is part of the iText (R) project. package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; -import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1BooleanTreeNode; import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TaggedObjectTreeNode; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.GeneralNamesCorrector; -import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.RelativeDistinguishedNameCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.types.DistributionPointNameCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.types.ReasonFlagsCorrector; import org.bouncycastle.asn1.ASN1BitString; import org.bouncycastle.asn1.ASN1Primitive; import org.bouncycastle.asn1.ASN1Sequence; -import org.bouncycastle.asn1.ASN1Set; import org.bouncycastle.asn1.ASN1TaggedObject; /** @@ -67,23 +66,6 @@ This file is part of the iText (R) project. * reasons [1] IMPLICIT ReasonFlags OPTIONAL, * cRLIssuer [2] IMPLICIT GeneralNames OPTIONAL * } - * - * DistributionPointName ::= CHOICE { - * fullName [0] IMPLICIT GeneralNames, - * nameRelativeToCRLIssuer [1] IMPLICIT RelativeDistinguishedName - * } - * - * ReasonFlags ::= BIT STRING { - * unused (0), - * keyCompromise (1), - * cACompromise (2), - * affiliationChanged (3), - * superseded (4), - * cessationOfOperation (5), - * certificateHold (6), - * privilegeWithdrawn (7), - * aACompromise (8) - * } * */ public final class CrlDistributionPointsCorrector extends AbstractCorrector { @@ -139,16 +121,24 @@ private static void correctDistributionPoint(AbstractAsn1TreeNode node) { node.setRfcFieldName("distributionPoint"); int i = 0; if (node.getChildCount() > i) { - final AbstractAsn1TreeNode distributionPoint = node.getChildAt(i); - if (isExplicitContextSpecificType(distributionPoint, 0)) { - correctDistributionPointName((Asn1TaggedObjectTreeNode) distributionPoint); + final AbstractAsn1TreeNode distributionPointName = node.getChildAt(i); + if (isExplicitContextSpecificType(distributionPointName, 0)) { + DistributionPointNameCorrector.INSTANCE.correct( + distributionPointName, + getBaseObjectUnchecked(distributionPointName), + "distributionPointName" + ); ++i; } } if (node.getChildCount() > i) { final AbstractAsn1TreeNode reasons = node.getChildAt(i); if (isImplicitContextSpecificType(reasons, 1)) { - correctReasonFlags((Asn1TaggedObjectTreeNode) reasons); + final ASN1TaggedObject reasonsObj = fixImplicitContextSpecificObject( + (Asn1TaggedObjectTreeNode) reasons, + ASN1BitString::getInstance + ); + ReasonFlagsCorrector.INSTANCE.correct(reasons, getBaseObject(reasonsObj), "reasons"); ++i; } } @@ -163,81 +153,4 @@ private static void correctDistributionPoint(AbstractAsn1TreeNode node) { } } } - - /** - *
-     * DistributionPointName ::= CHOICE {
-     *   fullName                   [0] IMPLICIT GeneralNames,
-     *   nameRelativeToCRLIssuer    [1] IMPLICIT RelativeDistinguishedName
-     * }
-     * 
- */ - private static void correctDistributionPointName(Asn1TaggedObjectTreeNode node) { - final ASN1Primitive obj = getBaseObject(node); - if (isImplicitContextSpecificType(obj, 0)) { - final ASN1TaggedObject newObj = fixImplicitContextSpecificObject( - node, - (ASN1TaggedObject) obj, - ASN1Sequence::getInstance - ); - GeneralNamesCorrector.INSTANCE.correct( - node, - getBaseObject(newObj), - "distributionPointName" - ); - } else if (isImplicitContextSpecificType(obj, 1)) { - final ASN1TaggedObject newObj = fixImplicitContextSpecificObject( - node, - (ASN1TaggedObject) obj, - ASN1Set::getInstance - ); - RelativeDistinguishedNameCorrector.INSTANCE.correct( - node, - getBaseObject(newObj), - "distributionPointName" - ); - } - } - - private static final String[] FLAG_NAMES = { - "unused", - "keyCompromise", - "caCompromise", - "affiliationChanged", - "superseded", - "cessationOfOperation", - "certificateHold", - "privilegeWithdrawn", - "aaCompromise", - }; - - /** - *
-     * ReasonFlags ::= BIT STRING {
-     *   unused                 (0),
-     *   keyCompromise          (1),
-     *   cACompromise           (2),
-     *   affiliationChanged     (3),
-     *   superseded             (4),
-     *   cessationOfOperation   (5),
-     *   certificateHold        (6),
-     *   privilegeWithdrawn     (7),
-     *   aACompromise           (8)
-     * }
-     * 
- */ - private static void correctReasonFlags(Asn1TaggedObjectTreeNode node) { - final ASN1TaggedObject obj = - fixImplicitContextSpecificObject(node, ASN1BitString::getInstance); - final ASN1Primitive baseObj = getBaseObject(obj); - if (!isUniversalType(baseObj, ASN1BitString.class)) { - return; - } - node.setRfcFieldName("reasons"); - // Will add nodes to "decipher" the bit string - final byte[] flags = ((ASN1BitString) baseObj).getBytes(); - for (int i = 0; i < FLAG_NAMES.length; ++i) { - node.add(new Asn1BooleanTreeNode(FLAG_NAMES[i], hasFlag(flags, i))); - } - } } diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlNumberCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlNumberCorrector.java new file mode 100644 index 00000000..d7a19114 --- /dev/null +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlNumberCorrector.java @@ -0,0 +1,88 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; + +import org.bouncycastle.asn1.ASN1Integer; +import org.bouncycastle.asn1.ASN1Primitive; + +/** + * Corrector for the crlNumber extension, as it is defined in RFC 5280. + * + *
+ * CRLNumber ::= INTEGER (0..MAX)
+ * 
+ */ +public final class CrlNumberCorrector extends AbstractCorrector { + /** + * Singleton instance of the corrector. + */ + public static final CrlNumberCorrector INSTANCE = new CrlNumberCorrector(); + + private CrlNumberCorrector() { + // singleton class + } + + /** + * OBJECT IDENTIFIER for the type, which is handled by the corrector. + */ + public static final String OID = "2.5.29.20"; + + /** + * {@inheritDoc} + */ + @Override + public String getDefaultVariableName() { + return "crlNumber"; + } + + /** + * {@inheritDoc} + */ + @Override + public void correct(AbstractAsn1TreeNode node, ASN1Primitive obj, String variableName) { + correctPrimitiveUniversalType(node, obj, ASN1Integer.class, variableName); + } +} diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CrlReasonCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlReasonCorrector.java similarity index 96% rename from src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CrlReasonCorrector.java rename to src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlReasonCorrector.java index 4ec7fdbb..3626637a 100644 --- a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CrlReasonCorrector.java +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlReasonCorrector.java @@ -40,7 +40,7 @@ This file is part of the iText (R) project. For more information, please contact iText Software Corp. at this address: sales@itextpdf.com */ -package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509; +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; @@ -78,6 +78,11 @@ private CrlReasonCorrector() { // singleton class } + /** + * OBJECT IDENTIFIER for the type, which is handled by the corrector. + */ + public static final String OID = "2.5.29.21"; + /** * {@inheritDoc} */ diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/DeltaCrlIndicatorCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/DeltaCrlIndicatorCorrector.java new file mode 100644 index 00000000..a80bb2db --- /dev/null +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/DeltaCrlIndicatorCorrector.java @@ -0,0 +1,87 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; + +import org.bouncycastle.asn1.ASN1Primitive; + +/** + * Corrector for the deltaCRLIndicator extension, as it is defined in RFC 5280. + * + *
+ * BaseCRLNumber ::= CRLNumber
+ * 
+ */ +public final class DeltaCrlIndicatorCorrector extends AbstractCorrector { + /** + * Singleton instance of the corrector. + */ + public static final DeltaCrlIndicatorCorrector INSTANCE = new DeltaCrlIndicatorCorrector(); + + private DeltaCrlIndicatorCorrector() { + // singleton class + } + + /** + * OBJECT IDENTIFIER for the type, which is handled by the corrector. + */ + public static final String OID = "2.5.29.27"; + + /** + * {@inheritDoc} + */ + @Override + public String getDefaultVariableName() { + return "baseCRLNumber"; + } + + /** + * {@inheritDoc} + */ + @Override + public void correct(AbstractAsn1TreeNode node, ASN1Primitive obj, String variableName) { + CrlNumberCorrector.INSTANCE.correct(node, obj, variableName); + } +} diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/FreshestCrlCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/FreshestCrlCorrector.java new file mode 100644 index 00000000..777318e0 --- /dev/null +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/FreshestCrlCorrector.java @@ -0,0 +1,87 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; + +import org.bouncycastle.asn1.ASN1Primitive; + +/** + * Corrector for the freshestCRL extension, as it is defined in RFC 5280. + * + *
+ * FreshestCRL ::= CRLDistributionPoints
+ * 
+ */ +public final class FreshestCrlCorrector extends AbstractCorrector { + /** + * Singleton instance of the corrector. + */ + public static final FreshestCrlCorrector INSTANCE = new FreshestCrlCorrector(); + + private FreshestCrlCorrector() { + // singleton class + } + + /** + * OBJECT IDENTIFIER for the type, which is handled by the corrector. + */ + public static final String OID = "2.5.29.46"; + + /** + * {@inheritDoc} + */ + @Override + public String getDefaultVariableName() { + return "freshestCRL"; + } + + /** + * {@inheritDoc} + */ + @Override + public void correct(AbstractAsn1TreeNode node, ASN1Primitive obj, String variableName) { + CrlDistributionPointsCorrector.INSTANCE.correct(node, obj, variableName); + } +} diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/InvalidityDateCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/InvalidityDateCorrector.java new file mode 100644 index 00000000..2848e6bf --- /dev/null +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/InvalidityDateCorrector.java @@ -0,0 +1,88 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; + +import org.bouncycastle.asn1.ASN1GeneralizedTime; +import org.bouncycastle.asn1.ASN1Primitive; + +/** + * Corrector for the invalidityDate extension, as it is defined in RFC 5280. + * + *
+ * InvalidityDate ::= GeneralizedTime
+ * 
+ */ +public final class InvalidityDateCorrector extends AbstractCorrector { + /** + * Singleton instance of the corrector. + */ + public static final InvalidityDateCorrector INSTANCE = new InvalidityDateCorrector(); + + private InvalidityDateCorrector() { + // singleton class + } + + /** + * OBJECT IDENTIFIER for the type, which is handled by the corrector. + */ + public static final String OID = "2.5.29.24"; + + /** + * {@inheritDoc} + */ + @Override + public String getDefaultVariableName() { + return "invalidityDate"; + } + + /** + * {@inheritDoc} + */ + @Override + public void correct(AbstractAsn1TreeNode node, ASN1Primitive obj, String variableName) { + correctPrimitiveUniversalType(node, obj, ASN1GeneralizedTime.class, variableName); + } +} diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuerAltNameCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuerAltNameCorrector.java new file mode 100644 index 00000000..cc25e572 --- /dev/null +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuerAltNameCorrector.java @@ -0,0 +1,88 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.GeneralNamesCorrector; + +import org.bouncycastle.asn1.ASN1Primitive; + +/** + * Corrector for the issuerAltName extension, as it is defined in RFC 5280. + * + *
+ * IssuerAltName ::= GeneralNames
+ * 
+ */ +public final class IssuerAltNameCorrector extends AbstractCorrector { + /** + * Singleton instance of the corrector. + */ + public static final IssuerAltNameCorrector INSTANCE = new IssuerAltNameCorrector(); + + private IssuerAltNameCorrector() { + // singleton class + } + + /** + * OBJECT IDENTIFIER for the type, which is handled by the corrector. + */ + public static final String OID = "2.5.29.18"; + + /** + * {@inheritDoc} + */ + @Override + public String getDefaultVariableName() { + return "issuerAltName"; + } + + /** + * {@inheritDoc} + */ + @Override + public void correct(AbstractAsn1TreeNode node, ASN1Primitive obj, String variableName) { + GeneralNamesCorrector.INSTANCE.correct(node, obj, variableName); + } +} diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuingDistributionPointCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuingDistributionPointCorrector.java new file mode 100644 index 00000000..06c0970d --- /dev/null +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuingDistributionPointCorrector.java @@ -0,0 +1,185 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TaggedObjectTreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractSequenceCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.SequenceFieldCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.types.DistributionPointNameCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.types.ReasonFlagsCorrector; + +import org.bouncycastle.asn1.ASN1BitString; +import org.bouncycastle.asn1.ASN1Boolean; +import org.bouncycastle.asn1.ASN1TaggedObject; + +/** + * Corrector for the issuingDistributionPoint extension, as it is defined in RFC 5280. + * + *
+ * IssuingDistributionPoint ::= SEQUENCE {
+ *   distributionPoint          [0] EXPLICIT DistributionPointName OPTIONAL,
+ *   onlyContainsUserCerts      [1] IMPLICIT BOOLEAN DEFAULT FALSE,
+ *   onlyContainsCACerts        [2] IMPLICIT BOOLEAN DEFAULT FALSE,
+ *   onlySomeReasons            [3] IMPLICIT ReasonFlags OPTIONAL,
+ *   indirectCRL                [4] IMPLICIT BOOLEAN DEFAULT FALSE,
+ *   onlyContainsAttributeCerts [5] IMPLICIT BOOLEAN DEFAULT FALSE
+ * }
+ * 
+ */ +public final class IssuingDistributionPointCorrector extends AbstractSequenceCorrector { + /** + * Singleton instance of the corrector. + */ + public static final IssuingDistributionPointCorrector INSTANCE = new IssuingDistributionPointCorrector(); + + private IssuingDistributionPointCorrector() { + // singleton class + } + + /** + * OBJECT IDENTIFIER for the type, which is handled by the corrector. + */ + public static final String OID = "2.5.29.28"; + + /** + * Static array of field correctors for the root sequence. + */ + private static final SequenceFieldCorrector[] FIELD_CORRECTORS = { + IssuingDistributionPointCorrector::correctDistributionPoint, + IssuingDistributionPointCorrector::correctOnlyContainsUserCerts, + IssuingDistributionPointCorrector::correctOnlyContainsCaCerts, + IssuingDistributionPointCorrector::correctOnlySomeReasons, + IssuingDistributionPointCorrector::correctIndirectCrl, + IssuingDistributionPointCorrector::correctOnlyContainsAttributeCerts, + }; + + /** + * {@inheritDoc} + */ + @Override + public String getDefaultVariableName() { + return "issuingDistributionPoint"; + } + + /** + * {@inheritDoc} + */ + @Override + protected SequenceFieldCorrector[] getFieldCorrectors() { + return FIELD_CORRECTORS; + } + + private static boolean correctDistributionPoint(AbstractAsn1TreeNode node) { + if (!isExplicitContextSpecificType(node, 0)) { + return false; + } + DistributionPointNameCorrector.INSTANCE.correct( + node, getBaseObjectUnchecked(node), "distributionPoint" + ); + return true; + } + + private static boolean correctOnlyContainsUserCerts(AbstractAsn1TreeNode node) { + if (!isImplicitContextSpecificType(node, 1)) { + return false; + } + final ASN1TaggedObject obj = fixImplicitContextSpecificObject( + (Asn1TaggedObjectTreeNode) node, ASN1Boolean::getInstance + ); + correctPrimitiveUniversalType( + node, getBaseObject(obj), ASN1Boolean.class, "onlyContainsUserCerts" + ); + return true; + } + + private static boolean correctOnlyContainsCaCerts(AbstractAsn1TreeNode node) { + if (!isImplicitContextSpecificType(node, 2)) { + return false; + } + final ASN1TaggedObject obj = fixImplicitContextSpecificObject( + (Asn1TaggedObjectTreeNode) node, ASN1Boolean::getInstance + ); + correctPrimitiveUniversalType( + node, getBaseObject(obj), ASN1Boolean.class, "onlyContainsCACerts" + ); + return true; + } + + private static boolean correctOnlySomeReasons(AbstractAsn1TreeNode node) { + if (!isImplicitContextSpecificType(node, 3)) { + return false; + } + final ASN1TaggedObject obj = fixImplicitContextSpecificObject( + (Asn1TaggedObjectTreeNode) node, ASN1BitString::getInstance + ); + ReasonFlagsCorrector.INSTANCE.correct(node, getBaseObject(obj), "onlySomeReasons"); + return true; + } + + private static boolean correctIndirectCrl(AbstractAsn1TreeNode node) { + if (!isImplicitContextSpecificType(node, 4)) { + return false; + } + final ASN1TaggedObject obj = fixImplicitContextSpecificObject( + (Asn1TaggedObjectTreeNode) node, ASN1Boolean::getInstance + ); + correctPrimitiveUniversalType( + node, getBaseObject(obj), ASN1Boolean.class, "indirectCRL" + ); + return true; + } + + private static boolean correctOnlyContainsAttributeCerts(AbstractAsn1TreeNode node) { + if (!isImplicitContextSpecificType(node, 5)) { + return false; + } + final ASN1TaggedObject obj = fixImplicitContextSpecificObject( + (Asn1TaggedObjectTreeNode) node, ASN1Boolean::getInstance + ); + correctPrimitiveUniversalType( + node, getBaseObject(obj), ASN1Boolean.class, "onlyContainsAttributeCerts" + ); + return true; + } +} diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/DistributionPointNameCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/DistributionPointNameCorrector.java new file mode 100644 index 00000000..6c1b370a --- /dev/null +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/DistributionPointNameCorrector.java @@ -0,0 +1,144 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.types; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TaggedObjectTreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.GeneralNamesCorrector; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.types.RelativeDistinguishedNameCorrector; + +import org.bouncycastle.asn1.ASN1Primitive; +import org.bouncycastle.asn1.ASN1Sequence; +import org.bouncycastle.asn1.ASN1Set; +import org.bouncycastle.asn1.ASN1TaggedObject; + +/** + * Corrector for the DistributionPointName type, as it is defined in RFC 5280. + * + *
+ * DistributionPointName ::= CHOICE {
+ *   fullName                   [0] IMPLICIT GeneralNames,
+ *   nameRelativeToCRLIssuer    [1] IMPLICIT RelativeDistinguishedName
+ * }
+ * 
+ */ +public final class DistributionPointNameCorrector extends AbstractCorrector { + /** + * Singleton instance of the corrector. + */ + public static final DistributionPointNameCorrector INSTANCE = new DistributionPointNameCorrector(); + + private DistributionPointNameCorrector() { + // singleton class + } + + /** + * {@inheritDoc} + */ + @Override + public String getDefaultVariableName() { + return "distributionPointName"; + } + + /** + * {@inheritDoc} + */ + @Override + public void correct(AbstractAsn1TreeNode node) { + // Because this is a CHOICE, we have special handling for default name + correct(node, (String) null); + } + + /** + * {@inheritDoc} + */ + @Override + public void correct(AbstractAsn1TreeNode node, ASN1Primitive obj) { + // Because this is a CHOICE, we have special handling for default name + correct(node, obj, null); + } + + /** + * {@inheritDoc} + */ + @Override + public void correct(AbstractAsn1TreeNode node, ASN1Primitive obj, String variableName) { + if (isImplicitContextSpecificType(obj, 0)) { + final ASN1TaggedObject newObj = fixImplicitContextSpecificObject( + (Asn1TaggedObjectTreeNode) node, + (ASN1TaggedObject) obj, + ASN1Sequence::getInstance + ); + GeneralNamesCorrector.INSTANCE.correct( + node, + getBaseObject(newObj), + getName(0, variableName) + ); + } else if (isImplicitContextSpecificType(obj, 1)) { + final ASN1TaggedObject newObj = fixImplicitContextSpecificObject( + (Asn1TaggedObjectTreeNode) node, + (ASN1TaggedObject) obj, + ASN1Set::getInstance + ); + RelativeDistinguishedNameCorrector.INSTANCE.correct( + node, + getBaseObject(newObj), + getName(1, variableName) + ); + } + } + + private static final String[] DEFAULT_VARIABLE_NAMES = { + "fullName", + "nameRelativeToCRLIssuer", + }; + + private static String getName(int tagNo, String variableName) { + assert (0 <= tagNo) && (tagNo < DEFAULT_VARIABLE_NAMES.length); + if (variableName != null) { + return variableName; + } + return DEFAULT_VARIABLE_NAMES[tagNo]; + } +} diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/ReasonFlagsCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/ReasonFlagsCorrector.java new file mode 100644 index 00000000..50d322b8 --- /dev/null +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/ReasonFlagsCorrector.java @@ -0,0 +1,114 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.types; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1BooleanTreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; + +import org.bouncycastle.asn1.ASN1BitString; +import org.bouncycastle.asn1.ASN1Primitive; + +/** + * Corrector for the ReasonFlags type, as it is defined in RFC 5280. + * + *
+ * ReasonFlags ::= BIT STRING {
+ *   unused                 (0),
+ *   keyCompromise          (1),
+ *   cACompromise           (2),
+ *   affiliationChanged     (3),
+ *   superseded             (4),
+ *   cessationOfOperation   (5),
+ *   certificateHold        (6),
+ *   privilegeWithdrawn     (7),
+ *   aACompromise           (8)
+ * }
+ * 
+ */ +public final class ReasonFlagsCorrector extends AbstractCorrector { + /** + * Singleton instance of the corrector. + */ + public static final ReasonFlagsCorrector INSTANCE = new ReasonFlagsCorrector(); + + private ReasonFlagsCorrector() { + // singleton class + } + + /** + * {@inheritDoc} + */ + @Override + public String getDefaultVariableName() { + return "reasons"; + } + + private static final String[] FLAG_NAMES = { + "unused", + "keyCompromise", + "caCompromise", + "affiliationChanged", + "superseded", + "cessationOfOperation", + "certificateHold", + "privilegeWithdrawn", + "aaCompromise", + }; + + /** + * {@inheritDoc} + */ + @Override + public void correct(AbstractAsn1TreeNode node, ASN1Primitive obj, String variableName) { + if (!isUniversalType(obj, ASN1BitString.class)) { + return; + } + node.setRfcFieldName(variableName); + // Will add nodes to "decipher" the bit string + final byte[] flags = ((ASN1BitString) obj).getBytes(); + for (int i = 0; i < FLAG_NAMES.length; ++i) { + node.add(new Asn1BooleanTreeNode(FLAG_NAMES[i], hasFlag(flags, i))); + } + } +} diff --git a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/RelativeDistinguishedNameCorrector.java b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/types/RelativeDistinguishedNameCorrector.java similarity index 99% rename from src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/RelativeDistinguishedNameCorrector.java rename to src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/types/RelativeDistinguishedNameCorrector.java index 431a7a8a..40a9cdc2 100644 --- a/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/RelativeDistinguishedNameCorrector.java +++ b/src/main/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/types/RelativeDistinguishedNameCorrector.java @@ -40,7 +40,7 @@ This file is part of the iText (R) project. For more information, please contact iText Software Corp. at this address: sales@itextpdf.com */ -package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509; +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.types; import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; import com.itextpdf.rups.view.itext.treenodes.asn1.correctors.AbstractCorrector; diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/ContentInfoCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/ContentInfoCorrectorTest.java index 5af7f2df..4d9f32b4 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/ContentInfoCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/ContentInfoCorrectorTest.java @@ -131,7 +131,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { /* * No need to fill the whole signedData here, as it is massive... * It will be tested separately anyway. diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/algorithms/Mgf1CorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/algorithms/Mgf1CorrectorTest.java index 43657754..113e120a 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/algorithms/Mgf1CorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/algorithms/Mgf1CorrectorTest.java @@ -131,7 +131,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "parameters: NULL", node.getChildAt(1)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new ASN1ObjectIdentifier("2.16.840.1.101.3.4.2.3"), // id-sha512 diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/algorithms/RsassaPssCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/algorithms/RsassaPssCorrectorTest.java index ef2a70bb..66af1702 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/algorithms/RsassaPssCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/algorithms/RsassaPssCorrectorTest.java @@ -177,7 +177,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "trailerField: 1 (trailerFieldBC)", node.getChildAt(3)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERTaggedObject(true, 0, new DERSequence(new ASN1Encodable[] { diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/pdf/PdfMacIntegrityInfoCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/pdf/PdfMacIntegrityInfoCorrectorTest.java index 5bca1b07..8031779d 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/pdf/PdfMacIntegrityInfoCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/pdf/PdfMacIntegrityInfoCorrectorTest.java @@ -107,7 +107,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "signatureDigest: 0x10203040", node.getChildAt(2)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new ASN1Integer(0), diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/pdf/RevocationInfoArchivalCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/pdf/RevocationInfoArchivalCorrectorTest.java index 5f53a77f..4ba8f5a8 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/pdf/RevocationInfoArchivalCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/pdf/RevocationInfoArchivalCorrectorTest.java @@ -228,7 +228,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { /* * No need to fill the whole crls/ocsps here, as they are massive... * They will be tested separately anyway. diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/AlgorithmIdentifierCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/AlgorithmIdentifierCorrectorTest.java index de36cc8c..d28daa8e 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/AlgorithmIdentifierCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/AlgorithmIdentifierCorrectorTest.java @@ -112,7 +112,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new ASN1ObjectIdentifier("1.2.840.113549.1.1.8"), // mgf1 diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/BasicOcspResponseCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/BasicOcspResponseCorrectorTest.java index 075c0189..7bc12142 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/BasicOcspResponseCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/BasicOcspResponseCorrectorTest.java @@ -937,7 +937,7 @@ private static void validateDefaultSingleResponseNode(AbstractAsn1TreeNode node) } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { /* * No need to fill extensions/certificates here, as they can be massive... * It will be tested separately anyway. diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CertificateCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CertificateCorrectorTest.java index fb63f9fb..a3e2444e 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CertificateCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CertificateCorrectorTest.java @@ -384,7 +384,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "signatureValue: 0x1122334455", node.getChildAt(2)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { /* * No need to fill everything here, as it will be massive... * It is tested individually anyway. diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CertificateSerialNumberCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CertificateSerialNumberCorrectorTest.java index a994eaa0..b4c4e12c 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CertificateSerialNumberCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CertificateSerialNumberCorrectorTest.java @@ -80,7 +80,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 1337", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new ASN1Integer(1337) ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CrlCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CrlCorrectorTest.java index d5bb5e83..889fe10b 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CrlCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CrlCorrectorTest.java @@ -324,7 +324,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "signatureValue: 0x1122334455", node.getChildAt(2)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { /* * No need to fill everything here, as it will be massive... * It is tested individually anyway. diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/ExtensionsCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/ExtensionsCorrectorTest.java index e7f66836..6bd71730 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/ExtensionsCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/ExtensionsCorrectorTest.java @@ -187,7 +187,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERSequence(new ASN1Encodable[] { diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/GeneralNamesCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/GeneralNamesCorrectorTest.java index b9e3007f..546a992a 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/GeneralNamesCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/GeneralNamesCorrectorTest.java @@ -107,7 +107,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "ipAddress: 0x7F000001", node.getChildAt(1)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERTaggedObject(false, 2, new DERIA5String("example.com")), diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/NameCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/NameCorrectorTest.java index b72dc6b7..46ef7756 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/NameCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/NameCorrectorTest.java @@ -145,7 +145,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERSet( diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/OcspResponseCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/OcspResponseCorrectorTest.java index 983909bf..07e95032 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/OcspResponseCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/OcspResponseCorrectorTest.java @@ -204,7 +204,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { /* * No need to fill the whole response bytes here, as it can massive... * It will be tested separately anyway. diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/PolicyInformationCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/PolicyInformationCorrectorTest.java index 8117f2b2..938ed9cc 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/PolicyInformationCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/PolicyInformationCorrectorTest.java @@ -223,7 +223,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new ASN1ObjectIdentifier("2.23.140.1.1"), // extended-validation diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/TimeCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/TimeCorrectorTest.java index eb8866b6..6d4866b8 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/TimeCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/TimeCorrectorTest.java @@ -94,7 +94,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect ); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERGeneralizedTime("202405011337") ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/TimeStampTokenInfoCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/TimeStampTokenInfoCorrectorTest.java index 8144c921..88928ea8 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/TimeStampTokenInfoCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/TimeStampTokenInfoCorrectorTest.java @@ -444,7 +444,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { /* * No need to fill extensions here, as they can be massive... * It will be tested separately anyway. diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/VersionCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/VersionCorrectorTest.java index b186a0ed..2425b3de 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/VersionCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/VersionCorrectorTest.java @@ -89,7 +89,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 0 (v1)", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new ASN1Integer(0) ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/CmsAlgorithmProtectionCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/CmsAlgorithmProtectionCorrectorTest.java index bea7fb32..68edaf9e 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/CmsAlgorithmProtectionCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/CmsAlgorithmProtectionCorrectorTest.java @@ -174,7 +174,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERSequence( diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ContentTypeCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ContentTypeCorrectorTest.java index e578998f..1f81ce6a 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ContentTypeCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ContentTypeCorrectorTest.java @@ -86,7 +86,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect ); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new ASN1ObjectIdentifier("1.2.840.113549.1.7.2") // signedData ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/MessageDigestCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/MessageDigestCorrectorTest.java index 1b34a515..6a218a9f 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/MessageDigestCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/MessageDigestCorrectorTest.java @@ -81,7 +81,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 0x0102FF", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DEROctetString(new byte[] {0x01, 0x02, (byte) 0xFF}) ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/RandomNonceCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/RandomNonceCorrectorTest.java index 88454aba..eaab7218 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/RandomNonceCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/RandomNonceCorrectorTest.java @@ -81,7 +81,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 0x0102FF0304", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DEROctetString(new byte[] {0x01, 0x02, (byte) 0xFF, 0x03, 0x04}) ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SequenceNumberCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SequenceNumberCorrectorTest.java index 98c96d70..2f36bf65 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SequenceNumberCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SequenceNumberCorrectorTest.java @@ -81,7 +81,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 777", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new ASN1Integer(777) ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningCertificateCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningCertificateCorrectorTest.java index 1bc784de..0b6ede12 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningCertificateCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningCertificateCorrectorTest.java @@ -273,7 +273,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERSequence( diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningCertificateV2CorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningCertificateV2CorrectorTest.java index 66998f41..fda9fcf9 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningCertificateV2CorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningCertificateV2CorrectorTest.java @@ -222,7 +222,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERSequence( diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningTimeCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningTimeCorrectorTest.java index ece7c2d4..b8d12351 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningTimeCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/SigningTimeCorrectorTest.java @@ -91,7 +91,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 202405011337 (2024-05-01T13:37:00Z)", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERGeneralizedTime("202405011337") ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/TimeStampTokenCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/TimeStampTokenCorrectorTest.java index 657ffa21..852999f0 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/TimeStampTokenCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/TimeStampTokenCorrectorTest.java @@ -113,7 +113,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { /* * No need to fill the whole signedData here, as it is massive... * It will be tested separately anyway. diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspAcceptableResponsesCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspAcceptableResponsesCorrectorTest.java index da68561c..67425dc1 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspAcceptableResponsesCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspAcceptableResponsesCorrectorTest.java @@ -101,7 +101,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect ); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new ASN1ObjectIdentifier("1.3.6.1.5.5.7.48.1.1") // id-pkix-ocsp-basic diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspArchiveCutoffCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspArchiveCutoffCorrectorTest.java index 6afed42e..ec13736c 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspArchiveCutoffCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspArchiveCutoffCorrectorTest.java @@ -81,7 +81,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 202405011337 (2024-05-01T13:37:00Z)", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERGeneralizedTime("202405011337") ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspCrlCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspCrlCorrectorTest.java index 8b459f6e..32e912f2 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspCrlCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspCrlCorrectorTest.java @@ -133,7 +133,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "crlTime: 202405011337 (2024-05-01T13:37:00Z)", node.getChildAt(2)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERTaggedObject(true, 0, new DERIA5String("https://example.com/")), diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspExtendedRevokeCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspExtendedRevokeCorrectorTest.java index cd35b905..6d625aac 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspExtendedRevokeCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspExtendedRevokeCorrectorTest.java @@ -81,7 +81,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": NULL", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( DERNull.INSTANCE ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspNocheckCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspNocheckCorrectorTest.java index 670a553c..7f9f2af9 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspNocheckCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspNocheckCorrectorTest.java @@ -81,7 +81,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": NULL", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( DERNull.INSTANCE ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspNonceCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspNonceCorrectorTest.java index 3dd91236..4c8504af 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspNonceCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspNonceCorrectorTest.java @@ -81,7 +81,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 0x0102FF", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DEROctetString(new byte[] {0x01, 0x02, (byte) 0xFF}) ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspPreferredSignatureAlgorithmsCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspPreferredSignatureAlgorithmsCorrectorTest.java index 12adc5da..fd233c7d 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspPreferredSignatureAlgorithmsCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspPreferredSignatureAlgorithmsCorrectorTest.java @@ -230,7 +230,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERSequence( diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspServiceLocatorCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspServiceLocatorCorrectorTest.java index a79a9f5e..bf648c07 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspServiceLocatorCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/attributes/ocsp/OcspServiceLocatorCorrectorTest.java @@ -166,7 +166,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERSequence( diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/ArchiveRevInfoCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/ArchiveRevInfoCorrectorTest.java index 9ed7d8d0..5669d0e9 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/ArchiveRevInfoCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/ArchiveRevInfoCorrectorTest.java @@ -116,7 +116,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "version: 1 (v1)", node.getChildAt(0)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence( new ASN1Integer(1) diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/AuthorityInfoAccessCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/AuthorityInfoAccessCorrectorTest.java index f806f896..8aae1e0d 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/AuthorityInfoAccessCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/AuthorityInfoAccessCorrectorTest.java @@ -150,7 +150,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence( new DERSequence(new ASN1Encodable[] { diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/AuthorityKeyIdentifierCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/AuthorityKeyIdentifierCorrectorTest.java index da6fd865..5fb70ecd 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/AuthorityKeyIdentifierCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/AuthorityKeyIdentifierCorrectorTest.java @@ -129,7 +129,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "authorityCertSerialNumber: 777", node.getChildAt(2)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERTaggedObject(false, 0, diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/BasicConstraintsCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/BasicConstraintsCorrectorTest.java index 706ffda9..dd9c38b3 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/BasicConstraintsCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/BasicConstraintsCorrectorTest.java @@ -109,7 +109,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "pathLenConstraint: 256", node.getChildAt(1)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { ASN1Boolean.getInstance(true), diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CertificateIssuerCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CertificateIssuerCorrectorTest.java new file mode 100644 index 00000000..fbfa0e88 --- /dev/null +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CertificateIssuerCorrectorTest.java @@ -0,0 +1,96 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TestUtil; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TreeNodeFactory; + +import org.bouncycastle.asn1.ASN1Integer; +import org.bouncycastle.asn1.DEROctetString; +import org.bouncycastle.asn1.DERSequence; +import org.bouncycastle.asn1.DERTaggedObject; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +final class CertificateIssuerCorrectorTest { + @Test + void correct_WithDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + CertificateIssuerCorrector.INSTANCE.correct(node); + validateDefaultNode(node, "certificateIssuer"); + } + + @Test + void correct_WithoutDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + CertificateIssuerCorrector.INSTANCE.correct(node, "ci"); + validateDefaultNode(node, "ci"); + } + + @Test + void correct_InvalidRoot() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new ASN1Integer(42) + ); + CertificateIssuerCorrector.INSTANCE.correct(node); + Assertions.assertNull(node.getRfcFieldName()); + } + + private static void validateDefaultNode(AbstractAsn1TreeNode node, String expectedVariableName) { + Asn1TestUtil.assertNodeMatches(1, expectedVariableName, node); + Asn1TestUtil.assertNodeMatches(0, "ipAddress: 0x7F000001", node.getChildAt(0)); + } + + private static AbstractAsn1TreeNode createDefaultNode() { + return Asn1TreeNodeFactory.fromPrimitive( + new DERSequence( + new DERTaggedObject(false, 7, + new DEROctetString(new byte[] {127, 0, 0, 1}) + ) + ) + ); + } +} diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CertificatePoliciesCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CertificatePoliciesCorrectorTest.java index 548e13bc..0d55ac9a 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CertificatePoliciesCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CertificatePoliciesCorrectorTest.java @@ -154,7 +154,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERSequence( diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlDistributionPointsCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlDistributionPointsCorrectorTest.java index 515dc66b..6aff7403 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlDistributionPointsCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlDistributionPointsCorrectorTest.java @@ -303,7 +303,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence( new DERSequence(new ASN1Encodable[] { diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlNumberCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlNumberCorrectorTest.java new file mode 100644 index 00000000..0e47115b --- /dev/null +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlNumberCorrectorTest.java @@ -0,0 +1,89 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TestUtil; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TreeNodeFactory; + +import org.bouncycastle.asn1.ASN1Integer; +import org.bouncycastle.asn1.DERSequence; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +final class CrlNumberCorrectorTest { + @Test + void correct_WithDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + CrlNumberCorrector.INSTANCE.correct(node); + validateDefaultNode(node, "crlNumber"); + } + + @Test + void correct_WithoutDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + CrlNumberCorrector.INSTANCE.correct(node, "cn"); + validateDefaultNode(node, "cn"); + } + + @Test + void correct_InvalidRoot() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new DERSequence() + ); + CrlNumberCorrector.INSTANCE.correct(node); + Assertions.assertNull(node.getRfcFieldName()); + } + + private static void validateDefaultNode(AbstractAsn1TreeNode node, String expectedVariableName) { + Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 1374", node); + } + + private static AbstractAsn1TreeNode createDefaultNode() { + return Asn1TreeNodeFactory.fromPrimitive( + new ASN1Integer(1374) + ); + } +} diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CrlReasonCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlReasonCorrectorTest.java similarity index 98% rename from src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CrlReasonCorrectorTest.java rename to src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlReasonCorrectorTest.java index c55ea5e4..7c890307 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/CrlReasonCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/CrlReasonCorrectorTest.java @@ -40,7 +40,7 @@ This file is part of the iText (R) project. For more information, please contact iText Software Corp. at this address: sales@itextpdf.com */ -package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509; +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TestUtil; @@ -96,7 +96,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 0 (unspecified)", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new ASN1Enumerated(0) ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/DeltaCrlIndicatorCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/DeltaCrlIndicatorCorrectorTest.java new file mode 100644 index 00000000..f9eb03cb --- /dev/null +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/DeltaCrlIndicatorCorrectorTest.java @@ -0,0 +1,89 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TestUtil; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TreeNodeFactory; + +import org.bouncycastle.asn1.ASN1Integer; +import org.bouncycastle.asn1.DERSequence; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +final class DeltaCrlIndicatorCorrectorTest { + @Test + void correct_WithDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + DeltaCrlIndicatorCorrector.INSTANCE.correct(node); + validateDefaultNode(node, "baseCRLNumber"); + } + + @Test + void correct_WithoutDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + DeltaCrlIndicatorCorrector.INSTANCE.correct(node, "bcn"); + validateDefaultNode(node, "bcn"); + } + + @Test + void correct_InvalidRoot() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new DERSequence() + ); + DeltaCrlIndicatorCorrector.INSTANCE.correct(node); + Assertions.assertNull(node.getRfcFieldName()); + } + + private static void validateDefaultNode(AbstractAsn1TreeNode node, String expectedVariableName) { + Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 6784", node); + } + + private static AbstractAsn1TreeNode createDefaultNode() { + return Asn1TreeNodeFactory.fromPrimitive( + new ASN1Integer(6784) + ); + } +} diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/ExtKeyUsageCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/ExtKeyUsageCorrectorTest.java index 84662267..c7465a8c 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/ExtKeyUsageCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/ExtKeyUsageCorrectorTest.java @@ -123,7 +123,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new ASN1ObjectIdentifier("1.3.6.1.5.5.7.3.8"), // id-kp-timeStamping diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/FreshestCrlCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/FreshestCrlCorrectorTest.java new file mode 100644 index 00000000..375eb69d --- /dev/null +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/FreshestCrlCorrectorTest.java @@ -0,0 +1,113 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TestUtil; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TreeNodeFactory; + +import org.bouncycastle.asn1.ASN1Encodable; +import org.bouncycastle.asn1.DERIA5String; +import org.bouncycastle.asn1.DERSequence; +import org.bouncycastle.asn1.DERSet; +import org.bouncycastle.asn1.DERTaggedObject; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +final class FreshestCrlCorrectorTest { + @Test + void correct_WithDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + FreshestCrlCorrector.INSTANCE.correct(node); + validateDefaultNode(node, "freshestCRL"); + } + + @Test + void correct_WithoutDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + FreshestCrlCorrector.INSTANCE.correct(node, "fc"); + validateDefaultNode(node, "fc"); + } + + @Test + void correct_InvalidRoot() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new DERSet() + ); + FreshestCrlCorrector.INSTANCE.correct(node); + Assertions.assertNull(node.getRfcFieldName()); + } + + private static void validateDefaultNode(AbstractAsn1TreeNode node, String expectedVariableName) { + Asn1TestUtil.assertNodeMatches(1, expectedVariableName, node); + { + final AbstractAsn1TreeNode dp = node.getChildAt(0); + Asn1TestUtil.assertNodeMatches(2, "distributionPoint", dp); + { + final AbstractAsn1TreeNode dpn = dp.getChildAt(0); + Asn1TestUtil.assertNodeMatches(1, "distributionPointName", dpn); + Asn1TestUtil.assertNodeMatches(0, "dnsName: example.com", dpn.getChildAt(0)); + } + Asn1TestUtil.assertNodeMatches(0, "crlIssuer", dp.getChildAt(1)); + } + } + + private static AbstractAsn1TreeNode createDefaultNode() { + return Asn1TreeNodeFactory.fromPrimitive( + new DERSequence( + new DERSequence(new ASN1Encodable[] { + new DERTaggedObject(true, 0, + new DERTaggedObject(false, 0, new DERSequence( + new DERTaggedObject(false, 2, new DERIA5String("example.com")) + )) + ), + new DERTaggedObject(false, 2, + new DERSequence() + ), + }) + ) + ); + } +} diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/InvalidityDateCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/InvalidityDateCorrectorTest.java new file mode 100644 index 00000000..267bc1f0 --- /dev/null +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/InvalidityDateCorrectorTest.java @@ -0,0 +1,89 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TestUtil; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TreeNodeFactory; + +import org.bouncycastle.asn1.ASN1Integer; +import org.bouncycastle.asn1.DERGeneralizedTime; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +final class InvalidityDateCorrectorTest { + @Test + void correct_WithDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + InvalidityDateCorrector.INSTANCE.correct(node); + validateDefaultNode(node, "invalidityDate"); + } + + @Test + void correct_WithoutDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + InvalidityDateCorrector.INSTANCE.correct(node, "id"); + validateDefaultNode(node, "id"); + } + + @Test + void correct_InvalidRoot() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new ASN1Integer(42) + ); + InvalidityDateCorrector.INSTANCE.correct(node); + Assertions.assertNull(node.getRfcFieldName()); + } + + private static void validateDefaultNode(AbstractAsn1TreeNode node, String expectedVariableName) { + Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 202607121242 (2026-07-12T12:42:00Z)", node); + } + + private static AbstractAsn1TreeNode createDefaultNode() { + return Asn1TreeNodeFactory.fromPrimitive( + new DERGeneralizedTime("202607121242") + ); + } +} diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuerAltNameCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuerAltNameCorrectorTest.java new file mode 100644 index 00000000..498ec8d0 --- /dev/null +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuerAltNameCorrectorTest.java @@ -0,0 +1,96 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TestUtil; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TreeNodeFactory; + +import org.bouncycastle.asn1.ASN1Integer; +import org.bouncycastle.asn1.DEROctetString; +import org.bouncycastle.asn1.DERSequence; +import org.bouncycastle.asn1.DERTaggedObject; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +final class IssuerAltNameCorrectorTest { + @Test + void correct_WithDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + IssuerAltNameCorrector.INSTANCE.correct(node); + validateDefaultNode(node, "issuerAltName"); + } + + @Test + void correct_WithoutDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + IssuerAltNameCorrector.INSTANCE.correct(node, "ian"); + validateDefaultNode(node, "ian"); + } + + @Test + void correct_InvalidRoot() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new ASN1Integer(42) + ); + IssuerAltNameCorrector.INSTANCE.correct(node); + Assertions.assertNull(node.getRfcFieldName()); + } + + private static void validateDefaultNode(AbstractAsn1TreeNode node, String expectedVariableName) { + Asn1TestUtil.assertNodeMatches(1, expectedVariableName, node); + Asn1TestUtil.assertNodeMatches(0, "ipAddress: 0xC0A80001", node.getChildAt(0)); + } + + private static AbstractAsn1TreeNode createDefaultNode() { + return Asn1TreeNodeFactory.fromPrimitive( + new DERSequence( + new DERTaggedObject(false, 7, + new DEROctetString(new byte[] {(byte) 192, (byte) 168, 0, 1}) + ) + ) + ); + } +} diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuingDistributionPointCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuingDistributionPointCorrectorTest.java new file mode 100644 index 00000000..9b32ae0e --- /dev/null +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/IssuingDistributionPointCorrectorTest.java @@ -0,0 +1,159 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TestUtil; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TreeNodeFactory; + +import org.bouncycastle.asn1.ASN1Boolean; +import org.bouncycastle.asn1.ASN1Encodable; +import org.bouncycastle.asn1.ASN1Integer; +import org.bouncycastle.asn1.DERBitString; +import org.bouncycastle.asn1.DERIA5String; +import org.bouncycastle.asn1.DERSequence; +import org.bouncycastle.asn1.DERTaggedObject; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +final class IssuingDistributionPointCorrectorTest { + @Test + void correct_WithDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + IssuingDistributionPointCorrector.INSTANCE.correct(node); + validateDefaultNode(node, "issuingDistributionPoint"); + } + + @Test + void correct_WithoutDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + IssuingDistributionPointCorrector.INSTANCE.correct(node, "idp"); + validateDefaultNode(node, "idp"); + } + + @Test + void correct_InvalidRoot() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive(new ASN1Integer(15)); + IssuingDistributionPointCorrector.INSTANCE.correct(node); + Asn1TestUtil.assertNodeMatches(0, "INTEGER: 15", node); + } + + @Test + void correct_EmptyRootSequence() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive(new DERSequence()); + IssuingDistributionPointCorrector.INSTANCE.correct(node); + Asn1TestUtil.assertNodeMatches(0, "issuingDistributionPoint", node); + } + + @Test + void correct_OnlyLastField() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new DERSequence( + new DERTaggedObject(false, 5, ASN1Boolean.TRUE) + ) + ); + IssuingDistributionPointCorrector.INSTANCE.correct(node); + Asn1TestUtil.assertNodeMatches(1, "issuingDistributionPoint", node); + Asn1TestUtil.assertNodeMatches(0, "onlyContainsAttributeCerts: TRUE", node.getChildAt(0)); + } + + @Test + void correct_SingleUnexpectedField() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new DERSequence(ASN1Boolean.FALSE) + ); + IssuingDistributionPointCorrector.INSTANCE.correct(node); + Asn1TestUtil.assertNodeMatches(1, "issuingDistributionPoint", node); + Asn1TestUtil.assertNodeMatches(0, "BOOLEAN: FALSE", node.getChildAt(0)); + } + + private static void validateDefaultNode(AbstractAsn1TreeNode node, String expectedVariableName) { + Asn1TestUtil.assertNodeMatches(6, expectedVariableName, node); + { + final AbstractAsn1TreeNode distributionPoint = node.getChildAt(0); + Asn1TestUtil.assertNodeMatches(1, "distributionPoint", distributionPoint); + Asn1TestUtil.assertNodeMatches( + 0, "uniformResourceIdentifier: https://example.com/", distributionPoint.getChildAt(0) + ); + } + Asn1TestUtil.assertNodeMatches(0, "onlyContainsUserCerts: FALSE", node.getChildAt(1)); + Asn1TestUtil.assertNodeMatches(0, "onlyContainsCACerts: TRUE", node.getChildAt(2)); + { + final AbstractAsn1TreeNode onlySomeReasons = node.getChildAt(3); + Asn1TestUtil.assertNodeMatches(9, "onlySomeReasons: 0b101010101", onlySomeReasons); + Asn1TestUtil.assertNodeMatches(0, "unused: TRUE", onlySomeReasons.getChildAt(0)); + Asn1TestUtil.assertNodeMatches(0, "keyCompromise: FALSE", onlySomeReasons.getChildAt(1)); + Asn1TestUtil.assertNodeMatches(0, "caCompromise: TRUE", onlySomeReasons.getChildAt(2)); + Asn1TestUtil.assertNodeMatches(0, "affiliationChanged: FALSE", onlySomeReasons.getChildAt(3)); + Asn1TestUtil.assertNodeMatches(0, "superseded: TRUE", onlySomeReasons.getChildAt(4)); + Asn1TestUtil.assertNodeMatches(0, "cessationOfOperation: FALSE", onlySomeReasons.getChildAt(5)); + Asn1TestUtil.assertNodeMatches(0, "certificateHold: TRUE", onlySomeReasons.getChildAt(6)); + Asn1TestUtil.assertNodeMatches(0, "privilegeWithdrawn: FALSE", onlySomeReasons.getChildAt(7)); + Asn1TestUtil.assertNodeMatches(0, "aaCompromise: TRUE", onlySomeReasons.getChildAt(8)); + } + Asn1TestUtil.assertNodeMatches(0, "indirectCRL: FALSE", node.getChildAt(4)); + Asn1TestUtil.assertNodeMatches(0, "onlyContainsAttributeCerts: TRUE", node.getChildAt(5)); + } + + private static AbstractAsn1TreeNode createDefaultNode() { + return Asn1TreeNodeFactory.fromPrimitive( + new DERSequence(new ASN1Encodable[] { + new DERTaggedObject(true, 0, + new DERTaggedObject(false, 0, new DERSequence( + new DERTaggedObject(false, 6, new DERIA5String( + "https://example.com/" + )) + )) + ), + new DERTaggedObject(false, 1, ASN1Boolean.FALSE), + new DERTaggedObject(false, 2, ASN1Boolean.TRUE), + new DERTaggedObject(false, 3, new DERBitString( + new byte[] {(byte) 0xAA, (byte) 0x80}, 7 + )), + new DERTaggedObject(false, 4, ASN1Boolean.FALSE), + new DERTaggedObject(false, 5, ASN1Boolean.TRUE), + }) + ); + } +} diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/KeyUsageCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/KeyUsageCorrectorTest.java index 410d88a5..dcf011d9 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/KeyUsageCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/KeyUsageCorrectorTest.java @@ -108,7 +108,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "decipherOnly: TRUE", node.getChildAt(8)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERBitString(new byte[] {(byte) 0b10101010, (byte) 0b10000000}, 7) ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/SubjectKeyIdentifierCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/SubjectKeyIdentifierCorrectorTest.java index c859a0f9..45b0dc39 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/SubjectKeyIdentifierCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/SubjectKeyIdentifierCorrectorTest.java @@ -81,7 +81,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": 0x01020304", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DEROctetString(new byte[] {0x01, 0x02, 0x03, 0x04}) ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/TimeStampCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/TimeStampCorrectorTest.java index 5c194122..87493918 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/TimeStampCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/TimeStampCorrectorTest.java @@ -126,7 +126,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "requiresAuth: TRUE", node.getChildAt(2)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new ASN1Integer(1), diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/UbiquityRightsCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/UbiquityRightsCorrectorTest.java index 68515db0..17b4a958 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/UbiquityRightsCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/UbiquityRightsCorrectorTest.java @@ -158,7 +158,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "mode: 1 (production)", node.getChildAt(2)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new ASN1Integer(1), diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/DistributionPointNameCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/DistributionPointNameCorrectorTest.java new file mode 100644 index 00000000..3316f75f --- /dev/null +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/DistributionPointNameCorrectorTest.java @@ -0,0 +1,152 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.types; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TestUtil; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TreeNodeFactory; + +import org.bouncycastle.asn1.ASN1Primitive; +import org.bouncycastle.asn1.DERIA5String; +import org.bouncycastle.asn1.DERSequence; +import org.bouncycastle.asn1.DERSet; +import org.bouncycastle.asn1.DERTaggedObject; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +final class DistributionPointNameCorrectorTest { + @Test + void correct_FullNameWithDefaultName() { + final AbstractAsn1TreeNode node = createFullNameNode(); + DistributionPointNameCorrector.INSTANCE.correct(node); + validateFullNameNode(node, "fullName"); + } + + @Test + void correct_FullNameWithoutDefaultName() { + final AbstractAsn1TreeNode node = createFullNameNode(); + DistributionPointNameCorrector.INSTANCE.correct(node, "dpn"); + validateFullNameNode(node, "dpn"); + } + + @Test + void correct_FullNameBehindTag() { + final ASN1Primitive obj = createFullNameNode().getAsn1Primitive(); + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new DERTaggedObject(true, 3, obj) + ); + DistributionPointNameCorrector.INSTANCE.correct(node, obj); + validateFullNameNode(node, "fullName"); + } + + @Test + void correct_NameRelativeToCRLIssuerWithDefaultName() { + final AbstractAsn1TreeNode node = createNameRelativeToCrlIssuerNode(); + DistributionPointNameCorrector.INSTANCE.correct(node); + validateNameRelativeToCrlIssuerNode(node, "nameRelativeToCRLIssuer"); + } + + @Test + void correct_NameRelativeToCRLIssuerWithoutDefaultName() { + final AbstractAsn1TreeNode node = createNameRelativeToCrlIssuerNode(); + DistributionPointNameCorrector.INSTANCE.correct(node, "dpn"); + validateNameRelativeToCrlIssuerNode(node, "dpn"); + } + + @Test + void correct_NameRelativeToCRLIssuerBehindTag() { + final ASN1Primitive obj = createNameRelativeToCrlIssuerNode().getAsn1Primitive(); + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new DERTaggedObject(true, 4, obj) + ); + DistributionPointNameCorrector.INSTANCE.correct(node, obj); + validateNameRelativeToCrlIssuerNode(node, "nameRelativeToCRLIssuer"); + } + + @Test + void correct_InvalidRoot() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new DERIA5String("example.com") + ); + DistributionPointNameCorrector.INSTANCE.correct(node); + Asn1TestUtil.assertNodeMatches(0, "IA5String: example.com", node); + } + + @Test + void correct_InvalidRootTagNum() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new DERTaggedObject(false, 2, new DERSet()) + ); + DistributionPointNameCorrector.INSTANCE.correct(node); + Asn1TestUtil.assertNodeMatches(0, "[2] IMPLICIT SET", node); + } + + private static void validateFullNameNode(AbstractAsn1TreeNode node, String expectedVariableName) { + Asn1TestUtil.assertNodeMatches(1, expectedVariableName, node); + Asn1TestUtil.assertNodeMatches( + 0, "uniformResourceIdentifier: https://example.com/", node.getChildAt(0) + ); + } + + private static AbstractAsn1TreeNode createFullNameNode() { + return Asn1TreeNodeFactory.fromPrimitive( + new DERTaggedObject(false, 0, new DERSequence( + new DERTaggedObject(false, 6, new DERIA5String("https://example.com/")) + )) + ); + } + + private static void validateNameRelativeToCrlIssuerNode(AbstractAsn1TreeNode node, String expectedVariableName) { + Asn1TestUtil.assertNodeMatches(1, expectedVariableName, node); + Asn1TestUtil.assertNodeMatches(0, "attributeTypeAndValue", node.getChildAt(0)); + } + + private static AbstractAsn1TreeNode createNameRelativeToCrlIssuerNode() { + return Asn1TreeNodeFactory.fromPrimitive( + new DERTaggedObject(false, 1, new DERSet( + new DERSequence() + )) + ); + } +} diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/ReasonFlagsCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/ReasonFlagsCorrectorTest.java new file mode 100644 index 00000000..63c93fa0 --- /dev/null +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/extensions/types/ReasonFlagsCorrectorTest.java @@ -0,0 +1,116 @@ +/* + This file is part of the iText (R) project. + Copyright (c) 1998-2026 Apryse Group NV + Authors: Apryse 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 + APRYSE GROUP. APRYSE 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: sales@itextpdf.com + */ +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.extensions.types; + +import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TestUtil; +import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TreeNodeFactory; + +import org.bouncycastle.asn1.DERBitString; +import org.bouncycastle.asn1.DERSequence; +import org.junit.jupiter.api.Assertions; +import org.junit.jupiter.api.Tag; +import org.junit.jupiter.api.Test; + +@Tag("UnitTest") +final class ReasonFlagsCorrectorTest { + @Test + void correct_WithDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + ReasonFlagsCorrector.INSTANCE.correct(node); + validateDefaultNode(node, "reasons"); + } + + @Test + void correct_WithoutDefaultName() { + final AbstractAsn1TreeNode node = createDefaultNode(); + ReasonFlagsCorrector.INSTANCE.correct(node, "rf"); + validateDefaultNode(node, "rf"); + } + + @Test + void correct_InvalidRoot() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new DERSequence() + ); + ReasonFlagsCorrector.INSTANCE.correct(node); + Assertions.assertNull(node.getRfcFieldName()); + } + + @Test + void correct_FullBitString() { + final AbstractAsn1TreeNode node = Asn1TreeNodeFactory.fromPrimitive( + new DERBitString(new byte[] {(byte) 0xAA, (byte) 0x80}, 7) + ); + ReasonFlagsCorrector.INSTANCE.correct(node); + Asn1TestUtil.assertNodeMatches(9, "reasons: 0b101010101", node); + Asn1TestUtil.assertNodeMatches(0, "unused: TRUE", node.getChildAt(0)); + Asn1TestUtil.assertNodeMatches(0, "keyCompromise: FALSE", node.getChildAt(1)); + Asn1TestUtil.assertNodeMatches(0, "caCompromise: TRUE", node.getChildAt(2)); + Asn1TestUtil.assertNodeMatches(0, "affiliationChanged: FALSE", node.getChildAt(3)); + Asn1TestUtil.assertNodeMatches(0, "superseded: TRUE", node.getChildAt(4)); + Asn1TestUtil.assertNodeMatches(0, "cessationOfOperation: FALSE", node.getChildAt(5)); + Asn1TestUtil.assertNodeMatches(0, "certificateHold: TRUE", node.getChildAt(6)); + Asn1TestUtil.assertNodeMatches(0, "privilegeWithdrawn: FALSE", node.getChildAt(7)); + Asn1TestUtil.assertNodeMatches(0, "aaCompromise: TRUE", node.getChildAt(8)); + } + + private static void validateDefaultNode(AbstractAsn1TreeNode node, String expectedVariableName) { + Asn1TestUtil.assertNodeMatches(9, expectedVariableName + ": 0b1", node); + Asn1TestUtil.assertNodeMatches(0, "unused: TRUE", node.getChildAt(0)); + Asn1TestUtil.assertNodeMatches(0, "keyCompromise: FALSE", node.getChildAt(1)); + Asn1TestUtil.assertNodeMatches(0, "caCompromise: FALSE", node.getChildAt(2)); + Asn1TestUtil.assertNodeMatches(0, "affiliationChanged: FALSE", node.getChildAt(3)); + Asn1TestUtil.assertNodeMatches(0, "superseded: FALSE", node.getChildAt(4)); + Asn1TestUtil.assertNodeMatches(0, "cessationOfOperation: FALSE", node.getChildAt(5)); + Asn1TestUtil.assertNodeMatches(0, "certificateHold: FALSE", node.getChildAt(6)); + Asn1TestUtil.assertNodeMatches(0, "privilegeWithdrawn: FALSE", node.getChildAt(7)); + Asn1TestUtil.assertNodeMatches(0, "aaCompromise: FALSE", node.getChildAt(8)); + } + + private static AbstractAsn1TreeNode createDefaultNode() { + return Asn1TreeNodeFactory.fromPrimitive( + new DERBitString((byte) 0x80, 7) + ); + } +} \ No newline at end of file diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/policies/CpsPointerCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/policies/CpsPointerCorrectorTest.java index f37586b8..d93dfbcd 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/policies/CpsPointerCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/policies/CpsPointerCorrectorTest.java @@ -81,7 +81,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, expectedVariableName + ": http://cps.uri", node); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERIA5String("http://cps.uri") ); diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/policies/UserNoticeCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/policies/UserNoticeCorrectorTest.java index 42cb1b72..e4aafc33 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/policies/UserNoticeCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/policies/UserNoticeCorrectorTest.java @@ -220,7 +220,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect Asn1TestUtil.assertNodeMatches(0, "explicitText: Shut it down!", node.getChildAt(1)); } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSequence(new ASN1Encodable[] { new DERSequence(new ASN1Encodable[] { diff --git a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/RelativeDistinguishedNameCorrectorTest.java b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/types/RelativeDistinguishedNameCorrectorTest.java similarity index 98% rename from src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/RelativeDistinguishedNameCorrectorTest.java rename to src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/types/RelativeDistinguishedNameCorrectorTest.java index 6340f1f3..c742f65d 100644 --- a/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/RelativeDistinguishedNameCorrectorTest.java +++ b/src/test/java/com/itextpdf/rups/view/itext/treenodes/asn1/correctors/x509/types/RelativeDistinguishedNameCorrectorTest.java @@ -40,7 +40,7 @@ This file is part of the iText (R) project. For more information, please contact iText Software Corp. at this address: sales@itextpdf.com */ -package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509; +package com.itextpdf.rups.view.itext.treenodes.asn1.correctors.x509.types; import com.itextpdf.rups.view.itext.treenodes.asn1.AbstractAsn1TreeNode; import com.itextpdf.rups.view.itext.treenodes.asn1.Asn1TestUtil; @@ -140,7 +140,7 @@ private static void validateDefaultNode(AbstractAsn1TreeNode node, String expect } } - private AbstractAsn1TreeNode createDefaultNode() { + private static AbstractAsn1TreeNode createDefaultNode() { return Asn1TreeNodeFactory.fromPrimitive( new DERSet( new DERSequence(new ASN1Encodable[] {