本文整理汇总了Java中eu.europa.esig.dss.utils.Utils.collectionSize方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.collectionSize方法的具体用法?Java Utils.collectionSize怎么用?Java Utils.collectionSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eu.europa.esig.dss.utils.Utils
的用法示例。
在下文中一共展示了Utils.collectionSize方法的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: testLoadAddAndDelete
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Test
public void testLoadAddAndDelete() throws IOException {
KeyStoreCertificateSource kscs = new KeyStoreCertificateSource(new File(KEYSTORE_FILEPATH), KEYSTORE_TYPE, KEYSTORE_PASSWORD);
assertNotNull(kscs);
int startSize = Utils.collectionSize(kscs.getCertificates());
assertTrue(startSize > 0);
CertificateToken token = DSSUtils.loadCertificate(new File("src/test/resources/citizen_ca.cer"));
kscs.addCertificateToKeyStore(token);
int sizeAfterAdd = Utils.collectionSize(kscs.getCertificates());
assertEquals(sizeAfterAdd,startSize + 1);
String tokenId = token.getDSSIdAsString();
CertificateToken certificate = kscs.getCertificate(tokenId);
assertNotNull(certificate);
kscs.deleteCertificateFromKeyStore(tokenId);
int sizeAfterDelete = Utils.collectionSize(kscs.getCertificates());
assertEquals(sizeAfterDelete,startSize);
}
示例3: getContainerType
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
public static ASiCContainerType getContainerType(DSSDocument archive, DSSDocument mimetype, String zipComment, List<DSSDocument> signedDocuments) {
ASiCContainerType containerType = getContainerTypeFromMimeType(archive.getMimeType());
if (containerType == null) {
containerType = getContainerTypeFromMimeTypeDocument(mimetype);
if (containerType == null) {
containerType = getContainerTypeFromZipComment(zipComment);
}
}
if (containerType == null) {
LOG.warn("Unable to define the ASiC Container type with its properties");
if (Utils.collectionSize(signedDocuments) <= 1) {
containerType = ASiCContainerType.ASiC_S;
} else {
containerType = ASiCContainerType.ASiC_E;
}
}
return containerType;
}
示例4: incorporateDigestValue
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* This method creates the ds:DigestValue DOM object.
*
* @param parentDom
* @param digestAlgorithm
* digest algorithm
* @param originalDocument
* to digest array of bytes
*/
protected void incorporateDigestValue(final Element parentDom, final DigestAlgorithm digestAlgorithm, final DSSDocument originalDocument) {
// <ds:DigestValue>b/JEDQH2S1Nfe4Z3GSVtObN34aVB1kMrEbVQZswThfQ=</ds:DigestValue>
final Element digestValueDom = documentDom.createElementNS(XMLNS, DS_DIGEST_VALUE);
String base64EncodedDigestBytes = null;
if (params.isManifestSignature()) {
List<DSSReference> references = params.getReferences();
if (Utils.collectionSize(references) != 1) {
throw new DSSException("Unsupported operation");
}
DSSReference dssReference = references.get(0);
List<DSSTransform> transforms = dssReference.getTransforms();
if (Utils.collectionSize(transforms) != 1) {
throw new DSSException("Unsupported operation");
}
Document doc = DomUtils.buildDOM(originalDocument.openStream());
DSSTransform dssTransform = transforms.get(0);
byte[] bytes = DSSXMLUtils.canonicalizeSubtree(dssTransform.getAlgorithm(), doc);
base64EncodedDigestBytes = Utils.toBase64(DSSUtils.digest(digestAlgorithm, bytes));
LOG.trace("C14n Digest value {} --> {}", parentDom.getNodeName(), base64EncodedDigestBytes);
} else {
base64EncodedDigestBytes = originalDocument.getDigest(digestAlgorithm);
if (LOG.isTraceEnabled()) {
LOG.trace("Digest value {} --> {}", parentDom.getNodeName(), base64EncodedDigestBytes);
}
}
final Text textNode = documentDom.createTextNode(base64EncodedDigestBytes);
digestValueDom.appendChild(textNode);
parentDom.appendChild(digestValueDom);
}
示例5: getBasicBuildingBlocksSignatureId
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* Returns the id of the token. The signature is identified by its index: 0 for the first one.
*
* @param index
* (position/order) of the signature within the report
* @return {@code String} identifying the token
*/
public String getBasicBuildingBlocksSignatureId(final int index) {
List<XmlBasicBuildingBlocks> bbbs = jaxbDetailedReport.getBasicBuildingBlocks();
if (Utils.collectionSize(bbbs) >= index) {
XmlBasicBuildingBlocks bbb = jaxbDetailedReport.getBasicBuildingBlocks().get(index);
if (bbb != null) {
return bbb.getId();
}
}
return null;
}
示例6: isQualifierInAdditionServiceInfos
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private boolean isQualifierInAdditionServiceInfos(List<String> qualifiers, List<String> asis) {
if (Utils.collectionSize(asis) >= 1) {
if (Utils.collectionSize(qualifiers) == 1) { // Cannot have more than 1 usage
String currentUsage = qualifiers.get(0);
String expectedASI = CORRESPONDANCE_MAP_QUALIFIER_ASI.get(currentUsage);
return asis.contains(expectedASI);
}
}
return true;
}
示例7: process
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
protected boolean process() {
/* ASiC-S -> nb files = 1 */
if ("ASiC-S".equals(containerInfo.getContainerType())) {
return 1 == Utils.collectionSize(containerInfo.getContentFiles());
} else if ("ASiC-E".equals(containerInfo.getContainerType())) {
String signatureFilename = signature.getSignatureFilename();
List<String> coveredFiles = getCoveredFilesBySignatureFilename(signatureFilename);
List<String> contentFiles = containerInfo.getContentFiles();
// check manifest <> content
if (!sameContent(coveredFiles, contentFiles)) {
return false;
}
// XAdES -> check signature scope
if (signature.getFormat().startsWith("XAdES")) {
List<String> coveredFilesFromScrope = getCoveredFilesFromScrope();
return sameContent(coveredFilesFromScrope, contentFiles);
}
// CAdES -> manifest file is signed
return true;
}
return false;
}
示例8: getOriginalDocumentStream
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
public InputStream getOriginalDocumentStream() throws DSSException {
final CMSTypedData signedContent = cmsSignedData.getSignedContent();
if (signedContent != null) {
return new ByteArrayInputStream(CMSUtils.getSignedContent(signedContent));
} else if (Utils.collectionSize(detachedContents) == 1) {
return detachedContents.get(0).openStream();
} else {
throw new DSSException("Only enveloping and detached signatures are supported");
}
}
示例9: removeLastTimestamp
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private List<TimestampToken> removeLastTimestamp(List<TimestampToken> timestamps) {
List<TimestampToken> tsps = new ArrayList<TimestampToken>();
Collections.copy(timestamps, tsps);
if (Utils.collectionSize(tsps) > 1) {
Collections.sort(tsps, new TimestampByGenerationTimeComparator());
tsps.remove(tsps.size() - 1);
}
return tsps;
}
示例10: getSignedDocuments
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public List<DSSDocument> getSignedDocuments() {
if (signedDocuments == null) {
if (Utils.collectionSize(filesToBeSigned) > 1) {
signedDocuments = Arrays.asList(createPackageZip(filesToBeSigned, signingDate));
} else {
signedDocuments = new ArrayList<DSSDocument>(filesToBeSigned);
}
}
return signedDocuments;
}
示例11: getToBeSigned
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public DSSDocument getToBeSigned() {
int nbEmbeddedSignatures = Utils.collectionSize(embeddedSignatures);
if (nbEmbeddedSignatures != 1) {
throw new DSSException("Unable to select the embedded signature (nb found:" + nbEmbeddedSignatures + ")");
}
return embeddedSignatures.get(0);
}
示例12: getSignedDocuments
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public List<DSSDocument> getSignedDocuments() {
int nbSignedFiles = Utils.collectionSize(embeddedSignedFiles);
if (nbSignedFiles != 1) {
throw new DSSException("Unable to select the document to be signed (nb found:" + nbSignedFiles + ")");
}
return embeddedSignedFiles;
}
示例13: getSignatureFileName
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
protected String getSignatureFileName(final ASiCParameters asicParameters, List<DSSDocument> existingSignatures) {
if (Utils.isStringNotBlank(asicParameters.getSignatureFileName())) {
return META_INF + asicParameters.getSignatureFileName();
}
int num = Utils.collectionSize(existingSignatures) + 1;
return ZIP_ENTRY_ASICE_METAINF_CADES_SIGNATURE.replace("001", ASiCUtils.getPadNumber(num));
}
示例14: getExistingSignature
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public DSSDocument getExistingSignature() {
// The new signature is added in the existing file
int nbEmbeddedSignatures = Utils.collectionSize(embeddedSignatures);
if (nbEmbeddedSignatures != 1) {
throw new DSSException("Unable to select the embedded signature (nb found:" + nbEmbeddedSignatures + ")");
}
return embeddedSignatures.get(0);
}
示例15: isForeSealsOnly
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
public static boolean isForeSealsOnly(List<String> additionalServiceInfos) {
return Utils.collectionSize(additionalServiceInfos) == 1 && isForeSeals(additionalServiceInfos);
}