private void checkConstruction( SemanticsInformation mv, DERObjectIdentifier semanticsIdentifier, GeneralName[] names) throws Exception { checkStatement(mv, semanticsIdentifier, names); mv = SemanticsInformation.getInstance(mv); checkStatement(mv, semanticsIdentifier, names); ASN1InputStream aIn = new ASN1InputStream(mv.toASN1Object().getEncoded()); ASN1Sequence seq = (ASN1Sequence)aIn.readObject(); mv = SemanticsInformation.getInstance(seq); checkStatement(mv, semanticsIdentifier, names); }
private void checkStatement( SemanticsInformation si, DERObjectIdentifier id, GeneralName[] names) { if (id != null) { if (!si.getSemanticsIdentifier().equals(id)) { fail("ids don't match."); } } else if (si.getSemanticsIdentifier() != null) { fail("statementId found when none expected."); } if (names != null) { GeneralName[] siNames = si.getNameRegistrationAuthorities(); for (int i = 0; i != siNames.length; i++) { if (!names[i].equals(siNames[i])) { fail("name registration authorities don't match."); } } } else if (si.getNameRegistrationAuthorities() != null) { fail("name registration authorities found when none expected."); } }
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(); }