本文整理汇总了Java中eu.europa.esig.dss.utils.Utils.isCollectionEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.isCollectionEmpty方法的具体用法?Java Utils.isCollectionEmpty怎么用?Java Utils.isCollectionEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eu.europa.esig.dss.utils.Utils
的用法示例。
在下文中一共展示了Utils.isCollectionEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSigner
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private DSSPrivateKeyEntry getSigner(List<DSSPrivateKeyEntry> keys) throws Exception {
DSSPrivateKeyEntry selectedKey = null;
if (Utils.isCollectionEmpty(keys)) {
throwException("No certificate found", null);
} else if (Utils.collectionSize(keys) == 1) {
selectedKey = keys.get(0);
} else {
FutureTask<DSSPrivateKeyEntry> future = new FutureTask<DSSPrivateKeyEntry>(new SelectCertificateTask(keys));
Platform.runLater(future);
selectedKey = future.get();
if (selectedKey == null) {
throwException("No selected certificate", null);
}
}
return selectedKey;
}
示例2: transformReference
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* Preconditions:
* - The reference data is XML
* - The last transformation is canonicalization.
*
* @param reference
* {@code DSSReference} to be transformed
* @return {@code DSSDocument} containing transformed reference's data
*/
@Override
protected DSSDocument transformReference(final DSSReference reference) {
DSSDocument dssDocument = reference.getContents();
final List<DSSTransform> transforms = reference.getTransforms();
if (Utils.isCollectionEmpty(transforms)) {
return dssDocument;
}
// In the case of ENVELOPED signature the document to sign is an XML. However one of the references can point to
// another document this test case is not taken into account!
Node nodeToTransform = null;
final String uri = reference.getUri();
// Check if the reference is related to the whole document
if (Utils.isStringNotBlank(uri) && uri.startsWith("#") && !isXPointer(uri)) {
final Document document = DomUtils.buildDOM(dssDocument);
DSSXMLUtils.recursiveIdBrowse(document.getDocumentElement());
final String uri_id = uri.substring(1);
nodeToTransform = document.getElementById(uri_id);
}
byte[] transformedReferenceBytes = applyTransformations(dssDocument, transforms, nodeToTransform);
return new InMemoryDocument(transformedReferenceBytes);
}
示例3: signDocument
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public DSSDocument signDocument(final DSSDocument toSignDocument, final XAdESSignatureParameters parameters, SignatureValue signatureValue)
throws DSSException {
if (parameters.getSignatureLevel() == null) {
throw new NullPointerException();
}
assertSigningDateInCertificateValidityRange(parameters);
parameters.getContext().setOperationKind(Operation.SIGNING);
SignatureProfile profile;
final ProfileParameters context = parameters.getContext();
if (context.getProfile() != null) {
profile = context.getProfile();
} else {
profile = new XAdESLevelBaselineB(certificateVerifier);
}
final DSSDocument signedDoc = profile.signDocument(toSignDocument, parameters, signatureValue.getValue());
final SignatureExtension<XAdESSignatureParameters> extension = getExtensionProfile(parameters);
if (extension != null) {
if (SignaturePackaging.DETACHED.equals(parameters.getSignaturePackaging()) && Utils.isCollectionEmpty(parameters.getDetachedContents())) {
List<DSSDocument> detachedContents = new ArrayList<DSSDocument>();
detachedContents.add(toSignDocument);
parameters.setDetachedContents(detachedContents);
}
final DSSDocument dssExtendedDocument = extension.extendSignatures(signedDoc, parameters);
// The deterministic id is reset between two consecutive signing operations. It prevents having two
// signatures with the same Id within the
// same document.
parameters.reinitDeterministicId();
dssExtendedDocument.setName(DSSUtils.getFinalFileName(toSignDocument, SigningOperation.SIGN, parameters.getSignatureLevel()));
return dssExtendedDocument;
}
parameters.reinitDeterministicId();
signedDoc.setName(DSSUtils.getFinalFileName(toSignDocument, SigningOperation.SIGN, parameters.getSignatureLevel()));
return signedDoc;
}
示例4: getQualifiedStatus
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public QualifiedStatus getQualifiedStatus() {
if (Utils.isCollectionEmpty(trustedServices)) {
return QualifiedStatus.NOT_QC;
} else {
for (TrustedServiceWrapper trustedService : trustedServices) {
List<String> capturedQualifiers = trustedService.getCapturedQualifiers();
// If overrules
if (Utils.isCollectionNotEmpty(capturedQualifiers)) {
if (ServiceQualification.isNotQualified(capturedQualifiers)) {
return QualifiedStatus.NOT_QC;
}
if (ServiceQualification.isQcStatement(capturedQualifiers)) {
return QualifiedStatus.QC;
}
}
}
return qualifiedInCert.getQualifiedStatus();
}
}
示例5: check
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public boolean check() {
if (Utils.isCollectionEmpty(trustedServices) || !qualified.check()) {
return false;
} else {
for (TrustedServiceWrapper trustedService : trustedServices) {
List<String> capturedQualifiers = trustedService.getCapturedQualifiers();
// If overrules
if (Utils.isCollectionNotEmpty(capturedQualifiers)) {
if (ServiceQualification.isQcNoQSCD(capturedQualifiers)) {
return false;
}
if (ServiceQualification.isQcWithQSCD(capturedQualifiers) || ServiceQualification.isQcQSCDManagedOnBehalf(capturedQualifiers)) {
return true;
}
}
}
return qscdFromCertificate.check();
}
}
示例6: isAllCertsHaveRevocationData
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private boolean isAllCertsHaveRevocationData(List<CertificateToken> certificates) {
for (CertificateToken certificateToken : certificates) {
if (isRevocationDataNotRequired(certificateToken)) {
// TODO we suppose that the certificate chain is well ordered
// It returns true to avoid checking upper levels than trusted certificates (cross certification)
return true;
}
Set<RevocationToken> revocationData = certificateToken.getRevocationTokens();
if (Utils.isCollectionEmpty(revocationData)) {
return false;
} else {
boolean foundInSignature = false;
for (RevocationToken revocationToken : revocationData) {
if (RevocationOrigin.SIGNATURE == revocationToken.getOrigin()) {
foundInSignature = true;
}
}
if (!foundInSignature) {
return false;
}
}
}
return true;
}
示例7: fromDocument
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* This method guesses the document format and returns an appropriate
* document validator.
*
* @param dssDocument
* The instance of {@code DSSDocument} to validate
* @return returns the specific instance of SignedDocumentValidator in terms
* of the document type
*/
public static SignedDocumentValidator fromDocument(final DSSDocument dssDocument) {
if (Utils.isCollectionEmpty(registredDocumentValidators)) {
throw new DSSException("No validator registred");
}
for (Class<SignedDocumentValidator> clazz : registredDocumentValidators) {
try {
Constructor<SignedDocumentValidator> defaultAndPrivateConstructor = clazz.getDeclaredConstructor();
defaultAndPrivateConstructor.setAccessible(true);
SignedDocumentValidator validator = defaultAndPrivateConstructor.newInstance();
if (validator.isSupported(dssDocument)) {
Constructor<? extends SignedDocumentValidator> constructor = clazz.getDeclaredConstructor(DSSDocument.class);
return constructor.newInstance(dssDocument);
}
} catch (Exception e) {
LOG.error("Cannot instanciate class '" + clazz.getName() + "' : " + e.getMessage(), e);
}
}
throw new DSSException("Document format not recognized/handled");
}
示例8: loadPotentialIssuerCertificates
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* This method loads the potential issuer certificate(s) from the given locations (AIA).
*
* @param cert
* certificate for which the issuer(s) should be loaded
* @param loader
* the data loader to use
* @return a list of potential issuers
*/
public static Collection<CertificateToken> loadPotentialIssuerCertificates(final CertificateToken cert, final DataLoader loader) {
List<String> urls = DSSASN1Utils.getCAAccessLocations(cert);
if (Utils.isCollectionEmpty(urls)) {
LOG.info("There is no AIA extension for certificate download.");
return Collections.emptyList();
}
if (loader == null) {
LOG.warn("There is no DataLoader defined to load Certificates from AIA extension (urls : {})", urls);
return Collections.emptyList();
}
for (String url : urls) {
LOG.debug("Loading certificate(s) from {}", url);
byte[] bytes = loader.get(url);
if (Utils.isArrayNotEmpty(bytes)) {
LOG.debug("Base64 content : {}", Utils.toBase64(bytes));
try (InputStream is = new ByteArrayInputStream(bytes)) {
return loadCertificates(is);
} catch (Exception e) {
LOG.warn("Unable to parse certificate(s) from AIA (url: {}) : {}", url, e.getMessage());
}
} else {
LOG.warn("Empty content from {}.", url);
}
}
return Collections.emptyList();
}
示例9: findCrl
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public CRLToken findCrl(final CertificateToken certificateToken) throws DSSException {
if (certificateToken == null) {
return null;
}
final CertificateToken issuerToken = certificateToken.getIssuerToken();
if (issuerToken == null) {
return null;
}
final List<String> crlUrls = DSSASN1Utils.getCrlUrls(certificateToken);
LOG.info("CRL's URL for " + certificateToken.getAbbreviation() + " : " + crlUrls);
if (Utils.isCollectionEmpty(crlUrls)) {
return null;
}
prioritize(crlUrls);
final DataLoader.DataAndUrl dataAndUrl = downloadCrl(crlUrls);
if (dataAndUrl == null) {
return null;
}
try (ByteArrayInputStream bais = new ByteArrayInputStream(dataAndUrl.data)) {
final CRLValidity crlValidity = CRLUtils.isValidCRL(bais, issuerToken);
final CRLToken crlToken = new CRLToken(certificateToken, crlValidity);
crlToken.setSourceURL(dataAndUrl.urlString);
crlToken.setAvailable(true);
return crlToken;
} catch (Exception e) {
LOG.warn("Unable to parse/validate the CRL (url:" + dataAndUrl.urlString + ") : " + e.getMessage(), e);
return null;
}
}
示例10: process
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
protected boolean process() {
if (Utils.isCollectionNotEmpty(trustedServices)) {
boolean esign = QCTypeIdentifiers.isQCTypeEsign(signingCertificate);
boolean eseal = QCTypeIdentifiers.isQCTypeEseal(signingCertificate);
boolean web = QCTypeIdentifiers.isQCTypeWeb(signingCertificate);
for (TrustedServiceWrapper trustedService : trustedServices) {
List<String> qualifiers = trustedService.getCapturedQualifiers();
List<String> usageQualifiers = ServiceQualification.getUsageQualifiers(qualifiers);
if (Utils.isCollectionEmpty(usageQualifiers)) {
List<String> asis = trustedService.getAdditionalServiceInfos();
if (esign && !AdditionalServiceInformation.isForeSignatures(asis)) {
errorMessage = MessageTag.QUAL_TL_CERT_CONS_ANS3;
return false;
} else if (eseal && !AdditionalServiceInformation.isForeSeals(asis)) {
errorMessage = MessageTag.QUAL_TL_CERT_CONS_ANS1;
return false;
} else if (web && !AdditionalServiceInformation.isForWebAuth(asis)) {
errorMessage = MessageTag.QUAL_TL_CERT_CONS_ANS2;
return false;
}
}
}
}
return true;
}
示例11: process
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
protected boolean process() {
if ("ASiC-S".equals(containerInfo.getContainerType())) { // ASiC-S no Manifest
message = MessageTag.BBB_FC_IMFP_ASICS;
error = MessageTag.BBB_FC_IMFP_ASICS_ANS;
return Utils.isCollectionEmpty(containerInfo.getManifestFiles());
} else { // ASiC-E one or more manifest
message = MessageTag.BBB_FC_IMFP_ASICE;
error = MessageTag.BBB_FC_IMFP_ASICE_ANS;
return Utils.isCollectionNotEmpty(containerInfo.getManifestFiles());
}
}
示例12: process
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
protected boolean process() {
List<String> commitmentTypeIdentifiers = signature.getCommitmentTypeIdentifiers();
List<String> expectedValues = constraint.getId();
if (Utils.isCollectionEmpty(commitmentTypeIdentifiers)) {
return false;
}
if (Utils.isCollectionNotEmpty(expectedValues)) {
return expectedValues.containsAll(commitmentTypeIdentifiers);
}
return true;
}
示例13: signDocument
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public DSSDocument signDocument(final DSSDocument toSignDocument, final CAdESSignatureParameters parameters, SignatureValue signatureValue)
throws DSSException {
assertSigningDateInCertificateValidityRange(parameters);
final SignaturePackaging packaging = parameters.getSignaturePackaging();
assertSignaturePackaging(packaging);
final SignatureAlgorithm signatureAlgorithm = parameters.getSignatureAlgorithm();
final CustomContentSigner customContentSigner = new CustomContentSigner(signatureAlgorithm.getJCEId(), signatureValue.getValue());
final SignerInfoGeneratorBuilder signerInfoGeneratorBuilder = cmsSignedDataBuilder.getSignerInfoGeneratorBuilder(parameters, true);
final CMSSignedData originalCmsSignedData = getCmsSignedData(toSignDocument, parameters);
if ((originalCmsSignedData == null) && SignaturePackaging.DETACHED.equals(packaging) && Utils.isCollectionEmpty(parameters.getDetachedContents())) {
parameters.setDetachedContents(Arrays.asList(toSignDocument));
}
final CMSSignedDataGenerator cmsSignedDataGenerator = cmsSignedDataBuilder.createCMSSignedDataGenerator(parameters, customContentSigner,
signerInfoGeneratorBuilder, originalCmsSignedData);
final DSSDocument toSignData = getToSignData(toSignDocument, parameters, originalCmsSignedData);
final CMSProcessableByteArray content = new CMSProcessableByteArray(DSSUtils.toByteArray(toSignData));
final boolean encapsulate = !SignaturePackaging.DETACHED.equals(packaging);
final CMSSignedData cmsSignedData = CMSUtils.generateCMSSignedData(cmsSignedDataGenerator, content, encapsulate);
DSSDocument signature = new CMSSignedDocument(cmsSignedData);
final SignatureLevel signatureLevel = parameters.getSignatureLevel();
if (!SignatureLevel.CAdES_BASELINE_B.equals(signatureLevel)) {
// true: Only the last signature will be extended
final SignatureExtension<CAdESSignatureParameters> extension = getExtensionProfile(parameters, true);
signature = extension.extendSignatures(signature, parameters);
}
signature.setName(DSSUtils.getFinalFileName(toSignDocument, SigningOperation.SIGN, parameters.getSignatureLevel()));
parameters.reinitDeterministicId();
return signature;
}
示例14: hasLTProfile
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
public boolean hasLTProfile() {
Map<String, List<CertificateToken>> certificateChains = getCertificatesWithinSignatureAndTimestamps(true);
boolean emptyOCSPs = Utils.isCollectionEmpty(getOCSPSource().getContainedOCSPResponses());
boolean emptyCRLs = Utils.isCollectionEmpty(getCRLSource().getContainedX509CRLs());
if (certificateChains.isEmpty() && (emptyOCSPs || emptyCRLs)) {
return false;
}
if (!isAllCertChainsHaveRevocationData(certificateChains)) {
return false;
}
return true;
}
示例15: getCrlUrls
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* Gives back the {@code List} of CRL URI meta-data found within the given X509 certificate.
*
* @param certificateToken
* the cert token certificate
* @param checkInTrustAnchors
* if true, the method will search in the ServiceSupplyPoint urls
* @return the {@code List} of CRL URI, or empty list if the extension is not present
*/
public static List<String> getCrlUrls(final CertificateToken certificateToken, boolean checkInTrustAnchors) {
final List<String> urls = new ArrayList<String>();
final byte[] crlDistributionPointsBytes = certificateToken.getCertificate().getExtensionValue(Extension.cRLDistributionPoints.getId());
if (crlDistributionPointsBytes != null) {
try {
final ASN1Sequence asn1Sequence = DSSASN1Utils.getAsn1SequenceFromDerOctetString(crlDistributionPointsBytes);
final CRLDistPoint distPoint = CRLDistPoint.getInstance(asn1Sequence);
final DistributionPoint[] distributionPoints = distPoint.getDistributionPoints();
for (final DistributionPoint distributionPoint : distributionPoints) {
final DistributionPointName distributionPointName = distributionPoint.getDistributionPoint();
if (DistributionPointName.FULL_NAME != distributionPointName.getType()) {
continue;
}
final GeneralNames generalNames = (GeneralNames) distributionPointName.getName();
final GeneralName[] names = generalNames.getNames();
for (final GeneralName name : names) {
String location = parseGn(name);
if (location != null) {
urls.add(location);
}
}
}
} catch (Exception e) {
LOG.error("Unable to parse cRLDistributionPoints", e);
}
}
if (Utils.isCollectionEmpty(urls) && checkInTrustAnchors) {
return getServiceSupplyPoints(certificateToken, "crl", "certificateRevocationList");
}
return urls;
}