当前位置: 首页>>代码示例>>Java>>正文


Java X509ExtensionUtil类代码示例

本文整理汇总了Java中org.bouncycastle.x509.extension.X509ExtensionUtil的典型用法代码示例。如果您正苦于以下问题:Java X509ExtensionUtil类的具体用法?Java X509ExtensionUtil怎么用?Java X509ExtensionUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


X509ExtensionUtil类属于org.bouncycastle.x509.extension包,在下文中一共展示了X509ExtensionUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSki

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
/**
 * 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
 * @throws DSSException
 */
public static byte[] getSki(final CertificateToken certificateToken, boolean computeIfMissing) throws DSSException {
	try {
		byte[] sKI = certificateToken.getCertificate().getExtensionValue(Extension.subjectKeyIdentifier.getId());
		if (Utils.isArrayNotEmpty(sKI)) {
			ASN1Primitive extension = X509ExtensionUtil.fromExtensionValue(sKI);
			SubjectKeyIdentifier skiBC = SubjectKeyIdentifier.getInstance(extension);
			return skiBC.getKeyIdentifier();
		} else if (computeIfMissing) {
			// If extension not present, we compute it from the certificate public key
			DLSequence seq = (DLSequence) DERSequence.fromByteArray(certificateToken.getPublicKey().getEncoded());
			DERBitString item = (DERBitString) seq.getObjectAt(1);
			return DSSUtils.digest(DigestAlgorithm.SHA1, item.getOctets());
		}
		return null;
	} catch (Exception e) {
		throw new DSSException(e);
	}
}
 
开发者ID:esig,项目名称:dss,代码行数:30,代码来源:DSSASN1Utils.java

示例2: copyAndAddExtension

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
/**
 * add a given extension field for the standard extensions tag (tag 3)
 * copying the extension value from another certificate.
 * @throws CertificateParsingException if the extension cannot be extracted.
 */
public void copyAndAddExtension(
    String          oid,
    boolean         critical,
    X509Certificate cert) 
    throws CertificateParsingException
{
    byte[] extValue = cert.getExtensionValue(oid);
    
    if (extValue == null)
    {
        throw new CertificateParsingException("extension " + oid + " not present");
    }
    
    try
    {
        ASN1Encodable value = X509ExtensionUtil.fromExtensionValue(extValue);

        this.addExtension(oid, critical, value);
    }
    catch (IOException e)
    {
        throw new CertificateParsingException(e.toString());
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:30,代码来源:X509V3CertificateGenerator.java

示例3: CRLDistributionPointsImpl

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的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);
				}
			}
		}
	}
}
 
开发者ID:Catherine22,项目名称:SecuritySample,代码行数:21,代码来源:CRLDistributionPointsImpl.java

示例4: SubjectAlternativeNameImpl

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的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);
		}
	}
}
 
开发者ID:Catherine22,项目名称:SecuritySample,代码行数:15,代码来源:SubjectAlternativeNameImpl.java

示例5: getAuthorityInfoAccess

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
/**
    * Returns the AuthorityInfoAccess extension value on list format.<br>
    * Otherwise, returns <b>list empty</b>.<br>
    * @return List Authority info access list
    */
public List<String> getAuthorityInfoAccess() {
	List<String> address = new ArrayList<String>();
	try {
		byte[] authorityInfoAccess = certificate.getExtensionValue(Extension.authorityInfoAccess.getId());
		if (authorityInfoAccess != null && authorityInfoAccess.length > 0) {
			AuthorityInformationAccess infoAccess = AuthorityInformationAccess.getInstance(X509ExtensionUtil
					.fromExtensionValue(authorityInfoAccess));
			for (AccessDescription desc : infoAccess.getAccessDescriptions())
				if (desc.getAccessLocation().getTagNo() == GeneralName.uniformResourceIdentifier)
					address.add(((DERIA5String) desc.getAccessLocation().getName()).getString());
		}
		return address;
	} catch (IOException error) {
		logger.info(error.getMessage());
		return address;
	}
}
 
开发者ID:demoiselle,项目名称:signer,代码行数:23,代码来源:BasicCertificate.java

示例6: loadTrustAnchor

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
protected static TrustAnchor loadTrustAnchor(String trustCertFileName)
	throws Exception
{
	X509Certificate cert = CertificateUtilities.loadCertificate(trustCertFileName);
	
	if (cert != null)
	{
	    byte[] ncBytes = cert
	            .getExtensionValue(X509Extensions.NameConstraints.getId());
	
	    if (ncBytes != null)
	    {
	        ASN1Encodable extValue = X509ExtensionUtil
	                .fromExtensionValue(ncBytes);
	        return new TrustAnchor(cert, extValue.getDEREncoded());
	    }
	    
	    return new TrustAnchor(cert, null);
	}
	
	return null;
}
 
开发者ID:edeoliveira,项目名称:Mailster,代码行数:23,代码来源:CertificateUtilities.java

示例7: getTrustAnchor

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
protected static TrustAnchor getTrustAnchor(String trustcert)
        throws Exception
{
    X509Certificate cert = loadCert(trustcert);
    if (cert != null)
    {
        byte[] ncBytes = cert
                .getExtensionValue(X509Extension.nameConstraints.getId());

        if (ncBytes != null)
        {
            ASN1Encodable extValue = X509ExtensionUtil
                    .fromExtensionValue(ncBytes);
            return new TrustAnchor(cert, extValue.toASN1Primitive().getEncoded(ASN1Encoding.DER));
        }
        return new TrustAnchor(cert, null);
    }
    return null;
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:20,代码来源:ValidateSignedMail.java

示例8: getTrustAnchor

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
private TrustAnchor getTrustAnchor(String trustcert) throws Exception
{
    X509Certificate cert = loadCert(trustcert);
    if (cert != null)
    {
        byte[] ncBytes = cert
                .getExtensionValue(X509Extension.nameConstraints.getId());

        if (ncBytes != null)
        {
            ASN1Encodable extValue = X509ExtensionUtil
                    .fromExtensionValue(ncBytes);
            return new TrustAnchor(cert, extValue.toASN1Primitive().getEncoded(ASN1Encoding.DER));
        }
        return new TrustAnchor(cert, null);
    }
    return null;
}
 
开发者ID:credentials,项目名称:irma_future_id,代码行数:19,代码来源:SignedMailValidatorTest.java

示例9: getInhabitAnyPolicyExtension

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
static String getInhabitAnyPolicyExtension(X509Certificate certificate) throws IOException {
    byte[] inhabitAnyPolicyBytes = certificate.getExtensionValue(Extension.inhibitAnyPolicy.toString());
    if (inhabitAnyPolicyBytes != null) {
        ASN1Integer skipCertsInteger = (ASN1Integer) X509ExtensionUtil.fromExtensionValue(inhabitAnyPolicyBytes);
        return skipCertsInteger.getValue().toString();
    }
    return "";
}
 
开发者ID:stevanmilic,项目名称:X509-certificate-manager,代码行数:9,代码来源:CertificateHelper.java

示例10: getAltNames

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
/**
 * Gets the list of alternative names of a given name type.
 * 
 * @param certificate the certificate to extract the alternative names from
 * @param nameTypes the name types
 * 
 * @return the alt names, of the given type, within the cert
 */
public static List getAltNames(X509Certificate certificate, Integer[] nameTypes) {
    Logger log = getLogger();
    if (certificate == null) {
        return null;
    }

    List<Object> names = new LinkedList<Object>();
    Collection<List<?>> altNames = null;
    try {
        altNames = X509ExtensionUtil.getSubjectAlternativeNames(certificate);
    } catch (CertificateParsingException e) {
        log.error("Encountered an problem trying to extract Subject Alternate "
                + "Name from supplied certificate: " + e);
        return names;
    }

    if (altNames != null) {
        // 0th position represents the alt name type
        // 1st position contains the alt name data
        for (List altName : altNames) {
            for (Integer nameType : nameTypes) {
                if (altName.get(0).equals(nameType)) {
                    names.add(convertAltNameType(nameType, altName.get(1)));
                    break;
                }
            }
        }
    }

    return names;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:X509Util.java

示例11: BasicConstraintsImpl

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
public BasicConstraintsImpl(X509Certificate cert) throws CertificateException, IOException {
	byte[] extVal = cert.getExtensionValue(Extension.basicConstraints.getId());
	if (extVal == null)
		return;
	org.bouncycastle.asn1.x509.BasicConstraints bc = org.bouncycastle.asn1.x509.BasicConstraints
			.getInstance(X509ExtensionUtil.fromExtensionValue(extVal));
	isCA = bc.isCA();
	pathLen = bc.getPathLenConstraint();
}
 
开发者ID:Catherine22,项目名称:SecuritySample,代码行数:10,代码来源:BasicConstraintsImpl.java

示例12: CertificatePoliciesImpl

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
public CertificatePoliciesImpl(X509Certificate cert) throws IOException {
	certificatePolicyIds = new ArrayList<>();
	byte[] extVal = cert.getExtensionValue(Extension.certificatePolicies.getId());
	if (extVal == null)
		return;
	org.bouncycastle.asn1.x509.CertificatePolicies cf = org.bouncycastle.asn1.x509.CertificatePolicies
			.getInstance(X509ExtensionUtil.fromExtensionValue(extVal));
	PolicyInformation[] information = cf.getPolicyInformation();
	for (PolicyInformation p : information) {
		ASN1ObjectIdentifier aIdentifier = p.getPolicyIdentifier();
		certificatePolicyIds.add(aIdentifier.getId());
	}
}
 
开发者ID:Catherine22,项目名称:SecuritySample,代码行数:14,代码来源:CertificatePoliciesImpl.java

示例13: KeyIdentifierImpl

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
public KeyIdentifierImpl(X509Certificate cert) throws CertificateException, IOException {
    byte[] extVal = cert.getExtensionValue(Extension.authorityKeyIdentifier.getId());
    if (extVal == null) {
        lock = true;
        return;
    }
    AuthorityKeyIdentifier aki = AuthorityKeyIdentifier.getInstance(X509ExtensionUtil.fromExtensionValue(extVal));
    keyIdentifier = aki.getKeyIdentifier();
}
 
开发者ID:Catherine22,项目名称:SecuritySample,代码行数:10,代码来源:KeyIdentifierImpl.java

示例14: ExtendedKeyUsageImpl

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
public ExtendedKeyUsageImpl(X509Certificate cert) throws IOException {
	keyPurposeIds = new ArrayList<>();
	byte[] extVal = cert.getExtensionValue(Extension.extendedKeyUsage.getId());
	if (extVal == null)
		return;
	org.bouncycastle.asn1.x509.ExtendedKeyUsage usage = org.bouncycastle.asn1.x509.ExtendedKeyUsage
			.getInstance(X509ExtensionUtil.fromExtensionValue(extVal));
	KeyPurposeId[] usages = usage.getUsages();
	for (int i = 0; i < usages.length; i++) {
		keyPurposeIds.add(usages[i].getId());
	}
}
 
开发者ID:Catherine22,项目名称:SecuritySample,代码行数:13,代码来源:ExtendedKeyUsageImpl.java

示例15: SubjectKeyIdentifierImpl

import org.bouncycastle.x509.extension.X509ExtensionUtil; //导入依赖的package包/类
public SubjectKeyIdentifierImpl(X509Certificate cert) throws IOException {
    byte[] extVal = cert.getExtensionValue(Extension.subjectKeyIdentifier.getId());
    if (extVal == null) {
        lock = true;
        return;
    }
    org.bouncycastle.asn1.x509.SubjectKeyIdentifier identifier = org.bouncycastle.asn1.x509.SubjectKeyIdentifier
            .getInstance(X509ExtensionUtil.fromExtensionValue(extVal));
    keyIdentifier = identifier.getKeyIdentifier();
}
 
开发者ID:Catherine22,项目名称:SecuritySample,代码行数:11,代码来源:SubjectKeyIdentifierImpl.java


注:本文中的org.bouncycastle.x509.extension.X509ExtensionUtil类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。