本文整理了Java中eu.europa.esig.dss.utils.Utils
类的一些代码示例,展示了Utils
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils
类的具体详情如下:
包路径:eu.europa.esig.dss.utils.Utils
类名称:Utils
暂无
代码示例来源:origin: esig/dss
@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;
}
代码示例来源:origin: esig/dss
private Date getExpirationDate(String algoToFind, List<Algo> algos, String format) {
SimpleDateFormat dateFormat = new SimpleDateFormat(Utils.isStringEmpty(format) ? DATE_FORMAT : format);
Date result = null;
for (Algo algo : algos) {
if (Utils.areStringsEqual(algoToFind, algo.getValue()) && Utils.isStringNotEmpty(algo.getDate())) {
try {
result = dateFormat.parse(algo.getDate());
} catch (Exception e) {
LOG.warn("Unable to parse date with pattern '{}' : {}", dateFormat.toPattern(), e.getMessage());
}
}
}
return result;
}
代码示例来源:origin: esig/dss
String ldapParams = Utils.substringAfter(urlString, "?");
StringTokenizer tokenizer = new StringTokenizer(ldapParams, "?");
String attributeName = (tokenizer.hasMoreTokens()) ? tokenizer.nextToken() : null;
if (Utils.isStringEmpty(attributeName)) {
final Attribute attribute = attributes.getAll().next();
final byte[] ldapBytes = (byte[]) attribute.get();
if (Utils.isArrayNotEmpty(ldapBytes)) {
return ldapBytes;
代码示例来源:origin: esig/dss
protected boolean processValueCheck(String value, String expected) {
if (Utils.isStringEmpty(value)) {
return false;
}
if (ALL_VALUE.equals(expected)) {
return true;
} else {
return Utils.areStringsEqual(expected, value);
}
}
代码示例来源:origin: esig/dss
protected boolean processValueCheck(String value) {
List<String> expecteds = constraint.getId();
if (Utils.isStringNotEmpty(value) && Utils.isCollectionNotEmpty(expecteds)) {
if (expecteds.contains(ALL_VALUE)) {
return true;
} else if (expecteds.contains(value)) {
return true;
}
}
return false;
}
代码示例来源:origin: esig/dss
public XmlSignature getXmlSignatureById(String signatureId) {
List<XmlSignature> signatures = jaxbDetailedReport.getSignatures();
if (Utils.isCollectionNotEmpty(signatures)) {
for (XmlSignature xmlSignature : signatures) {
if (Utils.areStringsEqual(signatureId, xmlSignature.getId())) {
return xmlSignature;
}
}
}
return null;
}
代码示例来源:origin: esig/dss
private List<String> getOidValues(List<? extends XmlOID> xmlOids) {
List<String> result = new ArrayList<String>();
if (Utils.isCollectionNotEmpty(xmlOids)) {
for (XmlOID xmlOID : xmlOids) {
result.add(xmlOID.getValue());
}
}
return result;
}
代码示例来源:origin: esig/dss
@Override
protected String getAdditionalInfo() {
if (Utils.isStringNotEmpty(pseudo)) {
Object[] params = new Object[] { pseudo };
return MessageFormat.format(AdditionalInfo.PSEUDO, params);
}
return null;
}
代码示例来源:origin: esig/dss
List<String> urls = DSSASN1Utils.getCAAccessLocations(cert);
if (Utils.isCollectionEmpty(urls)) {
LOG.info("There is no AIA extension for certificate download.");
return Collections.emptyList();
continue;
if (Utils.isArrayNotEmpty(bytes)) {
if (LOG.isDebugEnabled()) {
LOG.debug("Base64 content : {}", Utils.toBase64(bytes));
代码示例来源:origin: esig/dss
if (Utils.isCollectionNotEmpty(alternativeUrls)) {
LOG.info("OCSP alternative urls : {}", alternativeUrls);
if (Utils.isCollectionEmpty(ocspAccessLocations) && Utils.isCollectionEmpty(alternativeUrls)) {
LOG.debug("No OCSP location found for {}", dssIdAsString);
return null;
try {
final byte[] ocspRespBytes = dataLoader.post(ocspAccessLocation, content);
if (!Utils.isArrayEmpty(ocspRespBytes)) {
final OCSPResp ocspResp = new OCSPResp(ocspRespBytes);
OCSPRespStatus status = OCSPRespStatus.fromInt(ocspResp.getStatus());
代码示例来源:origin: esig/dss
public List<String> getCpsUrls() {
List<String> result = new ArrayList<String>();
List<XmlCertificatePolicy> certificatePolicyIds = certificate.getCertificatePolicies();
if (Utils.isCollectionNotEmpty(certificatePolicyIds)) {
for (XmlCertificatePolicy xmlCertificatePolicy : certificatePolicyIds) {
if (Utils.isStringNotBlank(xmlCertificatePolicy.getCpsUrl())) {
result.add(xmlCertificatePolicy.getCpsUrl());
}
}
}
return result;
}
代码示例来源:origin: esig/dss
@Test
public void listFiles() {
File folder = new File("src/main/java");
String[] extensions = new String[] { "java" };
Collection<File> listFiles = Utils.listFiles(folder, extensions, true);
assertTrue(Utils.isCollectionNotEmpty(listFiles));
extensions = new String[] { "doc", "pdf" };
listFiles = Utils.listFiles(folder, extensions, true);
assertTrue(Utils.isCollectionEmpty(listFiles));
}
代码示例来源:origin: esig/dss
/**
* Get the list of all QCStatement Ids that are present in the certificate.
* (As per ETSI EN 319 412-5 V2.1.1)
*
* @param certToken
* the certificate
* @return the list of QC Statements oids
*/
public static List<String> getQCStatementsIdList(final CertificateToken certToken) {
final List<String> extensionIdList = new ArrayList<String>();
final byte[] qcStatement = certToken.getCertificate().getExtensionValue(Extension.qCStatements.getId());
if (Utils.isArrayNotEmpty(qcStatement)) {
try {
final ASN1Sequence seq = getAsn1SequenceFromDerOctetString(qcStatement);
// Sequence of QCStatement
for (int ii = 0; ii < seq.size(); ii++) {
final QCStatement statement = QCStatement.getInstance(seq.getObjectAt(ii));
extensionIdList.add(statement.getStatementId().getId());
}
} catch (Exception e) {
LOG.warn("Unable to parse the qCStatements extension '" + Utils.toBase64(qcStatement) + "' : " + e.getMessage(), e);
}
}
return extensionIdList;
}
代码示例来源:origin: esig/dss
@Override
protected boolean process() {
return Utils.isStringNotBlank(zipComment);
}
代码示例来源:origin: esig/dss
@Test
public void isArrayNotEmptyObj() {
assertFalse(Utils.isArrayNotEmpty(new Object[] {}));
assertTrue(Utils.isArrayNotEmpty(new Object[] { null }));
assertTrue(Utils.isArrayNotEmpty(new Object[] { "1", 1 }));
}
代码示例来源:origin: esig/dss
private List<String> emptyToNull(List<String> listUrls) {
if (Utils.isCollectionEmpty(listUrls)) {
return null;
}
return listUrls;
}
代码示例来源:origin: esig/dss
@Override
public boolean check(CertificateToken certificateToken) {
X500Principal subjectX500Principal = certificateToken.getSubjectX500Principal();
if (Utils.isCollectionNotEmpty(subjectAttributeOids)) {
for (String oid : subjectAttributeOids) {
String attribute = DSSASN1Utils.extractAttributeFromX500Principal(new ASN1ObjectIdentifier(oid), subjectX500Principal);
if (Utils.isStringEmpty(attribute)) {
return false;
}
}
}
return true;
}
代码示例来源:origin: esig/dss
@Override
protected boolean process() {
return Utils.collectionSize(trustServicesAtTime) == 1;
}
代码示例来源:origin: esig/dss
@Test
public void getDigestSignaturePolicy() throws Exception {
FileInputStream fis = new FileInputStream("src/test/resources/signature-policy-example.der");
byte[] policyBytes = Utils.toByteArray(fis);
Utils.closeQuietly(fis);
byte[] signaturePolicyDigest = DSSASN1Utils.getAsn1SignaturePolicyDigest(DigestAlgorithm.SHA256, policyBytes);
String hexSignaturePolicyDigest = Utils.toHex(signaturePolicyDigest);
assertEquals("fe71e01aedd99f444238602d4e98f47bbab405c58c0e3811b9511dcd58c3c983", hexSignaturePolicyDigest);
}
代码示例来源:origin: esig/dss
@Test
public void loadCertificate() throws Exception {
CertificateToken certificate = DSSUtils.loadCertificate(new FileInputStream("src/test/resources/belgiumrs2.crt"));
assertNotNull(certificate);
FileInputStream fis = new FileInputStream("src/test/resources/belgiumrs2.crt");
byte[] byteArray = Utils.toByteArray(fis);
logger.info(Utils.toBase64(byteArray));
Utils.closeQuietly(fis);
CertificateToken certificate2 = DSSUtils.loadCertificate(byteArray);
assertNotNull(certificate2);
CertificateToken certificateNew = DSSUtils.loadCertificate(new FileInputStream("src/test/resources/belgiumrs2-new.crt"));
assertNotNull(certificateNew);
FileInputStream fisNew = new FileInputStream("src/test/resources/belgiumrs2-new.crt");
byte[] byteArrayNew = Utils.toByteArray(fisNew);
logger.info(Utils.toBase64(byteArrayNew));
Utils.closeQuietly(fisNew);
CertificateToken certificate2New = DSSUtils.loadCertificate(byteArrayNew);
assertNotNull(certificate2New);
// String cert =
// "PGh0bWw+PGhlYWQ+PHRpdGxlPlJlcXVlc3QgUmVqZWN0ZWQ8L3RpdGxlPjwvaGVhZD48Ym9keT5UaGUgcmVxdWVzdGVkIFVSTCB3YXMgcmVqZWN0ZWQuIFBsZWFzZSBjb25zdWx0IHdpdGggeW91ciBhZG1pbmlzdHJhdG9yLjxicj48YnI+WW91ciBzdXBwb3J0IElEIGlzOiAxMTY1Njg3NjQzMzgzMDI3NjMxNjwvYm9keT48L2h0bWw+";
// byte[] decodeBase64 = Base64.decodeBase64(cert);
// byte[] decodeBase642 = Base64.decodeBase64(decodeBase64);
// CertificateToken certificate3 =
// DSSUtils.loadCertificate(base64StringToBase64Binary);
// assertNotNull(certificate3);
}
内容来源于网络,如有侵权,请联系作者删除!