private void okPressed() { List<PolicyInformation> policyInformation = jpiCertificatePolicies.getPolicyInformation(); if (policyInformation.size() == 0) { JOptionPane.showMessageDialog(this, res.getString("DCertificatePolicies.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } CertificatePolicies certificatePolicies = new CertificatePolicies(policyInformation.toArray( new PolicyInformation[policyInformation.size()])); try { value = certificatePolicies.getEncoded(ASN1Encoding.DER); } catch (IOException ex) { DError dError = new DError(this, ex); dError.setLocationRelativeTo(this); dError.setVisible(true); return; } closeDialog(); }
/** * 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; }
/** * 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; }
private void prepopulateWithValue(byte[] value) throws IOException { CertificatePolicies certificatePolicies = CertificatePolicies.getInstance(value); List<PolicyInformation> accessDescriptionList = new ArrayList<PolicyInformation>(Arrays.asList(certificatePolicies.getPolicyInformation())); jpiCertificatePolicies.setPolicyInformation(accessDescriptionList); }