eu.europa.esig.dss.utils.Utils.isArrayNotEmpty()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中eu.europa.esig.dss.utils.Utils.isArrayNotEmpty()方法的一些代码示例,展示了Utils.isArrayNotEmpty()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.isArrayNotEmpty()方法的具体详情如下:
包路径:eu.europa.esig.dss.utils.Utils
类名称:Utils
方法名:isArrayNotEmpty

Utils.isArrayNotEmpty介绍

暂无

代码示例

代码示例来源:origin: esig/dss

final Attribute attribute = attributes.getAll().next();
final byte[] ldapBytes = (byte[]) attribute.get();
if (Utils.isArrayNotEmpty(ldapBytes)) {
  return ldapBytes;

代码示例来源:origin: esig/dss

continue;
if (Utils.isArrayNotEmpty(bytes)) {
  if (LOG.isDebugEnabled()) {
    LOG.debug("Base64 content : {}", Utils.toBase64(bytes));

代码示例来源: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

@Test
public void isArrayNotEmpty() {
  assertFalse(Utils.isArrayNotEmpty(new byte[] {}));
  assertTrue(Utils.isArrayNotEmpty(new byte[] { 1 }));
}

代码示例来源:origin: esig/dss

if (Utils.isArrayNotEmpty(bytes)) {
  final File out = getCacheFile(fileName);
  DSSUtils.saveToFile(bytes, out);

代码示例来源:origin: esig/dss

final List<String> qcTypesIdList = new ArrayList<String>();
final byte[] qcStatement = certToken.getCertificate().getExtensionValue(Extension.qCStatements.getId());
if (Utils.isArrayNotEmpty(qcStatement)) {
  try {
    final ASN1Sequence seq = getAsn1SequenceFromDerOctetString(qcStatement);

代码示例来源: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

@Test
public void ldapTest2() {
  String url = "ldap://postarca.posta.si/ou=POSTArCA,o=POSTA,c=SI?certificateRevocationList";
  assertTrue(Utils.isArrayNotEmpty(dataLoader.get(url)));
}

代码示例来源:origin: esig/dss

@Test
public void ldapTest3() {
  String url = "ldap://acldap.nlb.si/o=ACNLB,c=SI?certificateRevocationList";
  assertTrue(Utils.isArrayNotEmpty(dataLoader.get(url)));
}

代码示例来源:origin: esig/dss

@Test
public void ldapTest1() {
  String url = "ldap://x500.gov.si/ou=sigen-ca,o=state-institutions,c=si?certificateRevocationList?base";
  assertTrue(Utils.isArrayNotEmpty(dataLoader.get(url)));
}

代码示例来源:origin: esig/dss

if (Utils.isArrayNotEmpty(returnedBytes)) {
  final File cacheFile = getCacheFile(cacheFileName);
  DSSUtils.saveToFile(returnedBytes, cacheFile);

代码示例来源:origin: esig/dss

public static List<CertificatePolicy> getCertificatePolicies(final CertificateToken certToken) {
  List<CertificatePolicy> certificatePolicies = new ArrayList<CertificatePolicy>();
  final byte[] certificatePoliciesBinaries = certToken.getCertificate().getExtensionValue(Extension.certificatePolicies.getId());
  if (Utils.isArrayNotEmpty(certificatePoliciesBinaries)) {
    try {
      ASN1Sequence seq = getAsn1SequenceFromDerOctetString(certificatePoliciesBinaries);
      for (int ii = 0; ii < seq.size(); ii++) {
        CertificatePolicy cp = new CertificatePolicy();
        final PolicyInformation policyInfo = PolicyInformation.getInstance(seq.getObjectAt(ii));
        cp.setOid(policyInfo.getPolicyIdentifier().getId());
        ASN1Sequence policyQualifiersSeq = policyInfo.getPolicyQualifiers();
        if (policyQualifiersSeq != null) {
          for (int jj = 0; jj < policyQualifiersSeq.size(); jj++) {
            PolicyQualifierInfo pqi = PolicyQualifierInfo.getInstance(policyQualifiersSeq.getObjectAt(jj));
            if (PolicyQualifierId.id_qt_cps.equals(pqi.getPolicyQualifierId())) {
              cp.setCpsUrl(getString(pqi.getQualifier()));
            }
          }
        }
        certificatePolicies.add(cp);
      }
    } catch (Exception e) {
      LOG.warn("Unable to parse the certificatePolicies extension '" + Utils.toBase64(certificatePoliciesBinaries) + "' : " + e.getMessage(), e);
    }
  }
  return certificatePolicies;
}

代码示例来源:origin: esig/dss

/**
 * 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
 */
public static byte[] getSki(final CertificateToken certificateToken, boolean computeIfMissing) {
  try {
    byte[] sKI = certificateToken.getCertificate().getExtensionValue(Extension.subjectKeyIdentifier.getId());
    if (Utils.isArrayNotEmpty(sKI)) {
      ASN1Primitive extension = JcaX509ExtensionUtils.parseExtensionValue(sKI);
      SubjectKeyIdentifier skiBC = SubjectKeyIdentifier.getInstance(extension);
      return skiBC.getKeyIdentifier();
    } else if (computeIfMissing) {
      // If extension not present, we compute it from the certificate public key
      return computeSkiFromCert(certificateToken);
    }
    return null;
  } catch (IOException e) {
    throw new DSSException(e);
  }
}

代码示例来源:origin: esig/dss

@Test
public void testExtension() throws IOException {
  try (InputStream fis = CRLParserTest.class.getResourceAsStream("/crl_with_expiredCertsOnCRL_extension.crl");
      BufferedInputStream is = new BufferedInputStream(fis)) {
    CRLInfo handler = parser.retrieveInfo(is);
    assertEquals("1.2.840.113549.1.1.11", handler.getCertificateListSignatureAlgorithmOid());
    assertNotNull(handler.getIssuer());
    assertNotNull(handler.getThisUpdate());
    assertNotNull(handler.getNextUpdate());
    assertTrue(!handler.getCriticalExtensions().isEmpty());
    assertTrue(Utils.isArrayNotEmpty(handler.getCriticalExtension("2.5.29.28")));
    assertTrue(Utils.isArrayEmpty(handler.getNonCriticalExtension("2.5.29.28")));
    assertTrue(!handler.getNonCriticalExtensions().isEmpty());
    assertTrue(Utils.isArrayNotEmpty(handler.getNonCriticalExtension("2.5.29.60")));
    assertTrue(Utils.isArrayEmpty(handler.getCriticalExtension("2.5.29.60")));
    assertEquals("1.2.840.113549.1.1.11", handler.getTbsSignatureAlgorithmOid());
    byte[] signatureValue = handler.getSignatureValue();
    assertTrue(Utils.isArrayNotEmpty(signatureValue));
  }
}

代码示例来源:origin: esig/dss

@Test
public void testEidc201631() throws IOException {
  try (InputStream fis = CRLParserTest.class.getResourceAsStream("/eidc201631.crl"); BufferedInputStream is = new BufferedInputStream(fis)) {
    CRLInfo handler = parser.retrieveInfo(is);
    assertEquals("1.2.840.113549.1.1.11", handler.getCertificateListSignatureAlgorithmOid());
    assertNotNull(handler.getIssuer());
    assertNotNull(handler.getThisUpdate());
    assertNotNull(handler.getNextUpdate());
    assertEquals("1.2.840.113549.1.1.11", handler.getTbsSignatureAlgorithmOid());
    byte[] signatureValue = handler.getSignatureValue();
    assertTrue(Utils.isArrayNotEmpty(signatureValue));
  }
}

代码示例来源:origin: esig/dss

@Test
public void testBelgium4() throws IOException {
  try (InputStream fis = CRLParserTest.class.getResourceAsStream("/belgium4.crl"); BufferedInputStream is = new BufferedInputStream(fis)) {
    CRLInfo handler = parser.retrieveInfo(is);
    assertEquals("1.2.840.113549.1.1.5", handler.getCertificateListSignatureAlgorithmOid());
    assertNotNull(handler.getIssuer());
    assertNotNull(handler.getThisUpdate());
    assertNotNull(handler.getNextUpdate());
    assertEquals("1.2.840.113549.1.1.5", handler.getTbsSignatureAlgorithmOid());
    byte[] signatureValue = handler.getSignatureValue();
    assertTrue(Utils.isArrayNotEmpty(signatureValue));
  }
}

代码示例来源:origin: esig/dss

@Test
public void parseCRLWithoutRevokedCertificates() throws IOException {
  try (InputStream fis = CRLParserTest.class.getResourceAsStream("/DS_NA2_CA-B1.crl");
      BufferedInputStream is = new BufferedInputStream(fis)) {
    CRLInfo handler = parser.retrieveInfo(is);
    assertEquals("1.2.840.113549.1.1.11", handler.getCertificateListSignatureAlgorithmOid());
    assertNotNull(handler.getIssuer());
    assertNotNull(handler.getThisUpdate());
    assertNotNull(handler.getNextUpdate());
    assertTrue(handler.getCriticalExtensions().isEmpty());
    assertTrue(!handler.getNonCriticalExtensions().isEmpty());
    assertTrue(Utils.isArrayEmpty(handler.getNonCriticalExtension("2.5.29.60")));
    assertEquals("1.2.840.113549.1.1.11", handler.getTbsSignatureAlgorithmOid());
    byte[] signatureValue = handler.getSignatureValue();
    assertTrue(Utils.isArrayNotEmpty(signatureValue));
  }
}

相关文章