本文整理汇总了Java中org.bouncycastle.jce.X509Principal类的典型用法代码示例。如果您正苦于以下问题:Java X509Principal类的具体用法?Java X509Principal怎么用?Java X509Principal使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
X509Principal类属于org.bouncycastle.jce包,在下文中一共展示了X509Principal类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: AttributeCertificateHolder
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
public AttributeCertificateHolder(X509Certificate cert)
throws CertificateParsingException
{
X509Principal name;
try
{
name = PrincipalUtil.getIssuerX509Principal(cert);
}
catch (Exception e)
{
throw new CertificateParsingException(e.getMessage());
}
holder = new Holder(new IssuerSerial(generateGeneralNames(name),
new ASN1Integer(cert.getSerialNumber())));
}
示例2: matchesDN
import org.bouncycastle.jce.X509Principal; //导入依赖的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;
}
示例3: AttributeCertificateHolder
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
public AttributeCertificateHolder(X509Certificate cert)
throws CertificateParsingException
{
X509Principal name;
try
{
name = PrincipalUtil.getIssuerX509Principal(cert);
}
catch (Exception e)
{
throw new CertificateParsingException(e.getMessage());
}
holder = new Holder(new IssuerSerial(generateGeneralNames(name),
new DERInteger(cert.getSerialNumber())));
}
示例4: matchesDN
import org.bouncycastle.jce.X509Principal; //导入依赖的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())
.getEncoded()).equals(subject))
{
return true;
}
}
catch (IOException e)
{
}
}
}
return false;
}
示例5: generateCertificate
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
protected Certificate generateCertificate(KeyPair keyPair, String alias) throws GeneralSecurityException {
//test that Bouncy Castle provider is present and add it if it's not
if( Security.getProvider(org.bouncycastle.jce.provider.BouncyCastleProvider.PROVIDER_NAME) == null) {
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
}
X509V3CertificateGenerator certificateGenerator = new X509V3CertificateGenerator();
// X509Name nameInfo = new X509Name(false,"CN=" + alias);
certificateGenerator.setSignatureAlgorithm("MD5WithRSA");
certificateGenerator.setSerialNumber(new java.math.BigInteger("1"));
X509Principal nameInfo = new X509Principal("CN=" + alias);
certificateGenerator.setIssuerDN(nameInfo);
certificateGenerator.setSubjectDN(nameInfo); // note: same as issuer for self signed
certificateGenerator.setNotBefore(new Date());
Calendar c = Calendar.getInstance();
c.add(Calendar.DATE, CLIENT_CERT_EXPIRATION_DAYS);
certificateGenerator.setNotAfter(c.getTime());
certificateGenerator.setPublicKey(keyPair.getPublic());
return certificateGenerator.generate(keyPair.getPrivate(), org.bouncycastle.jce.provider.BouncyCastleProvider.PROVIDER_NAME);
}
示例6: createTrustCert
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
/**
* TrustAnchor's Cert
*/
private X509Certificate createTrustCert(
PublicKey pubKey,
PrivateKey privKey)
throws Exception
{
String issuer = "C=JP, O=policyMappingAdditionalTest, OU=trustAnchor";
String subject = "C=JP, O=policyMappingAdditionalTest, OU=trustAnchor";
v3CertGen.setSerialNumber(BigInteger.valueOf(10));
v3CertGen.setIssuerDN(new X509Principal(issuer));
v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30));
v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 30)));
v3CertGen.setSubjectDN(new X509Principal(subject));
v3CertGen.setPublicKey(pubKey);
v3CertGen.setSignatureAlgorithm("SHA1WithRSAEncryption");
X509Certificate cert = v3CertGen.generate(privKey);
return cert;
}
示例7: createIntmedCert
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
/**
* intermediate cert
*/
private X509Certificate createIntmedCert(
PublicKey pubKey,
PrivateKey caPrivKey,
PublicKey caPubKey,
CertificatePolicies policies,
Hashtable policyMap)
throws Exception
{
String issuer = "C=JP, O=policyMappingAdditionalTest, OU=trustAnchor";
String subject = "C=JP, O=policyMappingAdditionalTest, OU=intmedCA";
v3CertGen.reset();
v3CertGen.setSerialNumber(BigInteger.valueOf(20));
v3CertGen.setIssuerDN(new X509Principal(issuer));
v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30));
v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 30)));
v3CertGen.setSubjectDN(new X509Principal(subject));
v3CertGen.setPublicKey(pubKey);
v3CertGen.setSignatureAlgorithm("SHA1WithRSAEncryption");
v3CertGen.addExtension(X509Extensions.CertificatePolicies, true, policies);
v3CertGen.addExtension(X509Extensions.BasicConstraints, true, new BasicConstraints(true));
v3CertGen.addExtension(X509Extensions.PolicyMappings, true, new PolicyMappings(policyMap));
X509Certificate cert = v3CertGen.generate(caPrivKey);
return cert;
}
示例8: createEndEntityCert
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
/**
* endEntity cert
*/
private X509Certificate createEndEntityCert(
PublicKey pubKey,
PrivateKey caPrivKey,
PublicKey caPubKey,
ASN1EncodableVector policies)
throws Exception
{
String issuer = "C=JP, O=policyMappingAdditionalTest, OU=intMedCA";
String subject = "C=JP, O=policyMappingAdditionalTest, OU=endEntity";
v3CertGen.reset();
v3CertGen.setSerialNumber(BigInteger.valueOf(20));
v3CertGen.setIssuerDN(new X509Principal(issuer));
v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30));
v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 30)));
v3CertGen.setSubjectDN(new X509Principal(subject));
v3CertGen.setPublicKey(pubKey);
v3CertGen.setSignatureAlgorithm("SHA1WithRSAEncryption");
v3CertGen.addExtension(X509Extensions.CertificatePolicies,true,new DERSequence(policies));
X509Certificate cert = v3CertGen.generate(caPrivKey);
return cert;
}
示例9: generateSelfSignedSoftECCert
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
/**
* Create a self signed cert for our software emulation
*
* @param kp
* is the keypair for our certificate
* @return a self signed cert for our software emulation
* @throws InvalidKeyException
* on error
* @throws SignatureException
* on error
*/
private X509Certificate generateSelfSignedSoftECCert(KeyPair kp,
boolean compress) throws Exception
{
X509V3CertificateGenerator certGen = new X509V3CertificateGenerator();
ECPrivateKey privECKey = (ECPrivateKey)kp.getPrivate();
ECPublicKey pubECKey = (ECPublicKey)kp.getPublic();
if (!compress)
{
((ECPointEncoder)privECKey).setPointFormat("UNCOMPRESSED");
((ECPointEncoder)pubECKey).setPointFormat("UNCOMPRESSED");
}
certGen.setSignatureAlgorithm("ECDSAwithSHA1");
certGen.setSerialNumber(BigInteger.valueOf(1));
certGen.setIssuerDN(new X509Principal("CN=Software emul (EC Cert)"));
certGen.setNotBefore(new Date(System.currentTimeMillis() - 50000));
certGen.setNotAfter(new Date(System.currentTimeMillis() + 50000000));
certGen.setSubjectDN(new X509Principal("CN=Software emul (EC Cert)"));
certGen.setPublicKey((PublicKey)pubECKey);
return certGen.generate((PrivateKey)privECKey);
}
示例10: generateIntermediateCert
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
public static X509Certificate generateIntermediateCert(PublicKey intKey, PrivateKey caKey, X509Certificate caCert)
throws Exception
{
X509V3CertificateGenerator certGen = new X509V3CertificateGenerator();
certGen.setSerialNumber(BigInteger.valueOf(1));
certGen.setIssuerDN(PrincipalUtil.getSubjectX509Principal(caCert));
certGen.setNotBefore(new Date(System.currentTimeMillis() - 50000));
certGen.setNotAfter(new Date(System.currentTimeMillis() + 50000));
certGen.setSubjectDN(new X509Principal("CN=Test Intermediate Certificate"));
certGen.setPublicKey(intKey);
certGen.setSignatureAlgorithm("SHA256WithRSAEncryption");
certGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(caCert));
certGen.addExtension(X509Extensions.SubjectKeyIdentifier, false, new SubjectKeyIdentifierStructure(intKey));
certGen.addExtension(X509Extensions.BasicConstraints, true, new BasicConstraints(0));
certGen.addExtension(X509Extensions.KeyUsage, true, new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyCertSign | KeyUsage.cRLSign));
return certGen.generate(caKey, "BC");
}
示例11: generateEndEntityCert
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
public static X509Certificate generateEndEntityCert(PublicKey entityKey, PrivateKey caKey, X509Certificate caCert)
throws Exception
{
X509V3CertificateGenerator certGen = new X509V3CertificateGenerator();
certGen.setSerialNumber(BigInteger.valueOf(1));
certGen.setIssuerDN(PrincipalUtil.getSubjectX509Principal(caCert));
certGen.setNotBefore(new Date(System.currentTimeMillis() - 50000));
certGen.setNotAfter(new Date(System.currentTimeMillis() + 50000));
certGen.setSubjectDN(new X509Principal("CN=Test End Certificate"));
certGen.setPublicKey(entityKey);
certGen.setSignatureAlgorithm("SHA256WithRSAEncryption");
certGen.addExtension(X509Extensions.AuthorityKeyIdentifier, false, new AuthorityKeyIdentifierStructure(caCert));
certGen.addExtension(X509Extensions.SubjectKeyIdentifier, false, new SubjectKeyIdentifierStructure(entityKey));
certGen.addExtension(X509Extensions.BasicConstraints, true, new BasicConstraints(false));
certGen.addExtension(X509Extensions.KeyUsage, true, new KeyUsage(KeyUsage.digitalSignature | KeyUsage.keyEncipherment));
return certGen.generate(caKey, "BC");
}
示例12: getEncodedIssuerPrincipal
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
/**
* Returns the issuer of an attribute certificate or certificate.
*
* @param cert The attribute certificate or certificate.
* @return The issuer as <code>X509Principal</code>.
*/
protected static X509Principal getEncodedIssuerPrincipal(
Object cert)
{
if (cert instanceof X509Certificate)
{
try
{
return PrincipalUtil.getIssuerX509Principal((X509Certificate)cert);
}
catch (Exception e)
{
throw new IllegalStateException(e.toString());
}
}
else
{
return (X509Principal)((X509AttributeCertificate)cert).getIssuer().getPrincipals()[0];
}
}
示例13: getNames
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
private Object[] getNames(GeneralName[] names)
{
List l = new ArrayList(names.length);
for (int i = 0; i != names.length; i++)
{
if (names[i].getTagNo() == GeneralName.directoryName)
{
try
{
l.add(new X509Principal(
((ASN1Encodable)names[i].getName()).toASN1Primitive().getEncoded()));
}
catch (IOException e)
{
throw new RuntimeException("badly formed Name object");
}
}
}
return l.toArray(new Object[l.size()]);
}
示例14: matchesDN
import org.bouncycastle.jce.X509Principal; //导入依赖的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;
}
示例15: createEndEntityCert
import org.bouncycastle.jce.X509Principal; //导入依赖的package包/类
/**
* endEntity cert
*/
private X509Certificate createEndEntityCert(
PublicKey pubKey,
PrivateKey caPrivKey,
PublicKey caPubKey,
ASN1EncodableVector policies)
throws Exception
{
String issuer = "C=JP, O=policyMappingAdditionalTest, OU=intMedCA";
String subject = "C=JP, O=policyMappingAdditionalTest, OU=endEntity";
v3CertGen.reset();
v3CertGen.setSerialNumber(BigInteger.valueOf(20));
v3CertGen.setIssuerDN(new X509Principal(issuer));
v3CertGen.setNotBefore(new Date(System.currentTimeMillis() - 1000L * 60 * 60 * 24 * 30));
v3CertGen.setNotAfter(new Date(System.currentTimeMillis() + (1000L * 60 * 60 * 24 * 30)));
v3CertGen.setSubjectDN(new X509Principal(subject));
v3CertGen.setPublicKey(pubKey);
v3CertGen.setSignatureAlgorithm("SHA1WithRSAEncryption");
v3CertGen.addExtension(X509Extensions.CertificatePolicies,true,new DERSequence(policies));
X509Certificate cert = v3CertGen.generateX509Certificate(caPrivKey);
return cert;
}