private void okPressed() { PolicyMappings policyMappings = jpmPolicyMappings.getPolicyMappings(); ASN1Sequence policyMappingsSeq = (ASN1Sequence) policyMappings.toASN1Primitive(); if (policyMappingsSeq.size() == 0) { JOptionPane.showMessageDialog(this, res.getString("DPolicyMappings.ValueReq.message"), getTitle(), JOptionPane.WARNING_MESSAGE); return; } try { value = policyMappings.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; }
public static PolicyMappings buildPolicyMappings( org.xipki.ca.certprofile.x509.jaxb.PolicyMappings type) { ParamUtil.requireNonNull("type", type); List<PolicyIdMappingType> mappings = type.getMapping(); final int n = mappings.size(); CertPolicyId[] issuerDomainPolicy = new CertPolicyId[n]; CertPolicyId[] subjectDomainPolicy = new CertPolicyId[n]; for (int i = 0; i < n; i++) { PolicyIdMappingType mapping = mappings.get(i); ASN1ObjectIdentifier oid = new ASN1ObjectIdentifier( mapping.getIssuerDomainPolicy().getValue()); issuerDomainPolicy[i] = CertPolicyId.getInstance(oid); oid = new ASN1ObjectIdentifier(mapping.getSubjectDomainPolicy().getValue()); subjectDomainPolicy[i] = CertPolicyId.getInstance(oid); } return new PolicyMappings(issuerDomainPolicy, subjectDomainPolicy); }
/** * intermediate cert */ private X509Certificate createIntmedCert( PublicKey pubKey, PrivateKey caPrivKey, PublicKey caPubKey, ASN1EncodableVector 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, new DERSequence(policies)); v3CertGen.addExtension(X509Extensions.BasicConstraints, true, new BasicConstraints(true)); v3CertGen.addExtension(X509Extensions.PolicyMappings, true, new PolicyMappings(policyMap)); X509Certificate cert = v3CertGen.generateX509Certificate(caPrivKey); return cert; }
/** * Creates list of <code>PolicyMapping</code> objects from an <code>PolicyMappings</code> object. * * @param policyMappings * @return List of PolicyMapping */ public static List<PolicyMapping> getListOfPolicyMappings(PolicyMappings policyMappings) { ASN1Sequence policyMappingsSeq = (ASN1Sequence) policyMappings.toASN1Primitive(); ASN1Encodable[] policyMappingsArray = policyMappingsSeq.toArray(); List<PolicyMapping> policyMappingsList = new ArrayList<PolicyMapping>(); for (ASN1Encodable asn1Encodable : policyMappingsArray) { policyMappingsList.add(PolicyMapping.getInstance(asn1Encodable)); } return policyMappingsList; }
/** * Creates <code>PolicyMappings</code> objects from list of <code>PolicyMapping</code> * * @param listOfPolicyMappings * @return <code>PolicyMappings</code> object */ public static PolicyMappings createFromList(List<PolicyMapping> listOfPolicyMappings) { CertPolicyId[] issuerDomainPolicies = new CertPolicyId[listOfPolicyMappings.size()]; CertPolicyId[] subjectDomainPolicies = new CertPolicyId[listOfPolicyMappings.size()]; for (int i = 0; i < listOfPolicyMappings.size(); i++) { PolicyMapping policyMapping = listOfPolicyMappings.get(i); issuerDomainPolicies[i] = CertPolicyId.getInstance(policyMapping.getIssuerDomainPolicy()); subjectDomainPolicies[i] = CertPolicyId.getInstance(policyMapping.getSubjectDomainPolicy()); } return new PolicyMappings(issuerDomainPolicies, subjectDomainPolicies); }
/** * Add <code>PolicyMapping</code> to a <code>PolicyMappings</code> object * * @param policyMapping The policy mapping to be added. * @param policyMappings The policy mappings to add to. * @return New <code>PolicyMappings</code> object with additional policyMapping */ public static PolicyMappings add(PolicyMapping policyMapping, PolicyMappings policyMappings) { List<PolicyMapping> policyMappingsList = PolicyMappingsUtil.getListOfPolicyMappings(policyMappings); policyMappingsList.add(policyMapping); policyMappings = PolicyMappingsUtil.createFromList(policyMappingsList); return policyMappings; }
/** * Removes a <code>PolicyMapping</code> from a <code>PolicyMappings</code> object * * @param policyMapping The policy mapping to be removed. * @param policyMappings The policy mappings to remove from. * @return New <code>PolicyMappings</code> object without policyMapping */ public static PolicyMappings remove(PolicyMapping policyMapping, PolicyMappings policyMappings) { List<PolicyMapping> policyMappingsList = PolicyMappingsUtil.getListOfPolicyMappings(policyMappings); policyMappingsList.remove(policyMapping); policyMappings = PolicyMappingsUtil.createFromList(policyMappingsList); return policyMappings; }
private String getPolicyMappingsStringValue(byte[] value) throws IOException { // @formatter:off /* * PolicyMappings ::= ASN1Sequence SIZE (1..MAX) OF PolicyMappings * * PolicyMappings ::= ASN1Sequence { issuerDomainPolicy CertPolicyId, * subjectDomainPolicy CertPolicyId } * * CertPolicyId ::= OBJECT IDENTIFIER */ // @formatter:on StringBuilder sb = new StringBuilder(); PolicyMappings policyMappings = PolicyMappings.getInstance(value); ASN1Sequence policyMappingsSeq = (ASN1Sequence) policyMappings.toASN1Primitive(); int polMap = 0; for (ASN1Encodable policyMapping : policyMappingsSeq.toArray()) { ASN1Sequence policyMappingSeq = ASN1Sequence.getInstance(policyMapping.toASN1Primitive()); polMap++; sb.append(MessageFormat.format(res.getString("PolicyMapping"), polMap)); sb.append(NEWLINE); ASN1ObjectIdentifier issuerDomainPolicy = (ASN1ObjectIdentifier) policyMappingSeq.getObjectAt(0); ASN1ObjectIdentifier subjectDomainPolicy = (ASN1ObjectIdentifier) policyMappingSeq.getObjectAt(1); sb.append(INDENT); sb.append(MessageFormat.format(res.getString("IssuerDomainPolicy"), ObjectIdUtil.toString(issuerDomainPolicy))); sb.append(NEWLINE); sb.append(INDENT); sb.append(MessageFormat.format(res.getString("SubjectDomainPolicy"), ObjectIdUtil.toString(subjectDomainPolicy))); sb.append(NEWLINE); } return sb.toString(); }
private void prepopulateWithValue(byte[] value) throws IOException { PolicyMappings policyMappings = PolicyMappings.getInstance(value); jpmPolicyMappings.setPolicyMappings(policyMappings); }
/** * Get the class at of the cells at the given column position. * * @param col * The column position * @return The column cells' class */ @Override public Class<?> getColumnClass(int col) { return PolicyMappings.class; }
/** * Get policy mappings. * * @return Policy mappings */ public PolicyMappings getPolicyMappings() { return policyMappings; }
/** * Set policy mappings. * * @param policyMappings * Policy mappings */ public void setPolicyMappings(PolicyMappings policyMappings) { this.policyMappings = policyMappings; populate(); }