本文整理汇总了Java中eu.europa.esig.dss.utils.Utils.isArrayNotEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Utils.isArrayNotEmpty方法的具体用法?Java Utils.isArrayNotEmpty怎么用?Java Utils.isArrayNotEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eu.europa.esig.dss.utils.Utils
的用法示例。
在下文中一共展示了Utils.isArrayNotEmpty方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSki
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* This method returns SKI bytes from certificate.
*
* @param certificateToken
* {@code CertificateToken}
* @param computeIfMissing
* if the extension is missing and computeIfMissing = true, it will compute the SKI value from the Public
* Key
* @return ski bytes from the given certificate
* @throws DSSException
*/
public static byte[] getSki(final CertificateToken certificateToken, boolean computeIfMissing) throws DSSException {
try {
byte[] sKI = certificateToken.getCertificate().getExtensionValue(Extension.subjectKeyIdentifier.getId());
if (Utils.isArrayNotEmpty(sKI)) {
ASN1Primitive extension = X509ExtensionUtil.fromExtensionValue(sKI);
SubjectKeyIdentifier skiBC = SubjectKeyIdentifier.getInstance(extension);
return skiBC.getKeyIdentifier();
} else if (computeIfMissing) {
// If extension not present, we compute it from the certificate public key
DLSequence seq = (DLSequence) DERSequence.fromByteArray(certificateToken.getPublicKey().getEncoded());
DERBitString item = (DERBitString) seq.getObjectAt(1);
return DSSUtils.digest(DigestAlgorithm.SHA1, item.getOctets());
}
return null;
} catch (Exception e) {
throw new DSSException(e);
}
}
示例2: buildParameters
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private RemoteSignatureParameters buildParameters(DSSPrivateKeyEntry signer) {
updateProgress(20, 100);
RemoteSignatureParameters parameters = new RemoteSignatureParameters();
parameters.setAsicContainerType(model.getAsicContainerType());
parameters.setDigestAlgorithm(model.getDigestAlgorithm());
parameters.setSignatureLevel(model.getSignatureLevel());
parameters.setSignaturePackaging(model.getSignaturePackaging());
BLevelParameters bLevelParams = new BLevelParameters();
bLevelParams.setSigningDate(new Date());
parameters.setBLevelParams(bLevelParams);
parameters.setSigningCertificate(new RemoteCertificate(signer.getCertificate().getEncoded()));
parameters.setEncryptionAlgorithm(signer.getEncryptionAlgorithm());
CertificateToken[] certificateChain = signer.getCertificateChain();
if (Utils.isArrayNotEmpty(certificateChain)) {
List<RemoteCertificate> certificateChainList = new ArrayList<RemoteCertificate>();
for (CertificateToken certificateToken : certificateChain) {
certificateChainList.add(new RemoteCertificate(certificateToken.getEncoded()));
}
parameters.setCertificateChain(certificateChainList);
}
return parameters;
}
示例3: getMaskGenerationFunction
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
@Override
public MaskGenerationFunction getMaskGenerationFunction() {
try {
byte[] encryptionAlgParams = signerInformation.getEncryptionAlgParams();
if (Utils.isArrayNotEmpty(encryptionAlgParams) && !Arrays.equals(DERNull.INSTANCE.getEncoded(), encryptionAlgParams)) {
RSASSAPSSparams param = RSASSAPSSparams.getInstance(encryptionAlgParams);
AlgorithmIdentifier maskGenAlgorithm = param.getMaskGenAlgorithm();
if (PKCSObjectIdentifiers.id_mgf1.equals(maskGenAlgorithm.getAlgorithm())) {
AlgorithmIdentifier hashAlgo = param.getHashAlgorithm();
return MaskGenerationFunction.fromDigestAlgo(hashAlgo.getAlgorithm().getId());
} else {
LOG.warn("Unsupported mask algorithm : {}", maskGenAlgorithm.getAlgorithm());
}
}
} catch (IOException e) {
LOG.warn("Unable to analyze EncryptionAlgParams", e);
}
return null;
}
示例4: readVRI
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private void readVRI(PdfDict dssDictionary) {
PdfDict vriDict = dssDictionary.getAsDict(VRI_DICTIONARY_NAME);
if (vriDict != null) {
LOG.debug("There is a VRI dictionary in DSS dictionary");
try {
String[] names = vriDict.list();
if (Utils.isArrayNotEmpty(names)) {
for (String name : names) {
extractCertsFromArray(vriDict.getAsDict(name), VRI_DICTIONARY_NAME + "/" + name, CERT_ARRAY_NAME_VRI);
extractOCSPsFromArray(vriDict.getAsDict(name), VRI_DICTIONARY_NAME + "/" + name, OCSP_ARRAY_NAME_VRI);
extractCRLsFromArray(vriDict.getAsDict(name), VRI_DICTIONARY_NAME + "/" + name, CRL_ARRAY_NAME_VRI);
}
}
} catch (Exception e) {
LOG.debug("Unable to analyse VRI dictionary : " + e.getMessage());
}
} else {
LOG.debug("No VRI dictionary found in DSS dictionary");
}
}
示例5: validateDocument
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
public ReportsDTO validateDocument(RemoteDocument signedFile, RemoteDocument originalFile, RemoteDocument policy) {
DSSDocument signedDocument = new InMemoryDocument(signedFile.getBytes(), signedFile.getName(), signedFile.getMimeType());
SignedDocumentValidator signedDocValidator = SignedDocumentValidator.fromDocument(signedDocument);
signedDocValidator.setCertificateVerifier(verifier);
if (originalFile != null && Utils.isArrayNotEmpty(originalFile.getBytes())) {
List<DSSDocument> list = new ArrayList<DSSDocument>();
DSSDocument orignalDocument = new InMemoryDocument(originalFile.getBytes(), originalFile.getName(), originalFile.getMimeType());
list.add(orignalDocument);
signedDocValidator.setDetachedContents(list);
}
Reports reports = null;
if (policy == null) {
reports = signedDocValidator.validateDocument();
} else {
try (ByteArrayInputStream bais = new ByteArrayInputStream(policy.getBytes())) {
reports = signedDocValidator.validateDocument(bais);
} catch (IOException e) {
throw new DSSException(e);
}
}
return new ReportsDTO(reports.getDiagnosticDataJaxb(), reports.getSimpleReportJaxb(), reports.getDetailedReportJaxb());
}
示例6: ldapGet
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
/**
* This method retrieves data using LDAP protocol. - CRL from given LDAP
* url, e.g. ldap://ldap.infonotary.com/dc=identity-ca,dc=infonotary,dc=com
* - ex URL from AIA
* ldap://xadessrv.plugtests.net/CN=LevelBCAOK,OU=Plugtests_2015-2016,O=ETSI,C=FR?cACertificate;binary
*
* @param urlString
* @return
*/
protected byte[] ldapGet(final String urlString) {
final Hashtable<String, String> env = new Hashtable<String, String>();
env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory");
env.put(Context.PROVIDER_URL, urlString);
try {
// parse URL according to the template: 'ldap://host:port/DN?attributes?scope?filter?extensions'
String ldapParams = Utils.substringAfter(urlString, "?");
StringTokenizer tokenizer = new StringTokenizer(ldapParams, "?");
String attributeName = (tokenizer.hasMoreTokens()) ? tokenizer.nextToken() : null;
if (Utils.isStringEmpty(attributeName)) {
// default was CRL
attributeName = "certificateRevocationList;binary";
}
final DirContext ctx = new InitialDirContext(env);
final Attributes attributes = ctx.getAttributes(Utils.EMPTY_STRING, new String[] { attributeName });
if (attributes == null || attributes.size() < 1) {
LOG.warn("Cannot download CRL from: " + urlString + ", no attributes with name: " + attributeName + " returned");
} else {
final Attribute attribute = attributes.getAll().next();
final byte[] ldapBytes = (byte[]) attribute.get();
if (Utils.isArrayNotEmpty(ldapBytes)) {
return ldapBytes;
}
}
} catch (Exception e) {
LOG.warn(e.getMessage(), e);
}
return null;
}
示例7: 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();
}
示例8: getXmlClaimedRole
import eu.europa.esig.dss.utils.Utils; //导入方法依赖的package包/类
private List<String> getXmlClaimedRole(String[] claimedRoles) {
if (Utils.isArrayNotEmpty(claimedRoles)) {
return Arrays.asList(claimedRoles);
}
return Collections.emptyList();
}