當前位置: 首頁>>代碼示例>>Java>>正文


Java RDN類代碼示例

本文整理匯總了Java中org.bouncycastle.asn1.x500.RDN的典型用法代碼示例。如果您正苦於以下問題:Java RDN類的具體用法?Java RDN怎麽用?Java RDN使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


RDN類屬於org.bouncycastle.asn1.x500包,在下文中一共展示了RDN類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: rolesFromDN

import org.bouncycastle.asn1.x500.RDN; //導入依賴的package包/類
private Set<String> rolesFromDN(String userDN) throws LDAPException, GeneralSecurityException {
  SearchRequest searchRequest = new SearchRequest(config.getRoleBaseDN(),
      SearchScope.SUB, Filter.createEqualityFilter("uniqueMember", userDN));
  Set<String> roles = Sets.newLinkedHashSet();

  LDAPConnection connection = connectionFactory.getLDAPConnection();
  try {
    SearchResult sr = connection.search(searchRequest);

    for (SearchResultEntry sre : sr.getSearchEntries()) {
      X500Name x500Name = new X500Name(sre.getDN());
      RDN[] rdns = x500Name.getRDNs(BCStyle.CN);
      if (rdns.length == 0) {
        logger.error("Could not create X500 Name for role:" + sre.getDN());
      } else {
        String commonName = IETFUtils.valueToString(rdns[0].getFirst().getValue());
        roles.add(commonName);
      }
    }
  } finally {
    connection.close();
  }

  return roles;
}
 
開發者ID:square,項目名稱:keywhiz,代碼行數:26,代碼來源:LdapAuthenticator.java

示例2: areEqual

import org.bouncycastle.asn1.x500.RDN; //導入依賴的package包/類
public boolean areEqual(X500Name name1, X500Name name2)
{
    RDN[] rdns1 = name1.getRDNs();
    RDN[] rdns2 = name2.getRDNs();

    if (rdns1.length != rdns2.length)
    {
        return false;
    }

    for (int i = 0; i != rdns1.length; i++)
    {
        if (!rdnAreEqual(rdns1[i], rdns2[i]))
        {
            return false;
        }
    }

    return true;
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:21,代碼來源:BCStrictStyle.java

示例3: toString

import org.bouncycastle.asn1.x500.RDN; //導入依賴的package包/類
public String toString(X500Name name)
{
    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(',');
        }

        IETFUtils.appendRDN(buf, rdns[i], DefaultSymbols);
    }

    return buf.toString();
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:24,代碼來源:RFC4519Style.java

示例4: toString

import org.bouncycastle.asn1.x500.RDN; //導入依賴的package包/類
public String toString(X500Name name)
{
    StringBuffer buf = new StringBuffer();
    boolean first = true;

    RDN[] rdns = name.getRDNs();

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

        IETFUtils.appendRDN(buf, rdns[i], DefaultSymbols);
    }

    return buf.toString();
}
 
開發者ID:Appdome,項目名稱:ipack,代碼行數:24,代碼來源:BCStyle.java

示例5: 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

示例6: toString

import org.bouncycastle.asn1.x500.RDN; //導入依賴的package包/類
public String toString(X500Name name)
{
    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(',');
        }

        IETFUtils.appendRDN(buf, rdns[i], defaultSymbols);
    }

    return buf.toString();
}
 
開發者ID:ttt43ttt,項目名稱:gwt-crypto,代碼行數:24,代碼來源:RFC4519Style.java

示例7: toString

import org.bouncycastle.asn1.x500.RDN; //導入依賴的package包/類
public String toString(X500Name name)
{
    StringBuffer buf = new StringBuffer();
    boolean first = true;

    RDN[] rdns = name.getRDNs();

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

        IETFUtils.appendRDN(buf, rdns[i], defaultSymbols);
    }

    return buf.toString();
}
 
開發者ID:ttt43ttt,項目名稱:gwt-crypto,代碼行數:24,代碼來源:BCStyle.java

示例8: getCommonName

import org.bouncycastle.asn1.x500.RDN; //導入依賴的package包/類
/**
 * Gets the common name from the given X500Name.
 * 
 * @param name the X.500 name
 * @return the common name, null if not found
 */
public static String getCommonName(X500Name name)
{
	if (name == null)
	{
		return null;
	}

	RDN[] rdns = name.getRDNs(BCStyle.CN);
	if (rdns.length == 0)
	{
		return null;
	}

	return rdns[0].getFirst().getValue().toString();
}
 
開發者ID:gavioto,項目名稱:portecle,代碼行數:22,代碼來源:NameUtil.java

示例9: testGenerateInstanceRefreshRequestSubDomain

import org.bouncycastle.asn1.x500.RDN; //導入依賴的package包/類
@Test
public void testGenerateInstanceRefreshRequestSubDomain() {
    
    File privkey = new File("./src/test/resources/test_private_k0.pem");
    PrivateKey privateKey = Crypto.loadPrivateKey(privkey);

    InstanceRefreshRequest req = ZTSClient.generateInstanceRefreshRequest("coretech.system",
            "test", privateKey, "aws", 3600);
    assertNotNull(req);
    
    PKCS10CertificationRequest certReq = Crypto.getPKCS10CertRequest(req.getCsr());
    assertEquals("coretech.system.test", Crypto.extractX509CSRCommonName(certReq));

    X500Name x500name = certReq.getSubject();
    RDN cnRdn = x500name.getRDNs(BCStyle.CN)[0];
    assertEquals("coretech.system.test", IETFUtils.valueToString(cnRdn.getFirst().getValue()));
    assertEquals("test.coretech-system.aws.athenz.cloud", Crypto.extractX509CSRDnsNames(certReq).get(0));
}
 
開發者ID:yahoo,項目名稱:athenz,代碼行數:19,代碼來源:ZTSClientTest.java

示例10: getRdn

import org.bouncycastle.asn1.x500.RDN; //導入依賴的package包/類
/**
 * Returns the (first) value of the (first) RDN of type rdnOid
 *
 * @param dn The X500Name
 * @param rdnOid OID of wanted RDN
 * @return Value of requested RDN
 */
public static String getRdn(X500Name dn, ASN1ObjectIdentifier rdnOid) {

	if (dn == null || rdnOid == null) {
		return "";
	}

	RDN[] rdns = dn.getRDNs(rdnOid);
	String value = "";

	if (rdns.length > 0) {
		RDN rdn = rdns[0];
		value = rdn.getFirst().getValue().toString();
	}

	return value;
}
 
開發者ID:kaikramer,項目名稱:keystore-explorer,代碼行數:24,代碼來源:X500NameUtils.java

示例11: 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

示例12: testParseCsrRdnWithEMail

import org.bouncycastle.asn1.x500.RDN; //導入依賴的package包/類
@Test
public void testParseCsrRdnWithEMail() {
    String csrPemStr = this.getCsrWithReverseDnStructureOrder_AndEmail();
    PKCS10CertificationRequest req = csrParser.parseCsrPemString(csrPemStr);
    X500Name xname = req.getSubject();

    System.out.println("" + xname.toString());
    assertEquals("C=UK,O=eScienceDev,OU=Manchester,L=MC,CN=grid course eight,[email protected]", xname.toString());
    RDN[] rdn = req.getSubject().getRDNs(); // return an array of RDNs in structure order.
    assertEquals(rdn[5].getFirst().getType(), email);
    /*for (int i = 0; i < rdn.length; i++) {
     //System.out.println("ASN1: "+rdn[i].toASN1Primitive());
     AttributeTypeAndValue tv = rdn[i].getFirst();
     System.out.println("t: " + tv.getType().toString() + " v: " + tv.getValue().toString());
     }*/
    // Note the order of the RDNs reflects the X500Name
    assertEquals(rdn[0].getFirst().getType(), c);
    assertEquals(rdn[1].getFirst().getType(), orgname);
    assertEquals(rdn[2].getFirst().getType(), ou);
    assertEquals(rdn[3].getFirst().getType(), loc);
    assertEquals(rdn[4].getFirst().getType(), cn);
    assertEquals(rdn[5].getFirst().getType(), email);
}
 
開發者ID:UKCA,項目名稱:CAPortal,代碼行數:24,代碼來源:TestBC_PKCS10.java

示例13: match

import org.bouncycastle.asn1.x500.RDN; //導入依賴的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

示例14: 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

示例15: toString

import org.bouncycastle.asn1.x500.RDN; //導入依賴的package包/類
@Override
public String toString(X500Name name)
{
    StringBuilder buf = new StringBuilder();
    boolean first = true;

    RDN[] rdns = name.getRDNs();

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

        ExtendedIETFUtils.appendRDN(buf, rdns[i], defaultSymbols);
    }

    return buf.toString();
}
 
開發者ID:BandwidthOnDemand,項目名稱:nsi-dds,代碼行數:25,代碼來源:ExtendedRFC4519Style.java


注:本文中的org.bouncycastle.asn1.x500.RDN類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。