本文整理汇总了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;
}
示例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;
}
示例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();
}
示例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();
}
示例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;
}
示例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();
}
示例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();
}
示例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();
}
示例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));
}
示例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;
}
示例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));
}
}
}
示例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);
}
示例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;
}
}
示例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;
}
示例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();
}