Example usage for java.math BigInteger equals

List of usage examples for java.math BigInteger equals

Introduction

In this page you can find the example usage for java.math BigInteger equals.

Prototype

public boolean equals(Object x) 

Source Link

Document

Compares this BigInteger with the specified Object for equality.

Usage

From source file:eu.europa.ec.markt.dss.validation102853.xades.XAdESSignature.java

@Override
public SigningCertificate getSigningCertificate() {

    if (signingCert == null) {

        try {/*from w w  w. j ava2s.  c  o m*/

            signingCert = new SigningCertificate();
            /**
             * The ../SignedProperties/SignedSignatureProperties/SigningCertificate element MAY contain references and
             * digests values of other certificates (that MAY form a chain up to the point of trust).
             */

            final NodeList list = DSSXMLUtils.getNodeList(signatureElement, XPATH_SIGNING_CERTIFICATE_CERT);
            for (int ii = 0; ii < list.getLength(); ii++) {

                final Element element = (Element) list.item(ii);

                final Element digestMethodEl = DSSXMLUtils.getElement(element, XPATH__DIGEST_METHOD);
                if (digestMethodEl == null) {
                    continue;
                }
                final String xmlAlgoName = digestMethodEl.getAttribute(XMLE_ALGORITHM);
                final DigestAlgorithm digestAlgorithm = DigestAlgorithm.forXML(xmlAlgoName);
                final String shortAlgoNam = digestAlgorithm.getName();

                final Element digestValueEl = DSSXMLUtils.getElement(element, XPATH__CERT_DIGEST_DIGEST_VALUE);
                if (digestValueEl == null) {
                    continue;
                }
                final String digestValueBase64 = digestValueEl.getTextContent();

                /**
                 * 5.1.4.1 XAdES processing<br>
                 * <i>Candidates for the signing certificate extracted from ds:KeyInfo element</i> shall be checked
                 * against all references present in the ds:SigningCertificate property, if present, since one of these
                 * references shall be a reference to the signing certificate.
                 */
                final XAdESCertificateSource certSource = getCertificateSource();
                certSource.extract();
                for (CertificateToken token : certSource.getKeyInfoCertificates()) {

                    /**
                     * Step 1:<br>
                     * Take the first child of the property and check that the content of ds:DigestValue matches the
                     * result of digesting <i>the candidate for</i> the signing certificate with the algorithm indicated
                     * in ds:DigestMethod. If they do not match, take the next child and repeat this step until a matching
                     * child element has been found or all children of the element have been checked. If they do match,
                     * continue with step 2. If the last element is reached without finding any match, the validation of
                     * this property shall be taken as failed and INVALID/FORMAT_FAILURE is returned.
                     */
                    final String encoded;
                    if (digestAlgorithm.equals(DigestAlgorithm.RIPEMD160)) {

                        final RIPEMD160Digest digest = new RIPEMD160Digest();
                        final byte[] message = token.getCertificate().getEncoded();
                        digest.update(message, 0, message.length);
                        final byte[] digestValue = new byte[digest.getDigestSize()];
                        digest.doFinal(digestValue, 0);
                        encoded = DSSUtils.base64Encode(digestValue);
                    } else {

                        final MessageDigest digest = MessageDigest.getInstance(shortAlgoNam);
                        digest.update(token.getCertificate().getEncoded());
                        encoded = DSSUtils.base64Encode(digest.digest());
                    }
                    signingCert.setDigestMatch(false);
                    if (encoded.equals(digestValueBase64)) {

                        final Element issuerNameEl = DSSXMLUtils.getElement(element, XPATH__X509_ISSUER_NAME);
                        final X500Principal issuerName = new X500Principal(issuerNameEl.getTextContent());
                        final X500Principal candidateIssuerName = token.getIssuerX500Principal();
                        final boolean issuerNameMatches = candidateIssuerName.equals(issuerName);

                        final Element serialNumberEl = DSSXMLUtils.getElement(element,
                                XPATH__X509_SERIAL_NUMBER);
                        final BigInteger serialNumber = new BigInteger(serialNumberEl.getTextContent());
                        final BigInteger candidateSerialNumber = token.getSerialNumber();
                        final boolean serialNumberMatches = candidateSerialNumber.equals(serialNumber);

                        signingCert.setDigestMatch(true);
                        signingCert.setSerialNumberMatch(serialNumberMatches && issuerNameMatches);
                        signingCert.setCertToken(token);
                        return signingCert;
                    }
                }
            }
        } catch (NoSuchAlgorithmException e) {

            throw new DSSException(e);
        } catch (CertificateEncodingException e) {

            throw new DSSException(e);
        }
    }
    return signingCert;
}

From source file:org.opendaylight.netvirt.elan.internal.ElanInterfaceManager.java

void addElanInterface(List<ListenableFuture<Void>> futures, ElanInterface elanInterface,
        InterfaceInfo interfaceInfo, ElanInstance elanInstance) throws ElanException {
    Preconditions.checkNotNull(elanInstance, "elanInstance cannot be null");
    Preconditions.checkNotNull(interfaceInfo, "interfaceInfo cannot be null");
    Preconditions.checkNotNull(elanInterface, "elanInterface cannot be null");

    String interfaceName = elanInterface.getName();
    String elanInstanceName = elanInterface.getElanInstanceName();

    Elan elanInfo = ElanUtils.getElanByName(broker, elanInstanceName);
    WriteTransaction tx = broker.newWriteOnlyTransaction();
    if (elanInfo == null) {
        List<String> elanInterfaces = new ArrayList<>();
        elanInterfaces.add(interfaceName);
        ElanUtils.updateOperationalDataStore(broker, idManager, elanInstance, elanInterfaces, tx);
    } else {/*from  w ww.j  av a 2s . co  m*/
        createElanStateList(elanInstanceName, interfaceName, tx);
    }
    boolean isFirstInterfaceInDpn = false;
    // Specific actions to the DPN where the ElanInterface has been added,
    // for example, programming the
    // External tunnel table if needed or adding the ElanInterface to the
    // DpnInterfaces in the operational DS.
    BigInteger dpId = interfaceInfo != null ? dpId = interfaceInfo.getDpId() : null;
    DpnInterfaces dpnInterfaces = null;
    if (dpId != null && !dpId.equals(ElanConstants.INVALID_DPN)) {
        InstanceIdentifier<DpnInterfaces> elanDpnInterfaces = ElanUtils
                .getElanDpnInterfaceOperationalDataPath(elanInstanceName, dpId);
        Optional<DpnInterfaces> existingElanDpnInterfaces = elanUtils.read(broker,
                LogicalDatastoreType.OPERATIONAL, elanDpnInterfaces);
        if (!existingElanDpnInterfaces.isPresent()) {
            isFirstInterfaceInDpn = true;
            // ELAN's 1st ElanInterface added to this DPN
            dpnInterfaces = createElanInterfacesList(elanInstanceName, interfaceName, dpId, tx);
            // The 1st ElanInterface in a DPN must program the Ext Tunnel
            // table, but only if Elan has VNI
            if ((ElanUtils.isVxlan(elanInstance) || (ElanUtils.isVxlanSegment(elanInstance)))) {
                setExternalTunnelTable(dpId, elanInstance);
            }
            elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
        } else {
            List<String> elanInterfaces = existingElanDpnInterfaces.get().getInterfaces();
            elanInterfaces.add(interfaceName);
            if (elanInterfaces.size() == 1) { // 1st dpn interface
                elanL2GatewayUtils.installElanL2gwDevicesLocalMacsInDpn(dpId, elanInstance, interfaceName);
            }
            dpnInterfaces = updateElanDpnInterfacesList(elanInstanceName, dpId, elanInterfaces, tx);
        }
    }

    // add code to install Local/Remote BC group, unknow DMAC entry,
    // terminating service table flow entry
    // call bindservice of interfacemanager to create ingress table flow
    // enty.
    // Add interface to the ElanInterfaceForwardingEntires Container
    createElanInterfaceTablesList(interfaceName, tx);
    if (interfaceInfo != null) {
        installEntriesForFirstInterfaceonDpn(elanInstance, interfaceInfo, dpnInterfaces, isFirstInterfaceInDpn,
                tx);
    }
    futures.add(ElanUtils.waitForTransactionToComplete(tx));
    if (isFirstInterfaceInDpn && (ElanUtils.isVxlan(elanInstance) || ElanUtils.isVxlanSegment(elanInstance))) {
        //update the remote-DPNs remoteBC group entry with Tunnels
        LOG.trace("update remote bc group for elan {} on other DPNs for newly added dpn {}", elanInstance,
                dpId);
        setElanAndEtreeBCGrouponOtherDpns(elanInstance, dpId);
    }

    DataStoreJobCoordinator coordinator = DataStoreJobCoordinator.getInstance();
    InterfaceAddWorkerOnElanInterface addWorker = new InterfaceAddWorkerOnElanInterface(interfaceName,
            elanInterface, interfaceInfo, elanInstance, isFirstInterfaceInDpn, this);
    coordinator.enqueueJob(interfaceName, addWorker, ElanConstants.JOB_MAX_RETRIES);
}

From source file:org.opendaylight.netvirt.vpnmanager.VpnUtil.java

static java.util.Optional<String> allocateRdForExtraRouteAndUpdateUsedRdsMap(DataBroker dataBroker, long vpnId,
        Optional<Long> parentVpnId, String prefix, String vpnName, BigInteger dpnId,
        WriteTransaction writeOperTxn) {
    List<String> usedRds = getUsedRds(dataBroker, vpnId, prefix);
    //Check if rd is already allocated for the same prefix. Use same rd if extra route is behind same CSS.
    java.util.Optional<String> rdToAllocate = usedRds.stream().map(usedRd -> {
        Optional<Routes> vpnExtraRoutes = VpnExtraRouteHelper.getVpnExtraroutes(dataBroker, vpnName, usedRd,
                prefix);//from w w  w  .j  a v  a  2  s  .c  o m
        return vpnExtraRoutes.isPresent()
                ? new ImmutablePair<String, String>(vpnExtraRoutes.get().getNexthopIpList().get(0), usedRd)
                : new ImmutablePair<>("", "");
    }).filter(pair -> {
        if (pair.getLeft().isEmpty()) {
            return false;
        }
        Optional<Prefixes> prefixToInterface;
        //In case of VPN importing the routes, the interface is not present in the VPN
        //and has to be fetched from the VPN from which it imports
        if (parentVpnId.isPresent()) {
            prefixToInterface = getPrefixToInterface(dataBroker, parentVpnId.get(), pair.getLeft());
        } else {
            prefixToInterface = getPrefixToInterface(dataBroker, vpnId, pair.getLeft());
        }
        return prefixToInterface.isPresent() ? dpnId.equals(prefixToInterface.get().getDpnId()) : false;
    }).map(pair -> pair.getRight()).findFirst();
    if (rdToAllocate.isPresent()) {
        return rdToAllocate;
    }
    List<String> availableRds = getVpnRdsFromVpnInstanceConfig(dataBroker, vpnName);
    if (availableRds.isEmpty()) {
        LOG.debug("Internal vpn. Returning vpn name {} as rd", vpnName);
        usedRds.add(vpnName);
        syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, getUsedRdsIdentifier(vpnId, prefix),
                getDestPrefixesBuilder(prefix, usedRds).build());
        return java.util.Optional.ofNullable(vpnName);
    }
    LOG.trace(
            "Removing used rds {} from available rds {} vpnid {} . prefix is {} , vpname- {}, dpnId- {}, adj - {}",
            usedRds, availableRds, vpnId, prefix, vpnName, dpnId);
    availableRds.removeAll(usedRds);
    if (availableRds.isEmpty()) {
        LOG.error("No rd available from VpnInstance to allocate for prefix {}", prefix);
        return java.util.Optional.empty();
    }
    // If rd is not allocated for this prefix or if extra route is behind different CSS, select a new rd.
    String rd = availableRds.get(0);
    usedRds.add(rd);
    syncUpdate(dataBroker, LogicalDatastoreType.CONFIGURATION, getUsedRdsIdentifier(vpnId, prefix),
            getDestPrefixesBuilder(prefix, usedRds).build());
    return java.util.Optional.ofNullable(rd);
}

From source file:eu.europa.esig.dss.cades.validation.CAdESSignature.java

private boolean verifySigningCertificateReferences(final BigInteger signingTokenSerialNumber,
        final GeneralNames signingTokenIssuerName, final byte[] signingTokenCertHash, final byte[] certHash,
        final IssuerSerial issuerSerial) {

    signingCertificateValidity.setDigest(Base64.encodeBase64String(signingTokenCertHash));
    final boolean hashEqual = Arrays.equals(certHash, signingTokenCertHash);
    signingCertificateValidity.setDigestEqual(hashEqual);

    if (issuerSerial != null) {
        final BigInteger serialNumber = issuerSerial.getSerial().getValue();
        boolean serialNumberEqual = serialNumber.equals(signingTokenSerialNumber);
        signingCertificateValidity.setSerialNumberEqual(serialNumberEqual);

        final GeneralNames issuerName = issuerSerial.getIssuer();

        final String canonicalizedIssuerName = DSSASN1Utils.getCanonicalizedName(issuerName);
        final String canonicalizedSigningTokenIssuerName = DSSASN1Utils
                .getCanonicalizedName(signingTokenIssuerName);

        // DOES NOT WORK IN ALL CASES:
        // issuerNameEqual = issuerName.equals(signingTokenIssuerName);
        boolean issuerNameEqual = canonicalizedIssuerName.equals(canonicalizedSigningTokenIssuerName);
        signingCertificateValidity.setDistinguishedNameEqual(issuerNameEqual);
    }//from w  w w.  j a v  a2s. co m
    // Validation of the hash is sufficient
    return hashEqual;
}

From source file:com.kncwallet.wallet.ui.SendCoinsFragment.java

private void handleGo() {
    // create spend
    final BigInteger amount = amountCalculatorLink.getAmount();
    final SendRequest sendRequest = SendRequest.to(validatedAddress.address, amount);
    sendRequest.changeAddress = WalletUtils.pickOldestKey(wallet).toAddress(Constants.NETWORK_PARAMETERS);
    sendRequest.emptyWallet = amount.equals(wallet.getBalance(BalanceType.AVAILABLE));

    clearActionMode();// ww  w  .ja va2 s  .  c o m
    forceHideKeyboard();

    lookupContactBeforeSend(sendRequest, validatedAddress.address.toString());

}

From source file:org.estatio.api.Api.java

private LeaseTerm putLeaseTerm(final String leaseReference, final String unitReference,
        final BigInteger itemSequence, final String itemType, final LocalDate itemStartDate,
        final LocalDate startDate, final LocalDate endDate, final BigInteger sequence, final String statusStr) {
    final Lease lease = fetchLease(leaseReference);
    final Unit unit;
    if (unitReference != null) {
        unit = units.findUnitByReference(unitReference);
        if (unitReference != null && unit == null) {
            throw new ApplicationException(String.format("Unit with reference %s not found.", unitReference));
        }//from w  ww . j av a2 s .co m
    }
    final LeaseItemType leaseItemType = fetchLeaseItemType(itemType);
    final LeaseItem item = lease.findItem(leaseItemType, itemStartDate, itemSequence);
    if (item == null) {
        throw new ApplicationException(
                String.format("LeaseItem with reference %1$s, %2$s, %3$s, %4$s not found.", leaseReference,
                        leaseItemType.toString(), itemStartDate.toString(), itemSequence.toString()));
    }
    LeaseTerm term = item.findTermWithSequence(sequence);
    if (term == null) {
        if (sequence.equals(BigInteger.ONE)) {
            term = item.newTerm(startDate, endDate);
        } else {
            final LeaseTerm previousTerm = item.findTermWithSequence(sequence.subtract(BigInteger.ONE));
            term = previousTerm.createNext(startDate, endDate);
        }
        term.setSequence(sequence);
    }
    term.setStatus(org.estatio.dom.lease.LeaseTermStatus.valueOf(statusStr));
    return term;
}

From source file:org.sparkbit.jsonrpc.SparkBitJSONRPCServiceImpl.java

@Override
public Boolean deleteasset(String walletname, String assetRef) throws com.bitmechanic.barrister.RpcException {
    log.info("DELETE ASSET");
    log.info("wallet name = " + walletname);
    log.info("asset ref   = " + assetRef);

    Wallet w = getWalletForWalletName(walletname);
    boolean success = false;
    CSAsset asset = getAssetForAssetRefString(w, assetRef);
    if (asset != null) {
        int assetID = asset.getAssetID();
        BigInteger x = w.CS.getAssetBalance(assetID).total;
        boolean canDelete = x.equals(BigInteger.ZERO);

        // Delete invalid asset if property allows
        String s = controller.getModel().getUserPreference(BitcoinModel.CAN_DELETE_INVALID_ASSETS);
        boolean isAssetInvalid = asset.getAssetState() != CSAsset.CSAssetState.VALID;
        boolean deleteInvalidAsset = false;
        if (Boolean.TRUE.toString().equals(s) && isAssetInvalid) {
            deleteInvalidAsset = true;//www.  j  av a2  s. c  om
        }

        if (canDelete || deleteInvalidAsset) {
            success = w.CS.deleteAsset(asset);
            if (success) {
                // Note: the event can be fired, but the listener can do nothing if in headless mode.
                // We want main asset panel to refresh, since there isn't an event fired on manual reset.
                CSEventBus.INSTANCE.postAsyncEvent(CSEventType.ASSET_DELETED, assetID);
            } else {
                JSONRPCError.DELETE_ASSET_FAILED.raiseRpcException();
            }
        } else {
            if (isAssetInvalid) {
                JSONRPCError.DELETE_INVALID_ASSET_FAILED.raiseRpcException();
            } else {
                JSONRPCError.DELETE_ASSET_NONZERO_BALANCE.raiseRpcException();
            }
        }
    } else {
        if (isAssetRefValid(assetRef)) {
            JSONRPCError.ASSETREF_NOT_FOUND.raiseRpcException();
        } else {
            JSONRPCError.ASSETREF_INVALID.raiseRpcException();
        }
    }
    return success;
}

From source file:org.opendaylight.netvirt.elan.utils.ElanUtils.java

private boolean executeDeleteMacFlows(ElanInstance elanInfo, InterfaceInfo interfaceInfo, String macAddress,
        boolean deleteSmac, String elanInstanceName, BigInteger srcdpId, Long elanTag, BigInteger dstDpId,
        WriteTransaction deleteFlowGroupTx) {
    boolean isFlowsRemovedInSrcDpn = false;
    if (dstDpId.equals(srcdpId)) {
        isFlowsRemovedInSrcDpn = true;//from w  w w  . j  a v a 2  s. com
        deleteSmacAndDmacFlows(elanInfo, interfaceInfo, macAddress, deleteSmac, deleteFlowGroupTx);
    } else if (isDpnPresent(dstDpId)) {
        mdsalManager.removeFlowToTx(dstDpId,
                MDSALUtil.buildFlow(NwConstants.ELAN_DMAC_TABLE, getKnownDynamicmacFlowRef(
                        NwConstants.ELAN_DMAC_TABLE, dstDpId, srcdpId, macAddress, elanTag)),
                deleteFlowGroupTx);
        LOG.debug("Dmac flow entry deleted for elan:{}, logical interface port:{} and mac address:{} on dpn:{}",
                elanInstanceName, interfaceInfo.getPortName(), macAddress, dstDpId);
    }
    return isFlowsRemovedInSrcDpn;
}

From source file:eu.europa.esig.dss.xades.validation.XAdESSignature.java

@Override
public void checkSigningCertificate() {

    final CandidatesForSigningCertificate candidates = getCandidatesForSigningCertificate();
    /**//from www  .jav  a 2 s .co  m
     * The ../SignedProperties/SignedSignatureProperties/SigningCertificate element MAY contain references and digests values of other
     * certificates (that MAY form a chain up to the point of trust).
     */
    boolean isEn319132 = false;
    NodeList list = DSSXMLUtils.getNodeList(signatureElement, xPathQueryHolder.XPATH_SIGNING_CERTIFICATE_CERT);
    int length = list.getLength();
    if (length == 0) {
        list = DSSXMLUtils.getNodeList(signatureElement, xPathQueryHolder.XPATH_SIGNING_CERTIFICATE_CERT_V2);
        length = list.getLength();
        isEn319132 = true;
    }
    if (length == 0) {
        final CertificateValidity theCertificateValidity = candidates.getTheCertificateValidity();
        final CertificateToken certificateToken = theCertificateValidity == null ? null
                : theCertificateValidity.getCertificateToken();
        // The check need to be done at the level of KeyInfo
        for (final Reference reference : references) {

            final String uri = reference.getURI();
            if (!uri.startsWith("#")) {
                continue;
            }

            final String id = uri.substring(1);
            final Element element = signatureElement.getOwnerDocument().getElementById(id);
            // final Element element =
            // DSSXMLUtils.getElement(signatureElement, "");
            if (!hasSignatureAsParent(element)) {

                continue;
            }
            if ((certificateToken != null) && id.equals(certificateToken.getXmlId())) {

                theCertificateValidity.setSigned(element.getNodeName());
                return;
            }
        }
    }
    // This Map contains the list of the references to the certificate which
    // were already checked and which correspond to a certificate.
    Map<Element, Boolean> alreadyProcessedElements = new HashMap<Element, Boolean>();

    final List<CertificateValidity> certificateValidityList = candidates.getCertificateValidityList();
    for (final CertificateValidity certificateValidity : certificateValidityList) {

        final CertificateToken certificateToken = certificateValidity.getCertificateToken();
        for (int ii = 0; ii < length; ii++) {

            certificateValidity.setAttributePresent(true);
            final Element element = (Element) list.item(ii);
            if (alreadyProcessedElements.containsKey(element)) {
                continue;
            }
            final Element certDigestElement = DSSXMLUtils.getElement(element,
                    xPathQueryHolder.XPATH__CERT_DIGEST);
            certificateValidity.setDigestPresent(certDigestElement != null);

            final Element digestMethodElement = DSSXMLUtils.getElement(certDigestElement,
                    xPathQueryHolder.XPATH__DIGEST_METHOD);
            if (digestMethodElement == null) {
                continue;
            }
            final String xmlAlgorithmName = digestMethodElement.getAttribute(XMLE_ALGORITHM);
            // The default algorithm is used in case of bad encoded
            // algorithm name
            final DigestAlgorithm digestAlgorithm = DigestAlgorithm.forXML(xmlAlgorithmName,
                    DigestAlgorithm.SHA1);

            final Element digestValueElement = DSSXMLUtils.getElement(element,
                    xPathQueryHolder.XPATH__CERT_DIGEST_DIGEST_VALUE);
            if (digestValueElement == null) {
                continue;
            }
            // That must be a binary comparison
            final byte[] storedBase64DigestValue = DSSUtils
                    .base64StringToBase64Binary(digestValueElement.getTextContent());

            /**
             * Step 1:<br>
             * Take the first child of the property and check that the content of ds:DigestValue matches the result of digesting <i>the candidate
             * for</i> the signing certificate with the algorithm indicated in ds:DigestMethod. If they do not match, take the next child and
             * repeat this step until a matching child element has been found or all children of the element have been checked. If they do match,
             * continue with step 2. If the last element is reached without finding any match, the validation of this property shall be taken as
             * failed and INVALID/FORMAT_FAILURE is returned.
             */
            final byte[] digest = DSSUtils.digest(digestAlgorithm, certificateToken.getEncoded());
            final byte[] recalculatedBase64DigestValue = Base64.encodeBase64(digest);
            certificateValidity.setDigestEqual(false);
            BigInteger serialNumber = new BigInteger("0");
            if (Arrays.equals(recalculatedBase64DigestValue, storedBase64DigestValue)) {
                X500Principal issuerName = null;
                if (isEn319132) {
                    final Element issuerNameEl = DSSXMLUtils.getElement(element,
                            xPathQueryHolder.XPATH__X509_ISSUER_V2);
                    if (issuerNameEl != null) {
                        final String textContent = issuerNameEl.getTextContent();
                        ASN1InputStream is = new ASN1InputStream(Base64.decodeBase64(textContent));
                        ASN1Sequence seq = null;
                        try {
                            seq = (ASN1Sequence) is.readObject();
                            is.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                        //IssuerAndSerialNumber issuerAndSerial = new IssuerAndSerialNumber(seq);
                        IssuerAndSerialNumber issuerAndSerial = IssuerAndSerialNumber.getInstance(seq);
                        issuerName = new X500Principal(issuerAndSerial.getName().toString());
                        serialNumber = issuerAndSerial.getSerialNumber().getValue();
                    }
                } else {
                    final Element issuerNameEl = DSSXMLUtils.getElement(element,
                            xPathQueryHolder.XPATH__X509_ISSUER_NAME);
                    // This can be allayed when the distinguished name is not
                    // correctly encoded
                    // final String textContent =
                    // DSSUtils.unescapeMultiByteUtf8Literals(issuerNameEl.getTextContent());
                    final String textContent = issuerNameEl.getTextContent();

                    issuerName = DSSUtils.getX500PrincipalOrNull(textContent);
                }
                final X500Principal candidateIssuerName = certificateToken.getIssuerX500Principal();

                // final boolean issuerNameMatches =
                // candidateIssuerName.equals(issuerName);
                final boolean issuerNameMatches = DSSUtils.x500PrincipalAreEquals(candidateIssuerName,
                        issuerName);
                if (!issuerNameMatches) {

                    final String c14nCandidateIssuerName = candidateIssuerName.getName(X500Principal.CANONICAL);
                    LOG.info("candidateIssuerName: " + c14nCandidateIssuerName);
                    final String c14nIssuerName = issuerName == null ? ""
                            : issuerName.getName(X500Principal.CANONICAL);
                    LOG.info("issuerName         : " + c14nIssuerName);
                }

                if (!isEn319132) {
                    final Element serialNumberEl = DSSXMLUtils.getElement(element,
                            xPathQueryHolder.XPATH__X509_SERIAL_NUMBER);
                    final String serialNumberText = serialNumberEl.getTextContent();
                    // serial number can contain leading and trailing whitespace.
                    serialNumber = new BigInteger(serialNumberText.trim());
                }
                final BigInteger candidateSerialNumber = certificateToken.getSerialNumber();
                final boolean serialNumberMatches = candidateSerialNumber.equals(serialNumber);

                certificateValidity.setDigestEqual(true);
                certificateValidity.setSerialNumberEqual(serialNumberMatches);
                certificateValidity.setDistinguishedNameEqual(issuerNameMatches);
                // The certificate was identified
                alreadyProcessedElements.put(element, true);
                // If the signing certificate is not set yet then it must be
                // done now. Actually if the signature is tempered then the
                // method checkSignatureIntegrity cannot set the signing
                // certificate.
                if (candidates.getTheCertificateValidity() == null) {

                    candidates.setTheCertificateValidity(certificateValidity);
                }
                break;
            }
        }
    }
}