protected static boolean isNotEmpty(Collection<?> col) { return CollectionUtil.isNonEmpty(col); }
protected static boolean isNotEmpty(Collection<?> col) { return CollectionUtil.isNonEmpty(col); }
@Override public void run() { if (inProcess.get()) { return; } inProcess.set(true); try { // just updated within the last 2 minutes if (System.currentTimeMillis() - lastUpdate < 2 * MINUTE) { return; } LOG.info("scheduled configuring CAs {}", autoConfCaNames); Set<String> failedCaNames = autoConfCas(autoConfCaNames); if (CollectionUtil.isNonEmpty(failedCaNames)) { LOG.warn("could not configure following CAs {}", failedCaNames); } } finally { lastUpdate = System.currentTimeMillis(); inProcess.set(false); } }
NameIdStore(String table, Map<String, Integer> entries) { this.table = Args.notNull(table, "table"); this.entries = new HashMap<>(); if (CollectionUtil.isNonEmpty(entries)) { for (String name : entries.keySet()) { addEntry(name, entries.get(name)); } } }
private static String toString(Set<ASN1ObjectIdentifier> oids) { if (oids == null) { return "null"; } StringBuilder sb = new StringBuilder(); sb.append("["); for (ASN1ObjectIdentifier oid : oids) { String name = ObjectIdentifiers.getName(oid); if (name != null) { sb.append(name); sb.append(" (").append(oid.getId()).append(")"); } else { sb.append(oid.getId()); } sb.append(", "); } if (CollectionUtil.isNonEmpty(oids)) { int len = sb.length(); sb.delete(len - 2, len); } sb.append("]"); return sb.toString(); } // method toString
@Override protected Object execute0() throws Exception { if (caManager.getCa(caName) == null) { throw new CmdFailure("could not find CA '" + caName + "'"); } StringBuilder sb = new StringBuilder(); Set<String> entries = caManager.getCertprofilesForCa(caName); if (CollectionUtil.isNonEmpty(entries)) { sb.append("certificate Profiles supported by CA " + caName).append("\n"); for (String name: entries) { sb.append("\t").append(name).append("\n"); } } else { sb.append("\tno profile for CA " + caName + " is configured"); } println(sb.toString()); return null; }
public static AuthorityInformationAccess createAuthorityInformationAccess( List<String> caIssuerUris, List<String> ocspUris) { if (CollectionUtil.isEmpty(caIssuerUris) && CollectionUtil.isEmpty(ocspUris)) { throw new IllegalArgumentException("caIssuerUris and ospUris may not be both empty"); } List<AccessDescription> accessDescriptions = new ArrayList<>(ocspUris.size()); if (CollectionUtil.isNonEmpty(caIssuerUris)) { for (String uri : caIssuerUris) { GeneralName gn = new GeneralName(GeneralName.uniformResourceIdentifier, uri); accessDescriptions.add( new AccessDescription(X509ObjectIdentifiers.id_ad_caIssuers, gn)); } } if (CollectionUtil.isNonEmpty(ocspUris)) { for (String uri : ocspUris) { GeneralName gn = new GeneralName(GeneralName.uniformResourceIdentifier, uri); accessDescriptions.add(new AccessDescription(X509ObjectIdentifiers.id_ad_ocsp, gn)); } } DERSequence seq = new DERSequence(accessDescriptions.toArray(new AccessDescription[0])); return AuthorityInformationAccess.getInstance(seq); }
if (CollectionUtil.isNonEmpty(extensionOids)) { StringBuilder extensionsSb = new StringBuilder(200); for (String oid : extensionOids) {
if (CollectionUtil.isNonEmpty(extensionOids)) { StringBuilder extensionsSb = new StringBuilder(200); for (String oid : extensionOids) {
if (CollectionUtil.isNonEmpty(acceptVersions) && !acceptVersions.contains(version)) { Integer ver = null; for (Integer m : acceptVersions) { if (CollectionUtil.isNonEmpty(supportedProfileNames)) { List<JSONObject> jsonCertprofiles = new LinkedList<>(); root.put("certprofiles", jsonCertprofiles);
@Override public void clearPublishQueue(String caName, List<String> publisherNames) throws CaMgmtException { asssertMasterMode(); publisherNames = CollectionUtil.toLowerCaseList(publisherNames); if (caName == null) { if (CollectionUtil.isNonEmpty(publisherNames)) { throw new IllegalArgumentException("non-empty publisherNames is not allowed"); } try { certstore.clearPublishQueue((NameId) null, (NameId) null); } catch (OperationException ex) { throw new CaMgmtException(ex.getMessage(), ex); } return; } caName = caName.toLowerCase(); X509Ca ca = x509cas.get(caName); if (ca == null) { throw new CaMgmtException(concat("could not find CA named ", caName)); } ca.clearPublishQueue(publisherNames); } // method clearPublishQueue
if (CollectionUtil.isNonEmpty(sigAlgos)) { pairs.putPair(KEY_PROTECTION_SIGALGO, algosAsString(this.sigAlgoValidator.getAlgoNames())); if (CollectionUtil.isNonEmpty(popoAlgos)) { pairs.putPair(KEY_POPO_SIGALGO, algosAsString(this.popoAlgoValidator.getAlgoNames())); if (CollectionUtil.isNonEmpty(pbmOwfs)) { pairs.putPair(KEY_PROTECTION_PBM_OWF, algosAsString(pbmOwfs)); if (CollectionUtil.isNonEmpty(pbmMacs)) { pairs.putPair(KEY_PROTECTION_PBM_MAC, algosAsString(pbmMacs));
if (CollectionUtil.isNonEmpty(sigAlgos)) { pairs.putPair(KEY_PROTECTION_SIGALGO, algosAsString(this.sigAlgoValidator.getAlgoNames())); if (CollectionUtil.isNonEmpty(popoAlgos)) { pairs.putPair(KEY_POPO_SIGALGO, algosAsString(this.popoAlgoValidator.getAlgoNames())); if (CollectionUtil.isNonEmpty(pbmOwfs)) { pairs.putPair(KEY_PROTECTION_PBM_OWF, algosAsString(pbmOwfs)); if (CollectionUtil.isNonEmpty(pbmMacs)) { pairs.putPair(KEY_PROTECTION_PBM_MAC, algosAsString(pbmMacs));
if (CollectionUtil.isNonEmpty(itvs)) { hdrBuilder.setGeneralInfo(itvs.toArray(new InfoTypeAndValue[0]));
public static org.bouncycastle.asn1.x509.CertificatePolicies createCertificatePolicies( List<CertificatePolicyInformation> policyInfos) throws CertprofileException { ParamUtil.requireNonEmpty("policyInfos", policyInfos); int size = policyInfos.size(); PolicyInformation[] infos = new PolicyInformation[size]; int idx = 0; for (CertificatePolicyInformation policyInfo : policyInfos) { String policyId = policyInfo.getCertPolicyId(); List<CertificatePolicyQualifier> qualifiers = policyInfo.getQualifiers(); ASN1Sequence policyQualifiers = null; if (CollectionUtil.isNonEmpty(qualifiers)) { policyQualifiers = createPolicyQualifiers(qualifiers); } ASN1ObjectIdentifier policyOid = new ASN1ObjectIdentifier(policyId); infos[idx++] = (policyQualifiers == null) ? new PolicyInformation(policyOid) : new PolicyInformation(policyOid, policyQualifiers); } return new org.bouncycastle.asn1.x509.CertificatePolicies(infos); }
private PKCS10CertificationRequest generateRequest(ConcurrentContentSigner signer, SubjectPublicKeyInfo subjectPublicKeyInfo, X500Name subjectDn, Map<ASN1ObjectIdentifier, ASN1Encodable> attributes) throws XiSecurityException { ParamUtil.requireNonNull("signer", signer); ParamUtil.requireNonNull("subjectPublicKeyInfo", subjectPublicKeyInfo); ParamUtil.requireNonNull("subjectDn", subjectDn); PKCS10CertificationRequestBuilder csrBuilder = new PKCS10CertificationRequestBuilder(subjectDn, subjectPublicKeyInfo); if (CollectionUtil.isNonEmpty(attributes)) { for (ASN1ObjectIdentifier attrType : attributes.keySet()) { csrBuilder.addAttribute(attrType, attributes.get(attrType)); } } ConcurrentBagEntrySigner signer0; try { signer0 = signer.borrowSigner(); } catch (NoIdleSignerException ex) { throw new XiSecurityException(ex.getMessage(), ex); } try { return csrBuilder.build(signer0.value()); } finally { signer.requiteSigner(signer0); } }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); if (CollectionUtil.isNonEmpty(needExtensions)) { ASN1EncodableVector vec = new ASN1EncodableVector(); for (ASN1ObjectIdentifier m : needExtensions) { vec.add(m); } vector.add(new DERTaggedObject(true, 0, new DERSequence(vec))); } if (CollectionUtil.isNonEmpty(wantExtensions)) { ASN1EncodableVector vec = new ASN1EncodableVector(); for (ASN1ObjectIdentifier m : wantExtensions) { vec.add(m); } vector.add(new DERTaggedObject(true, 1, new DERSequence(vec))); } return new DERSequence(vector); }
if (CollectionUtil.isNonEmpty(oidTypes)) { oids = new LinkedList<>(); for (OidWithDescType k : oidTypes) {
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new DERUTF8String(control.getLabel())); byte[] id = control.getId(); if (id != null) { vector.add(new DERTaggedObject(0, new DEROctetString(id))); } Set<KeyUsage> usages = control.getUsages(); if (CollectionUtil.isNonEmpty(usages)) { ASN1EncodableVector asn1Usages = new ASN1EncodableVector(); for (KeyUsage usage : usages) { int value = usageToValueMap.get(usage); asn1Usages.add(new ASN1Enumerated(value)); } vector.add(new DERTaggedObject(1, new DERSequence(asn1Usages))); } if (control.getExtractable() != null) { vector.add(new DERTaggedObject(2, ASN1Boolean.getInstance(control.getExtractable()))); } return new DERSequence(vector); }
@Override public ASN1Primitive toASN1Primitive() { ASN1EncodableVector vector = new ASN1EncodableVector(); vector.add(new DERUTF8String(control.getLabel())); byte[] id = control.getId(); if (id != null) { vector.add(new DERTaggedObject(0, new DEROctetString(id))); } Set<P11KeyUsage> usages = control.getUsages(); if (CollectionUtil.isNonEmpty(usages)) { ASN1EncodableVector asn1Usages = new ASN1EncodableVector(); for (P11KeyUsage usage : usages) { int value = usageToValueMap.get(usage); asn1Usages.add(new ASN1Enumerated(value)); } vector.add(new DERTaggedObject(1, new DERSequence(asn1Usages))); } if (control.getExtractable() != null) { vector.add(new DERTaggedObject(2, ASN1Boolean.getInstance(control.getExtractable()))); } return new DERSequence(vector); }