final DERObject obj = getExtensionValue(x509cert, X509Extensions.QCStatements.getId());
if (obj == null) {
return null;
}
final ASN1Sequence seq = (ASN1Sequence)obj;
MonetaryValue mv = null;
// Look through all the QCStatements and see if we have a stadard ETSI LimitValue
for (int i = 0; i < seq.size(); i++) {
final QCStatement qc = QCStatement.getInstance(seq.getObjectAt(i));
final DERObjectIdentifier oid = qc.getStatementId();
if ((oid != null) && oid.equals(ETSIQCObjectIdentifiers.id_etsi_qcs_LimiteValue)) {
// We MAY have a MonetaryValue object here
final ASN1Encodable enc = qc.getStatementInfo();
if (enc != null) {
mv = MonetaryValue.getInstance(enc);
// We can break the loop now, we got it!
break;
}
}
}
if (mv != null) {
final BigInteger amount = mv.getAmount();
final BigInteger exp = mv.getExponent();
final BigInteger ten = BigInteger.valueOf(10);
// A possibly gotcha here if the monetary value is larger than what fits in a long...
final long value = amount.longValue() * (ten.pow(exp.intValue())).longValue();
if (value < 0) {
log.error("ETSI LimitValue amount is < 0.");
}
final String curr = mv.getCurrency().getAlphabetic();
if (curr == null) {
log.error("ETSI LimitValue currency is null");
}
if ( (value >= 0) && (curr != null) ) {
ret = value + " "+curr;