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


Java IETFUtils.valueToString方法代码示例

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


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

示例1: rolesFromDN

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的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: extractJidAndName

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
public static Pair<Jid,String> extractJidAndName(X509Certificate certificate) throws CertificateEncodingException, InvalidJidException, CertificateParsingException {
	Collection<List<?>> alternativeNames = certificate.getSubjectAlternativeNames();
	List<String> emails = new ArrayList<>();
	if (alternativeNames != null) {
		for(List<?> san : alternativeNames) {
			Integer type = (Integer) san.get(0);
			if (type == 1) {
				emails.add((String) san.get(1));
			}
		}
	}
	X500Name x500name = new JcaX509CertificateHolder(certificate).getSubject();
	if (emails.size() == 0) {
		emails.add(IETFUtils.valueToString(x500name.getRDNs(BCStyle.EmailAddress)[0].getFirst().getValue()));
	}
	String name = IETFUtils.valueToString(x500name.getRDNs(BCStyle.CN)[0].getFirst().getValue());
	if (emails.size() >= 1) {
		return new Pair<>(Jid.fromString(emails.get(0)), name);
	} else {
		return null;
	}
}
 
开发者ID:xavierle,项目名称:messengerxmpp,代码行数:23,代码来源:CryptoHelper.java

示例3: checkRdn

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的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: getSubjectCNFromCertificate

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
public static String getSubjectCNFromCertificate(X509Certificate certificate) {
    try {
        X500Name x500name = new JcaX509CertificateHolder(certificate).getIssuer();
        RDN cn = x500name.getRDNs(BCStyle.CN)[0];
        return IETFUtils.valueToString(cn.getFirst().getValue());
    } catch (CertificateEncodingException e) {
        log.error("Unable to get issuer CN", e);
        return null;
    }
}
 
开发者ID:e-gov,项目名称:TARA-Server,代码行数:11,代码来源:X509Utils.java

示例5: handle

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
@Override
public HttpResponse handle(HttpRequest request, MiddlewareChain chain) {
    request = MixinUtils.mixin(request, new Class[]{PrincipalAvailable.class});
    String clientDN = request.getHeaders().get("X-Client-DN");
    if (!isAuthenticated((PrincipalAvailable) request) && clientDN != null) {
        RDN cn = new X500Name(clientDN).getRDNs(BCStyle.CN)[0];
        String account = IETFUtils.valueToString(cn.getFirst().getValue());

    }
    return castToHttpResponse(chain.next(request));
}
 
开发者ID:kawasima,项目名称:bouncr,代码行数:12,代码来源:ClientAuthenticateMiddleware.java

示例6: extractJidAndName

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
public static Pair<Jid,String> extractJidAndName(X509Certificate certificate) throws CertificateEncodingException, InvalidJidException, CertificateParsingException {
	Collection<List<?>> alternativeNames = certificate.getSubjectAlternativeNames();
	List<String> emails = new ArrayList<>();
	if (alternativeNames != null) {
		for(List<?> san : alternativeNames) {
			Integer type = (Integer) san.get(0);
			if (type == 1) {
				emails.add((String) san.get(1));
			}
		}
	}
	X500Name x500name = new JcaX509CertificateHolder(certificate).getSubject();
	if (emails.size() == 0 && x500name.getRDNs(BCStyle.EmailAddress).length > 0) {
		emails.add(IETFUtils.valueToString(x500name.getRDNs(BCStyle.EmailAddress)[0].getFirst().getValue()));
	}
	String name = x500name.getRDNs(BCStyle.CN).length > 0 ? IETFUtils.valueToString(x500name.getRDNs(BCStyle.CN)[0].getFirst().getValue()) : null;
	if (emails.size() >= 1) {
		return new Pair<>(Jid.fromString(emails.get(0)), name);
	} else if (name != null){
		try {
			Jid jid = Jid.fromString(name);
			if (jid.isBareJid() && !jid.isDomainJid()) {
				return new Pair<>(jid,null);
			}
		} catch (InvalidJidException e) {
			return null;
		}
	}
	return null;
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:31,代码来源:CryptoHelper.java

示例7: getEmailFromCert

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

示例8: extractX509CSRCommonName

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
public static String extractX509CSRCommonName(PKCS10CertificationRequest certReq) {
    
    String cn = null;
    X500Name x500name = certReq.getSubject();
    RDN cnRdn = x500name.getRDNs(BCStyle.CN)[0];
    if (cnRdn != null) {
        cn = IETFUtils.valueToString(cnRdn.getFirst().getValue());
    }
    return cn;
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:11,代码来源:Crypto.java

示例9: extractX509CertCommonName

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
public static String extractX509CertCommonName(X509Certificate x509Cert) {
    
    // in case there are multiple CNs, we're only looking at the first one

    String cn = null;
    String principalName = x509Cert.getSubjectX500Principal().getName();
    if (principalName != null && !principalName.isEmpty()) {
        X500Name x500name = new X500Name(principalName);
        RDN cnRdn = x500name.getRDNs(BCStyle.CN)[0];
        if (cnRdn != null) {
            cn = IETFUtils.valueToString(cnRdn.getFirst().getValue());
        }
    }
    return cn;
}
 
开发者ID:yahoo,项目名称:athenz,代码行数:16,代码来源:Crypto.java

示例10: extractJidAndName

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
public static Pair<Jid, String> extractJidAndName(X509Certificate certificate) throws CertificateEncodingException, InvalidJidException, CertificateParsingException {
    Collection<List<?>> alternativeNames = certificate.getSubjectAlternativeNames();
    List<String> emails = new ArrayList<>();
    if (alternativeNames != null) {
        for (List<?> san : alternativeNames) {
            Integer type = (Integer) san.get(0);
            if (type == 1) {
                emails.add((String) san.get(1));
            }
        }
    }
    X500Name x500name = new JcaX509CertificateHolder(certificate).getSubject();
    if (emails.size() == 0 && x500name.getRDNs(BCStyle.EmailAddress).length > 0) {
        emails.add(IETFUtils.valueToString(x500name.getRDNs(BCStyle.EmailAddress)[0].getFirst().getValue()));
    }
    String name = x500name.getRDNs(BCStyle.CN).length > 0 ? IETFUtils.valueToString(x500name.getRDNs(BCStyle.CN)[0].getFirst().getValue()) : null;
    if (emails.size() >= 1) {
        return new Pair<>(Jid.fromString(emails.get(0)), name);
    } else if (name != null) {
        try {
            Jid jid = Jid.fromString(name);
            if (jid.isBareJid() && !jid.isDomainJid()) {
                return new Pair<>(jid, null);
            }
        } catch (InvalidJidException e) {
            return null;
        }
    }
    return null;
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:31,代码来源:CryptoHelper.java

示例11: getSingleRDN

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
private String getSingleRDN(ASN1ObjectIdentifier oid) {
    RDN[] rdn = mName.getRDNs(oid);

    if (rdn.length > 0) {
        return IETFUtils.valueToString(rdn[0].getFirst().getValue());
    }

    return null;
}
 
开发者ID:bbqsrc,项目名称:robust-android,代码行数:10,代码来源:SimpleX500Name.java

示例12: getSubjectCommonName

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
/**
 * @param aCert
 *        Source certificate. May not be <code>null</code>.
 * @return The common name of the certificate subject
 * @throws CertificateEncodingException
 *         In case of an internal error
 */
@Nonnull
public static String getSubjectCommonName (@Nonnull final X509Certificate aCert) throws CertificateEncodingException
{
  ValueEnforcer.notNull (aCert, "Certificate");
  final X500Name x500name = new JcaX509CertificateHolder (aCert).getSubject ();
  final RDN cn = x500name.getRDNs (BCStyle.CN)[0];
  return IETFUtils.valueToString (cn.getFirst ().getValue ());
}
 
开发者ID:phax,项目名称:as2-peppol-client,代码行数:16,代码来源:AS2ClientHelper.java

示例13: getSubject

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
public SubjectInfo getSubject(X500Name requestedSubject)
        throws CertprofileException, BadCertTemplateException {
    SubjectInfo subjectInfo = certprofile.getSubject(requestedSubject);
    RDN[] countryRdns = subjectInfo.grantedSubject().getRDNs(ObjectIdentifiers.DN_C);
    if (countryRdns != null) {
        for (RDN rdn : countryRdns) {
            String textValue = IETFUtils.valueToString(rdn.getFirst().getValue());
            if (!SubjectDnSpec.isValidCountryAreaCode(textValue)) {
                throw new BadCertTemplateException("invalid country/area code '" + textValue
                        + "'");
            }
        }
    }
    return subjectInfo;
}
 
开发者ID:xipki,项目名称:xipki,代码行数:16,代码来源:IdentifiedX509Certprofile.java

示例14: getUserName

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
public String getUserName()
{
    try {
        X500Name x500name = new JcaX509CertificateHolder(clientCert).getSubject();
        RDN cn = x500name.getRDNs(BCStyle.CN)[0];
        return IETFUtils.valueToString(cn.getFirst().getValue());
    } catch (CertificateEncodingException e) {
        return "";
    }
}
 
开发者ID:enioka,项目名称:jqm,代码行数:11,代码来源:CertificateToken.java

示例15: ietfUtilsTest

import org.bouncycastle.asn1.x500.style.IETFUtils; //导入方法依赖的package包/类
private void ietfUtilsTest()
    throws Exception
{
    IETFUtils.valueToString(new DERUTF8String(" "));
}
 
开发者ID:ttt43ttt,项目名称:gwt-crypto,代码行数:6,代码来源:X500NameTest.java


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