Search in sources :

Example 1 with Asn1Type

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);
}
Also used : Value(org.eclipse.titan.designer.AST.Value) ASN1Type(org.eclipse.titan.designer.AST.ASN1.ASN1Type) ObjectSet(org.eclipse.titan.designer.AST.ASN1.ObjectSet) ASN1Object(org.eclipse.titan.designer.AST.ASN1.ASN1Object)

Example 2 with Asn1Type

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);
}
Also used : Asn1Type(io.churchkey.asn1.Asn1Type) Pem(io.churchkey.util.Pem) DerParser(io.churchkey.asn1.DerParser)

Example 3 with Asn1Type

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;
}
Also used : Asn1Parser(org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser) IFile(org.eclipse.core.resources.IFile) SyntacticErrorStorage(org.eclipse.titan.common.parsers.SyntacticErrorStorage) ASN1Type(org.eclipse.titan.designer.AST.ASN1.ASN1Type)

Aggregations

ASN1Type (org.eclipse.titan.designer.AST.ASN1.ASN1Type)2 Asn1Type (io.churchkey.asn1.Asn1Type)1 DerParser (io.churchkey.asn1.DerParser)1 Pem (io.churchkey.util.Pem)1 IFile (org.eclipse.core.resources.IFile)1 SyntacticErrorStorage (org.eclipse.titan.common.parsers.SyntacticErrorStorage)1 ASN1Object (org.eclipse.titan.designer.AST.ASN1.ASN1Object)1 ObjectSet (org.eclipse.titan.designer.AST.ASN1.ObjectSet)1 Value (org.eclipse.titan.designer.AST.Value)1 Asn1Parser (org.eclipse.titan.designer.parsers.asn1parser.Asn1Parser)1