Java Code Examples for org.bouncycastle.asn1.x509.PolicyInformation

The following are top voted examples for showing how to use org.bouncycastle.asn1.x509.PolicyInformation. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: ipack   File: OtherSigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }

    PolicyInformation[] ps = new PolicyInformation[policies.size()];

    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }

    return ps;
}
 
Example 2
Project: ipack   File: SigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }
    
    PolicyInformation[] ps = new PolicyInformation[policies.size()];
    
    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }
    
    return ps;
}
 
Example 3
Project: gwt-crypto   File: OtherSigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }

    PolicyInformation[] ps = new PolicyInformation[policies.size()];

    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }

    return ps;
}
 
Example 4
Project: gwt-crypto   File: SigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }
    
    PolicyInformation[] ps = new PolicyInformation[policies.size()];
    
    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }
    
    return ps;
}
 
Example 5
Project: gwt-crypto   File: SigningCertificateV2.java   View source code 6 votes vote down vote up
public SigningCertificateV2(
    ESSCertIDv2[] certs,
    PolicyInformation[] policies)
{
    ASN1EncodableVector v = new ASN1EncodableVector();
    for (int i=0; i < certs.length; i++)
    {
        v.add(certs[i]);
    }
    this.certs = new DERSequence(v);

    if (policies != null)
    {
        v = new ASN1EncodableVector();
        for (int i=0; i < policies.length; i++)
        {
            v.add(policies[i]);
        }
        this.policies = new DERSequence(v);
    }
}
 
Example 6
Project: Aki-SSL   File: OtherSigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }

    PolicyInformation[] ps = new PolicyInformation[policies.size()];

    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }

    return ps;
}
 
Example 7
Project: Aki-SSL   File: SigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }
    
    PolicyInformation[] ps = new PolicyInformation[policies.size()];
    
    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }
    
    return ps;
}
 
Example 8
Project: Aki-SSL   File: SigningCertificateV2.java   View source code 6 votes vote down vote up
public SigningCertificateV2(
    ESSCertIDv2[] certs,
    PolicyInformation[] policies)
{
    ASN1EncodableVector v = new ASN1EncodableVector();
    for (int i=0; i < certs.length; i++)
    {
        v.add(certs[i]);
    }
    this.certs = new DERSequence(v);

    if (policies != null)
    {
        v = new ASN1EncodableVector();
        for (int i=0; i < policies.length; i++)
        {
            v.add(policies[i]);
        }
        this.policies = new DERSequence(v);
    }
}
 
Example 9
Project: keystore-explorer   File: DCertificatePolicies.java   View source code 6 votes vote down vote up
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();
}
 
Example 10
Project: keystore-explorer   File: PolicyInformationTableCellRend.java   View source code 6 votes vote down vote up
/**
 * Returns the rendered cell.
 *
 * @param jtPolicyInformation
 *            The JTable
 * @param value
 *            The value to assign to the cell
 * @param isSelected
 *            True if cell is selected
 * @param row
 *            The row of the cell to render
 * @param col
 *            The column of the cell to render
 * @param hasFocus
 *            If true, render cell appropriately
 * @return The renderered cell
 */
@Override
public Component getTableCellRendererComponent(JTable jtPolicyInformation, Object value, boolean isSelected,
		boolean hasFocus, int row, int col) {
	JLabel cell = (JLabel) super.getTableCellRendererComponent(jtPolicyInformation, value, isSelected, hasFocus,
			row, col);

	PolicyInformation policyInformation = (PolicyInformation) value;

	try {
		String policyInformationStr = PolicyInformationUtil.toString(policyInformation);
		cell.setText(policyInformationStr);
		cell.setToolTipText(policyInformationStr);
	} catch (IOException ex) {
		throw new RuntimeException(ex); // We build this data so should not
		// happen
	}

	cell.setHorizontalAlignment(LEFT);
	cell.setBorder(new EmptyBorder(0, 5, 0, 5));

	return cell;
}
 
Example 11
Project: keystore-explorer   File: DPolicyInformationChooser.java   View source code 6 votes vote down vote up
private void populate(PolicyInformation policyInformation) throws IOException {
	if (policyInformation != null) {
		joiPolicyIdentifier.setObjectId(policyInformation.getPolicyIdentifier());

		ASN1Sequence policyQualifierInfoSeq = policyInformation.getPolicyQualifiers();

		if (policyQualifierInfoSeq != null) {
			List<PolicyQualifierInfo> policyQualifierInfo = new ArrayList<PolicyQualifierInfo>();

			for (int i = 0; i < policyQualifierInfoSeq.size(); i++) {
				PolicyQualifierInfo policyQualInfo = PolicyQualifierInfo.getInstance(
						policyQualifierInfoSeq.getObjectAt(i));
				policyQualifierInfo.add(policyQualInfo);
			}

			jpqPolicyQualifiers.setPolicyQualifierInfo(policyQualifierInfo);
		}
	}
}
 
Example 12
Project: keystore-explorer   File: PolicyInformationTableModel.java   View source code 6 votes vote down vote up
/**
 * Load the PolicyInformationTableModel with policy information.
 *
 * @param policyInformation
 *            The policy information
 */
public void load(List<PolicyInformation> policyInformation) {
	PolicyInformation[] policyInformationArray = policyInformation.toArray(new PolicyInformation[policyInformation
	                                                                                             .size()]);
	Arrays.sort(policyInformationArray, new PolicyInformationComparator());

	data = new Object[policyInformation.size()][1];

	int i = 0;
	for (PolicyInformation policyInfo : policyInformationArray) {
		data[i][0] = policyInfo;
		i++;
	}

	fireTableDataChanged();
}
 
Example 13
Project: TinyTravelTracker   File: OtherSigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }

    PolicyInformation[] ps = new PolicyInformation[policies.size()];

    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }

    return ps;
}
 
Example 14
Project: TinyTravelTracker   File: SigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }
    
    PolicyInformation[] ps = new PolicyInformation[policies.size()];
    
    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }
    
    return ps;
}
 
Example 15
Project: TinyTravelTracker   File: SigningCertificateV2.java   View source code 6 votes vote down vote up
public SigningCertificateV2(
    ESSCertIDv2[] certs,
    PolicyInformation[] policies)
{
    ASN1EncodableVector v = new ASN1EncodableVector();
    for (int i=0; i < certs.length; i++)
    {
        v.add(certs[i]);
    }
    this.certs = new DERSequence(v);

    if (policies != null)
    {
        v = new ASN1EncodableVector();
        for (int i=0; i < policies.length; i++)
        {
            v.add(policies[i]);
        }
        this.policies = new DERSequence(v);
    }
}
 
Example 16
Project: CryptMeme   File: OtherSigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }

    PolicyInformation[] ps = new PolicyInformation[policies.size()];

    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }

    return ps;
}
 
Example 17
Project: CryptMeme   File: SigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }
    
    PolicyInformation[] ps = new PolicyInformation[policies.size()];
    
    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }
    
    return ps;
}
 
Example 18
Project: CryptMeme   File: SigningCertificateV2.java   View source code 6 votes vote down vote up
public SigningCertificateV2(
    ESSCertIDv2[] certs,
    PolicyInformation[] policies)
{
    ASN1EncodableVector v = new ASN1EncodableVector();
    for (int i=0; i < certs.length; i++)
    {
        v.add(certs[i]);
    }
    this.certs = new DERSequence(v);

    if (policies != null)
    {
        v = new ASN1EncodableVector();
        for (int i=0; i < policies.length; i++)
        {
            v.add(policies[i]);
        }
        this.policies = new DERSequence(v);
    }
}
 
Example 19
Project: xipki   File: XmlX509CertprofileUtil.java   View source code 6 votes vote down vote up
public static org.bouncycastle.asn1.x509.CertificatePolicies createCertificatePolicies(
        List<CertificatePolicyInformation> policyInfos) throws CertprofileException {
    ParamUtil.requireNonEmpty("policyInfos", policyInfos);

    int size = policyInfos.size();
    PolicyInformation[] infos = new PolicyInformation[size];

    int idx = 0;
    for (CertificatePolicyInformation policyInfo : policyInfos) {
        String policyId = policyInfo.certPolicyId();
        List<CertificatePolicyQualifier> qualifiers = policyInfo.qualifiers();

        ASN1Sequence policyQualifiers = null;
        if (CollectionUtil.isNonEmpty(qualifiers)) {
            policyQualifiers = createPolicyQualifiers(qualifiers);
        }

        ASN1ObjectIdentifier policyOid = new ASN1ObjectIdentifier(policyId);
        infos[idx++] = (policyQualifiers == null) ? new PolicyInformation(policyOid)
                : new PolicyInformation(policyOid, policyQualifiers);
    }

    return new org.bouncycastle.asn1.x509.CertificatePolicies(infos);
}
 
Example 20
Project: irma_future_id   File: OtherSigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }

    PolicyInformation[] ps = new PolicyInformation[policies.size()];

    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }

    return ps;
}
 
Example 21
Project: irma_future_id   File: SigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }
    
    PolicyInformation[] ps = new PolicyInformation[policies.size()];
    
    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }
    
    return ps;
}
 
Example 22
Project: irma_future_id   File: SigningCertificateV2.java   View source code 6 votes vote down vote up
public SigningCertificateV2(
    ESSCertIDv2[] certs,
    PolicyInformation[] policies)
{
    ASN1EncodableVector v = new ASN1EncodableVector();
    for (int i=0; i < certs.length; i++)
    {
        v.add(certs[i]);
    }
    this.certs = new DERSequence(v);

    if (policies != null)
    {
        v = new ASN1EncodableVector();
        for (int i=0; i < policies.length; i++)
        {
            v.add(policies[i]);
        }
        this.policies = new DERSequence(v);
    }
}
 
Example 23
Project: bc-java   File: OtherSigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }

    PolicyInformation[] ps = new PolicyInformation[policies.size()];

    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }

    return ps;
}
 
Example 24
Project: bc-java   File: SigningCertificate.java   View source code 6 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }
    
    PolicyInformation[] ps = new PolicyInformation[policies.size()];
    
    for (int i = 0; i != policies.size(); i++)
    {
        ps[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }
    
    return ps;
}
 
Example 25
Project: bc-java   File: SigningCertificateV2.java   View source code 6 votes vote down vote up
public SigningCertificateV2(
    ESSCertIDv2[] certs,
    PolicyInformation[] policies)
{
    ASN1EncodableVector v = new ASN1EncodableVector();
    for (int i=0; i < certs.length; i++)
    {
        v.add(certs[i]);
    }
    this.certs = new DERSequence(v);

    if (policies != null)
    {
        v = new ASN1EncodableVector();
        for (int i=0; i < policies.length; i++)
        {
            v.add(policies[i]);
        }
        this.policies = new DERSequence(v);
    }
}
 
Example 26
Project: proactive-component-monitoring   File: CertTools.java   View source code 6 votes vote down vote up
/**
 * Get a certificate policy ID from a certificate policies extension
 *
 * @param cert certificate containing the extension
 * @param pos position of the policy id, if several exist, the first is as pos 0
 * @return String with the certificate policy OID
 * @throws IOException if extension can not be parsed
 */
public static String getCertificatePolicyId(X509Certificate cert, int pos) throws IOException {
    byte[] extvalue = cert.getExtensionValue(X509Extensions.CertificatePolicies.getId());
    if (extvalue == null) {
        return null;
    }
    DEROctetString oct = (DEROctetString) (new ASN1InputStream(new ByteArrayInputStream(extvalue))
            .readObject());
    ASN1Sequence seq = (ASN1Sequence) new ASN1InputStream(new ByteArrayInputStream(oct.getOctets()))
            .readObject();

    // Check the size so we don't ArrayIndexOutOfBounds
    if (seq.size() < (pos + 1)) {
        return null;
    }
    PolicyInformation pol = new PolicyInformation((ASN1Sequence) seq.getObjectAt(pos));
    String id = pol.getPolicyIdentifier().getId();
    return id;
}
 
Example 27
Project: ipack   File: DVCSRequestInformationBuilder.java   View source code 5 votes vote down vote up
public void setRequestPolicy(PolicyInformation requestPolicy)
{
    if (initialInfo != null)
    {
        throw new IllegalStateException("cannot change request policy in existing DVCSRequestInformation");
    }

    this.requestPolicy = requestPolicy;
}
 
Example 28
Project: ipack   File: PathProcInput.java   View source code 5 votes vote down vote up
public PathProcInput(PolicyInformation[] acceptablePolicySet, boolean inhibitPolicyMapping, boolean explicitPolicyReqd, boolean inhibitAnyPolicy)
{
    this.acceptablePolicySet = acceptablePolicySet;
    this.inhibitPolicyMapping = inhibitPolicyMapping;
    this.explicitPolicyReqd = explicitPolicyReqd;
    this.inhibitAnyPolicy = inhibitAnyPolicy;
}
 
Example 29
Project: ipack   File: PathProcInput.java   View source code 5 votes vote down vote up
private static PolicyInformation[] fromSequence(ASN1Sequence seq)
{
    PolicyInformation[] tmp = new PolicyInformation[seq.size()];

    for (int i = 0; i != tmp.length; i++)
    {
        tmp[i] = PolicyInformation.getInstance(seq.getObjectAt(i));
    }

    return tmp;
}
 
Example 30
Project: ipack   File: SigningCertificateV2.java   View source code 5 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }

    PolicyInformation[] policyInformations = new PolicyInformation[policies.size()];
    for (int i = 0; i != policies.size(); i++)
    {
        policyInformations[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }
    return policyInformations;
}
 
Example 31
Project: ipack   File: DVCSRequestInfo.java   View source code 5 votes vote down vote up
/**
 * Get policy, under which the validation is requested.
 *
 * @return policy identifier or null, if any policy is acceptable.
 */
public PolicyInformation getRequestPolicy()
{
    if (data.getRequestPolicy() != null)
    {
        return data.getRequestPolicy();
    }
    return null;
}
 
Example 32
Project: X509-certificate-manager   File: CertificateHelper.java   View source code 5 votes vote down vote up
static void setCertificatePoliciesExtension(X509v3CertificateBuilder certificateBuilder, boolean isCritical,
                                            boolean anyPolicy, String cpsURI) throws IOException {
    if (anyPolicy) {
        PolicyQualifierInfo policyQualifierInfo = new PolicyQualifierInfo(cpsURI);
        PolicyInformation policyInformation = new PolicyInformation(PolicyQualifierId.id_qt_cps,
                new DERSequence(policyQualifierInfo));
        CertificatePolicies certificatePolicies = new CertificatePolicies(policyInformation);
        certificateBuilder.addExtension(Extension.certificatePolicies, isCritical, certificatePolicies);
    }
}
 
Example 33
Project: SecuritySample   File: CertificatePoliciesImpl.java   View source code 5 votes vote down vote up
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());
	}
}
 
Example 34
Project: gwt-crypto   File: DVCSRequestInformationBuilder.java   View source code 5 votes vote down vote up
public void setRequestPolicy(PolicyInformation requestPolicy)
{
    if (initialInfo != null)
    {
        throw new IllegalStateException("cannot change request policy in existing DVCSRequestInformation");
    }

    this.requestPolicy = requestPolicy;
}
 
Example 35
Project: gwt-crypto   File: PathProcInput.java   View source code 5 votes vote down vote up
public PathProcInput(PolicyInformation[] acceptablePolicySet, boolean inhibitPolicyMapping, boolean explicitPolicyReqd, boolean inhibitAnyPolicy)
{
    this.acceptablePolicySet = acceptablePolicySet;
    this.inhibitPolicyMapping = inhibitPolicyMapping;
    this.explicitPolicyReqd = explicitPolicyReqd;
    this.inhibitAnyPolicy = inhibitAnyPolicy;
}
 
Example 36
Project: gwt-crypto   File: PathProcInput.java   View source code 5 votes vote down vote up
private static PolicyInformation[] fromSequence(ASN1Sequence seq)
{
    PolicyInformation[] tmp = new PolicyInformation[seq.size()];

    for (int i = 0; i != tmp.length; i++)
    {
        tmp[i] = PolicyInformation.getInstance(seq.getObjectAt(i));
    }

    return tmp;
}
 
Example 37
Project: gwt-crypto   File: SigningCertificateV2.java   View source code 5 votes vote down vote up
public PolicyInformation[] getPolicies()
{
    if (policies == null)
    {
        return null;
    }

    PolicyInformation[] policyInformations = new PolicyInformation[policies.size()];
    for (int i = 0; i != policies.size(); i++)
    {
        policyInformations[i] = PolicyInformation.getInstance(policies.getObjectAt(i));
    }
    return policyInformations;
}
 
Example 38
Project: gwt-crypto   File: DVCSRequestInfo.java   View source code 5 votes vote down vote up
/**
 * Get policy, under which the validation is requested.
 *
 * @return policy identifier or null, if any policy is acceptable.
 */
public PolicyInformation getRequestPolicy()
{
    if (data.getRequestPolicy() != null)
    {
        return data.getRequestPolicy();
    }
    return null;
}
 
Example 39
Project: Aki-SSL   File: DVCSRequestInformationBuilder.java   View source code 5 votes vote down vote up
public void setRequestPolicy(PolicyInformation requestPolicy)
{
    if (initialInfo != null)
    {
        throw new IllegalStateException("cannot change request policy in existing DVCSRequestInformation");
    }

    this.requestPolicy = requestPolicy;
}
 
Example 40
Project: Aki-SSL   File: PathProcInput.java   View source code 5 votes vote down vote up
public PathProcInput(PolicyInformation[] acceptablePolicySet, boolean inhibitPolicyMapping, boolean explicitPolicyReqd, boolean inhibitAnyPolicy)
{
    this.acceptablePolicySet = acceptablePolicySet;
    this.inhibitPolicyMapping = inhibitPolicyMapping;
    this.explicitPolicyReqd = explicitPolicyReqd;
    this.inhibitAnyPolicy = inhibitAnyPolicy;
}