Examples of Sig


Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

      if (list!=null) for(ExprVar expr: list) {
         if (expr==null) { nextIsExact=true; continue; }
         String name = expr.label;
         dup(expr.span(), name, true);
         if (path.length()==0) {
            Sig newSig = addSig(name, null, null, null, null, WHERE.make(expr.span()));
            if (nextIsExact) exactSigs.add(newSig);
         } else {
            params.put(name, null);
            if (nextIsExact) exactParams.add(name);
         }
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

               throw new ErrorSyntax(open.pos,
                     "You supplied "+open.args.size()+" arguments to the open statement, but the imported module requires "
                     +sub.params.size()+" arguments.");
            int i=0;
            for(Map.Entry<String,Sig> p: sub.params.entrySet()) {
               Sig old = p.getValue();
               String kn = p.getKey(), vn = open.args.get(i);
               i++;
               Sig vv=mod.getRawSIG(open.pos, vn);
               if (vv==null) {if (old==null) {missing=open; missingName=vn;} continue;}
               if (old==vv) continue;
               if (old!=null) throw new ErrorFatal(open.pos, "Internal error (module re-instantiated with different arguments)");
               if (vv==NONE) throw new ErrorSyntax(open.pos, "You cannot use \"none\" as an instantiating argument.");
               chg=true;
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

   //============================================================================================================================//

   /** Add a sig declaration. */
   Sig addSig(String name, ExprVar par, List<ExprVar> parents, List<Decl> fields, Expr fact, Attr... attributes) throws Err {
      Sig obj;
      Pos pos = Pos.UNKNOWN.merge(WHERE.find(attributes));
      status = 3;
      dup(pos, name, true);
      String full = (path.length()==0) ? "this/"+name : path+"/"+name;
      Pos subset=null, subsig=null;
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

   }

   /** The given Sig will now point to a nonnull Sig. */
   private static Sig resolveSig(CompModule res, Set<Object> topo, Sig oldS) throws Err {
      if (res.new2old.containsKey(oldS)) return oldS;
      Sig realSig;
      final Pos pos = oldS.pos;
      final CompModule u = res.sig2module.get(oldS);
      final String name = base(oldS);
      final String fullname = (u.path.length()==0) ? ("this/"+name) : (u.path+"/"+name);
      if (!topo.add(oldS)) throw new ErrorType(pos, "Sig "+oldS+" is involved in a cyclic inheritance.");
      if (oldS instanceof SubsetSig)  {
         List<Sig> parents = new ArrayList<Sig>();
         for(Sig n: ((SubsetSig)oldS).parents) {
            Sig parentAST = u.getRawSIG(n.pos, n.label);
            if (parentAST==null) throw new ErrorSyntax(n.pos, "The sig \""+n.label+"\" cannot be found.");
            parents.add(resolveSig(res, topo, parentAST));
         }
         realSig = new SubsetSig(fullname, parents, oldS.attributes.toArray(new Attr[0]));
      } else {
         Sig sup = ((PrimSig)oldS).parent;
         Sig parentAST = u.getRawSIG(sup.pos, sup.label);
         if (parentAST==null) throw new ErrorSyntax(sup.pos, "The sig \""+sup.label+"\" cannot be found.");
         Sig parent = resolveSig(res, topo, parentAST);
         if (!(parent instanceof PrimSig)) throw new ErrorSyntax(sup.pos, "Cannot extend the subset signature \"" + parent
               + "\".\n" + "A signature can only extend a toplevel signature or a subsignature.");
         PrimSig p = (PrimSig)parent;
         realSig = new PrimSig(fullname, p, oldS.attributes.toArray(new Attr[0]));
      }
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

         if (f.decls.size()>0) e = ExprQt.Op.SOME.make(null, null, f.decls, e);
      }
      if (e==null) e = ExprConstant.TRUE;
      TempList<CommandScope> sc=new TempList<CommandScope>(cmd.scope.size());
      for(CommandScope et: cmd.scope) {
         Sig s = getRawSIG(et.sig.pos, et.sig.label);
         if (s==null) throw new ErrorSyntax(et.sig.pos, "The sig \""+et.sig.label+"\" cannot be found.");
         sc.add(new CommandScope(null, s, et.isExact, et.startingScope, et.endingScope, et.increment));
      }
      return new Command(cmd.pos, cmd.label, cmd.check, cmd.overall, cmd.bitwidth, cmd.maxseq, cmd.expects, sc.makeConst(), exactSigs, globalFacts.and(e), parent);
   }
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

            if (a.parent!=null && a.parent!=UNIV) expr = sig2meta.get(a.parent);
         }
         e.getValue().addDefinedField(Pos.UNKNOWN, null, Pos.UNKNOWN, "parent", (expr==null ? ExprConstant.EMPTYNESS : expr));
      }
      for(Map.Entry<Sig,PrimSig> e: sig2meta.entrySet()) {
         Sig s = e.getKey();
         PrimSig s2 = e.getValue();
         Expr allfields = ExprConstant.EMPTYNESS;
         for(Field f: s.getFields()) {
            PrimSig metaF = field2meta.get(f);
            if (allfields==ExprConstant.EMPTYNESS) allfields = metaF; else allfields = allfields.plus(metaF);
         }
         if (s instanceof PrimSig) for(Sig c: (((PrimSig)s).descendents())) for(Field f: c.getFields()) {
            PrimSig metaF = field2meta.get(f);
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

      for(CompModule x: root.allModules) {
         errors = x.resolveFuncBody(rep, errors, warns);
         errors = x.resolveAssertions(rep, errors, warns);
         errors = x.resolveFacts(root, rep, errors, warns);
         // also, we can collect up all the exact sigs and add them to the root module's list of exact sigs
         for(String n: x.exactParams) { Sig sig = x.params.get(n); if (sig!=null) root.exactSigs.add(sig); }
      }
      if (!errors.isEmpty()) throw errors.pick();
      // Typecheck the run/check commands (which can refer to function bodies and assertions)
      root.resolveCommands(root.getAllReachableFacts());
      if (!errors.isEmpty()) throw errors.pick();
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

      if (name.equals("seq/Int"))    return ExprUnary.Op.NOOP.make(pos, SEQIDX);
      if (name.equals("String"))     return ExprUnary.Op.NOOP.make(pos, STRING);
      if (name.equals("none"))       return ExprUnary.Op.NOOP.make(pos, NONE);
      if (name.equals("iden"))       return ExprConstant.Op.IDEN.make(pos, 0);
      if (name.equals("sig$") || name.equals("field$")) if (world!=null) {
         Sig s = world.sigs.get(name);
         if (s!=null) return ExprUnary.Op.NOOP.make(pos, s);
      }
      final List<Object> ans = name.indexOf('/')>=0 ? getRawQS(fun?5:1, name) : getRawNQS(this, fun?5:1, name);
      final Sig param = params.get(name); if (param!=null && !ans.contains(param)) ans.add(param);
      for(Object x: ans) {
         if (x instanceof Sig) {
            Sig y = (Sig)x;
            ch.add(ExprUnary.Op.NOOP.make(pos, y, null, 0));
            re.add("sig "+y.label);
         }
         else if (x instanceof Func) {
            Func f = (Func)x;
View Full Code Here

Examples of edu.mit.csail.sdg.alloy4compiler.ast.Sig

                i++;
                if (i>=t.length-1 || !(t[i] instanceof String) || !(t[i+1] instanceof String)) return null;
                String sigName = (String)(t[i]);
                i++;
                String fieldName = (String)(t[i]);
                Sig first = hasSig(sigs,sigName);
                if (first==null) return null;
                Expression expr = null;
                if (fieldName.length()==0) {
                    expr=frame.a2k(first);
                } else {
                    for(Field field:first.getFields()) if (field.label.equals(fieldName)) {
                        expr=frame.a2k(field);
                        while(expr instanceof BinaryExpression) expr=((BinaryExpression)expr).right();
                        break;
                    }
                }
View Full Code Here

Examples of org.kapott.hbci.security.Sig

            if (signit) {
                HBCIUtils.log("trying to insert signature",HBCIUtils.LOG_DEBUG);
                HBCIUtilsInternal.getCallback().status(mainPassport,HBCICallback.STATUS_MSG_SIGN,null);
               
                // signatur erzeugen und an nachricht anh�ngen
                Sig sig=SigFactory.getInstance().createSig(getParentHandlerData(),msg,passports);
                try {
                    if (!sig.signIt()) {
                        String errmsg=HBCIUtilsInternal.getLocMsg("EXCMSG_CANTSIGN");
                        if (!HBCIUtilsInternal.ignoreError(null,"client.errors.ignoreSignErrors",errmsg)) {
                            throw new HBCI_Exception(errmsg);
                        }
                    }
                } finally {
                    SigFactory.getInstance().unuseObject(sig);
                }

                // alle rewrites erledigen, die *nach* dem hinzuf�gen der signatur stattfinden m�ssen
                for (int i=0;i<rewriters.length;i++) {
                    MSG old=msg;
                    msg=rewriters[i].outgoingSigned(old,gen);
                    if (msg!=old) {
                        MSGFactory.getInstance().unuseObject(old);
                    }
                }
            }
           
            /* zu jeder SyntaxElement-Referenz (2:3,1)==(SEG:DEG,DE) den Pfad
               des jeweiligen Elementes speichern */
            Properties paths=new Properties();
            msg.getElementPaths(paths,null,null,null);
            ret.addData(paths);
           
            /* f�r alle Elemente (Pfadnamen) die aktuellen Werte speichern,
               wie sie bei der ausgehenden Nachricht versandt werden */
            Hashtable<String,String> current=new Hashtable<String,String>();
            msg.extractValues(current);
            Properties origs=new Properties();
            for (Enumeration<String> e=current.keys();e.hasMoreElements();) {
                String key= e.nextElement();
                String value= current.get(key);
                origs.setProperty("orig_"+key,value);
            }
            ret.addData(origs);
           
            // zu versendene nachricht loggen
            String outstring=msg.toString(0);
            HBCIUtils.log("sending message: "+outstring,HBCIUtils.LOG_DEBUG2);

            // max. nachrichtengr��e aus BPD �berpr�fen
            int maxmsgsize=mainPassport.getMaxMsgSizeKB();
            if (maxmsgsize!=0 && (outstring.length()>>10)>maxmsgsize) {
                String errmsg=HBCIUtilsInternal.getLocMsg("EXCMSG_MSGTOOLARGE",
                                                  new Object[] {Integer.toString(outstring.length()>>10),Integer.toString(maxmsgsize)});
                if (!HBCIUtilsInternal.ignoreError(null,"client.errors.ignoreMsgSizeErrors",errmsg))
                    throw new HBCI_Exception(errmsg);
            }
           
            // soll nachricht verschl�sselt werden?
            if (cryptit) {
                HBCIUtils.log("trying to encrypt message",HBCIUtils.LOG_DEBUG);
                HBCIUtilsInternal.getCallback().status(mainPassport,HBCICallback.STATUS_MSG_CRYPT,null);
               
                // nachricht verschl�sseln
                MSG   old=msg;
                Crypt crypt=CryptFactory.getInstance().createCrypt(getParentHandlerData(),old);
                try {
                    msg=crypt.cryptIt("Crypted");
                } finally {
                    CryptFactory.getInstance().unuseObject(crypt);
                    if (msg!=old) {
                        MSGFactory.getInstance().unuseObject(old);
                    }
                }
               
                if (!msg.getName().equals("Crypted")) {
                    String errmsg=HBCIUtilsInternal.getLocMsg("EXCMSG_CANTCRYPT");
                    if (!HBCIUtilsInternal.ignoreError(null,"client.errors.ignoreCryptErrors",errmsg))
                        throw new HBCI_Exception(errmsg);
                }

                // verschl�sselte nachricht patchen
                for (int i=0;i<rewriters.length;i++) {
                    MSG oldMsg=msg;
                    msg=rewriters[i].outgoingCrypted(oldMsg,gen);
                    if (msg!=oldMsg) {
                        MSGFactory.getInstance().unuseObject(oldMsg);
                    }
                }
               
                HBCIUtils.log("encrypted message to be sent: "+msg.toString(0),HBCIUtils.LOG_DEBUG2);
            }

            // basic-values der ausgehenden nachricht merken
            String msgPath=msg.getPath();
            String msgnum=msg.getValueOfDE(msgPath+".MsgHead.msgnum");
            String dialogid=msg.getValueOfDE(msgPath+".MsgHead.dialogid");
            String hbciversion=msg.getValueOfDE(msgPath+".MsgHead.hbciversion");
           
            // nachricht versenden und antwortnachricht empfangen
            HBCIUtils.log("communicating dialogid/msgnum "+dialogid+"/"+msgnum,HBCIUtils.LOG_DEBUG);
            MSG old=msg;
            msg=mainPassport.getComm().pingpong(currentMsgName,old);
            if (msg!=old) {
                MSGFactory.getInstance().unuseObject(old);
            }

            // ist antwortnachricht verschl�sselt?
            boolean crypted=msg.getName().equals("CryptedRes");
            if (crypted) {
                HBCIUtilsInternal.getCallback().status(mainPassport,HBCICallback.STATUS_MSG_DECRYPT,null);
               
                // wenn ja, dann nachricht entschl�sseln
                Crypt  crypt=CryptFactory.getInstance().createCrypt(getParentHandlerData(),msg);
                String newmsgstring;
                try {
                    newmsgstring=crypt.decryptIt();
                } finally {
                    CryptFactory.getInstance().unuseObject(crypt);
                }
                gen.set("_origSignedMsg",newmsgstring);
               
                // alle patches f�r die unverschl�sselte nachricht durchlaufen
                for (int i=0;i<rewriters.length;i++) {
                    newmsgstring=rewriters[i].incomingClearText(newmsgstring,gen);
                }
               
                HBCIUtils.log("decrypted message after rewriting: "+newmsgstring,HBCIUtils.LOG_DEBUG2);
               
                // nachricht als plaintextnachricht parsen
                try {
                    HBCIUtilsInternal.getCallback().status(mainPassport,HBCICallback.STATUS_MSG_PARSE,currentMsgName+"Res");
                    HBCIUtils.log("message to pe parsed: "+msg.toString(0),HBCIUtils.LOG_DEBUG2);
                    MSG oldMsg=msg;
                    msg=MSGFactory.getInstance().createMSG(currentMsgName+"Res",newmsgstring,newmsgstring.length(),gen);
                    if (msg!=oldMsg) {
                        MSGFactory.getInstance().unuseObject(oldMsg);
                    }
                } catch (Exception ex) {
                    throw new CanNotParseMessageException(HBCIUtilsInternal.getLocMsg("EXCMSG_CANTPARSE"),newmsgstring,ex);
                }
            }
           
            HBCIUtils.log("received message after decryption: "+msg.toString(0),HBCIUtils.LOG_DEBUG2);

            // alle patches f�r die plaintextnachricht durchlaufen
            for (int i=0;i<rewriters.length;i++) {
                MSG oldMsg=msg;
                msg=rewriters[i].incomingData(oldMsg,gen);
                if (msg!=oldMsg) {
                    MSGFactory.getInstance().unuseObject(oldMsg);
                }
            }
           
            // daten aus nachricht in status-objekt einstellen
            HBCIUtils.log("extracting data from received message",HBCIUtils.LOG_DEBUG);
            Properties p=msg.getData();
            p.setProperty("_msg", gen.get("_origSignedMsg"));
            ret.addData(p);
           
            // �berpr�fen einiger constraints, die in einer antwortnachricht eingehalten werden m�ssen
            msgPath=msg.getPath();
            try {
                String hbciversion2=msg.getValueOfDE(msgPath+".MsgHead.hbciversion");
                if (!hbciversion2.equals(hbciversion))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVVERSION",new Object[] {hbciversion2,
                            hbciversion}));
                String msgnum2=msg.getValueOfDE(msgPath+".MsgHead.msgnum");
                if (!msgnum2.equals(msgnum))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVMSGNUM_HEAD",new Object[] {msgnum2,msgnum}));
                msgnum2=msg.getValueOfDE(msgPath+".MsgTail.msgnum");
                if (!msgnum2.equals(msgnum))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVMSGNUM_TAIL",new Object[] {msgnum2,msgnum}));
                String dialogid2=msg.getValueOfDE(msgPath+".MsgHead.dialogid");
                if (!dialogid.equals("0")&&!dialogid2.equals(dialogid))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVDIALOGID",new Object[] {dialogid2,dialogid}));
                if (!dialogid.equals("0")&&!msg.getValueOfDE(msgPath+".MsgHead.MsgRef.dialogid").equals(dialogid))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVDIALOGID_REF"));
                if (!msg.getValueOfDE(msgPath+".MsgHead.MsgRef.msgnum").equals(msgnum))
                    throw new HBCI_Exception(HBCIUtilsInternal.getLocMsg("EXCMSG_INVMSGNUM_REF"));
            } catch (HBCI_Exception e) {
                String errmsg=HBCIUtilsInternal.getLocMsg("EXCMSG_MSGCHECK")+": "+HBCIUtils.exception2String(e);
                if (!HBCIUtilsInternal.ignoreError(null,"client.errors.ignoreMsgCheckErrors",errmsg))
                    throw e;
            }
           
            // �berpr�fen der signatur
            HBCIUtils.log("looking for a signature",HBCIUtils.LOG_DEBUG);
            HBCIUtilsInternal.getCallback().status(mainPassport,HBCICallback.STATUS_MSG_VERIFY,null);
            boolean sigOk=false;
            Sig     sig=SigFactory.getInstance().createSig(getParentHandlerData(),msg,passports);
            try {
                sigOk=sig.verify();
            } finally {
                SigFactory.getInstance().unuseObject(sig);
            }
           
            // fehlermeldungen erzeugen, wenn irgendwelche fehler aufgetreten sind
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.