what-the-bank/sources/org/bouncycastle/jce/provider/X509StoreLDAPCerts.java

75 lines
3.5 KiB
Java
Raw Normal View History

2024-07-27 18:17:47 +07:00
package org.bouncycastle.jce.provider;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import org.bouncycastle.jce.X509LDAPCertStoreParameters;
import org.bouncycastle.util.Selector;
import org.bouncycastle.util.StoreException;
import org.bouncycastle.x509.X509CertPairStoreSelector;
import org.bouncycastle.x509.X509CertStoreSelector;
import org.bouncycastle.x509.X509CertificatePair;
import org.bouncycastle.x509.X509StoreParameters;
import org.bouncycastle.x509.X509StoreSpi;
import org.bouncycastle.x509.util.LDAPStoreHelper;
/* loaded from: classes6.dex */
public class X509StoreLDAPCerts extends X509StoreSpi {
private LDAPStoreHelper helper;
@Override // org.bouncycastle.x509.X509StoreSpi
public void engineInit(X509StoreParameters x509StoreParameters) {
if (x509StoreParameters instanceof X509LDAPCertStoreParameters) {
this.helper = new LDAPStoreHelper((X509LDAPCertStoreParameters) x509StoreParameters);
return;
}
StringBuilder sb = new StringBuilder("Initialization parameters must be an instance of ");
sb.append(X509LDAPCertStoreParameters.class.getName());
sb.append(".");
throw new IllegalArgumentException(sb.toString());
}
@Override // org.bouncycastle.x509.X509StoreSpi
public Collection engineGetMatches(Selector selector) throws StoreException {
Collection certificatesFromCrossCertificatePairs;
if (!(selector instanceof X509CertStoreSelector)) {
return Collections.EMPTY_SET;
}
X509CertStoreSelector x509CertStoreSelector = (X509CertStoreSelector) selector;
HashSet hashSet = new HashSet();
if (x509CertStoreSelector.getBasicConstraints() <= 0) {
if (x509CertStoreSelector.getBasicConstraints() == -2) {
certificatesFromCrossCertificatePairs = this.helper.getUserCertificates(x509CertStoreSelector);
hashSet.addAll(certificatesFromCrossCertificatePairs);
return hashSet;
}
hashSet.addAll(this.helper.getUserCertificates(x509CertStoreSelector));
}
hashSet.addAll(this.helper.getCACertificates(x509CertStoreSelector));
certificatesFromCrossCertificatePairs = getCertificatesFromCrossCertificatePairs(x509CertStoreSelector);
hashSet.addAll(certificatesFromCrossCertificatePairs);
return hashSet;
}
private Collection getCertificatesFromCrossCertificatePairs(X509CertStoreSelector x509CertStoreSelector) throws StoreException {
HashSet hashSet = new HashSet();
X509CertPairStoreSelector x509CertPairStoreSelector = new X509CertPairStoreSelector();
x509CertPairStoreSelector.setForwardSelector(x509CertStoreSelector);
x509CertPairStoreSelector.setReverseSelector(new X509CertStoreSelector());
HashSet<X509CertificatePair> hashSet2 = new HashSet(this.helper.getCrossCertificatePairs(x509CertPairStoreSelector));
HashSet hashSet3 = new HashSet();
HashSet hashSet4 = new HashSet();
for (X509CertificatePair x509CertificatePair : hashSet2) {
if (x509CertificatePair.getForward() != null) {
hashSet3.add(x509CertificatePair.getForward());
}
if (x509CertificatePair.getReverse() != null) {
hashSet4.add(x509CertificatePair.getReverse());
}
}
hashSet.addAll(hashSet3);
hashSet.addAll(hashSet4);
return hashSet;
}
}