use of io.churchkey.asn1.Asn1Type in project titan.EclipsePlug-ins by eclipse.
the class ObjectClassSyntax_Parser method visitSetting.
@Override
public /**
* {@inheritDoc}
*/
void visitSetting(final ObjectClassSyntax_setting parameter) {
FieldSetting fieldSetting = null;
switch(parameter.getSettingType()) {
case S_T:
final ASN1Type type = parseType();
if (null != type) {
fieldSetting = new FieldSetting_Type(parameter.getIdentifier().newInstance(), type);
fieldSetting.setLocation(mBlock.getLocation());
}
break;
case S_V:
final Value value = parseValue();
if (value != null) {
fieldSetting = new FieldSetting_Value(parameter.getIdentifier().newInstance(), value);
fieldSetting.setLocation(mBlock.getLocation());
}
break;
case S_VS:
// TODO mark as NOT SUPPORTED
break;
case S_O:
final ASN1Object object = parseObject();
if (null != object) {
fieldSetting = new FieldSetting_Object(parameter.getIdentifier().newInstance(), object);
fieldSetting.setLocation(mBlock.getLocation());
}
break;
case S_OS:
final ObjectSet objectSet = parseObjectSet();
if (null != objectSet) {
fieldSetting = new FieldSetting_ObjectSet(parameter.getIdentifier().newInstance(), objectSet);
fieldSetting.setLocation(mBlock.getLocation());
}
break;
case S_UNDEF:
// FATAL ERROR
default:
break;
}
previousSuccess = null != fieldSetting;
myObject.addFieldSetting(fieldSetting);
}
use of io.churchkey.asn1.Asn1Type in project churchkey by tomitribe.
the class BeginEcParameters method decode.
public static Object decode(final byte[] bytes) throws IOException {
if (!Utils.startsWith("-----BEGIN EC PARAMETERS-----", bytes)) {
throw new IllegalArgumentException("Contents do not start with -----BEGIN EC PARAMETERS-----");
}
final Pem pem = Pem.parse(bytes);
final byte[] data = pem.getData();
final Asn1Type type = new DerParser(data).readObject().getType();
if (type == Asn1Type.SEQUENCE) {
return EcCurveParams.parse(data);
}
if (type == Asn1Type.OBJECT_IDENTIFIER) {
return EcCurveParams.parseOid(data);
}
throw new UnsupportedOperationException("Unexpected ASN1 type: " + type);
}
use of io.churchkey.asn1.Asn1Type in project titan.EclipsePlug-ins by eclipse.
the class ObjectClassSyntax_Parser method parseType.
private ASN1Type parseType() {
ASN1Type type = null;
if (mBlock != null) {
final Asn1Parser parser = BlockLevelTokenStreamTracker.getASN1ParserForBlock(mBlock, internalIndex);
if (parser != null) {
type = parser.pr_special_Type().type;
internalIndex += parser.nof_consumed_tokens();
final List<SyntacticErrorStorage> errors = parser.getErrorStorage();
if (null != errors && !errors.isEmpty()) {
for (int i = 0; i < errors.size(); i++) {
final IFile file = (IFile) mBlock.getLocation().getFile();
ParserMarkerSupport.createOnTheFlyMixedMarker(file, errors.get(i), IMarker.SEVERITY_ERROR);
}
}
}
}
return type;
}
Aggregations