本文整理汇总了Java中org.bouncycastle.asn1.x509.GeneralNames类的典型用法代码示例。如果您正苦于以下问题:Java GeneralNames类的具体用法?Java GeneralNames怎么用?Java GeneralNames使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
GeneralNames类属于org.bouncycastle.asn1.x509包,在下文中一共展示了GeneralNames类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: extractX509CSRDnsNames
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
public static List<String> extractX509CSRDnsNames(PKCS10CertificationRequest certReq) {
List<String> dnsNames = new ArrayList<>();
Attribute[] attributes = certReq.getAttributes(PKCSObjectIdentifiers.pkcs_9_at_extensionRequest);
for (Attribute attribute : attributes) {
for (ASN1Encodable value : attribute.getAttributeValues()) {
Extensions extensions = Extensions.getInstance(value);
GeneralNames gns = GeneralNames.fromExtensions(extensions, Extension.subjectAlternativeName);
for (GeneralName name : gns.getNames()) {
if (name.getTagNo() == GeneralName.dNSName) {
dnsNames.add(((DERIA5String) name.getName()).getString());
}
}
}
}
return dnsNames;
}
示例2: matchesDN
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
private boolean matchesDN(X500Principal subject, GeneralNames targets)
{
GeneralName[] names = targets.getNames();
for (int i = 0; i != names.length; i++)
{
GeneralName gn = names[i];
if (gn.getTagNo() == GeneralName.directoryName)
{
try
{
if (new X500Principal(((ASN1Encodable)gn.getName()).toASN1Primitive().getEncoded()).equals(subject))
{
return true;
}
}
catch (IOException e)
{
}
}
}
return false;
}
示例3: matchesDN
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
private boolean matchesDN(X509Principal subject, GeneralNames targets)
{
GeneralName[] names = targets.getNames();
for (int i = 0; i != names.length; i++)
{
GeneralName gn = names[i];
if (gn.getTagNo() == GeneralName.directoryName)
{
try
{
if (new X509Principal(((ASN1Encodable)gn.getName()).toASN1Primitive()
.getEncoded()).equals(subject))
{
return true;
}
}
catch (IOException e)
{
}
}
}
return false;
}
示例4: getCRLDistUrls
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
protected Vector getCRLDistUrls(CRLDistPoint crlDistPoints)
{
Vector urls = new Vector();
if (crlDistPoints != null)
{
DistributionPoint[] distPoints = crlDistPoints.getDistributionPoints();
for (int i = 0; i < distPoints.length; i++)
{
DistributionPointName dp_name = distPoints[i].getDistributionPoint();
if (dp_name.getType() == DistributionPointName.FULL_NAME)
{
GeneralName[] generalNames = GeneralNames.getInstance(dp_name.getName()).getNames();
for (int j = 0; j < generalNames.length; j++)
{
if (generalNames[j].getTagNo() == GeneralName.uniformResourceIdentifier)
{
String url = ((DERIA5String) generalNames[j].getName()).getString();
urls.add(url);
}
}
}
}
}
return urls;
}
示例5: matchesDN
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
private boolean matchesDN(X500Name subject, GeneralNames targets)
{
GeneralName[] names = targets.getNames();
for (int i = 0; i != names.length; i++)
{
GeneralName gn = names[i];
if (gn.getTagNo() == GeneralName.directoryName)
{
if (X500Name.getInstance(gn.getName()).equals(subject))
{
return true;
}
}
}
return false;
}
示例6: getRevokedCertificate
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
public X509CRLEntryHolder getRevokedCertificate(BigInteger serialNumber)
{
GeneralNames currentCA = issuerName;
for (Enumeration en = x509CRL.getRevokedCertificateEnumeration(); en.hasMoreElements();)
{
TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)en.nextElement();
if (entry.getUserCertificate().getValue().equals(serialNumber))
{
return new X509CRLEntryHolder(entry, isIndirect, currentCA);
}
if (isIndirect && entry.hasExtensions())
{
Extension currentCaName = entry.getExtensions().getExtension(Extension.certificateIssuer);
if (currentCaName != null)
{
currentCA = GeneralNames.getInstance(currentCaName.getParsedValue());
}
}
}
return null;
}
示例7: getRevokedCertificates
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
/**
* Return a collection of X509CRLEntryHolder objects, giving the details of the
* revoked certificates that appear on this CRL.
*
* @return the revoked certificates as a collection of X509CRLEntryHolder objects.
*/
public Collection getRevokedCertificates()
{
TBSCertList.CRLEntry[] entries = x509CRL.getRevokedCertificates();
List l = new ArrayList(entries.length);
GeneralNames currentCA = issuerName;
for (Enumeration en = x509CRL.getRevokedCertificateEnumeration(); en.hasMoreElements();)
{
TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)en.nextElement();
X509CRLEntryHolder crlEntry = new X509CRLEntryHolder(entry, isIndirect, currentCA);
l.add(crlEntry);
currentCA = crlEntry.getCertificateIssuer();
}
return l;
}
示例8: loadCRLEntries
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
private Set loadCRLEntries()
{
Set entrySet = new HashSet();
Enumeration certs = c.getRevokedCertificateEnumeration();
X500Name previousCertificateIssuer = null; // the issuer
while (certs.hasMoreElements())
{
TBSCertList.CRLEntry entry = (TBSCertList.CRLEntry)certs.nextElement();
X509CRLEntryObject crlEntry = new X509CRLEntryObject(entry, isIndirect, previousCertificateIssuer);
entrySet.add(crlEntry);
if (isIndirect && entry.hasExtensions())
{
Extension currentCaName = entry.getExtensions().getExtension(Extension.certificateIssuer);
if (currentCaName != null)
{
previousCertificateIssuer = X500Name.getInstance(GeneralNames.getInstance(currentCaName.getParsedValue()).getNames()[0].getName());
}
}
}
return entrySet;
}
示例9: CRLDistributionPointsImpl
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
public CRLDistributionPointsImpl(X509Certificate cert) throws CertificateException, IOException {
URINames = new ArrayList<>();
byte[] extVal = cert.getExtensionValue(Extension.cRLDistributionPoints.getId());
if (extVal == null)
return;
CRLDistPoint crlDistPoint = CRLDistPoint.getInstance(X509ExtensionUtil.fromExtensionValue(extVal));
DistributionPoint[] points = crlDistPoint.getDistributionPoints();
for (DistributionPoint p : points) {
GeneralNames tmp = p.getCRLIssuer();
if (tmp != null) {
GeneralName[] crlIssers = tmp.getNames();
for (int i = 0; i < crlIssers.length; i++) {
if (crlIssers[i].getTagNo() == GeneralName.uniformResourceIdentifier) {
String issuerUrl = crlIssers[i].toString();
URINames.add(issuerUrl);
}
}
}
}
}
示例10: SubjectAlternativeNameImpl
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
public SubjectAlternativeNameImpl(X509Certificate cert) throws IOException {
DNSNames = new ArrayList<>();
byte[] extVal = cert.getExtensionValue(Extension.subjectAlternativeName.getId());
if (extVal == null)
return;
GeneralNames gn = GeneralNames.getInstance(X509ExtensionUtil.fromExtensionValue(extVal));
GeneralName[] names = gn.getNames();
for (GeneralName name : names) {
if (name.getTagNo() == GeneralName.dNSName) {
String dns = name.getName().toString();
DNSNames.add(dns);
}
}
}
示例11: matchesDN
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
private boolean matchesDN(X500Principal subject, GeneralNames targets)
{
GeneralName[] names = targets.getNames();
for (int i = 0; i != names.length; i++)
{
GeneralName gn = names[i];
if (gn.getTagNo() == GeneralName.directoryName)
{
try
{
if (new X500Principal(((ASN1Encodable)gn.getName()).getEncoded()).equals(subject))
{
return true;
}
}
catch (IOException e)
{
}
}
}
return false;
}
示例12: performTest
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
public void performTest()
throws Exception
{
DistributionPointName name = new DistributionPointName(
new GeneralNames(new GeneralName(new X500Name("cn=test"))));
ReasonFlags reasonFlags = new ReasonFlags(ReasonFlags.cACompromise);
checkPoint(6, name, true, true, reasonFlags, true, true);
checkPoint(2, name, false, false, reasonFlags, false, false);
checkPoint(0, null, false, false, null, false, false);
try
{
IssuingDistributionPoint.getInstance(new Object());
fail("getInstance() failed to detect bad object.");
}
catch (IllegalArgumentException e)
{
// expected
}
}
示例13: getValue
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
@Override
public Attribute getValue() {
try {
X509Certificate cert = (X509Certificate) certificates[0];
Digest digest = DigestFactory.getInstance().factoryDefault();
digest.setAlgorithm(DigestAlgorithmEnum.SHA_1);
byte[] hash = digest.digest(cert.getEncoded());
X500Name dirName = new X500Name(cert.getSubjectDN().getName());
GeneralName name = new GeneralName(dirName);
GeneralNames issuer = new GeneralNames(name);
ASN1Integer serial = new ASN1Integer(cert.getSerialNumber());
IssuerSerial issuerSerial = new IssuerSerial(issuer, serial);
ESSCertID essCertId = new ESSCertID(hash, issuerSerial);
return new Attribute(new ASN1ObjectIdentifier(identifier), new DERSet(new DERSequence(new ASN1Encodable[]{new DERSequence(essCertId), new DERSequence(DERNull.INSTANCE)})));
} catch (CertificateEncodingException ex) {
throw new SignerException(ex.getMessage());
}
}
示例14: getValue
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
@Override
public Attribute getValue() throws SignerException {
try {
X509Certificate cert = (X509Certificate) certificates[0];
X509Certificate issuerCert = (X509Certificate) certificates[1];
Digest digest = DigestFactory.getInstance().factoryDefault();
digest.setAlgorithm(DigestAlgorithmEnum.SHA_256);
byte[] certHash = digest.digest(cert.getEncoded());
X500Name dirName = new X500Name(issuerCert.getSubjectX500Principal().getName());
GeneralName name = new GeneralName(dirName);
GeneralNames issuer = new GeneralNames(name);
ASN1Integer serialNumber = new ASN1Integer(cert.getSerialNumber());
IssuerSerial issuerSerial = new IssuerSerial(issuer, serialNumber);
AlgorithmIdentifier algId = new AlgorithmIdentifier(NISTObjectIdentifiers.id_sha256);// SHA-256
ESSCertIDv2 essCertIDv2 = new ESSCertIDv2(algId, certHash, issuerSerial);
// return new Attribute(new ASN1ObjectIdentifier(identifier), new DERSet(new DERSequence(essCertIDv2)));
return new Attribute(new ASN1ObjectIdentifier(identifier), new DERSet(new DERSequence(
new ASN1Encodable[] { new DERSequence(essCertIDv2) })));
} catch (CertificateEncodingException ex) {
throw new SignerException(ex.getMessage());
}
}
示例15: getGeneralNamesString
import org.bouncycastle.asn1.x509.GeneralNames; //导入依赖的package包/类
/**
* Get a formatted string value for the supplied general names object.
*
* @param generalNames General names
* @return Formatted string
* @throws IOException
*/
private String getGeneralNamesString(GeneralNames generalNames, LinkClass linkClass)
throws IOException
{
GeneralName[] names = generalNames.getNames();
StringBuilder strBuff = new StringBuilder();
strBuff.append("<ul>");
for (GeneralName name : names)
{
strBuff.append("<li>");
strBuff.append(getGeneralNameString(name, linkClass));
strBuff.append("</li>");
}
strBuff.append("</ul>");
return strBuff.toString();
}