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


Java AttributeTypeAndValue类代码示例

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


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

示例1: appendTypeAndValue

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的package包/类
public static void appendTypeAndValue(
    StringBuffer          buf,
    AttributeTypeAndValue typeAndValue,
    Hashtable             oidSymbols)
{
    String  sym = (String)oidSymbols.get(typeAndValue.getType());

    if (sym != null)
    {
        buf.append(sym);
    }
    else
    {
        buf.append(typeAndValue.getType().getId());
    }

    buf.append('=');

    buf.append(valueToString(typeAndValue.getValue()));
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:21,代码来源:IETFUtils.java

示例2: getCommonName

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的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

示例3: verifyCertificateCommonName

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的package包/类
static void verifyCertificateCommonName(X500Name subject, String commonName) {
    List<AttributeTypeAndValue> attributesAndValues = Arrays.stream(subject.getRDNs())
            .flatMap(rdn -> rdn.isMultiValued() ?
                    Stream.of(rdn.getTypesAndValues()) : Stream.of(rdn.getFirst()))
            .filter(attr -> attr.getType() == BCStyle.CN)
            .collect(Collectors.toList());

    if (attributesAndValues.size() != 1) {
        throw new IllegalArgumentException("Only 1 common name should be set");
    }

    String actualCommonName = DERUTF8String.getInstance(attributesAndValues.get(0).getValue()).getString();
    if (! actualCommonName.equals(commonName)) {
        throw new IllegalArgumentException("Expected common name to be " + commonName + ", but was " + actualCommonName);
    }
}
 
开发者ID:vespa-engine,项目名称:vespa,代码行数:17,代码来源:CertificateSigner.java

示例4: RdnPanelList

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的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

示例5: match

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的package包/类
public boolean match(Certificate cert) {
    if (!(cert instanceof X509Certificate)) {
        return false;
    }
    if (rdnArray == null) {
        return true;
    }
    try {
        X500Name x500name = getX500SubjectName((X509Certificate) cert);
        boolean ok = true;
        for (RDN rdn : rdnArray) {
            AttributeTypeAndValue expectedTypeAndValue = rdn.getFirst();

            ok = ok && contains(x500name, expectedTypeAndValue);
        }
        return ok;
    } catch (CertificateEncodingException e) {
        return false;
    }
}
 
开发者ID:guardtime,项目名称:ksi-java-sdk,代码行数:21,代码来源:X509CertificateSubjectRdnSelector.java

示例6: checkRdn

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的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

示例7: appendTypeAndValue

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的package包/类
public static void appendTypeAndValue(
    StringBuilder          buf,
    AttributeTypeAndValue typeAndValue,
    Map<ASN1ObjectIdentifier, String> oidSymbols)
{
    String  sym = oidSymbols.get(typeAndValue.getType());

    if (sym != null)
    {
        buf.append(sym);
    }
    else
    {
        buf.append(typeAndValue.getType().getId());
    }

    buf.append('=');

    buf.append(valueToString(typeAndValue.getValue()));
}
 
开发者ID:BandwidthOnDemand,项目名称:nsi-dds,代码行数:21,代码来源:ExtendedIETFUtils.java

示例8: appendRDN

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的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

示例9: atvAreEqual

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的package包/类
private static boolean atvAreEqual(AttributeTypeAndValue atv1, AttributeTypeAndValue atv2)
{
    if (atv1 == atv2)
    {
        return true;
    }

    if (atv1 == null)
    {
        return false;
    }

    if (atv2 == null)
    {
        return false;
    }

    ASN1ObjectIdentifier o1 = atv1.getType();
    ASN1ObjectIdentifier o2 = atv2.getType();

    if (!o1.equals(o2))
    {
        return false;
    }

    String v1 = IETFUtils.canonicalize(IETFUtils.valueToString(atv1.getValue()));
    String v2 = IETFUtils.canonicalize(IETFUtils.valueToString(atv2.getValue()));

    if (!v1.equals(v2))
    {
        return false;
    }

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

示例10: calculateHashCode

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的package包/类
public int calculateHashCode(X500Name name)
{
    int hashCodeValue = 0;
    RDN[] rdns = name.getRDNs();

    // this needs to be order independent, like equals
    for (int i = 0; i != rdns.length; i++)
    {
        if (rdns[i].isMultiValued())
        {
            AttributeTypeAndValue[] atv = rdns[i].getTypesAndValues();

            for (int j = 0; j != atv.length; j++)
            {
                hashCodeValue ^= atv[j].getType().hashCode();
                hashCodeValue ^= calcHashCode(atv[j].getValue());
            }
        }
        else
        {
            hashCodeValue ^= rdns[i].getFirst().getType().hashCode();
            hashCodeValue ^= calcHashCode(rdns[i].getFirst().getValue());
        }
    }

    return hashCodeValue;
}
 
开发者ID:Appdome,项目名称:ipack,代码行数:28,代码来源:RFC4519Style.java

示例11: reorderDn

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的package包/类
/**
 * Reorders DN to the order the elements appear in the RFC 2253 table
 *
 * https://www.ietf.org/rfc/rfc2253.txt
 *
 * String  X.500 AttributeType
 * ------------------------------
 * CN      commonName
 * L       localityName
 * ST      stateOrProvinceName
 * O       organizationName
 * OU      organizationalUnitName
 * C       countryName
 * STREET  streetAddress
 * DC      domainComponent
 * UID     userid
 *
 * @param dn a possibly unordered DN
 * @return the ordered dn
 */
public static String reorderDn(String dn) {
    RDN[] rdNs = new X500Name(dn).getRDNs();
    Arrays.sort(rdNs, new Comparator<RDN>() {
        @Override
        public int compare(RDN o1, RDN o2) {
            AttributeTypeAndValue o1First = o1.getFirst();
            AttributeTypeAndValue o2First = o2.getFirst();

            ASN1ObjectIdentifier o1Type = o1First.getType();
            ASN1ObjectIdentifier o2Type = o2First.getType();

            Integer o1Rank = dnOrderMap.get(o1Type);
            Integer o2Rank = dnOrderMap.get(o2Type);
            if (o1Rank == null) {
                if (o2Rank == null) {
                    int idComparison = o1Type.getId().compareTo(o2Type.getId());
                    if (idComparison != 0) {
                        return idComparison;
                    }
                    return String.valueOf(o1Type).compareTo(String.valueOf(o2Type));
                }
                return 1;
            } else if (o2Rank == null) {
                return -1;
            }
            return o1Rank - o2Rank;
        }
    });
    return new X500Name(rdNs).toString();
}
 
开发者ID:apache,项目名称:nifi-registry,代码行数:51,代码来源:CertificateUtils.java

示例12: appendRDN

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的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

示例13: getEmailFromCert

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的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

示例14: toString

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的package包/类
@Override
public String toString(X500Name name) {
	// Convert in reverse
	StringBuffer buf = new StringBuffer();
	boolean first = true;

	RDN[] rdns = name.getRDNs();

	for (int i = rdns.length - 1; i >= 0; i--) {
		if (first) {
			first = false;
		} else {
			buf.append(',');
		}

		if (rdns[i].isMultiValued()) {
			AttributeTypeAndValue[] atv = rdns[i].getTypesAndValues();
			boolean firstAtv = true;

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

				IETFUtils.appendTypeAndValue(buf, atv[j], DefaultSymbols);
			}
		} else {
			IETFUtils.appendTypeAndValue(buf, rdns[i].getFirst(), DefaultSymbols);
		}
	}

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

示例15: extractCommonName

import org.bouncycastle.asn1.x500.AttributeTypeAndValue; //导入依赖的package包/类
private static String extractCommonName(X500Name name) {
	for (RDN rdn : name.getRDNs()) {
		AttributeTypeAndValue atav = rdn.getFirst();

		if (atav.getType().equals(BCStyle.CN)) {
			return atav.getValue().toString();
		}
	}

	return null;
}
 
开发者ID:kaikramer,项目名称:keystore-explorer,代码行数:12,代码来源:X509CertUtil.java


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