Пример #1
0
 /// <summary>Check whether line starts with object declaration.</summary>
 /// <param name="lineTokenizer">tokenizer, built by single line.</param>
 /// <returns>object number and generation if check is successful, otherwise - null.</returns>
 public static int[] CheckObjectStart(iText.IO.Source.PdfTokenizer lineTokenizer)
 {
     try {
         lineTokenizer.Seek(0);
         if (!lineTokenizer.NextToken() || lineTokenizer.GetTokenType() != PdfTokenizer.TokenType.Number)
         {
             return(null);
         }
         int num = lineTokenizer.GetIntValue();
         if (!lineTokenizer.NextToken() || lineTokenizer.GetTokenType() != PdfTokenizer.TokenType.Number)
         {
             return(null);
         }
         int gen = lineTokenizer.GetIntValue();
         if (!lineTokenizer.NextToken())
         {
             return(null);
         }
         if (!JavaUtil.ArraysEquals(Obj, lineTokenizer.GetByteContent()))
         {
             return(null);
         }
         return(new int[] { num, gen });
     }
     catch (Exception) {
     }
     // empty on purpose
     return(null);
 }
Пример #2
0
 /// <summary>Checks equality of matrices.</summary>
 /// <param name="obj">the other Matrix that needs to be compared with this matrix.</param>
 /// <returns>true if both matrices are equal</returns>
 /// <seealso cref="System.Object.Equals(System.Object)"/>
 public override bool Equals(Object obj)
 {
     if (!(obj is iText.Kernel.Geom.Matrix))
     {
         return(false);
     }
     return(JavaUtil.ArraysEquals(vals, ((iText.Kernel.Geom.Matrix)obj).vals));
 }
Пример #3
0
        public virtual void Barcode03Test()
        {
            byte[] expected = new byte[] { 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1,
                                           0, 0, 1, 0, 0, 1, 0, 0, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 1 };
            byte[] barcodeBytes = BarcodeMSI.GetBarsMSI("1234");
            bool   isEqual      = JavaUtil.ArraysEquals(expected, barcodeBytes);

            NUnit.Framework.Assert.IsTrue(isEqual);
        }
        public virtual void RetrieveAlignAndMeetEmptySlice()
        {
            String align = SvgConstants.Values.DEFAULT_ASPECT_RATIO;
            String meet  = SvgConstants.Values.SLICE;

            String[] cmpAlignAndMeet = new String[] { align, meet };
            String[] outAlignAndMeet = RetrieveAlignAndMeet("", meet);
            //should fail, because align attribute must be present
            NUnit.Framework.Assert.IsFalse(JavaUtil.ArraysEquals(cmpAlignAndMeet, outAlignAndMeet));
        }
Пример #5
0
 public override bool Equals(Object o)
 {
     if (this == o)
     {
         return(true);
     }
     if (o == null || GetType() != o.GetType())
     {
         return(false);
     }
     iText.Layout.Font.Range range = (iText.Layout.Font.Range)o;
     return(JavaUtil.ArraysEquals(ranges, range.ranges));
 }
Пример #6
0
 /// <summary>Two Glyphs are equal if their unicode characters, code and normalized width are equal.</summary>
 /// <param name="obj">The object</param>
 /// <returns>True if this equals obj cast to Glyph, false otherwise.</returns>
 public override bool Equals(Object obj)
 {
     if (this == obj)
     {
         return(true);
     }
     if (obj == null || GetType() != obj.GetType())
     {
         return(false);
     }
     iText.IO.Font.Otf.Glyph other = (iText.IO.Font.Otf.Glyph)obj;
     return(JavaUtil.ArraysEquals(chars, other.chars) && code == other.code && width == other.width);
 }
Пример #7
0
 /// <summary>Indicates whether the color is equal to the given color.</summary>
 /// <remarks>
 /// Indicates whether the color is equal to the given color.
 /// The
 /// <see cref="colorSpace">color space</see>
 /// and
 /// <see cref="colorValue">color value</see>
 /// are considered during the comparison.
 /// </remarks>
 public override bool Equals(Object o)
 {
     if (this == o)
     {
         return(true);
     }
     if (o == null || GetType() != o.GetType())
     {
         return(false);
     }
     iText.Kernel.Colors.Color color = (iText.Kernel.Colors.Color)o;
     return((colorSpace != null ? colorSpace.GetPdfObject().Equals(color.colorSpace.GetPdfObject()) : color.colorSpace
             == null) && JavaUtil.ArraysEquals(colorValue, color.colorValue));
 }
 public override bool Equals(Object o)
 {
     if (this == o)
     {
         return(true);
     }
     if (o == null || GetType() != o.GetType())
     {
         return(false);
     }
     iText.Kernel.Colors.Gradients.GradientColorStop that = (iText.Kernel.Colors.Gradients.GradientColorStop)o;
     return(JavaUtil.FloatCompare(that.opacity, opacity) == 0 && JavaUtil.DoubleCompare(that.offset, offset) ==
            0 && JavaUtil.DoubleCompare(that.hintOffset, hintOffset) == 0 && JavaUtil.ArraysEquals(rgb, that.rgb) &&
            offsetType == that.offsetType && hintOffsetType == that.hintOffsetType);
 }
Пример #9
0
 public override bool Equals(Object o)
 {
     if (this == o)
     {
         return(true);
     }
     if (o == null || GetType() != o.GetType())
     {
         return(false);
     }
     FontCacheKey.FontCacheBytesKey that = (FontCacheKey.FontCacheBytesKey)o;
     if (fontLength != that.fontLength)
     {
         return(false);
     }
     return(JavaUtil.ArraysEquals(firstFontBytes, that.firstFontBytes));
 }
Пример #10
0
        /// <summary><inheritDoc/></summary>
        public override GlyphLine DecodeIntoGlyphLine(PdfString content)
        {
            byte[]        contentBytes = content.GetValueBytes();
            IList <Glyph> glyphs       = new List <Glyph>(contentBytes.Length);

            foreach (byte b in contentBytes)
            {
                int   code  = b & 0xff;
                Glyph glyph = null;
                if (toUnicode != null && toUnicode.Lookup(code) != null && (glyph = fontProgram.GetGlyphByCode(code)) != null
                    )
                {
                    if (!JavaUtil.ArraysEquals(toUnicode.Lookup(code), glyph.GetChars()))
                    {
                        // Copy the glyph because the original one may be reused (e.g. standard Helvetica font program)
                        glyph = new Glyph(glyph);
                        glyph.SetChars(toUnicode.Lookup(code));
                    }
                }
                else
                {
                    int uni = fontEncoding.GetUnicode(code);
                    if (uni > -1)
                    {
                        glyph = GetGlyph(uni);
                    }
                    else
                    {
                        if (fontEncoding.GetBaseEncoding() == null)
                        {
                            glyph = fontProgram.GetGlyphByCode(code);
                        }
                    }
                }
                if (glyph != null)
                {
                    glyphs.Add(glyph);
                }
            }
            return(new GlyphLine(glyphs));
        }
Пример #11
0
 public override bool Equals(Object o)
 {
     if (this == o)
     {
         return(true);
     }
     if (o == null || GetType() != o.GetType())
     {
         return(false);
     }
     TypographyUtils.TypographyMethodSignature that = (TypographyUtils.TypographyMethodSignature)o;
     if (!className.Equals(that.className))
     {
         return(false);
     }
     if (!JavaUtil.ArraysEquals(parameterTypes, that.parameterTypes))
     {
         return(false);
     }
     return(methodName != null?methodName.Equals(that.methodName) : that.methodName == null);
 }
Пример #12
0
 /// <seealso cref="System.Object.Equals(System.Object)"/>
 public override bool Equals(Object obj)
 {
     if (this == obj)
     {
         return(true);
     }
     if (obj == null)
     {
         return(false);
     }
     if (GetType() != obj.GetType())
     {
         return(false);
     }
     iText.Kernel.Geom.Vector other = (iText.Kernel.Geom.Vector)obj;
     if (!JavaUtil.ArraysEquals(vals, other.vals))
     {
         return(false);
     }
     return(true);
 }
 public override bool Equals(Object obj)
 {
     return(obj is iText.Kernel.Pdf.SerializedObjectContent && GetHashCode() == obj.GetHashCode() && JavaUtil.ArraysEquals
                (serializedContent, ((iText.Kernel.Pdf.SerializedObjectContent)obj).serializedContent));
 }
Пример #14
0
 public override bool Equals(Object o)
 {
     return(this == o || o != null && GetType() == o.GetType() && JavaUtil.ArraysEquals(content, ((iText.Kernel.Pdf.PdfLiteral
                                                                                                   )o).content));
 }
Пример #15
0
        /// <summary>Add verification for a particular signature.</summary>
        /// <param name="signatureName">the signature to validate (it may be a timestamp)</param>
        /// <param name="ocsp">the interface to get the OCSP</param>
        /// <param name="crl">the interface to get the CRL</param>
        /// <param name="certOption">options as to how many certificates to include</param>
        /// <param name="level">the validation options to include</param>
        /// <param name="certInclude">certificate inclusion options</param>
        /// <returns>true if a validation was generated, false otherwise</returns>
        /// <exception cref="Org.BouncyCastle.Security.GeneralSecurityException"/>
        /// <exception cref="System.IO.IOException"/>
        public virtual bool AddVerification(String signatureName, IOcspClient ocsp, ICrlClient crl, LtvVerification.CertificateOption
                                            certOption, LtvVerification.Level level, LtvVerification.CertificateInclusion certInclude)
        {
            if (used)
            {
                throw new InvalidOperationException(PdfException.VerificationAlreadyOutput);
            }
            PdfPKCS7 pk = sgnUtil.VerifySignature(signatureName);

            LOGGER.Info("Adding verification for " + signatureName);
            X509Certificate[] xc = pk.GetCertificates();
            X509Certificate   cert;
            X509Certificate   signingCert = pk.GetSigningCertificate();

            LtvVerification.ValidationData vd = new LtvVerification.ValidationData();
            for (int k = 0; k < xc.Length; ++k)
            {
                cert = (X509Certificate)xc[k];
                LOGGER.Info("Certificate: " + cert.SubjectDN);
                if (certOption == LtvVerification.CertificateOption.SIGNING_CERTIFICATE && !cert.Equals(signingCert))
                {
                    continue;
                }
                byte[] ocspEnc = null;
                if (ocsp != null && level != LtvVerification.Level.CRL)
                {
                    ocspEnc = ocsp.GetEncoded(cert, GetParent(cert, xc), null);
                    if (ocspEnc != null)
                    {
                        vd.ocsps.Add(BuildOCSPResponse(ocspEnc));
                        LOGGER.Info("OCSP added");
                    }
                }
                if (crl != null && (level == LtvVerification.Level.CRL || level == LtvVerification.Level.OCSP_CRL || (level
                                                                                                                      == LtvVerification.Level.OCSP_OPTIONAL_CRL && ocspEnc == null)))
                {
                    ICollection <byte[]> cims = crl.GetEncoded(cert, null);
                    if (cims != null)
                    {
                        foreach (byte[] cim in cims)
                        {
                            bool dup = false;
                            foreach (byte[] b in vd.crls)
                            {
                                if (JavaUtil.ArraysEquals(b, cim))
                                {
                                    dup = true;
                                    break;
                                }
                            }
                            if (!dup)
                            {
                                vd.crls.Add(cim);
                                LOGGER.Info("CRL added");
                            }
                        }
                    }
                }
                if (certInclude == LtvVerification.CertificateInclusion.YES)
                {
                    vd.certs.Add(cert.GetEncoded());
                }
            }
            if (vd.crls.Count == 0 && vd.ocsps.Count == 0)
            {
                return(false);
            }
            validated.Put(GetSignatureHashKey(signatureName), vd);
            return(true);
        }
Пример #16
0
 public override bool Equals(Object o)
 {
     if (this == o)
     {
         return(true);
     }
     if (!(o is iText.Layout.Font.FontInfo))
     {
         return(false);
     }
     iText.Layout.Font.FontInfo that = (iText.Layout.Font.FontInfo)o;
     return((fontName != null ? fontName.Equals(that.fontName) : that.fontName == null) && range.Equals(that.range
                                                                                                        ) && JavaUtil.ArraysEquals(fontData, that.fontData) && (encoding != null ? encoding.Equals(that.encoding
                                                                                                                                                                                                   ) : that.encoding == null));
 }