Java Code Examples for org.bouncycastle.asn1.ASN1String#getString()

The following examples show how to use org.bouncycastle.asn1.ASN1String#getString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CAdESSignature.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public List<SignerRole> getClaimedSignerRoles() {
	final SignerAttribute signerAttr = getSignerAttributeV1();
	final SignerAttributeV2 signerAttrV2 = getSignerAttributeV2();

	Object[] signerAttrValues = null;
	try {

		if (signerAttr != null) {
			signerAttrValues = signerAttr.getValues();
		} else if (signerAttrV2 != null) {
			signerAttrValues = signerAttrV2.getValues();
		}
		if (signerAttrValues == null) {
			return Collections.emptyList();
		}

		final List<SignerRole> claimedRoles = new ArrayList<>();
		for (final Object signerAttrValue : signerAttrValues) {
			if (!(signerAttrValue instanceof org.bouncycastle.asn1.x509.Attribute[])) {
				continue;
			}
			final org.bouncycastle.asn1.x509.Attribute[] signerAttrValueArray = (org.bouncycastle.asn1.x509.Attribute[]) signerAttrValue;
			for (final org.bouncycastle.asn1.x509.Attribute claimedRole : signerAttrValueArray) {
				final ASN1Encodable[] attrValues1 = claimedRole.getAttrValues().toArray();
				for (final ASN1Encodable asn1Encodable : attrValues1) {
					if (asn1Encodable instanceof ASN1String) {
						ASN1String asn1String = (ASN1String) asn1Encodable;
						final String role = asn1String.getString();
						claimedRoles.add(new SignerRole(role, EndorsementType.CLAIMED));
					}
				}
			}
		}
		return claimedRoles;
	} catch (Exception e) {
		LOG.error("Error when dealing with claimed signer roles : {}", signerAttrValues, e);
		return Collections.emptyList();
	}
}
 
Example 2
Source File: AbstractCRLUtils.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
private String getUrl(DistributionPointName distributionPoint) {
	if ((distributionPoint != null) && (DistributionPointName.FULL_NAME == distributionPoint.getType())) {
		final GeneralNames generalNames = (GeneralNames) distributionPoint.getName();
		if ((generalNames != null) && (generalNames.getNames() != null && generalNames.getNames().length > 0)) {
			for (GeneralName generalName : generalNames.getNames()) {
				if (GeneralName.uniformResourceIdentifier == generalName.getTagNo()) {
					ASN1String str = (ASN1String) ((DERTaggedObject) generalName.toASN1Primitive()).getObject();
					return str.getString();
				}
			}
		}
	}
	return null;
}
 
Example 3
Source File: DSSASN1Utils.java    From dss with GNU Lesser General Public License v2.1 5 votes vote down vote up
private static String parseGn(GeneralName gn) {
	try {
		if (GeneralName.uniformResourceIdentifier == gn.getTagNo()) {
			ASN1String str = (ASN1String) ((DERTaggedObject) gn.toASN1Primitive()).getObject();
			return str.getString();
		}
	} catch (Exception e) {
		LOG.warn("Unable to parse GN '{}'", gn, e);
	}
	return null;
}
 
Example 4
Source File: ScepResponder.java    From xipki with Apache License 2.0 5 votes vote down vote up
private static String getChallengePassword(CertificationRequestInfo csr) {
  ASN1Set attrs = csr.getAttributes();
  for (int i = 0; i < attrs.size(); i++) {
    Attribute attr = Attribute.getInstance(attrs.getObjectAt(i));
    if (PKCSObjectIdentifiers.pkcs_9_at_challengePassword.equals(attr.getAttrType())) {
      ASN1String str = (ASN1String) attr.getAttributeValues()[0];
      return str.getString();
    }
  }
  return null;
}
 
Example 5
Source File: CaUtil.java    From xipki with Apache License 2.0 5 votes vote down vote up
public static String getChallengePassword(CertificationRequestInfo csr) {
  Args.notNull(csr, "csr");
  ASN1Set attrs = csr.getAttributes();
  for (int i = 0; i < attrs.size(); i++) {
    Attribute attr = Attribute.getInstance(attrs.getObjectAt(i));
    if (PKCSObjectIdentifiers.pkcs_9_at_challengePassword.equals(attr.getAttrType())) {
      ASN1String str = (ASN1String) attr.getAttributeValues()[0];
      return str.getString();
    }
  }
  return null;
}