コード例 #1
0
        private static string GetEntryDigestAttributeName(DigestAlgorithm digestAlgorithm)
        {
            if (digestAlgorithm.Equals(DigestAlgorithm.SHA1))
            {
                return("SHA1-Digest");
            }

            if (digestAlgorithm.Equals(DigestAlgorithm.SHA256))
            {
                return("SHA-256-Digest");
            }

            throw new ArgumentException(
                      "Unexpected content digest algorithm: " + digestAlgorithm);
        }
コード例 #2
0
        /// <exception cref="Sharpen.NoSuchAlgorithmException"></exception>
        public override byte[] EncryptDigest(byte[] digestValue, DigestAlgorithm digestAlgo
                                             , IDssPrivateKeyEntry keyEntry)
        {
            try
            {
                ByteArrayOutputStream digestInfo = new ByteArrayOutputStream();
                //jbonilla: cambio de enum a clase.
                if (digestAlgo.Equals(DigestAlgorithm.SHA1))
                {
                    digestInfo.Write(Constants.SHA1_DIGEST_INFO_PREFIX);
                }
                else
                {
                    if (digestAlgo.Equals(DigestAlgorithm.SHA256))
                    {
                        digestInfo.Write(Constants.SHA256_DIGEST_INFO_PREFIX);
                    }
                    else
                    {
                        if (digestAlgo.Equals(DigestAlgorithm.SHA256))
                        {
                            digestInfo.Write(Constants.SHA512_DIGEST_INFO_PREFIX);
                        }
                    }
                }
                digestInfo.Write(digestValue);
                //Sharpen.Cipher cipher = Sharpen.Cipher.GetInstance(keyEntry.GetSignatureAlgorithm
                //    ().GetPadding());
                IBufferedCipher cipher = CipherUtilities.GetCipher(keyEntry.GetSignatureAlgorithm
                                                                       ().GetPadding());

                //cipher.Init(Sharpen.Cipher.ENCRYPT_MODE, ((KSPrivateKeyEntry)keyEntry).GetPrivateKey
                //    ());
                cipher.Init(true, ((KSPrivateKeyEntry)keyEntry).PrivateKey);
                return(cipher.DoFinal(digestInfo.ToByteArray()));
            }
            catch (IOException e)
            {
                // Writing in a ByteArrayOutputStream. Should never happens.
                throw new RuntimeException(e);
            }

            /*catch (NoSuchPaddingException e)
             * {
             *  throw new RuntimeException(e);
             * }*/
            catch (InvalidKeyException e)
            {
                throw new RuntimeException(e);
            }

            /*catch (IllegalBlockSizeException e)
             * {
             *  throw new RuntimeException(e);
             * }
             * catch (BadPaddingException)
             * {
             *  // More likely the password is not good.
             *  throw new BadPasswordException(BadPasswordException.MSG.PKCS12_BAD_PASSWORD);
             * }*/
        }
コード例 #3
0
        /// <exception cref="Sharpen.NoSuchAlgorithmException"></exception>
        public override byte[] EncryptDigest(byte[] digestValue, DigestAlgorithm digestAlgo
            , IDssPrivateKeyEntry keyEntry)
        {
            try
            {
                ByteArrayOutputStream digestInfo = new ByteArrayOutputStream();
                //jbonilla: cambio de enum a clase.
                if (digestAlgo.Equals(DigestAlgorithm.SHA1))
                {
                    digestInfo.Write(Constants.SHA1_DIGEST_INFO_PREFIX);
                }
                else
                {
                    if (digestAlgo.Equals(DigestAlgorithm.SHA256))
                    {
                        digestInfo.Write(Constants.SHA256_DIGEST_INFO_PREFIX);
                    }
                    else
                    {
                        if (digestAlgo.Equals(DigestAlgorithm.SHA256))
                        {
                            digestInfo.Write(Constants.SHA512_DIGEST_INFO_PREFIX);
                        }
                    }
                }
                digestInfo.Write(digestValue);
                //Sharpen.Cipher cipher = Sharpen.Cipher.GetInstance(keyEntry.GetSignatureAlgorithm
                //    ().GetPadding());
                IBufferedCipher cipher = CipherUtilities.GetCipher(keyEntry.GetSignatureAlgorithm
                    ().GetPadding());

                //cipher.Init(Sharpen.Cipher.ENCRYPT_MODE, ((KSPrivateKeyEntry)keyEntry).GetPrivateKey
                //    ());
                cipher.Init(true, ((KSPrivateKeyEntry)keyEntry).PrivateKey);
                return cipher.DoFinal(digestInfo.ToByteArray());
            }
            catch (IOException e)
            {
                // Writing in a ByteArrayOutputStream. Should never happens.
                throw new RuntimeException(e);
            }
            /*catch (NoSuchPaddingException e)
            {
                throw new RuntimeException(e);
            }*/
            catch (InvalidKeyException e)
            {
                throw new RuntimeException(e);
            }
            /*catch (IllegalBlockSizeException e)
            {
                throw new RuntimeException(e);
            }
            catch (BadPaddingException)
            {
                // More likely the password is not good.
                throw new BadPasswordException(BadPasswordException.MSG.PKCS12_BAD_PASSWORD);
            }*/
        }
        /// <summary>
        /// Returns true if OrgApacheSlingDistributionSerializationImplVltVaultDistributionProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingDistributionSerializationImplVltVaultDistributionProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingDistributionSerializationImplVltVaultDistributionProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ) &&
                 (
                     ImportMode == other.ImportMode ||
                     ImportMode != null &&
                     ImportMode.Equals(other.ImportMode)
                 ) &&
                 (
                     AclHandling == other.AclHandling ||
                     AclHandling != null &&
                     AclHandling.Equals(other.AclHandling)
                 ) &&
                 (
                     PackageRoots == other.PackageRoots ||
                     PackageRoots != null &&
                     PackageRoots.Equals(other.PackageRoots)
                 ) &&
                 (
                     PackageFilters == other.PackageFilters ||
                     PackageFilters != null &&
                     PackageFilters.Equals(other.PackageFilters)
                 ) &&
                 (
                     PropertyFilters == other.PropertyFilters ||
                     PropertyFilters != null &&
                     PropertyFilters.Equals(other.PropertyFilters)
                 ) &&
                 (
                     TempFsFolder == other.TempFsFolder ||
                     TempFsFolder != null &&
                     TempFsFolder.Equals(other.TempFsFolder)
                 ) &&
                 (
                     UseBinaryReferences == other.UseBinaryReferences ||
                     UseBinaryReferences != null &&
                     UseBinaryReferences.Equals(other.UseBinaryReferences)
                 ) &&
                 (
                     AutoSaveThreshold == other.AutoSaveThreshold ||
                     AutoSaveThreshold != null &&
                     AutoSaveThreshold.Equals(other.AutoSaveThreshold)
                 ) &&
                 (
                     CleanupDelay == other.CleanupDelay ||
                     CleanupDelay != null &&
                     CleanupDelay.Equals(other.CleanupDelay)
                 ) &&
                 (
                     FileThreshold == other.FileThreshold ||
                     FileThreshold != null &&
                     FileThreshold.Equals(other.FileThreshold)
                 ) &&
                 (
                     MEGA_BYTES == other.MEGA_BYTES ||
                     MEGA_BYTES != null &&
                     MEGA_BYTES.Equals(other.MEGA_BYTES)
                 ) &&
                 (
                     UseOffHeapMemory == other.UseOffHeapMemory ||
                     UseOffHeapMemory != null &&
                     UseOffHeapMemory.Equals(other.UseOffHeapMemory)
                 ) &&
                 (
                     DigestAlgorithm == other.DigestAlgorithm ||
                     DigestAlgorithm != null &&
                     DigestAlgorithm.Equals(other.DigestAlgorithm)
                 ) &&
                 (
                     MonitoringQueueSize == other.MonitoringQueueSize ||
                     MonitoringQueueSize != null &&
                     MonitoringQueueSize.Equals(other.MonitoringQueueSize)
                 ) &&
                 (
                     PathsMapping == other.PathsMapping ||
                     PathsMapping != null &&
                     PathsMapping.Equals(other.PathsMapping)
                 ) &&
                 (
                     StrictImport == other.StrictImport ||
                     StrictImport != null &&
                     StrictImport.Equals(other.StrictImport)
                 ));
        }
コード例 #5
0
        /// <summary>
        /// Returns true if OrgApacheSlingDistributionSerializationImplDistributionPackageBuProperties instances are equal
        /// </summary>
        /// <param name="other">Instance of OrgApacheSlingDistributionSerializationImplDistributionPackageBuProperties to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(OrgApacheSlingDistributionSerializationImplDistributionPackageBuProperties other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Name == other.Name ||
                     Name != null &&
                     Name.Equals(other.Name)
                     ) &&
                 (
                     Type == other.Type ||
                     Type != null &&
                     Type.Equals(other.Type)
                 ) &&
                 (
                     FormatTarget == other.FormatTarget ||
                     FormatTarget != null &&
                     FormatTarget.Equals(other.FormatTarget)
                 ) &&
                 (
                     TempFsFolder == other.TempFsFolder ||
                     TempFsFolder != null &&
                     TempFsFolder.Equals(other.TempFsFolder)
                 ) &&
                 (
                     FileThreshold == other.FileThreshold ||
                     FileThreshold != null &&
                     FileThreshold.Equals(other.FileThreshold)
                 ) &&
                 (
                     MemoryUnit == other.MemoryUnit ||
                     MemoryUnit != null &&
                     MemoryUnit.Equals(other.MemoryUnit)
                 ) &&
                 (
                     UseOffHeapMemory == other.UseOffHeapMemory ||
                     UseOffHeapMemory != null &&
                     UseOffHeapMemory.Equals(other.UseOffHeapMemory)
                 ) &&
                 (
                     DigestAlgorithm == other.DigestAlgorithm ||
                     DigestAlgorithm != null &&
                     DigestAlgorithm.Equals(other.DigestAlgorithm)
                 ) &&
                 (
                     MonitoringQueueSize == other.MonitoringQueueSize ||
                     MonitoringQueueSize != null &&
                     MonitoringQueueSize.Equals(other.MonitoringQueueSize)
                 ) &&
                 (
                     CleanupDelay == other.CleanupDelay ||
                     CleanupDelay != null &&
                     CleanupDelay.Equals(other.CleanupDelay)
                 ) &&
                 (
                     PackageFilters == other.PackageFilters ||
                     PackageFilters != null &&
                     PackageFilters.Equals(other.PackageFilters)
                 ) &&
                 (
                     PropertyFilters == other.PropertyFilters ||
                     PropertyFilters != null &&
                     PropertyFilters.Equals(other.PropertyFilters)
                 ));
        }