use of org.bouncycastle.asn1.x509.qualified.SemanticsInformation in project keystore-explorer by kaikramer.
the class X509Ext method getQcStatementsStringValue.
private String getQcStatementsStringValue(byte[] octets) throws IOException {
// @formatter:off
/*
QCStatements ::= SEQUENCE OF QSStatement
QSStatement ::= SEQUENCE
{
statementId OBJECT IDENTIFIER,
statementInfo ANY DEFINED BY statementId OPTIONAL
}
QcEuLimitValue ::= MonetaryValue
QcRetentionPeriod ::= INTEGER
*/
// @formatter:on
StringBuilder sb = new StringBuilder();
int qcStatementNr = 0;
ASN1Sequence qcStatements = ASN1Sequence.getInstance(octets);
for (ASN1Encodable asn1Encodable : qcStatements.toArray()) {
QCStatement qcStatement = QCStatement.getInstance(asn1Encodable);
ASN1ObjectIdentifier statementId = qcStatement.getStatementId();
ASN1Encodable statementInfo = qcStatement.getStatementInfo();
int indentLevel = 1;
sb.append(MessageFormat.format(res.getString("QCStatement.QCStatement"), ++qcStatementNr));
sb.append(NEWLINE);
QcStatementType qcStatementType = QcStatementType.resolveOid(statementId.getId());
if (qcStatementType != null) {
switch(qcStatementType) {
case QC_SYNTAX_V1:
case QC_SYNTAX_V2:
SemanticsInformation semanticsInfo = SemanticsInformation.getInstance(statementInfo);
sb.append(getSemanticInformationValueString(qcStatementType, semanticsInfo, indentLevel));
break;
case QC_COMPLIANCE:
// no statementInfo
sb.append(INDENT.toString(indentLevel));
sb.append(res.getString(QcStatementType.QC_COMPLIANCE.getResKey()));
sb.append(NEWLINE);
break;
case QC_EU_LIMIT_VALUE:
sb.append(INDENT.toString(indentLevel));
sb.append(res.getString(QcStatementType.QC_EU_LIMIT_VALUE.getResKey()));
sb.append(NEWLINE);
sb.append(getMonetaryValueStringValue(statementInfo, indentLevel + 1));
break;
case QC_RETENTION_PERIOD:
ASN1Integer asn1Integer = ASN1Integer.getInstance(statementInfo);
sb.append(INDENT.toString(indentLevel));
sb.append(MessageFormat.format(res.getString(QcStatementType.QC_RETENTION_PERIOD.getResKey()), asn1Integer.getValue().toString()));
sb.append(NEWLINE);
break;
case QC_SSCD:
// no statementInfo
sb.append(INDENT.toString(indentLevel));
sb.append(res.getString(QcStatementType.QC_SSCD.getResKey()));
sb.append(NEWLINE);
break;
case QC_PDS:
ASN1Sequence pdsLocations = ASN1Sequence.getInstance(statementInfo);
sb.append(INDENT.toString(indentLevel));
sb.append(res.getString(QcStatementType.QC_PDS.getResKey()));
for (ASN1Encodable pdsLoc : pdsLocations) {
sb.append(NEWLINE);
sb.append(INDENT.toString(indentLevel + 1));
DLSequence pds = (DLSequence) pdsLoc;
sb.append(MessageFormat.format(res.getString("QCPDS.locations"), pds.getObjectAt(1), pds.getObjectAt(0)));
}
sb.append(NEWLINE);
break;
case QC_TYPE:
sb.append(INDENT.toString(indentLevel));
sb.append(res.getString(QcStatementType.QC_TYPE.getResKey()));
ASN1Sequence qcTypes = ASN1Sequence.getInstance(statementInfo);
for (ASN1Encodable type : qcTypes) {
sb.append(NEWLINE);
sb.append(INDENT.toString(indentLevel + 1));
sb.append(ObjectIdUtil.toString((ASN1ObjectIdentifier) type));
}
sb.append(NEWLINE);
}
} else {
// unknown statement type
sb.append(INDENT.toString(indentLevel));
sb.append(ObjectIdUtil.toString(statementId));
if (statementInfo != null) {
sb.append(statementInfo.toString());
}
sb.append(NEWLINE);
}
}
return sb.toString();
}
use of org.bouncycastle.asn1.x509.qualified.SemanticsInformation in project keystore-explorer by kaikramer.
the class X509Ext method getSemanticInformationValueString.
private String getSemanticInformationValueString(QcStatementType qcStatementType, SemanticsInformation semanticsInfo, int baseIndentLevel) throws IOException {
// @formatter:off
/*
SemanticsInformation ::= SEQUENCE
{
semanticsIdentifier OBJECT IDENTIFIER OPTIONAL,
nameRegistrationAuthorities NameRegistrationAuthorities OPTIONAL
}
NameRegistrationAuthorities ::= SEQUENCE SIZE(1..MAX) OF GeneralName
*/
// @formatter:on
ASN1ObjectIdentifier semanticsIdentifier = semanticsInfo.getSemanticsIdentifier();
GeneralName[] nameRegistrationAuthorities = semanticsInfo.getNameRegistrationAuthorities();
StringBuilder sb = new StringBuilder();
sb.append(INDENT.toString(baseIndentLevel));
if (qcStatementType == QcStatementType.QC_SYNTAX_V1) {
sb.append(res.getString(QcStatementType.QC_SYNTAX_V1.getResKey()));
} else {
sb.append(res.getString(QcStatementType.QC_SYNTAX_V2.getResKey()));
}
sb.append(NEWLINE);
if (semanticsIdentifier != null) {
sb.append(INDENT.toString(baseIndentLevel + 1));
sb.append(MessageFormat.format(res.getString("QCSyntax.SemanticsIdentifier"), semanticsIdentifier.getId()));
sb.append(NEWLINE);
}
if (nameRegistrationAuthorities != null) {
sb.append(INDENT.toString(baseIndentLevel + 1));
sb.append(res.getString("QCSyntax.NameRegistrationAuthorities"));
sb.append(NEWLINE);
for (GeneralName nameRegistrationAuthority : nameRegistrationAuthorities) {
sb.append(INDENT.toString(baseIndentLevel + 2));
sb.append(GeneralNameUtil.toString(nameRegistrationAuthority));
sb.append(NEWLINE);
}
}
return sb.toString();
}
Aggregations