当前位置: 首页>>代码示例>>Java>>正文


Java RDN.getTypesAndValues方法代码示例

本文整理汇总了Java中org.bouncycastle.asn1.x500.RDN.getTypesAndValues方法的典型用法代码示例。如果您正苦于以下问题:Java RDN.getTypesAndValues方法的具体用法?Java RDN.getTypesAndValues怎么用?Java RDN.getTypesAndValues使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.bouncycastle.asn1.x500.RDN的用法示例。


在下文中一共展示了RDN.getTypesAndValues方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getCommonName

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
public static String getCommonName(X500Name name) {
    ParamUtil.requireNonNull("name", name);
    RDN[] rdns = name.getRDNs(ObjectIdentifiers.DN_CN);
    if (rdns != null && rdns.length > 0) {
        RDN rdn = rdns[0];
        AttributeTypeAndValue atv = null;
        if (rdn.isMultiValued()) {
            for (AttributeTypeAndValue m : rdn.getTypesAndValues()) {
                if (m.getType().equals(ObjectIdentifiers.DN_CN)) {
                    atv = m;
                    break;
                }
            }
        } else {
            atv = rdn.getFirst();
        }
        return (atv == null) ? null : rdnValueToString(atv.getValue());
    }
    return null;
}
 
开发者ID:xipki,项目名称:xitk,代码行数:21,代码来源:X509Util.java

示例2: RdnPanelList

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
public RdnPanelList(X500Name x500Name, boolean editable) {
	setLayout(new MigLayout("insets dialog, flowy", "[right]", "[]rel[]"));

	// we have to reverse RDN order for dialog
	List<RDN> rdnsAsList = Arrays.asList(x500Name.getRDNs());
	Collections.reverse(rdnsAsList);

	for (RDN rdn : rdnsAsList) {
		this.editable = editable;
		for (AttributeTypeAndValue atav : rdn.getTypesAndValues()) {
			String type = OidDisplayNameMapping.getDisplayNameForOid(atav.getType().getId());
			String value = atav.getValue().toString();
			addItem(new RdnPanel(new JComboBox<Object>(comboBoxEntries), type, value, this, editable));
		}
	}
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:17,代码来源:RdnPanelList.java

示例3: checkRdn

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
private boolean checkRdn(RDN certRDN, AttributeTypeAndValue expectedTypeAndValue) {
    String expectedValue = IETFUtils.valueToString(expectedTypeAndValue.getValue());
    boolean constraintFound = false;
    AttributeTypeAndValue[] typesAndValues = certRDN.getTypesAndValues();
    for (AttributeTypeAndValue typesAndValue : typesAndValues) {
        if (typesAndValue.getType().equals(expectedTypeAndValue.getType())) {
            String actualValue = IETFUtils.valueToString(typesAndValue.getValue());
            if (actualValue.equals(expectedValue)) {
                constraintFound = true;
            } else {
                constraintFound = false;
                break;
            }
        }
    }

    return constraintFound;
}
 
开发者ID:guardtime,项目名称:ksi-java-sdk,代码行数:19,代码来源:X509CertificateSubjectRdnSelector.java

示例4: appendRDN

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
public static void appendRDN(
    StringBuffer          buf,
    RDN                   rdn,
    Hashtable             oidSymbols)
{
    if (rdn.isMultiValued())
    {
        AttributeTypeAndValue[] atv = rdn.getTypesAndValues();
        boolean firstAtv = true;

        for (int j = 0; j != atv.length; j++)
        {
            if (firstAtv)
            {
                firstAtv = false;
            }
            else
            {
                buf.append('+');
            }

            IETFUtils.appendTypeAndValue(buf, atv[j], oidSymbols);
        }
    }
    else
    {
        IETFUtils.appendTypeAndValue(buf, rdn.getFirst(), oidSymbols);
    }
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:30,代码来源:IETFUtils.java

示例5: appendRDN

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
public static void appendRDN(
    StringBuffer          buf,
    RDN                   rdn,
    Hashtable             oidSymbols)
{
    if (rdn.isMultiValued())
    {
        AttributeTypeAndValue[] atv = rdn.getTypesAndValues();
        boolean firstAtv = true;

        for (int j = 0; j != atv.length; j++)
        {
            if (firstAtv)
            {
                firstAtv = false;
            }
            else
            {
                buf.append('+');
            }

            IETFUtils.appendTypeAndValue(buf, atv[j], oidSymbols);
        }
    }
    else
    {
        if (rdn.getFirst() != null)
        {
            IETFUtils.appendTypeAndValue(buf, rdn.getFirst(), oidSymbols);
        }
    }
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:33,代码来源:IETFUtils.java

示例6: getEmailFromCert

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
/**
 * Extract email addresses from a certificate
 * 
 * @param cert the X509 certificate holder
 * @return a List of all email addresses found
 * @throws CertificateException
 */
private static List<String> getEmailFromCert(X509CertificateHolder cert)
        throws CertificateException {
    List<String> res = new ArrayList<>();

    X500Name subject = cert.getSubject();
    for (RDN emails : subject.getRDNs(BCStyle.EmailAddress)) {
        for (AttributeTypeAndValue emailAttr: emails.getTypesAndValues()) {
            log.debug("Add email from RDN: " + IETFUtils.valueToString(emailAttr.getValue()));
            res.add(IETFUtils.valueToString(emailAttr.getValue()));
        }
    }

    Extension subjectAlternativeNames = cert
            .getExtension(Extension.subjectAlternativeName);
    if (subjectAlternativeNames != null) {
        for (GeneralName name : GeneralNames.getInstance(
                subjectAlternativeNames.getParsedValue()).getNames()) {
            if (name.getTagNo() == GeneralName.rfc822Name) {
                String email = IETFUtils.valueToString(name.getName());
                log.debug("Add email from subjectAlternativeName: " + email);
                res.add(email);
            }
        }
    }

    return res;
}
 
开发者ID:johrstrom,项目名称:cloud-meter,代码行数:35,代码来源:SMIMEAssertion.java

示例7: testReadCertificate

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
@Test
public void testReadCertificate() throws Exception {
	KeyStore keyStore = KeyStore.getInstance("PKCS12");
	LOG.debug("eHealth PKCS12 path: " + this.config.getEHealthPKCS12Path());
	FileInputStream fileInputStream = new FileInputStream(this.config.getEHealthPKCS12Path());
	keyStore.load(fileInputStream, this.config.getEHealthPKCS12Password().toCharArray());
	Enumeration<String> aliasesEnum = keyStore.aliases();
	while (aliasesEnum.hasMoreElements()) {
		String alias = aliasesEnum.nextElement();
		LOG.debug("alias: " + alias);
		X509Certificate certificate = (X509Certificate) keyStore.getCertificate(alias);
		// LOG.debug("certificate: " + certificate);
		LOG.debug("certificate subject: " + certificate.getSubjectX500Principal());

		X509CertificateHolder certificateHolder = new X509CertificateHolder(certificate.getEncoded());
		X500Name subjectName = certificateHolder.getSubject();
		RDN[] rdns = subjectName.getRDNs();
		for (RDN rdn : rdns) {
			LOG.debug("--------");
			AttributeTypeAndValue[] attributes = rdn.getTypesAndValues();
			for (AttributeTypeAndValue attribute : attributes) {
				LOG.debug(attribute.getType() + " = " + attribute.getValue());
				LOG.debug("value type: " + attribute.getValue().getClass().getName());
			}
		}

		Certificate[] certificateChain = keyStore.getCertificateChain(alias);
		for (Certificate cert : certificateChain) {
			// LOG.debug("certificate chain: " + cert);
		}
	}
}
 
开发者ID:e-Contract,项目名称:mycarenet,代码行数:33,代码来源:EHealthCertificateTest.java

示例8: testGenerateCertificate

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
@Test
public void testGenerateCertificate() throws Exception {
	CertRASession certRASession = new CertRASession("[email protected]", "0478/299492");

	String ssin = CertRAClient.getSSIN(this.signCertificateChain.get(0));

	X500NameBuilder nameBuilder = new X500NameBuilder();
	nameBuilder.addRDN(X509ObjectIdentifiers.countryName, new DERPrintableString("BE"));
	nameBuilder.addRDN(X509ObjectIdentifiers.organization, new DERPrintableString("Federal Government"));
	nameBuilder.addRDN(X509ObjectIdentifiers.organizationalUnitName,
			new DERPrintableString("eHealth-platform Belgium"));
	nameBuilder.addRDN(X509ObjectIdentifiers.organizationalUnitName, new DERPrintableString("SSIN=" + ssin));
	nameBuilder.addRDN(X509ObjectIdentifiers.commonName, new DERPrintableString("SSIN=" + ssin));
	X500Name name = nameBuilder.build();
	byte[] encodedCsr = certRASession.generateCSR(name);

	PKCS10CertificationRequest csr = new PKCS10CertificationRequest(encodedCsr);
	LOG.debug("CSR subject: " + csr.getSubject());
	X500Name subjectName = csr.getSubject();
	RDN[] rdns = subjectName.getRDNs();
	for (RDN rdn : rdns) {
		LOG.debug("--------");
		AttributeTypeAndValue[] attributes = rdn.getTypesAndValues();
		for (AttributeTypeAndValue attribute : attributes) {
			LOG.debug(attribute.getType() + " = " + attribute.getValue());
			LOG.debug("value type: " + attribute.getValue().getClass().getName());
		}
	}
}
 
开发者ID:e-Contract,项目名称:mycarenet,代码行数:30,代码来源:CertRAClientTest.java

示例9: appendRDN

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
public static void appendRDN(
    StringBuilder          buf,
    RDN                   rdn,
    Map<ASN1ObjectIdentifier, String> oidSymbols)
{
    if (rdn.isMultiValued())
    {
        AttributeTypeAndValue[] atv = rdn.getTypesAndValues();
        boolean firstAtv = true;

        for (int j = 0; j != atv.length; j++)
        {
            if (firstAtv)
            {
                firstAtv = false;
            }
            else
            {
                buf.append('+');
            }

            ExtendedIETFUtils.appendTypeAndValue(buf, atv[j], oidSymbols);
        }
    }
    else
    {
        if (rdn.getFirst() != null)
        {
            ExtendedIETFUtils.appendTypeAndValue(buf, rdn.getFirst(), oidSymbols);
        }
    }
}
 
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:33,代码来源:ExtendedIETFUtils.java

示例10: rDNAreEqual

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
public static boolean rDNAreEqual(RDN rdn1, RDN rdn2)
{
    if (rdn1.isMultiValued())
    {
        if (rdn2.isMultiValued())
        {
            AttributeTypeAndValue[] atvs1 = rdn1.getTypesAndValues();
            AttributeTypeAndValue[] atvs2 = rdn2.getTypesAndValues();

            if (atvs1.length != atvs2.length)
            {
                return false;
            }

            for (int i = 0; i != atvs1.length; i++)
            {
                if (!atvAreEqual(atvs1[i], atvs2[i]))
                {
                    return false;
                }
            }
        }
        else
        {
            return false;
        }
    }
    else
    {
        if (!rdn2.isMultiValued())
        {
            return atvAreEqual(rdn1.getFirst(), rdn2.getFirst());
        }
        else
        {
            return false;
        }
    }

    return true;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:42,代码来源:IETFUtils.java

示例11: getDistributionPointNameString

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
private String getDistributionPointNameString(DistributionPointName distributionPointName, String baseIndent)
		throws IOException {
	// @formatter:off

	/*
	 * DistributionPointName ::= CHOICE {
	 * 		fullname [0] GeneralNames,
	 * 		nameRelativeToCRLIssuer [1] RelativeDistinguishedName
	 * }
	 *
	 * RelativeDistinguishedName ::= SET SIZE (1 .. MAX) OF
	 * AttributeTypeAndValue
	 *
	 * AttributeTypeAndValue ::= ASN1Sequence { type AttributeType, value
	 * AttributeValue }
	 */

	// @formatter: on

	StringBuilder sb = new StringBuilder();

	sb.append(baseIndent);
	sb.append(res.getString("DistributionPointName"));
	sb.append(NEWLINE);

	if (distributionPointName.getType() == DistributionPointName.FULL_NAME) {
		sb.append(baseIndent);
		sb.append(INDENT);
		sb.append(res.getString("DistributionPointFullName"));
		sb.append(NEWLINE);

		GeneralNames generalNames = GeneralNames.getInstance(distributionPointName.getName());

		for (GeneralName generalName : generalNames.getNames()) {
			sb.append(baseIndent);
			sb.append(INDENT);
			sb.append(INDENT);
			sb.append(GeneralNameUtil.toString(generalName));
			sb.append(NEWLINE);
		}
	} else {
		// DistributionPointName.TAG_NAMERELATIVETOCRLISSUER
		sb.append(baseIndent);
		sb.append(INDENT);
		sb.append(res.getString("DistributionPointNameRelativeToCrlIssuer"));
		sb.append(NEWLINE);

		RDN rdn = RDN.getInstance(distributionPointName.getName());

		for (AttributeTypeAndValue attributeTypeAndValue : rdn.getTypesAndValues()) {
			ASN1ObjectIdentifier attributeType = attributeTypeAndValue.getType();
			ASN1Encodable attributeValue = attributeTypeAndValue.getValue();

			String attributeTypeStr = getAttributeTypeString(attributeType);
			String attributeValueStr = getAttributeValueString(attributeType, attributeValue);

			sb.append(baseIndent);
			sb.append(INDENT);
			sb.append(INDENT);
			sb.append(MessageFormat.format("{0}={1}", attributeTypeStr, attributeValueStr));
			sb.append(NEWLINE);
		}
	}

	return sb.toString();
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:67,代码来源:X509Ext.java

示例12: doInternalPrivateKey

import org.bouncycastle.asn1.x500.RDN; //导入方法依赖的package包/类
private void doInternalPrivateKey(CertificateResource resource,
		InputStream key, String passphrase, InputStream file,
		InputStream bundle) throws InvalidPassphraseException,
		CertificateException, IOException, FileFormatException,
		MismatchedCertificateException {
	
	X509Certificate cert = X509CertificateUtils.loadCertificateFromPEM(file);

	X509Certificate[] ca = X509CertificateUtils
			.loadCertificateChainFromPEM(bundle);

	X509CertificateUtils.validateChain(ca, cert);

	KeyPair pair = X509CertificateUtils.loadKeyPairFromPEM(key, 
			passphrase.toCharArray());

	if (!pair.getPublic().equals(cert.getPublicKey())) {
		throw new MismatchedCertificateException(
				"The certificate does not match the private key.");
	}

	ByteArrayOutputStream privateKeyFile = new ByteArrayOutputStream();
	X509CertificateUtils.saveKeyPair(pair, privateKeyFile);

	ByteArrayOutputStream certStream = new ByteArrayOutputStream();
	X509CertificateUtils.saveCertificate(new Certificate[] { cert },
			certStream);

	ByteArrayOutputStream caStream = new ByteArrayOutputStream();
	X509CertificateUtils.saveCertificate(ca, caStream);

	X500Name x500name = new JcaX509CertificateHolder(cert).getSubject();
	RDN cn = x500name.getRDNs(BCStyle.CN)[0];
	for (RDN rdn : x500name.getRDNs()) {
		for (AttributeTypeAndValue v : rdn.getTypesAndValues()) {
			log.info(v.getType().toString() + ": "
					+ IETFUtils.valueToString(v.getValue()));
		}
	}
	if (!resource.getName().equals(DEFAULT_CERTIFICATE_NAME)) {
		resource.setName(IETFUtils.valueToString(cn.getFirst().getValue()));
	}
	resource.setCommonName(IETFUtils
			.valueToString(cn.getFirst().getValue()));
	resource.setCountry("");
	resource.setLocation("");
	resource.setOrganization("");
	resource.setOrganizationalUnit("");
	resource.setState("");
	resource.setPrivateKey(new String(privateKeyFile.toByteArray(), "UTF-8"));
	resource.setCertificate(new String(certStream.toByteArray(), "UTF-8"));
	resource.setBundle(new String(caStream.toByteArray(), "UTF-8"));

}
 
开发者ID:ludup,项目名称:hypersocket-framework,代码行数:55,代码来源:CertificateResourceServiceImpl.java


注:本文中的org.bouncycastle.asn1.x500.RDN.getTypesAndValues方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。