Java 类org.bouncycastle.asn1.x509.PolicyMappings 实例源码

项目:keystore-explorer    文件:DPolicyMappings.java   
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();
}
项目:CryptMeme    文件:PKIXPolicyMappingTest.java   
/**
 * 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;
}
项目:xipki    文件:XmlX509CertprofileUtil.java   
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);
}
项目:irma_future_id    文件:PKIXPolicyMappingTest.java   
/**
 * 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;
}
项目:irma_future_id    文件:PKIXPolicyMappingTest.java   
/**
 * 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;
}
项目:bc-java    文件:PKIXPolicyMappingTest.java   
/**
 * 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;
}
项目:bc-java    文件:PKIXPolicyMappingTest.java   
/**
 * 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;
}
项目:keystore-explorer    文件:PolicyMappingsUtil.java   
/**
 * 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;
}
项目:keystore-explorer    文件:PolicyMappingsUtil.java   
/**
 * 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);
}
项目:keystore-explorer    文件:PolicyMappingsUtil.java   
/**
 * 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;
}
项目:keystore-explorer    文件:PolicyMappingsUtil.java   
/**
 * 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;
}
项目:keystore-explorer    文件:X509Ext.java   
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();
}
项目:keystore-explorer    文件:DPolicyMappings.java   
private void prepopulateWithValue(byte[] value) throws IOException {
    PolicyMappings policyMappings = PolicyMappings.getInstance(value);

    jpmPolicyMappings.setPolicyMappings(policyMappings);
}
项目:keystore-explorer    文件:PolicyMappingsTableModel.java   
/**
 * 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;
}
项目:keystore-explorer    文件:JPolicyMappings.java   
/**
 * Get policy mappings.
 *
 * @return Policy mappings
 */
public PolicyMappings getPolicyMappings() {
    return policyMappings;
}
项目:keystore-explorer    文件:JPolicyMappings.java   
/**
 * Set policy mappings.
 *
 * @param policyMappings
 *            Policy mappings
 */
public void setPolicyMappings(PolicyMappings policyMappings) {
    this.policyMappings = policyMappings;
    populate();
}